From b2117d79971f78c9b43a9764e2232fd0656acc41 Mon Sep 17 00:00:00 2001
From: Paul Kaplan <pkaplan@media.mit.edu>
Date: Mon, 14 Jan 2019 14:24:16 -0500
Subject: [PATCH] Force deny getUserMedia in tests, see if that works on travis

---
 test/helpers/selenium-helper.js | 5 ++---
 test/integration/blocks.test.js | 6 +++++-
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/test/helpers/selenium-helper.js b/test/helpers/selenium-helper.js
index ca0b8cfee..12549e933 100644
--- a/test/helpers/selenium-helper.js
+++ b/test/helpers/selenium-helper.js
@@ -49,9 +49,8 @@ class SeleniumHelper {
             args.push('--headless');
         }
 
-        // Stub getUserMedia to prevent permissions access issues
-        args.push('--use-fake-ui-for-media-stream');
-        args.push('--fake-device-for-media-stream');
+        // Stub getUserMedia to always not allow access
+        args.push('--use-fake-ui-for-media-stream=deny');
 
         chromeCapabilities.set('chromeOptions', {args});
         chromeCapabilities.setLoggingPrefs({
diff --git a/test/integration/blocks.test.js b/test/integration/blocks.test.js
index 6ca2d279c..950d28587 100644
--- a/test/integration/blocks.test.js
+++ b/test/integration/blocks.test.js
@@ -158,7 +158,7 @@ describe('Working with the blocks', () => {
         await expect(logs).toEqual([]);
     });
 
-    test('Record option from sound block menu opens sound recorder', async () => {
+    test.only('Record option from sound block menu opens sound recorder', async () => {
         await loadUri(uri);
         await clickXpath('//button[@title="Try It"]');
         await clickText('Code');
@@ -166,6 +166,10 @@ describe('Working with the blocks', () => {
         await new Promise(resolve => setTimeout(resolve, 1000)); // Wait for scroll animation
         await clickText('Meow', scope.blocksTab); // Click "play sound <Meow> until done" block
         await clickText('record'); // Click "record..." option in the block's sound menu
+        // Access has been force denied, so close the alert that comes up
+        await driver.sleep(1000); // getUserMedia requests are very slow to fail for some reason
+        await driver.switchTo().alert()
+            .accept();
         await findByText('Record Sound'); // Sound recorder is open
         const logs = await getLogs();
         await expect(logs).toEqual([]);
-- 
GitLab