Serialize toolbox writes and preserve concurrent edits
Some checks failed
Deploy Sokko G / deploy (push) Failing after 2s

This commit is contained in:
Shinuwa 2026-09-10 19:09:48 +02:00
parent 7521d50626
commit a4cf633ab4
12 changed files with 381 additions and 320 deletions

29
e2e/persistence.spec.js Normal file
View file

@ -0,0 +1,29 @@
// Rôle : vérifie l'atomicité des snapshots avec une vraie transaction IndexedDB.
import { test, expect } from "@playwright/test";
import { resetSokkoStorage } from "./helpers/storage.js";
test("a synchronous snapshot error aborts all its IndexedDB writes", async ({ page }) => {
await resetSokkoStorage(page);
const result = await page.evaluate(async () => {
const db = await import("/src/utils/indexedDbStorage.js");
await db.setToolboxSnapshot([{ id: "saved", modules: [] }], { game: "saved" }, { "saved:note": { text: "Keep" } });
let errorName = "";
try {
await db.setToolboxSnapshot([{ id: "broken" }], {}, { "broken:note": { invalid: () => {} } });
} catch (error) {
errorName = error.name;
}
return {
errorName,
toolboxes: await db.getToolboxes(),
links: await db.getLinks(),
modules: await db.getAllModuleData()
};
});
expect(result).toEqual({
errorName: "DataCloneError",
toolboxes: [{ id: "saved", modules: [] }],
links: { game: "saved" },
modules: [{ key: "saved:note", data: { text: "Keep" } }]
});
});