From fa7511335150907432a85ece9f0779a609080079 Mon Sep 17 00:00:00 2001
From: Paul Kaplan <pkaplan@media.mit.edu>
Date: Wed, 23 May 2018 10:33:12 -0400
Subject: [PATCH] Add integration test for list monitor.

Tests adding a list through the UI, the add <thing> blocks, the reported value and adding items using the monitor UI
---
 test/integration/blocks.test.js | 34 +++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/test/integration/blocks.test.js b/test/integration/blocks.test.js
index 4963c5e44..8b2acdc73 100644
--- a/test/integration/blocks.test.js
+++ b/test/integration/blocks.test.js
@@ -90,6 +90,40 @@ describe('Working with the blocks', () => {
         await expect(logs).toEqual([]);
     });
 
+    test('Creating a list', async () => {
+        await loadUri(uri);
+        await clickXpath('//button[@title="tryit"]');
+        await clickText('Code');
+        await clickText('Variables', scope.blocksTab);
+        await new Promise(resolve => setTimeout(resolve, 1000)); // Wait for scroll animation
+
+        await clickText('Make a List');
+        let el = await findByXpath("//input[@placeholder='']");
+        await el.sendKeys('list1');
+        await clickButton('OK');
+
+        // Click the "add <thing> to list" block 3 times
+        await clickText('add', scope.blocksTab);
+        await clickText('add', scope.blocksTab);
+        await clickText('add', scope.blocksTab);
+        await clickText('list1', scope.blocksTab);
+        await findByText('thing thing thing', scope.reportedValue); // Tooltip with result
+
+        // Interact with the monitor, adding an item
+        await findByText('list1', scope.monitors); // Just to be sure it is there
+        await clickText('+', scope.monitors);
+        el = await findByXpath(`//body//${scope.monitors}//input`);
+        await el.sendKeys('thing2');
+        await clickText('list1', scope.monitors); // Blur the input to submit
+
+        // Check that the list value has been propagated.
+        await clickText('list1', scope.blocksTab);
+        await findByText('thing thing thing thing2', scope.reportedValue); // Tooltip with result
+
+        const logs = await getLogs();
+        await expect(logs).toEqual([]);
+    });
+
     test('Custom procedures', async () => {
         await loadUri(uri);
         await clickXpath('//button[@title="tryit"]');
-- 
GitLab