diff --git a/src/e2e/app-test-fixtures.ts b/src/e2e/app-test-fixtures.ts index 7e5077e77..41a047c78 100644 --- a/src/e2e/app-test-fixtures.ts +++ b/src/e2e/app-test-fixtures.ts @@ -14,16 +14,19 @@ type Options = { noIndexedDB: boolean; /** Open the editor before the test. Off for tests that embed it. */ autoGoto: boolean; + /** Show the dialogs that greet a browser on its first visit. */ + welcome: boolean; }; export const test = base.extend({ noIndexedDB: [false, { option: true }], autoGoto: [true, { option: true }], + welcome: [false, { option: true }], // On the context rather than the app fixture: the compliance notice is a // modal dialog that hides the page from the accessibility tree, so a test // that only drives the pages needs the cookie just as much as one that // drives the editor. - context: async ({ context, noIndexedDB }, use) => { + context: async ({ context, noIndexedDB, welcome }, use) => { await context.grantPermissions(["clipboard-read", "clipboard-write"]); await context.addCookies([ { @@ -45,6 +48,13 @@ export const test = base.extend({ url: baseUrl, }, ]); + if (!welcome) { + // In storage rather than the URL's flag params, which in-app links + // drop, so a reload after following one still has it. + await context.addInitScript(() => { + localStorage.setItem("flags", "noWelcome"); + }); + } if (noIndexedDB) { await context.addInitScript(() => { // The getter lives on the prototype so an own property is needed. diff --git a/src/e2e/app.ts b/src/e2e/app.ts index 2b979df1e..916471169 100644 --- a/src/e2e/app.ts +++ b/src/e2e/app.ts @@ -36,8 +36,6 @@ export interface UrlOptions { language?: string; /** Iframe controller mode, as embedded by classroom. */ controller?: boolean; - /** Show the dialogs that greet a browser on its first visit. */ - welcome?: boolean; } interface SaveOptions { @@ -848,11 +846,7 @@ export const appUrlPattern = (path: string = ""): RegExp => { }; export const appUrl = (path: string, options: UrlOptions = {}): string => { - const flags = new Set([ - "none", - ...(options.welcome ? [] : ["noWelcome"]), - ...(options.flags ?? []), - ]); + const flags = new Set(["none", ...(options.flags ?? [])]); const params: Array<[string, string]> = Array.from(flags).map((f) => [ "flag", f, diff --git a/src/e2e/home.test.ts b/src/e2e/home.test.ts index 20a102ac2..9fc8bee87 100644 --- a/src/e2e/home.test.ts +++ b/src/e2e/home.test.ts @@ -32,20 +32,24 @@ test.describe("home page", () => { await homePage.expectNoNewAccessibilityViolations(); }); - test("shows what's new once", async ({ homePage }) => { - // Not homePage.goto(): the dialog repeats the heading it waits for. - await homePage.page.goto(homeUrl({ welcome: true })); - const dialog = modalDialog(homePage.page); - await expect( - dialog.getByRole("heading", { name: "What's new in the Python Editor" }) - ).toBeVisible(); - await homePage.expectNoNewAccessibilityViolations(); - await dialog.getByRole("button", { name: "Get started" }).click(); - await expect(dialog).toBeHidden(); + test.describe(() => { + test.use({ welcome: true }); - await homePage.page.reload(); - await homePage.expectOnPage(); - await expect(dialog).toBeHidden(); + test("shows what's new once", async ({ homePage }) => { + // Not homePage.goto(): the dialog repeats the heading it waits for. + await homePage.page.goto(homeUrl()); + const dialog = modalDialog(homePage.page); + await expect( + dialog.getByRole("heading", { name: "What's new in the Python Editor" }) + ).toBeVisible(); + await homePage.expectNoNewAccessibilityViolations(); + await dialog.getByRole("button", { name: "Get started" }).click(); + await expect(dialog).toBeHidden(); + + await homePage.page.reload(); + await homePage.expectOnPage(); + await expect(dialog).toBeHidden(); + }); }); test("creates a project and opens it in the editor", async ({