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

@ -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");