sokko-g/e2e/memos-ticker.spec.js
Shinuwa 22b397ebfa Document Sokko G's architecture and folders, and move JavaScript file headers to JSDoc @file blocks
Add ARCHITECTURE.md (layers, flows, folder map, glossary), CONTRIBUTING.md
(setup and step-by-step recipes) and a README in each main folder, with an
index of docs/. Convert the 511 JavaScript headers from "// Rôle :" lines to
JSDoc @file blocks, define a three-level header template in website/AGENTS.md
and check the header in tests/file-headers.test.mjs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-01 09:42:13 +01:00

123 lines
5.6 KiB
JavaScript

/**
* @file 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 { readStoredModuleData, readStoredToolbox, resetSokkoStorage } from "./helpers/storage.js";
async function seedMemosToolbox(page) {
await resetSokkoStorage(page);
await page.evaluate(async () => {
await new Promise((resolve, reject) => {
const request = globalThis.indexedDB.open("sokkog", 1);
request.onsuccess = () => {
const db = request.result;
const tx = db.transaction(["kv", "modules"], "readwrite");
const soonReset = new Date(Date.now() + 60 * 60 * 1000);
const resetTime = `${String(soonReset.getHours()).padStart(2, "0")}:${String(soonReset.getMinutes()).padStart(2, "0")}`;
tx.objectStore("kv").put([
{
id: "memo-toolbox",
name: "Toolbox mémos",
modules: [
{ id: "memos", type: "memos", title: "Mémos" },
{ id: "planner-one", type: "taskPlanner", title: "Urgent planner" },
{ id: "planner-two", type: "taskPlanner", title: "Other planner" }
],
moduleColumns: 1
}
], "toolboxes");
tx.objectStore("kv").put({ mhwilds: "memo-toolbox" }, "links");
tx.objectStore("modules").put({
key: "memo-toolbox:memos",
data: { items: [{ id: "memo-1", text: "Préparer les potions", color: "#f6c453" }] }
});
tx.objectStore("modules").put({
key: "memo-toolbox:planner-one",
data: {
resetTime,
tasks: [
{ id: "category-parent", title: "Raid principal", type: "unique", category: "Raid" },
{ id: "daily-task", title: "Faire le donjon", type: "daily" },
{ id: "done-task", title: "Déjà terminée", type: "daily", checked: true, checkedAt: Date.now() }
],
relations: [{ id: "relation", fromTaskId: "daily-task", toTaskId: "category-parent" }]
}
});
tx.objectStore("modules").put({
key: "memo-toolbox:planner-two",
data: { tasks: [{ id: "unique-task", title: "Ponctuelle", type: "unique" }] }
});
tx.oncomplete = () => { db.close(); resolve(); };
tx.onerror = () => reject(tx.error);
};
request.onerror = () => reject(request.error);
});
});
await page.reload();
}
test("shows and persists the memo ticker on linked game and full toolbox pages", async ({ page }) => {
await seedMemosToolbox(page);
await page.goto("/#/games/mhwilds/monsters");
const globalTicker = page.locator(".global-memos-ticker");
await expect(globalTicker).toBeVisible();
await expect(globalTicker).toContainText("Préparer les potions");
await expect(globalTicker).toHaveCSS("position", "fixed");
await page.goto("/#/games/aniimo/aniimos");
await expect(globalTicker).toHaveCount(0);
await page.goto("/#/toolbox/memo-toolbox");
await expect(globalTicker).toBeVisible();
const toggle = page.locator(".memos-ticker-toggle");
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");
await toggle.click();
await expect(globalTicker).toBeVisible();
await page.goto("/#/toolboxes");
await expect(globalTicker).toHaveCount(0);
});
test("links a planner, shows its reset warning and clears the link when it is removed", async ({ page }) => {
await seedMemosToolbox(page);
await page.goto("/#/toolbox/memo-toolbox");
const memos = page.locator('[data-module-id="memos"]');
await memos.getByRole("button", { name: "Configuration", exact: true }).click();
const dataSectionBox = await memos.locator(".module-configuration-data").boundingBox();
const settingsSectionBox = await memos.locator(".module-configuration-specific").boundingBox();
expect(settingsSectionBox.y).toBeGreaterThan(dataSectionBox.y + dataSectionBox.height);
expect(settingsSectionBox.width).toBeCloseTo(dataSectionBox.width, 0);
const plannerSelect = memos.getByRole("combobox", { name: "Planificateur lié", exact: true });
await expect(plannerSelect).toHaveValue("");
await plannerSelect.selectOption("planner-one");
const globalTicker = page.locator(".global-memos-ticker");
await expect(globalTicker).toContainText("Tâche : Raid Faire le donjon expire bientôt");
await expect(globalTicker).not.toContainText("Déjà terminée");
await expect(globalTicker.locator(".memos-ticker-item.is-task-warning .ui-icon-warning")).toHaveCount(2);
const planner = page.locator('[data-module-id="planner-one"]');
await planner.getByRole("button", { name: "Retirer Urgent planner", exact: true }).click();
await page.getByRole("dialog").getByRole("button", { name: "Retirer", exact: true }).click();
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();
await expect(plannerSelect).toHaveValue("");
});