Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/e2e/app-test-fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<MyFixtures & Options>({
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([
{
Expand All @@ -45,6 +48,13 @@ export const test = base.extend<MyFixtures & Options>({
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.
Expand Down
8 changes: 1 addition & 7 deletions src/e2e/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -848,11 +846,7 @@ export const appUrlPattern = (path: string = ""): RegExp => {
};

export const appUrl = (path: string, options: UrlOptions = {}): string => {
const flags = new Set<string>([
"none",
...(options.welcome ? [] : ["noWelcome"]),
...(options.flags ?? []),
]);
const flags = new Set<string>(["none", ...(options.flags ?? [])]);
const params: Array<[string, string]> = Array.from(flags).map((f) => [
"flag",
f,
Expand Down
30 changes: 17 additions & 13 deletions src/e2e/home.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 ({
Expand Down
Loading