Stabilize E2E persistence checks before reloads
Some checks failed
Validate Sokko G / validate (push) Failing after 12m44s

This commit is contained in:
Shinuwa 2026-10-23 19:59:45 +02:00
parent 7691a1dda8
commit 27a6c90c25
12 changed files with 116 additions and 16 deletions

View file

@ -2,14 +2,7 @@
import { expect, test } from "@playwright/test";
import { Buffer } from "node:buffer";
import { createToolboxImportPayload } from "./helpers/toolboxImport.js";
async function firstStoredModuleData(page) {
return page.evaluate(async () => {
const db = await import("/src/utils/indexedDbStorage.js");
const snapshot = await db.getToolboxSnapshot();
return Object.values(snapshot.moduleData)[0] || null;
});
}
import { readStoredModuleData } from "./helpers/storage.js";
async function setup(page, type, data) {
await page.goto("/#/toolboxes");
@ -43,13 +36,16 @@ test("links persist creation and copying; deleting a category preserves its link
await expect(form.locator('input[type="url"]')).toHaveValue("");
await tool.getByRole("button", { name: "Copier Guide", exact: true }).click();
await expect.poll(() => page.evaluate(() => globalThis.navigator.clipboard.readText())).toBe("https://example.com/guide");
await expect.poll(async () => (await readStoredModuleData(page, "links"))?.links?.some((item) => item.title === "Guide")).toBe(true);
await page.reload();
await expect(link).toHaveAttribute("href", "https://example.com/guide");
await tool.getByRole("button", { name: "Supprimer la catégorie Reference", exact: true }).click();
await expect(tool.getByRole("heading", { name: "Reference", exact: true })).toHaveCount(0);
await expect.poll(async () => (await readStoredModuleData(page, "links"))?.links?.some((item) => item.title === "Guide" && !item.category)).toBe(true);
await page.reload();
await expect(link).toBeVisible();
await tool.getByRole("button", { name: "Supprimer Guide", exact: true }).click();
await expect.poll(async () => Boolean((await readStoredModuleData(page, "links"))?.links?.some((item) => item.title === "Guide"))).toBe(false);
await page.reload();
await expect(link).toHaveCount(0);
});
@ -63,12 +59,15 @@ test("counters persist signed values and reset without affecting other counters"
await expect(item.locator("strong")).toHaveText("1");
await tool.getByRole("button", { name: "Décrémenter Attempts", exact: true }).click({ clickCount: 2 });
await expect(item.locator("strong")).toHaveText("-1");
await expect.poll(async () => (await readStoredModuleData(page, "counters"))?.counters?.find((counter) => counter.label === "Attempts")?.value).toBe(-1);
await page.reload();
await expect(item.locator("strong")).toHaveText("-1");
await tool.getByRole("button", { name: "Réinitialiser Attempts", exact: true }).click();
await expect.poll(async () => (await readStoredModuleData(page, "counters"))?.counters?.find((counter) => counter.label === "Attempts")?.value).toBe(0);
await page.reload();
await expect(item.locator("strong")).toHaveText("0");
await tool.getByRole("button", { name: "Supprimer Attempts", exact: true }).click();
await expect.poll(async () => (await readStoredModuleData(page, "counters"))?.counters?.some((counter) => counter.label === "Attempts")).toBe(false);
await page.reload();
await expect(tool.locator(".counter-item")).toHaveCount(1);
await expect(tool.locator(".counter-value strong")).toHaveText("9");
@ -111,7 +110,7 @@ test("checklist quantities are clamped and completed categories hide without los
await expect(quantity).toHaveValue("3");
await tool.getByRole("radio", { name: "Cachée quand terminée", exact: true }).click();
await expect(quantity).toHaveCount(0);
await expect.poll(async () => (await firstStoredModuleData(page))?.hideCompletedSectionsFully).toBe(true);
await expect.poll(async () => (await readStoredModuleData(page, "checklist"))?.hideCompletedSectionsFully).toBe(true);
await page.reload();
await expect(tool.getByRole("radio", { name: "Cachée quand terminée", exact: true })).toHaveAttribute("aria-checked", "true");
await tool.getByRole("radio", { name: "Visible quand terminée", exact: true }).click();
@ -120,17 +119,17 @@ test("checklist quantities are clamped and completed categories hide without los
await hideCompleted.click();
await expect(hideCompleted).toHaveAttribute("aria-pressed", "true");
await expect(quantity).toHaveCount(0);
await expect.poll(async () => (await firstStoredModuleData(page))?.hideCompletedItems).toBe(true);
await expect.poll(async () => (await readStoredModuleData(page, "checklist"))?.hideCompletedItems).toBe(true);
await page.reload();
await expect(hideCompleted).toHaveAttribute("aria-pressed", "true");
await hideCompleted.click();
await expect(quantity).toHaveValue("3");
await tool.getByRole("button", { name: "Retirer une quantité", exact: true }).click();
await expect.poll(async () => (await firstStoredModuleData(page))?.sections?.[0]?.items?.[0]?.qtyCurrent).toBe(2);
await expect.poll(async () => (await readStoredModuleData(page, "checklist"))?.sections?.[0]?.items?.[0]?.qtyCurrent).toBe(2);
await page.reload();
await expect(quantity).toHaveValue("2");
await tool.getByRole("button", { name: "Supprimer Ore", exact: true }).click();
await expect.poll(async () => Boolean((await firstStoredModuleData(page))?.sections?.length)).toBe(false);
await expect.poll(async () => Boolean((await readStoredModuleData(page, "checklist"))?.sections?.length)).toBe(false);
await page.reload();
await expect(quantity).toHaveCount(0);
});