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);
});

View file

@ -1,5 +1,6 @@
// Rôle : vérifie les calculs hiérarchiques et les actions du calculateur dans une toolbox réelle.
import { expect, test } from "@playwright/test";
import { readStoredModuleData } from "./helpers/storage.js";
async function setup(page) {
await page.goto("/#/toolboxes");
@ -52,6 +53,7 @@ test("parent edits recalculate descendants and survive reload; deleting a parent
await expression.fill("20");
await tool.getByRole("button", { name: "Mettre à jour", exact: true }).click();
await expect(entry(tool, "Child").locator("strong")).toHaveAttribute("aria-label", "60");
await expect.poll(async () => (await readStoredModuleData(page, "calculator"))?.entries?.find((item) => item.label === "Parent")?.value).toBe(20);
await page.reload();
await expect(entry(tool, "Parent").locator("strong")).toHaveAttribute("aria-label", "20");
await expect(entry(tool, "Child").locator("strong")).toHaveAttribute("aria-label", "60");
@ -60,6 +62,7 @@ test("parent edits recalculate descendants and survive reload; deleting a parent
await expect(tool.locator(".calculator-entry")).toHaveCount(0);
await expect(expression).toHaveValue("");
await expect(tool.getByRole("button", { name: "Enregistrer", exact: true })).toBeDisabled();
await expect.poll(async () => (await readStoredModuleData(page, "calculator"))?.entries?.length || 0).toBe(0);
await page.reload();
await expect(tool.getByText("Aucun résultat enregistré.", { exact: true })).toBeVisible();
});
@ -101,6 +104,7 @@ test("current values are subtracted from totals and kept during recalculation",
await expression.fill("20");
await tool.getByRole("button", { name: "Mettre à jour", exact: true }).click();
await expect(entry(tool, "Child").locator("strong")).toHaveAttribute("aria-label", "160");
await expect.poll(async () => (await readStoredModuleData(page, "calculator"))?.entries?.find((item) => item.label === "Child")?.value).toBe(160);
await page.reload();
await entry(tool, "Child").getByTitle("Modifier", { exact: true }).click();
await expect(current).toHaveValue("20");
@ -164,6 +168,7 @@ test("reordering roots keeps descendants attached and rejects moving a child to
await expect(tool.locator(".calculator-entry em")).toHaveText(["Second", "First", "Child"]);
await drag("Child", "Second");
await expect(tool.locator(".calculator-entry em")).toHaveText(["Second", "First", "Child"]);
await expect.poll(async () => (await readStoredModuleData(page, "calculator"))?.entries?.map((item) => item.label)).toEqual(["Second", "First", "Child"]);
await page.reload();
await expect(tool.locator(".calculator-entry em")).toHaveText(["Second", "First", "Child"]);
await tool.getByRole("button", { name: "Supprimer First", exact: true }).click();

View file

@ -286,6 +286,7 @@ for (const width of [1280, 768]) {
await drawer.locator('[data-module-type="checklist"]').filter({ has: page.getByRole("button", { name: "Retirer capture", exact: true }) }).getByRole("checkbox", { name: "Terminer Loufeuteau", exact: true }).check();
await closeDrawer(page);
await expect(card).toHaveCount(0);
await expect.poll(async () => (await readModule(page, "capture")).items.find((item) => item.label === "Loufeuteau")?.qtyCurrent).toBe(1);
await expect.poll(() => page.evaluate((key) => globalThis.localStorage.getItem(key), storageKey)).not.toBeNull();
await page.evaluate(() => globalThis.sessionStorage.clear());
await page.reload();
@ -341,6 +342,7 @@ for (const [gameId, category, cardClass, dataPath, dataKey, checklistTitle] of [
await expect(page.locator(`${cardClass}[data-checklist-complete="true"]`)).toHaveCount(1);
await toggleHidden(page);
await expect(page.locator(cardClass)).toHaveCount(count - 1);
await expect.poll(async () => (await readModule(page, "progress")).items[0]?.qtyCurrent).toBe(1);
await page.setViewportSize({ width: 390, height: 844 });
await page.reload();
await assertLink(page, "progress", true);
@ -380,6 +382,11 @@ test("deleting a selected checklist clears its link immediately", async ({ page
await page.getByRole("dialog").getByRole("button", { name: "Retirer", exact: true }).click();
await expect(activeButtons(page)).toHaveCount(0);
await expect(hiddenSwitch(page)).toHaveCount(0);
await expect.poll(async () => page.evaluate(async () => {
const db = await import("/src/utils/indexedDbStorage.js");
const snapshot = await db.getToolboxSnapshot("guide");
return snapshot.toolboxes.find((toolbox) => toolbox.id === "guide")?.modules.some((module) => module.id === "capture");
})).toBe(false);
await page.reload();
await assertLink(page, "", false);
expect(await page.evaluate((key) => globalThis.localStorage.getItem(key), storageKey)).toBeNull();

View file

@ -28,3 +28,49 @@ export async function resetSokkoStorage(page) {
});
});
}
export async function readStoredSnapshot(page) {
return page.evaluate(() => new Promise((resolve, reject) => {
const request = window.indexedDB.open("sokkog", 1);
request.onupgradeneeded = () => {
const db = request.result;
if (!db.objectStoreNames.contains("kv")) db.createObjectStore("kv");
if (!db.objectStoreNames.contains("modules")) db.createObjectStore("modules", { keyPath: "key" });
};
request.onerror = () => reject(request.error);
request.onsuccess = () => {
const db = request.result;
const transaction = db.transaction(["kv", "modules"], "readonly");
const toolboxesRequest = transaction.objectStore("kv").get("toolboxes");
const linksRequest = transaction.objectStore("kv").get("links");
const modulesRequest = transaction.objectStore("modules").getAll();
transaction.oncomplete = () => {
db.close();
resolve({
toolboxes: toolboxesRequest.result || [],
links: linksRequest.result || {},
moduleData: Object.fromEntries(modulesRequest.result.map(({ key, data }) => [key, data]))
});
};
transaction.onerror = () => reject(transaction.error);
transaction.onabort = () => reject(transaction.error);
};
}));
}
export async function readStoredModuleData(page, type, toolboxId = "") {
const snapshot = await readStoredSnapshot(page);
const toolbox = snapshot.toolboxes.find((item) => (
(!toolboxId || item.id === toolboxId)
&& item.modules.some((module) => module.type === type)
));
if (!toolbox) return null;
const module = toolbox?.modules.find((item) => item.type === type);
if (!module) return null;
return snapshot.moduleData[`${toolbox.id}:${module.id}`] || null;
}
export async function readStoredToolbox(page, toolboxId) {
const snapshot = await readStoredSnapshot(page);
return snapshot.toolboxes.find((toolbox) => toolbox.id === toolboxId) || null;
}

View file

@ -1,6 +1,6 @@
// Rôle : vérifie la bande de mémos fixe sur les pages de toolbox et de jeu associées.
import { test, expect } from "@playwright/test";
import { resetSokkoStorage } from "./helpers/storage.js";
import { readStoredModuleData, readStoredToolbox, resetSokkoStorage } from "./helpers/storage.js";
async function seedMemosToolbox(page) {
await resetSokkoStorage(page);
@ -72,6 +72,7 @@ test("shows and persists the memo ticker on linked game and full toolbox pages",
await expect(toggle).toHaveAccessibleName("Masquer la bande");
await toggle.click();
await expect(globalTicker).toHaveCount(0);
await expect.poll(async () => (await readStoredModuleData(page, "memos", "memo-toolbox"))?.tickerEnabled).toBe(false);
await page.reload();
await expect(globalTicker).toHaveCount(0);
await expect(toggle).toHaveAccessibleName("Afficher la bande");
@ -107,6 +108,11 @@ test("links a planner, shows its reset warning and clears the link when it is re
await expect(planner).toHaveCount(0);
await expect(plannerSelect).toHaveValue("");
await expect(globalTicker).not.toContainText("Faire le donjon");
await expect.poll(async () => {
const toolbox = await readStoredToolbox(page, "memo-toolbox");
const memosData = await readStoredModuleData(page, "memos", "memo-toolbox");
return [toolbox?.modules.some((module) => module.id === "planner-one"), memosData?.plannerLink || ""];
}).toEqual([false, ""]);
await page.reload();
await memos.getByRole("button", { name: "Configuration", exact: true }).click();

View file

@ -2,6 +2,7 @@
import { test, expect } from "@playwright/test";
import { readFile } from "node:fs/promises";
import { URL } from "node:url";
import { readStoredSnapshot } from "./helpers/storage.js";
const site = JSON.parse(await readFile("website/public/data/site.json", "utf8"));
const content = site.home.onboarding;
@ -72,6 +73,7 @@ test("home onboarding creates the initial tools and starts the tutorial", async
await expect(page.locator('[data-module-type="memos"]')).toBeVisible();
await expect(page.locator('[data-module-type="links"]')).toBeVisible();
await expect(page.locator(".toolbox-tutorial-count")).toHaveText(/^1\//);
await expect.poll(async () => (await readStoredSnapshot(page)).toolboxes.some((toolbox) => toolbox.name === "Prise en main")).toBe(true);
await page.goto("/#/");
await expect(page.getByRole("region", { name: content.title, exact: true })).toBeVisible();
await page.reload();

View file

@ -1,6 +1,7 @@
// Rôle : vérifie la visibilité de la prise en main sur le vrai build après création et suppression persistées.
import { test, expect } from "@playwright/test";
import { readFile } from "node:fs/promises";
import { readStoredSnapshot } from "../helpers/storage.js";
const site = JSON.parse(await readFile("website/public/data/site.json", "utf8"));
@ -19,6 +20,7 @@ test("production home hides onboarding after creation and restores it after dele
await expect(page).toHaveURL(/#\/toolbox\//);
await expect(page.locator('[data-module-type="memos"]')).toBeVisible();
await expect(page.locator('[data-module-type="links"]')).toBeVisible();
await expect.poll(async () => (await readStoredSnapshot(page)).toolboxes.some((toolbox) => toolbox.name === "Production toolbox")).toBe(true);
await page.goto("/#/");
await expect(page.getByRole("heading", { name: site.home.hero.title, exact: true })).toBeVisible();
@ -33,6 +35,7 @@ test("production home hides onboarding after creation and restores it after dele
await page.getByRole("button", { name: "Supprimer Production toolbox", exact: true }).click();
await page.getByRole("dialog").getByRole("button", { name: "Supprimer", exact: true }).click();
await expect(page.locator(".toolbox-card")).toHaveCount(0);
await expect.poll(async () => (await readStoredSnapshot(page)).toolboxes.length).toBe(0);
await page.goto("/#/");
await expect(onboarding).toBeVisible();
await page.reload();

View file

@ -2,6 +2,7 @@
import { expect, test } from "@playwright/test";
import { Buffer } from "node:buffer";
import { createToolboxImportPayload } from "./helpers/toolboxImport.js";
import { readStoredModuleData } from "./helpers/storage.js";
async function setup(page) {
await page.goto("/#/toolboxes");
@ -45,6 +46,10 @@ test("headers retain cell references and resizing removes only out-of-bounds dat
await column.press("Escape");
await expect(column).toHaveValue("Quantity");
await expect(cell(table, "C1")).toHaveValue("5");
await expect.poll(async () => {
const data = await readStoredModuleData(page, "table");
return [data?.columnLabels?.[0], data?.rowLabels?.[0]];
}).toEqual(["Quantity", "Materials"]);
await page.reload();
await expect(column).toHaveValue("Quantity");
await expect(row).toHaveValue("Materials");
@ -62,6 +67,10 @@ test("headers retain cell references and resizing removes only out-of-bounds dat
}
await expect(table.getByRole("button", { name: "Supprimer la dernière ligne", exact: true })).toBeDisabled();
await expect(table.getByRole("button", { name: "Supprimer la dernière colonne", exact: true })).toBeDisabled();
await expect.poll(async () => {
const data = await readStoredModuleData(page, "table");
return [data?.rows, data?.columns];
}).toEqual([1, 1]);
await page.reload();
await expect(table.getByRole("textbox", { name: /^Cellule / })).toHaveCount(1);
await expect(cell(table, "A1")).toHaveValue("2");
@ -96,6 +105,7 @@ test("keyboard selection copies evaluated TSV, pastes blocks and clears only sel
await cell(table, "A1").click();
await table.getByRole("button", { name: "Copier les valeurs", exact: true }).click();
await expect.poll(() => page.evaluate(() => globalThis.navigator.clipboard.readText())).toBe("2\t3\t5\n4\t6\t\n\t\t");
await expect.poll(async () => (await readStoredModuleData(page, "table"))?.cells?.C3).toBeUndefined();
await page.reload();
await expect(cell(table, "C1")).toHaveValue("5");
await expect(cell(table, "C3")).toHaveValue("");
@ -119,6 +129,7 @@ test("pointer selections move blocks and insert ranges into formulas without cha
await expect(cell(table, "C2")).toHaveValue("5");
await expect(cell(table, "A1")).toHaveValue("2");
await expect(cell(table, "B1")).toHaveValue("3");
await expect.poll(async () => (await readStoredModuleData(page, "table"))?.cells).toMatchObject({ A3: "4", B3: "6", C2: "=(A1+B1)" });
await page.reload();
await expect(cell(table, "C2")).toHaveValue("5");
await expect(cell(table, "A2")).toHaveValue("");

View file

@ -2,6 +2,7 @@
import { expect, test } from "@playwright/test";
import { Buffer } from "node:buffer";
import { createToolboxImportPayload } from "./helpers/toolboxImport.js";
import { readStoredModuleData } from "./helpers/storage.js";
async function setup(page) {
await page.goto("/#/toolboxes");
@ -46,11 +47,16 @@ test("creates and edits a categorized task with a multiline description and pers
await description.press("Enter");
await description.pressSequentially("Second line");
await tool.getByRole("textbox", { name: "Catégorie Renamed", exact: true }).click();
await expect.poll(async () => {
const task = (await readStoredModuleData(page, "taskPlanner"))?.tasks?.find((item) => item.title === "Renamed");
return [task?.description, task?.category];
}).toEqual(["First line\nSecond line", "Crafting"]);
await page.reload();
await tool.getByRole("button", { name: "Afficher la description Renamed", exact: true }).click();
await expect(description).toHaveValue("First line\nSecond line");
await expect(tool.getByRole("textbox", { name: "Catégorie Renamed", exact: true })).toHaveValue("Crafting");
await tool.getByRole("button", { name: "Supprimer Renamed", exact: true }).click();
await expect.poll(async () => (await readStoredModuleData(page, "taskPlanner"))?.tasks?.some((task) => task.title === "Renamed")).toBe(false);
await page.reload();
await expect(tool.locator(".task-planner-title-input")).toHaveCount(3);
await expect(tool.getByRole("button", { name: "Supprimer Renamed", exact: true })).toHaveCount(0);
@ -70,6 +76,7 @@ test("parent links inherit categories, warn without blocking completion and are
await expect(tool.getByRole("checkbox", { name: "Marquer non effectué Child", exact: true })).toBeChecked();
await tool.getByRole("checkbox", { name: "Marquer effectué Parent", exact: true }).check();
await expect(tool.locator(".task-planner-warning")).toHaveCount(0);
await expect.poll(async () => (await readStoredModuleData(page, "taskPlanner"))?.tasks?.find((task) => task.title === "Parent")?.checked).toBe(true);
await page.reload();
await tool.getByRole("button", { name: "Réglages de la tâche Child", exact: true }).click();
await expect(tool.getByRole("checkbox", { name: "Pré requis Parent", exact: true })).toBeChecked();
@ -78,6 +85,7 @@ test("parent links inherit categories, warn without blocking completion and are
await expect(tool.getByText("Aucun parent", { exact: true })).toBeVisible();
await tool.getByRole("button", { name: "Afficher la description Child", exact: true }).click();
await expect(category).toBeEnabled();
await expect.poll(async () => (await readStoredModuleData(page, "taskPlanner"))?.tasks?.some((task) => task.title === "Parent")).toBe(false);
await page.reload();
await expect(tool.getByRole("button", { name: "Supprimer Child", exact: true })).toBeVisible();
await expect(tool.getByRole("button", { name: "Supprimer Parent", exact: true })).toHaveCount(0);
@ -96,6 +104,7 @@ test("recurring resets preserve unique completions and cleanup deletes only comp
const hide = tool.getByRole("button", { name: "Masquer les tâches effectuées", exact: true });
await hide.click();
await expect(tool.getByRole("button", { name: "Supprimer Parent", exact: true })).toHaveCount(0);
await expect.poll(async () => (await readStoredModuleData(page, "taskPlanner"))?.hideCompleted).toBe(true);
await page.reload();
await expect(hide).toHaveAttribute("aria-pressed", "true");
await hide.click();
@ -104,6 +113,7 @@ test("recurring resets preserve unique completions and cleanup deletes only comp
const cleanup = tool.getByRole("button", { name: "Nettoyer les tâches ponctuelles effectuées", exact: true });
await cleanup.click();
await expect(cleanup).toBeDisabled();
await expect.poll(async () => (await readStoredModuleData(page, "taskPlanner"))?.tasks?.some((task) => task.title === "Parent")).toBe(false);
await page.reload();
await expect(tool.locator(".task-planner-title-input")).toHaveCount(2);
await expect(tool.getByRole("checkbox", { name: "Marquer effectué Child", exact: true })).toBeVisible();
@ -129,6 +139,7 @@ test("reordering a parent moves its subtree and rejects detaching a child", asyn
await expect.poll(titles).toEqual(["Parent", "Child", "Weekly"]);
await drag("Child", "Weekly");
await expect.poll(titles).toEqual(["Parent", "Child", "Weekly"]);
await expect.poll(async () => (await readStoredModuleData(page, "taskPlanner"))?.tasks?.map((task) => task.title)).toEqual(["Parent", "Weekly", "Child"]);
await page.reload();
await expect.poll(titles).toEqual(["Parent", "Child", "Weekly"]);
await tool.getByRole("button", { name: "Réglages de la tâche Child", exact: true }).click();

View file

@ -3,6 +3,7 @@ import { expect, test } from "@playwright/test";
import { readFile } from "node:fs/promises";
import { Buffer } from "node:buffer";
import { fileURLToPath, URL } from "node:url";
import { readStoredSnapshot } from "./helpers/storage.js";
const imagePath = fileURLToPath(new URL("../website/public/static/img/toolbox-icons/sword.webp", import.meta.url));
const fixture = JSON.parse(await readFile(new URL("./fixtures/toolbox-export.json", import.meta.url), "utf8"));
@ -53,6 +54,7 @@ test("saves a cropped cover through reload and export/import, then returns to an
const savedCover = await picker(page).locator("img").getAttribute("src");
expect(savedCover).toMatch(/^data:image\/(webp|jpeg);base64,/);
await expect.poll(() => picker(page).locator("img").evaluate((img) => [img.naturalWidth, img.naturalHeight])).toEqual([620, 248]);
await expect.poll(async () => (await readStoredSnapshot(page)).toolboxes.find((toolbox) => toolbox.name === "Cover workflow")?.customCover).toBe(savedCover);
await page.reload();
await expect(picker(page).locator("img")).toHaveAttribute("src", savedCover);
await page.goto("/#/toolboxes");
@ -71,6 +73,10 @@ test("saves a cropped cover through reload and export/import, then returns to an
await expect(page.getByRole("button", { name: "Utiliser l'icône sword", exact: true })).toHaveAttribute("aria-pressed", "false");
await page.getByRole("button", { name: "Utiliser l'icône sword", exact: true }).click();
await expect(picker(page).locator("img")).toHaveAttribute("src", /sword\.webp$/);
await expect.poll(async () => {
const toolbox = (await readStoredSnapshot(page)).toolboxes.find((item) => item.name === "Imported cover");
return [toolbox?.icon.endsWith("sword.webp"), toolbox?.customCover || ""];
}).toEqual([true, ""]);
await page.reload();
await expect(picker(page).locator("img")).toHaveAttribute("src", /sword\.webp$/);
await page.goto("/#/toolboxes");

View file

@ -1,7 +1,7 @@
// Rôle : valide l’accès immédiat aux toolboxes et aux réglages locaux de la collection.
/* global document, Buffer */
import { expect, test } from "@playwright/test";
import { resetSokkoStorage } from "./helpers/storage.js";
import { readStoredSnapshot, resetSokkoStorage } from "./helpers/storage.js";
function toolbox(id, name) {
return {
@ -176,6 +176,7 @@ test("renders ten toolboxes without overflow and persists card reordering", asyn
await page.mouse.up();
await expect(cards.nth(0).getByRole("heading")).toHaveText(/Collection 2/);
await expect.poll(async () => (await readStoredSnapshot(page)).toolboxes[0]?.id).toBe("toolbox-2");
await page.reload();
await expect(cards.nth(0).getByRole("heading")).toHaveText(/Collection 2/);
});

View file

@ -4,7 +4,7 @@ import { expect, test } from "@playwright/test";
import { readFileSync } from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
import { resetSokkoStorage } from "./helpers/storage.js";
import { readStoredModuleData, resetSokkoStorage } from "./helpers/storage.js";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const fixturePath = path.join(__dirname, "fixtures", "toolbox-export.json");
@ -141,6 +141,7 @@ test("keeps an uncommitted memo through unrelated app updates and saves multilin
await editor.pressSequentially("Troisieme ligne");
await editor.blur();
await expect(editor).toHaveValue("Premiere ligne\nDeuxieme ligne\nTroisieme ligne");
await expect.poll(async () => (await readStoredModuleData(page, "memos"))?.items?.[0]?.text).toBe("Premiere ligne\nDeuxieme ligne\nTroisieme ligne");
await page.reload();
await expect(editor).toHaveValue("Premiere ligne\nDeuxieme ligne\nTroisieme ligne");
await editor.fill(" Premiere ligne\nDeuxieme ligne\nTroisieme ligne ");
@ -566,6 +567,7 @@ test("edits a table with formulas and persists values", async ({ page }) => {
await tableCell(table, "C1").press("Enter");
await expect(tableCell(table, "C1")).toHaveValue("36");
await expect.poll(async () => (await readStoredModuleData(page, "table"))?.cells).toMatchObject({ A1: "12", B1: "3", C1: "=A1*B1" });
await page.reload();
await expect(tableCell(moduleByType(page, "table"), "A1")).toHaveValue("12");
await expect(tableCell(moduleByType(page, "table"), "C1")).toHaveValue("36");
@ -614,6 +616,7 @@ test("creates edits summarizes and deletes equipment", async ({ page }) => {
await expect(equipmentPlanner.getByText("Attaque").first()).toBeVisible();
await expect(equipmentPlanner.getByText("12").first()).toBeVisible();
await expect.poll(async () => (await readStoredModuleData(page, "equipmentPlanner"))?.equipments?.[0]?.characteristics?.[0]?.name).toBe("Attaque");
await page.reload();
const persistedPlanner = moduleByType(page, "equipmentPlanner");
await expect(persistedPlanner.getByText("Épée E2E")).toBeVisible();
@ -638,7 +641,7 @@ test("edits rich notepad content and persists it", async ({ page }) => {
await expect(editor).toContainText("Note E2E importante");
await expect(notepad.getByRole("heading", { name: "Note E2E importante" })).toBeVisible();
await page.waitForTimeout(500);
await expect.poll(async () => (await readStoredModuleData(page, "notepad"))?.pages?.[0]?.text).toBe("Note E2E importante");
await page.reload();
const persistedEditor = moduleByType(page, "notepad").getByRole("textbox");
await expect(persistedEditor).toContainText("Note E2E importante");