Audit the project and secure toolbox data

This commit is contained in:
Shinuwa 2026-10-14 16:59:09 +02:00
parent 96af62edf0
commit e87edda5c7
40 changed files with 2324 additions and 125 deletions

View file

@ -49,7 +49,7 @@ for (const width of [1280, 390]) {
await expect(prismana).toHaveAttribute("aria-pressed", "false");
await prismana.click();
await expect(page.locator('.aniimo-result:not([data-form="prismana_form"])')).toHaveCount(0);
await expect(page.getByRole("tablist")).toHaveCount(0);
await expect(page.locator('.aniimo-tabs[role="tablist"]')).toHaveCount(0);
expect(await page.locator('img[src="/static/icons/prismana.svg"]').evaluate((image) => image.complete && image.naturalWidth > 0)).toBe(true);
await page.getByRole("searchbox").fill("iris");
await expect(cards(page)).toHaveCount(3);

View file

@ -1,15 +1,26 @@
// Rôle : couvre les parcours persistants des liens, compteurs, checklists et galeries d'images.
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;
});
}
async function setup(page, type, data) {
await page.goto("/#/toolboxes");
await page.getByText("Importer une toolbox", { exact: true }).locator('input[type="file"]').setInputFiles({
name: "basic.json", mimeType: "application/json",
buffer: Buffer.from(JSON.stringify({
toolbox: { id: "basic", name: "Basic workflows", modules: [{ id: "tool", type, title: "Tool" }] },
modules: { tool: data },
})),
buffer: Buffer.from(JSON.stringify(createToolboxImportPayload({
id: "basic",
name: "Basic workflows",
modules: [{ id: "tool", type, title: "Tool" }],
moduleData: { tool: data },
}))),
});
await page.getByRole("link", { name: "Ouvrir Basic workflows", exact: true }).first().click();
const tool = page.locator(`[data-module-type="${type}"]`);
@ -69,19 +80,16 @@ test("empty collection tools explain that they have no content", async ({ page }
await page.getByText("Importer une toolbox", { exact: true }).locator('input[type="file"]').setInputFiles({
name: "empty-tools.json",
mimeType: "application/json",
buffer: Buffer.from(JSON.stringify({
toolbox: {
id: "empty-tools",
name: "Empty tools",
modules: [
buffer: Buffer.from(JSON.stringify(createToolboxImportPayload({
id: "empty-tools",
name: "Empty tools",
modules: [
{ id: "checklist", type: "checklist", title: "Checklist" },
{ id: "images", type: "images", title: "Images" },
{ id: "links", type: "links", title: "Links" },
{ id: "counters", type: "counters", title: "Counters" }
]
},
modules: {}
}))
]
})))
});
await page.getByRole("link", { name: "Ouvrir Empty tools", exact: true }).first().click();
await expect(page.getByText("Aucun élément dans cette checklist.", { exact: true })).toBeVisible();
@ -103,6 +111,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 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();
@ -111,14 +120,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 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 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 page.reload();
await expect(quantity).toHaveCount(0);
});

View file

@ -2,6 +2,7 @@
/* global window, document, IDBObjectStore, DOMException */
import { test, expect } from "@playwright/test";
import { Buffer } from "node:buffer";
import { createToolboxImportPayload } from "./helpers/toolboxImport.js";
async function setup(page) {
await page.route("**/__media-seed", (route) => route.fulfill({ contentType: "text/html", body: "<!doctype html><title>Seed</title>" }));
@ -97,7 +98,9 @@ test("creation, import and deletion preserve unread media and global exports inc
expect(await page.evaluate(() => window.moduleReads.every((key) => ["a:timer", "a:calendar"].includes(key)))).toBe(true);
await page.goto("/#/toolboxes");
await page.getByText("Importer une toolbox", { exact: true }).locator("input").setInputFiles({
name: "import.json", mimeType: "application/json", buffer: Buffer.from(JSON.stringify({ toolbox: { id: "source", name: "Imported", modules: [] }, modules: {} }))
name: "import.json",
mimeType: "application/json",
buffer: Buffer.from(JSON.stringify(createToolboxImportPayload({ id: "source", name: "Imported", modules: [] })))
});
await expect(page.locator(".toolbox-card")).toHaveCount(4);
expect((await disk(page)).modules).toMatchObject(seeded.modules);
@ -137,10 +140,12 @@ test("opening and editing one toolbox only reads its media and reuses it on retu
await page.getByRole("button", { name: "Afficher l'ajout de Images", exact: true }).click();
await page.getByRole("textbox", { name: "Libellé de l'image", exact: true }).fill("Edited");
await expect.poll(async () => (await disk(page)).modules["a:images"].images[0].label).toBe("Edited");
const readsAfterEdit = await page.evaluate(() => window.moduleReads.length);
expect(readsAfterEdit).toBe(initialReads + 1);
await page.goto("/#/toolboxes");
await page.getByRole("link", { name: "Ouvrir Alpha", exact: true }).first().click();
await expect(page.getByText("Edited", { exact: true })).toBeVisible();
expect(await page.evaluate(() => window.moduleReads.length)).toBe(initialReads);
expect(await page.evaluate(() => window.moduleReads.length)).toBe(readsAfterEdit);
});
test("the game drawer loads only the linked toolbox media", async ({ page }) => {

View file

@ -1,4 +1,5 @@
{
"version": 2,
"toolbox": {
"id": "fixture-toolbox",
"name": "Fixture Toolbox",
@ -11,23 +12,37 @@
}
],
"moduleColumns": 1,
"moduleOrder": {
"one": [
"fixture-note"
],
"two": [
[
"fixture-note"
],
[]
]
}
"spaces": [
{
"id": "fixture-default",
"name": "Défaut",
"moduleOrder": {
"one": [
"fixture-note"
],
"two": [
[
"fixture-note"
],
[]
]
}
}
],
"defaultSpaceId": "fixture-default",
"activeSpaceId": "fixture-default"
},
"modules": {
"fixture-note": {
"html": "<p>Imported fixture note</p>",
"text": "Imported fixture note",
"updatedAt": "2026-08-24T10:00:00.000Z"
"pages": [
{
"id": "fixture-page",
"title": "Page 1",
"html": "<p>Imported fixture note</p>",
"text": "Imported fixture note",
"updatedAt": "2026-08-24T10:00:00.000Z"
}
]
}
}
}

View file

@ -0,0 +1,23 @@
// Rôle : construit des fichiers d'import toolbox v2 canoniques pour les parcours navigateur.
import { createToolboxExportPayload } from "../../website/src/features/toolboxes/storage/toolboxStorage.js";
export function createToolboxImportPayload({ id, name, modules, moduleData = {} }) {
const moduleIds = modules.map((module) => module.id);
const toolbox = {
id,
name,
modules,
spaces: [{
id: "default",
name: "Défaut",
moduleOrder: { one: moduleIds, two: [moduleIds, []] }
}],
defaultSpaceId: "default",
activeSpaceId: "default",
updatedAt: "2026-10-14T12:00:00.000Z"
};
const storedModuleData = Object.fromEntries(
Object.entries(moduleData).map(([moduleId, data]) => [`${id}:${moduleId}`, data])
);
return createToolboxExportPayload(toolbox, storedModuleData);
}

View file

@ -0,0 +1,76 @@
// Rôle : vérifie le refus atomique des imports invalides et la fusion des imports entre pages.
/* global Buffer */
import { expect, test } from "@playwright/test";
import { resetSokkoStorage } from "./helpers/storage.js";
function payload(name, id = "source") {
return {
version: 2,
toolbox: {
id,
name,
modules: [{ id: "note", type: "notepad", title: "Notes" }],
spaces: [{ id: "default", name: "Défaut", moduleOrder: { one: ["note"], two: [["note"], []] } }],
defaultSpaceId: "default",
activeSpaceId: "default",
updatedAt: "2026-10-14T12:00:00.000Z"
},
modules: {
note: { pages: [{ id: "page", title: "Page 1", html: `<p>${name}</p>`, text: name }] }
}
};
}
async function importIndividual(page, value, filename = "toolbox.json") {
await page.getByText("Importer une toolbox", { exact: true }).locator("input[type='file']").setInputFiles({
name: filename,
mimeType: "application/json",
buffer: Buffer.from(JSON.stringify(value))
});
}
async function snapshot(page) {
return page.evaluate(async () => (await import("/src/utils/indexedDbStorage.js")).getToolboxSnapshot());
}
test("an unsupported import reports its version and preserves every stored value", async ({ page }) => {
await resetSokkoStorage(page);
await page.goto("/#/toolboxes");
await importIndividual(page, payload("Conservée"));
await expect(page.getByRole("link", { name: "Ouvrir Conservée", exact: true }).first()).toBeVisible();
const before = await snapshot(page);
const invalid = payload("À refuser", "invalid");
invalid.version = 999;
invalid.toolbox.modules[0].type = "inconnu";
await importIndividual(page, invalid, "invalid.json");
const dialog = page.getByRole("dialog", { name: "Import impossible" });
await expect(dialog).toContainText("version 999 non prise en charge");
await dialog.getByRole("button", { name: "Compris", exact: true }).click();
expect(await snapshot(page)).toEqual(before);
await expect(page.getByRole("link", { name: "Ouvrir Conservée", exact: true }).first()).toBeVisible();
await expect(page.getByRole("link", { name: "Ouvrir À refuser", exact: true })).toHaveCount(0);
});
test("two pages importing from the same old state retain both toolboxes and their data", async ({ page, context }) => {
await resetSokkoStorage(page);
await page.goto("/#/toolboxes");
const otherPage = await context.newPage();
await otherPage.goto("/#/toolboxes");
await expect(page.getByText("Importer une toolbox", { exact: true })).toBeVisible();
await expect(otherPage.getByText("Importer une toolbox", { exact: true })).toBeVisible();
await Promise.all([
importIndividual(page, payload("Import A", "a"), "a.json"),
importIndividual(otherPage, payload("Import B", "b"), "b.json")
]);
for (const target of [page, otherPage]) {
await expect(target.getByRole("link", { name: "Ouvrir Import A", exact: true }).first()).toBeVisible();
await expect(target.getByRole("link", { name: "Ouvrir Import B", exact: true }).first()).toBeVisible();
}
const stored = await snapshot(page);
expect(stored.toolboxes.map((toolbox) => toolbox.name).sort()).toEqual(["Import A", "Import B"]);
expect(Object.values(stored.moduleData).map((data) => data.pages[0].text).sort()).toEqual(["Import A", "Import B"]);
});

View file

@ -46,3 +46,139 @@ test("partial snapshots preserve deferred values and roll back deletes on failur
afterSuccess: [{ key: "media", data: { image: "Keep" } }, { key: "note", data: { text: "New" } }]
});
});
async function runMutation(page, expected, next) {
return page.evaluate(async ({ expectedState, nextState }) => {
const [{ mutateToolboxStorage }, { createStorageMutation }] = await Promise.all([
import("/src/utils/indexedDbStorage.js"),
import("/src/features/toolboxes/storage/storageMutation.js")
]);
try {
await mutateToolboxStorage(createStorageMutation(expectedState, nextState));
return { ok: true };
} catch (error) {
return { ok: false, name: error.name, conflicts: error.conflicts || [] };
}
}, { expectedState: expected, nextState: next });
}
test("concurrent storage mutations merge independent resources and reject stale replacements", async ({ page, context }) => {
await resetSokkoStorage(page);
const otherPage = await context.newPage();
await otherPage.goto("/");
const empty = { toolboxes: [], links: {}, moduleData: {} };
const toolbox = (id, moduleId) => ({ id, name: id, modules: [{ id: moduleId, type: "notepad" }] });
const withA = {
toolboxes: [toolbox("a", "note-a")], links: {}, moduleData: { "a:note-a": { text: "A" } }
};
const withB = {
toolboxes: [toolbox("b", "note-b")], links: {}, moduleData: { "b:note-b": { text: "B" } }
};
expect(await Promise.all([
runMutation(page, empty, withA),
runMutation(otherPage, empty, withB)
])).toEqual([{ ok: true }, { ok: true }]);
const readSnapshot = () => page.evaluate(async () => (await import("/src/utils/indexedDbStorage.js")).getToolboxSnapshot());
let confirmed = await readSnapshot();
expect(confirmed.toolboxes.map((item) => item.id).sort()).toEqual(["a", "b"]);
expect(Object.keys(confirmed.moduleData).sort()).toEqual(["a:note-a", "b:note-b"]);
const editA = { ...confirmed, moduleData: { ...confirmed.moduleData, "a:note-a": { text: "A2" } } };
const editB = { ...confirmed, moduleData: { ...confirmed.moduleData, "b:note-b": { text: "B2" } } };
expect(await Promise.all([
runMutation(page, confirmed, editA),
runMutation(otherPage, confirmed, editB)
])).toEqual([{ ok: true }, { ok: true }]);
confirmed = await readSnapshot();
expect(confirmed.moduleData).toEqual({ "a:note-a": { text: "A2" }, "b:note-b": { text: "B2" } });
const firstReplacement = { ...confirmed, moduleData: { ...confirmed.moduleData, "a:note-a": { text: "Premier" } } };
const secondReplacement = { ...confirmed, moduleData: { ...confirmed.moduleData, "a:note-a": { text: "Second" } } };
const replacements = await Promise.all([
runMutation(page, confirmed, firstReplacement),
runMutation(otherPage, confirmed, secondReplacement)
]);
expect(replacements.filter((result) => result.ok)).toHaveLength(1);
expect(replacements.filter((result) => result.name === "StorageConflictError")).toHaveLength(1);
confirmed = await readSnapshot();
const withoutA = {
...confirmed,
toolboxes: confirmed.toolboxes.filter((item) => item.id !== "a"),
moduleData: Object.fromEntries(Object.entries(confirmed.moduleData).filter(([key]) => !key.startsWith("a:")))
};
const staleMediaWrite = {
...confirmed,
moduleData: { ...confirmed.moduleData, "a:note-a": { text: "Ressuscité" } }
};
expect(await runMutation(page, confirmed, withoutA)).toEqual({ ok: true });
expect(await runMutation(otherPage, confirmed, staleMediaWrite)).toMatchObject({ ok: false, name: "StorageConflictError" });
confirmed = await readSnapshot();
expect(confirmed.toolboxes.map((item) => item.id)).toEqual(["b"]);
expect(confirmed.moduleData["a:note-a"]).toBeUndefined();
});
test("two open pages keep both toolbox creations and refresh their lists", async ({ page, context }) => {
await resetSokkoStorage(page);
await page.goto("/#/toolboxes");
const otherPage = await context.newPage();
await otherPage.goto("/#/toolboxes");
await expect(page.getByRole("button", { name: "Nouvelle toolbox" })).toBeVisible();
await expect(otherPage.getByRole("button", { name: "Nouvelle toolbox" })).toBeVisible();
async function createToolbox(target, name) {
await target.getByRole("button", { name: "Nouvelle toolbox" }).click();
const dialog = target.getByRole("dialog", { name: "Nouvelle toolbox" });
await dialog.getByLabel("Nom").fill(name);
await dialog.getByRole("button", { name: "Créer" }).click();
}
await Promise.all([
createToolbox(page, "Onglet A"),
createToolbox(otherPage, "Onglet B")
]);
await page.goto("/#/toolboxes");
await otherPage.goto("/#/toolboxes");
for (const target of [page, otherPage]) {
await expect(target.getByRole("link", { name: "Ouvrir Onglet A", exact: true }).first()).toBeVisible();
await expect(target.getByRole("link", { name: "Ouvrir Onglet B", exact: true }).first()).toBeVisible();
await target.reload();
await expect(target.getByRole("link", { name: "Ouvrir Onglet A", exact: true }).first()).toBeVisible();
await expect(target.getByRole("link", { name: "Ouvrir Onglet B", exact: true }).first()).toBeVisible();
}
});
test("a stale toolbox replacement shows a conflict and reloads the confirmed version", async ({ page, context }) => {
await resetSokkoStorage(page);
await page.goto("/#/toolboxes");
await page.getByRole("button", { name: "Nouvelle toolbox" }).click();
const creation = page.getByRole("dialog", { name: "Nouvelle toolbox" });
await creation.getByLabel("Nom").fill("Version initiale");
await creation.getByRole("button", { name: "Créer" }).click();
await expect(page.getByRole("heading", { name: "Version initiale" })).toBeVisible();
const expected = await page.evaluate(async () => (await import("/src/utils/indexedDbStorage.js")).getToolboxSnapshot());
const remote = {
...expected,
toolboxes: expected.toolboxes.map((toolbox) => toolbox.name === "Version initiale"
? { ...toolbox, name: "Version distante", updatedAt: "2026-10-14T08:00:00.000Z" }
: toolbox)
};
const otherPage = await context.newPage();
await otherPage.goto("/");
expect(await runMutation(otherPage, expected, remote)).toEqual({ ok: true });
const title = page.locator("h1.toolbox-title");
await title.fill("Version locale");
await title.blur();
const conflict = page.getByRole("dialog", { name: "Erreur de stockage local" });
await expect(conflict).toContainText("modifiées dans un autre onglet");
await expect(page.getByRole("heading", { name: "Version distante" })).toBeVisible();
await conflict.getByRole("button", { name: "Compris" }).click();
const confirmed = await page.evaluate(async () => (await import("/src/utils/indexedDbStorage.js")).getToolboxSnapshot());
expect(confirmed.toolboxes.find((toolbox) => toolbox.name === "Version distante")).toBeTruthy();
expect(confirmed.toolboxes.find((toolbox) => toolbox.name === "Version locale")).toBeFalsy();
});

View file

@ -24,10 +24,10 @@ async function setup(page, fault) {
if (window.storageFault === "open") throw new DOMException("Ouverture indisponible", "UnknownError");
return open.apply(this, args);
};
const getAll = IDBObjectStore.prototype.getAll;
IDBObjectStore.prototype.getAll = function (...args) {
const get = IDBObjectStore.prototype.get;
IDBObjectStore.prototype.get = function (...args) {
if (window.storageFault === "read" && this.name === "modules") throw new DOMException("Lecture indisponible", "UnknownError");
return getAll.apply(this, args);
return get.apply(this, args);
};
const put = IDBObjectStore.prototype.put;
IDBObjectStore.prototype.put = function (...args) {

View file

@ -1,15 +1,18 @@
// Rôle : vérifie les dimensions, sélections et échanges de cellules du tableau réel.
import { expect, test } from "@playwright/test";
import { Buffer } from "node:buffer";
import { createToolboxImportPayload } from "./helpers/toolboxImport.js";
async function setup(page) {
await page.goto("/#/toolboxes");
await page.getByText("Importer une toolbox", { exact: true }).locator('input[type="file"]').setInputFiles({
name: "table.json", mimeType: "application/json",
buffer: Buffer.from(JSON.stringify({
toolbox: { id: "table-fixture", name: "Table workflows", modules: [{ id: "grid", type: "table", title: "Tableau" }] },
modules: { grid: { rows: 3, columns: 3, cells: { A1: "2", B1: "3", C1: "=A1+B1", A2: "4", B2: "6", C3: "removed" } } },
})),
buffer: Buffer.from(JSON.stringify(createToolboxImportPayload({
id: "table-fixture",
name: "Table workflows",
modules: [{ id: "grid", type: "table", title: "Tableau" }],
moduleData: { grid: { rows: 3, columns: 3, cells: { A1: "2", B1: "3", C1: "=A1+B1", A2: "4", B2: "6", C3: "removed" } } },
}))),
});
await page.getByRole("link", { name: "Ouvrir Table workflows", exact: true }).first().click();
const table = page.locator('[data-module-type="table"]');

View file

@ -1,19 +1,22 @@
// Rôle : vérifie l'édition, les prérequis et les réinitialisations du planificateur réel.
import { expect, test } from "@playwright/test";
import { Buffer } from "node:buffer";
import { createToolboxImportPayload } from "./helpers/toolboxImport.js";
async function setup(page) {
await page.goto("/#/toolboxes");
await page.getByText("Importer une toolbox", { exact: true }).locator('input[type="file"]').setInputFiles({
name: "tasks.json", mimeType: "application/json",
buffer: Buffer.from(JSON.stringify({
toolbox: { id: "tasks", name: "Task workflows", modules: [{ id: "planner", type: "taskPlanner", title: "Tasks" }] },
modules: { planner: { resetTime: "00:00", weeklyResetDay: 1, tasks: [
buffer: Buffer.from(JSON.stringify(createToolboxImportPayload({
id: "tasks",
name: "Task workflows",
modules: [{ id: "planner", type: "taskPlanner", title: "Tasks" }],
moduleData: { planner: { resetTime: "00:00", weeklyResetDay: 1, tasks: [
{ id: "parent", title: "Parent", type: "unique", category: "Raid" },
{ id: "child", title: "Child", type: "daily" },
{ id: "weekly", title: "Weekly", type: "weekly" },
] } },
})),
}))),
});
await page.getByRole("link", { name: "Ouvrir Task workflows", exact: true }).first().click();
const tool = page.locator('[data-module-type="taskPlanner"]');

View file

@ -1,18 +1,21 @@
// Rôle : vérifie les modales d'échange texte, les erreurs et la persistance des imports réels.
import { expect, test } from "@playwright/test";
import { Buffer } from "node:buffer";
import { createToolboxImportPayload } from "./helpers/toolboxImport.js";
async function setup(page) {
await page.goto("/#/toolboxes");
await page.getByText("Importer une toolbox", { exact: true }).locator('input[type="file"]').setInputFiles({
name: "exchange.json", mimeType: "application/json",
buffer: Buffer.from(JSON.stringify({
toolbox: { id: "exchange", name: "Text exchange", modules: [
buffer: Buffer.from(JSON.stringify(createToolboxImportPayload({
id: "exchange",
name: "Text exchange",
modules: [
{ id: "table", type: "table", title: "Tableau" },
{ id: "calc", type: "calculator", title: "Calculateur" },
] },
modules: { table: { rows: 2, columns: 2, cells: {} }, calc: { entries: [{ id: "original", label: "Original", value: 7, formula: "7" }] } },
})),
],
moduleData: { table: { rows: 2, columns: 2, cells: {} }, calc: { entries: [{ id: "original", label: "Original", value: 7, formula: "7" }] } },
}))),
});
await page.getByRole("link", { name: "Ouvrir Text exchange", exact: true }).first().click();
}
@ -45,6 +48,15 @@ test("table text import/export preserves formulas and labels, copies read-only t
await dialog.getByRole("button", { name: "Importer le TSV", exact: true }).click();
await expect(dialog).toBeHidden();
await expect(table.getByRole("textbox", { name: "Cellule B2", exact: true })).toHaveValue("10");
await expect.poll(() => page.evaluate(async () => {
const db = await import("/src/utils/indexedDbStorage.js");
const snapshot = await db.getToolboxSnapshot();
return Object.values(snapshot.moduleData).some((data) => (
data.columnLabels?.[0] === "Quantity"
&& data.rowLabels?.[0] === "Ore"
&& data.cells?.B1 === "=A1*2"
));
})).toBe(true);
await page.reload();
await expect(table.getByRole("textbox", { name: "Intitulé de colonne A", exact: true })).toHaveValue("Quantity");
await expect(table.getByRole("textbox", { name: "Intitulé de ligne 1", exact: true })).toHaveValue("Ore");

View file

@ -70,6 +70,7 @@ test("saves a cropped cover through reload and export/import, then returns to an
await expect(page.getByRole("button", { name: "Remplacer l'image de card" })).toHaveAttribute("aria-pressed", "true");
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\.png$/);
await page.reload();
await expect(picker(page).locator("img")).toHaveAttribute("src", /sword\.png$/);
await page.goto("/#/toolboxes");

View file

@ -73,6 +73,11 @@ test("creates at most five spaces and moves tools with the accessible selector",
await expect(page.getByRole("button", { name: "Nouvel espace" })).toBeEnabled();
await expect(page.getByRole("tab", { name: "Défaut" })).toHaveAttribute("aria-selected", "true");
await expect(page.locator("[data-module-id='a']")).toBeVisible();
await expect.poll(() => page.evaluate(async () => {
const db = await import("/src/utils/indexedDbStorage.js");
const toolbox = (await db.getToolboxes()).find((item) => item.id === "spaces");
return toolbox?.activeSpaceId === toolbox?.defaultSpaceId && toolbox?.spaces.length === 4;
})).toBe(true);
await page.reload();
await expect(page.getByRole("tab", { name: "Défaut" })).toHaveAttribute("aria-selected", "true");
});
@ -199,6 +204,10 @@ test("the linked game drawer shares the persisted active space", async ({ page }
await expect(drawer.locator("[data-module-id='a']")).toBeVisible();
await drawer.getByRole("tab", { name: "Défaut" }).click();
await expect(drawer.locator("[data-module-id='a']")).toHaveCount(0);
await expect.poll(() => page.evaluate(async () => {
const db = await import("/src/utils/indexedDbStorage.js");
return (await db.getToolboxes()).find((item) => item.id === "drawer-spaces")?.activeSpaceId;
})).toBe("default");
await page.reload();
await page.getByRole("tab", { name: "Toolbox", exact: true }).click();
await expect(page.locator("#toolbox-drawer").getByRole("tab", { name: "Défaut" })).toHaveAttribute("aria-selected", "true");

View file

@ -34,7 +34,9 @@ async function addTool(page, name) {
await page.getByRole("button", { name: "Ajouter un outil", exact: true }).click();
const addDialog = page.getByRole("dialog", { name: "Ajouter un outil" });
await expect(addDialog).toBeVisible();
await addDialog.getByRole("button", { name }).click();
await addDialog.locator(".tool-add-card").filter({
has: page.getByText(name, { exact: true })
}).click();
}
function moduleByType(page, type) {