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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"pg-connection-string": "2.14.1"
},
"devDependencies": {
"@playwright/test": "1.56.0",
"@playwright/test": "1.63.0",
"fflate": "0.8.3",
"prettier": "3.9.9"
}
Expand Down
42 changes: 16 additions & 26 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 30 additions & 7 deletions tests/browser/report-preferences.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ test("English is the default and theme follows the system until explicitly chose
page,
}) => {
await page.emulateMedia({ colorScheme: "dark" });
await page.addInitScript(() => localStorage.clear());
await page.goto(reportUrl);
await expect(page.locator("html")).toHaveAttribute("lang", "en");
await expect(page.locator("html")).toHaveAttribute("data-theme", "dark");
Expand All @@ -141,12 +140,36 @@ test("English is the default and theme follows the system until explicitly chose
localStorage.getItem("dbdep-locale"),
]),
).toEqual(["light", "es"]);
// Remove the initialization script by loading the same file in a new page in this context.
const reloaded = await page.context().newPage();
await reloaded.goto(reportUrl);
await expect(reloaded.locator("html")).toHaveAttribute("lang", "es");
await expect(reloaded.locator("html")).toHaveAttribute("data-theme", "light");
await reloaded.close();
await page.reload();
await expect(page.locator("html")).toHaveAttribute("lang", "es");
await expect(page.locator("html")).toHaveAttribute("data-theme", "light");
});

test("report preferences persist between tabs with the same HTTP origin", async ({
page,
context,
}) => {
// Cross-tab storage sharing is defined for HTTP origins, not file URLs.
const url = "http://127.0.0.1:4173/preference-report.html";
const body = await readFile(new URL(reportUrl), "utf8");
await context.route(url, (route) =>
route.fulfill({ contentType: "text/html", body }),
);
await page.emulateMedia({ colorScheme: "light" });
await page.goto(url);
await page.getByRole("button", { name: "Switch to dark mode" }).click();
await page.getByRole("button", { name: "Español", exact: true }).click();
expect(
await page.evaluate(() => [
localStorage.getItem("dbdep-theme"),
localStorage.getItem("dbdep-locale"),
]),
).toEqual(["dark", "es"]);
const reopened = await context.newPage();
await reopened.goto(url);
await expect(reopened.locator("html")).toHaveAttribute("lang", "es");
await expect(reopened.locator("html")).toHaveAttribute("data-theme", "dark");
await reopened.close();
});

test("preferences remain usable when browser storage throws", async ({
Expand Down
3 changes: 3 additions & 0 deletions tests/browser/site-docs.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ test("the skip link focuses the current documentation page without changing its
page,
}) => {
await page.goto(`${site}/#/docs/installation`);
await expect(
page.getByRole("link", { name: "Skip to content" }),
).toBeVisible();
await page.keyboard.press("Tab");
await expect(
page.getByRole("link", { name: "Skip to content" }),
Expand Down
Loading