test(e2e): reconcile shell and smoke consumers with approved lifetime and locale contracts

This commit is contained in:
cesnimda
2026-10-21 12:48:44 +02:00
parent 32e464f612
commit 508d68e16d
5 changed files with 316 additions and 12 deletions
+6 -11
View File
@@ -323,33 +323,28 @@ for (const mode of ["light", "dark"] as const) for (const language of ["en", "nb
}
};
await choose(t.settingsTabBackup);
// Complete the real export after navigating back to the bottom action.
// Otherwise clicking General correctly dismisses the toast via click-away.
let release!: () => void;
const held = new Promise<void>(resolve => { release = resolve; });
await page.route(`${apiUrl}/export/account`, async route => {
// One native ZIP, replayed for viewport checks to respect the 2/minute owner limit.
exported ??= await route.fetch();
expect(exported.status()).toBe(200);
await held;
await route.fulfill({ response: exported });
}, { times: 1 });
const download = page.waitForEvent("download");
await main.getByRole("button", { name: t.accountExportDownload, exact: true }).click();
await choose(t.settingsTabGeneral);
const manage = main.getByRole("button", { name: t.settingsManageConnectedAccounts, exact: true });
await manage.focus();
release();
expect((await download).suggestedFilename()).toMatch(/\.zip$/);
// Keep the private-export owner mounted; leaving Backup intentionally disposes late downloads.
const encrypted = main.getByRole("button", { name: t.backupDownload, exact: true });
await expect(encrypted).toBeEnabled();
await encrypted.focus();
const toast = page.getByRole("alert").filter({ hasText: t.accountExportDownloaded });
await expect(toast).toBeVisible();
// Deliberately align at the viewport end: reserved page space alone does
// not stop native scrolling from placing an action underneath the toast.
await manage.evaluate(node => node.scrollIntoView({ block: "end" }));
await encrypted.evaluate(node => node.scrollIntoView({ block: "end" }));
// Hover uses Snackbar's normal pause behavior; timing is not shortened or mocked.
await toast.hover();
await toast.getByRole("button").focus();
await exposed(manage);
await exposed(encrypted);
await capture(page, info, `open-toast-${width}-${suffix}`);
await expect(toast).toBeVisible();
await exposed(toast.getByRole("button"));
+11 -1
View File
@@ -40,6 +40,10 @@ async function loginAs(page: Page, email: string, password: string) {
await page.getByLabel("Current password").fill(password);
await page.getByRole("button", { name: "Sign in", exact: true }).click();
await expect(page).toHaveURL(/\/dashboard$/);
if (email === "e2e@example.test") {
await setEnglishPreference(page);
await page.reload();
}
await expect(page.getByRole("heading", { name: "Dashboard", exact: true })).toBeVisible();
}
@@ -49,6 +53,7 @@ async function login(page: Page) {
async function loginForApiSetup(page: Page) {
expect((await page.request.post(`${apiUrl}/auth/login`, { data: { email: "e2e@example.test", password: "E2ePassword123!" } })).status()).toBe(200);
await setEnglishPreference(page);
}
async function csrfHeader(page: Page) {
@@ -59,6 +64,11 @@ async function csrfHeader(page: Page) {
return { "X-CSRF-TOKEN": cookie!.value, "X-Session-Context": me.sessionContext };
}
async function setEnglishPreference(page: Page) {
const headers = await csrfHeader(page);
expect((await page.request.put(`${apiUrl}/auth/preferences/language`, { headers, data: { language: "en" } })).status()).toBe(204);
}
test.beforeEach(async ({ page }) => {
await page.addInitScript(() => window.localStorage.setItem("uiLanguage", "en"));
});
@@ -117,7 +127,7 @@ test("login establishes an authenticated session", async ({ page }) => {
await login(page);
await expect(page.getByText("e2e@example.test").first()).toBeVisible();
await expect(page.getByTestId("admin-version-badge")).toHaveText("ve2e-verification");
await expect(page.getByLabel("Application version e2e-verification, commit e2e1234")).toBeVisible();
await expect(page.getByRole("img", { name: "Application version e2e-verification, commit e2e1234", exact: true })).toBeVisible();
await page.getByRole("button", { name: "Notifications" }).click();
await expect(page.getByLabel("Notifications panel")).toBeVisible();