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
This commit is contained in:
Matt Weiden
2020-05-12 13:01:57 -07:00
committed by GitHub
parent c1bf491a96
commit e55595cc55
3 changed files with 17 additions and 2 deletions
+11
View File
@@ -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", () => {
+2 -2
View File
@@ -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;
},
+4
View File
@@ -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)