From 91ac9d772fb862041db14f09fa33972b6836ed6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Chmiela?= Date: Fri, 20 Dec 2019 19:58:00 +0100 Subject: [PATCH] [bare-expo][test-suite] Add support for expo-notifications test on web vapidPublicKey generated in the exponentjs Firebase project --- apps/bare-expo/app.json | 4 ++++ apps/bare-expo/e2e/TestSuite-test.web.js | 12 ++++++++++-- apps/test-suite/TestUtils.js | 3 ++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/apps/bare-expo/app.json b/apps/bare-expo/app.json index f0622a85d3a20..7a5d48a36b9b0 100644 --- a/apps/bare-expo/app.json +++ b/apps/bare-expo/app.json @@ -15,6 +15,10 @@ "include": ["test-suite", "bare-expo"] } } + }, + "notification": { + "serviceWorkerPath": "/expo-service-worker.js", + "vapidPublicKey": "BNHvR05XkY5LH9GdN0GreLx2wZnK9IwNJGVmo3jujIkFni4of26E3U3fnt9nUrZfM7h0omdIHKM0eshkzTSFOWQ" } } } diff --git a/apps/bare-expo/e2e/TestSuite-test.web.js b/apps/bare-expo/e2e/TestSuite-test.web.js index c1dc11e26fdad..0a11b2b57daf5 100644 --- a/apps/bare-expo/e2e/TestSuite-test.web.js +++ b/apps/bare-expo/e2e/TestSuite-test.web.js @@ -1,4 +1,4 @@ -/* global page */ +/* global page, browser */ import { setDefaultOptions } from 'expect-puppeteer'; import config from '../jest-puppeteer.config'; @@ -16,9 +16,12 @@ const TESTS = [ 'Contacts', 'Random', 'Crypto', + // Overridding permissions doesn't work in headless mode + // see https://github.com/puppeteer/puppeteer/issues/3279 + !config.launch.headless && 'expo-notifications', // 'Haptics', // 'SecureStore', -]; +].filter(t => t); // This is how long we allocate for the actual tests to be run after the test screen has mounted. const MIN_TIME = 50000; @@ -28,6 +31,11 @@ setDefaultOptions({ timeout: MIN_TIME * 1.5, }); +beforeAll(async () => { + const context = browser.defaultBrowserContext(); + await context.overridePermissions(config.url, ['notifications']); +}); + function matchID(id, ...props) { return expect(page).toMatchElement(`div[data-testid="${id}"]`, ...props); } diff --git a/apps/test-suite/TestUtils.js b/apps/test-suite/TestUtils.js index c4d34e560cdda..8591aaabb4ea5 100644 --- a/apps/test-suite/TestUtils.js +++ b/apps/test-suite/TestUtils.js @@ -68,7 +68,8 @@ export function getTestModules() { modules.push( require('./tests/Contacts'), // require('./tests/SVG'), - require('./tests/Localization') + require('./tests/Localization'), + optionalRequire('./tests/NewNotifications') ); if (browserSupportsWebGL()) {