Improve compact desktop usability and action guidance
All checks were successful
Deploy Sokko G / deploy (push) Successful in 19s

This commit is contained in:
Shinuwa 2026-10-05 21:47:16 +02:00
parent 0ac1a0974e
commit 0fc18cd8b9
24 changed files with 325 additions and 90 deletions

View file

@ -18,11 +18,14 @@ async function setup(page) {
context.fillRect(0, 0, 32, 32);
const green = canvas.toDataURL();
const targetAt = Date.now() + 60000;
const currentDate = new Date();
const currentDateKey = `${currentDate.getFullYear()}-${String(currentDate.getMonth() + 1).padStart(2, "0")}-${String(currentDate.getDate()).padStart(2, "0")}`;
const toolboxes = [
{ id: "a", name: "Alpha", updatedAt: "2026-09-12T12:00:00Z", modules: [
{ id: "images", type: "images", title: "Images" },
{ id: "map", type: "imageAnnotation", title: "Carte" },
{ id: "timer", type: "timer", title: "Timer" }
{ id: "timer", type: "timer", title: "Timer" },
{ id: "calendar", type: "calendar", title: "Calendrier" }
] },
{ id: "b", name: "Beta", updatedAt: "2026-09-12T12:00:00Z", modules: [{ id: "images", type: "images", title: "Images" }] }
];
@ -30,6 +33,7 @@ async function setup(page) {
"a:images": { images: [{ id: "red", label: "Rouge", dataUrl: red }] },
"a:map": { image: green, markers: [{ id: "marker", x: 25, y: 50, label: "Entrée" }], drawings: { strokes: [{ id: "stroke", color: "#f6c453", width: 4, points: [{ x: 10, y: 10 }, { x: 80, y: 80 }] }] } },
"a:timer": { countdowns: [{ id: "alert", type: "duration", label: "Alerte fermée", targetAt, durationMs: 60000, alertMode: "site" }] },
"a:calendar": { viewMode: "month", events: [{ id: "current", title: "Événement persistant", startDate: currentDateKey, endDate: currentDateKey, repeat: "none", alertMode: "site", alertOffsetMinutes: [0] }] },
"b:images": { images: [{ id: "green", label: "Vert", dataUrl: green }] }
};
await db.setToolboxSnapshot(toolboxes, { mhwilds: "a" }, modules);
@ -71,12 +75,16 @@ async function exportJson(page, buttonName = "Exporter tout") {
test("closed media stays unread while site-wide timer alerts still fire", async ({ page }) => {
const seeded = await setup(page);
expect(await page.evaluate(() => window.moduleReads)).not.toEqual([]);
expect(await page.evaluate(() => window.moduleReads.every((key) => key === "a:timer"))).toBe(true);
expect(await page.evaluate(() => window.moduleReads.every((key) => ["a:timer", "a:calendar"].includes(key)))).toBe(true);
await expect(page.getByRole("status").filter({ hasText: "Événement persistant" })).toBeVisible();
await page.clock.install({ time: new Date(seeded.targetAt - 3000) });
await page.clock.pauseAt(new Date(seeded.targetAt - 2000));
await page.clock.runFor(3000);
await expect(page.getByRole("status").filter({ hasText: "Alerte fermée" })).toBeVisible();
expect(await page.evaluate(() => window.moduleReads.every((key) => key === "a:timer"))).toBe(true);
await page.clock.runFor(7000);
await expect(page.getByRole("status").filter({ hasText: "Alerte fermée" })).toBeVisible();
await expect(page.getByRole("status").filter({ hasText: "Événement persistant" })).toBeVisible();
expect(await page.evaluate(() => window.moduleReads.every((key) => ["a:timer", "a:calendar"].includes(key)))).toBe(true);
});
test("creation, import and deletion preserve unread media and global exports include it", async ({ page }) => {
@ -86,14 +94,14 @@ test("creation, import and deletion preserve unread media and global exports inc
await page.getByRole("button", { name: "Créer", exact: true }).click();
await expect.poll(async () => (await disk(page)).toolboxes.length).toBe(3);
expect((await disk(page)).modules).toMatchObject(seeded.modules);
expect(await page.evaluate(() => window.moduleReads.every((key) => key === "a:timer"))).toBe(true);
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: {} }))
});
await expect(page.locator(".toolbox-card")).toHaveCount(4);
expect((await disk(page)).modules).toMatchObject(seeded.modules);
expect(await page.evaluate(() => window.moduleReads.every((key) => key === "a:timer"))).toBe(true);
expect(await page.evaluate(() => window.moduleReads.every((key) => ["a:timer", "a:calendar"].includes(key)))).toBe(true);
const exported = await exportJson(page);
for (const key of ["a:images", "a:map", "b:images"]) expect(exported.modules[key]).toEqual(seeded.modules[key]);
await page.getByRole("button", { name: "Supprimer Beta", exact: true }).click();