From e55595cc55e782dfa7a3dd88c9b093d7843d91b5 Mon Sep 17 00:00:00 2001 From: Matt Weiden <538456+mweiden@users.noreply.github.com> Date: Tue, 12 May 2020 13:01:57 -0700 Subject: [PATCH] Fix smoke tests to work with remote deployments of cellxgene (#1469) * Add test for terms of service * Add workaround for chromium CSP require-trusted-types-for error --- client/__tests__/e2e/e2e.test.js | 11 +++++++++++ client/__tests__/e2e/puppeteerUtils.js | 4 ++-- client/__tests__/e2e/testBrowser.js | 4 ++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/client/__tests__/e2e/e2e.test.js b/client/__tests__/e2e/e2e.test.js index 1710da9c..226d37f1 100644 --- a/client/__tests__/e2e/e2e.test.js +++ b/client/__tests__/e2e/e2e.test.js @@ -29,6 +29,17 @@ describe("did launch", () => { ); expect(element).toBe(data.title); }); + + test("terms of service, if they are there", async () => { + try { + await utils.clickOn("tos-cookies-accept", { timeout: 500 }); + } catch { + console.warn("No terms of service footer detected.") + } + page.waitFor(50); // give the footer a chance to disappear + const result = await page.$("[data-testid='tos-cookies-accept']"); + expect(result).toBeNull(); + }); }); describe("metadata loads", () => { diff --git a/client/__tests__/e2e/puppeteerUtils.js b/client/__tests__/e2e/puppeteerUtils.js index c72a865b..e7374f8b 100644 --- a/client/__tests__/e2e/puppeteerUtils.js +++ b/client/__tests__/e2e/puppeteerUtils.js @@ -44,8 +44,8 @@ export const puppeteerUtils = (page) => ({ }, async clickOn(testid, options = {}) { - await this.waitByID(testid); - const click = await page.click(`[data-testid='${testid}']`, options); + await this.waitByID(testid, options); + const click = await page.click(`[data-testid='${testid}']`); await page.waitFor(50); return click; }, diff --git a/client/__tests__/e2e/testBrowser.js b/client/__tests__/e2e/testBrowser.js index 8aa57bca..2931c17f 100644 --- a/client/__tests__/e2e/testBrowser.js +++ b/client/__tests__/e2e/testBrowser.js @@ -36,6 +36,10 @@ export async function setupTestBrowser() { page.on("console", async (msg) => { // If there is a console.error but an error is not thrown, this will ensure the test fails if (msg.type() === "error") { + // TODO: chromium does not currently support the CSP directive on the + // line below, so we swallow this error. Remove this when the test + // suite uses a browser version that supports this directive. + if (msg.text() === "Unrecognized Content-Security-Policy directive 'require-trusted-types-for'.\n") return; const errorMsgText = await Promise.all( // TODO can we do this without internal properties? msg.args().map((arg) => arg._remoteObject.description)