From 843d66e35961ba42152196413da1e10548702340 Mon Sep 17 00:00:00 2001 From: Matt Hillsdon Date: Mon, 23 Nov 2026 13:42:27 +0000 Subject: [PATCH] Keep noWelcome on in e2e after in-app navigation The flag was only in the URL, which in-app links drop, so a reload after following one showed What's new on stages where noWelcome is off by default. Set it in localStorage from the fixture instead, with an option for the test that wants the dialog. --- src/e2e/app-test-fixtures.ts | 12 +++++++++++- src/e2e/app.ts | 8 +------- src/e2e/home.test.ts | 30 +++++++++++++++++------------- 3 files changed, 29 insertions(+), 21 deletions(-) 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 ({