sokko-g/e2e/goal-selection.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

47 lines
1.9 KiB
JavaScript

/**
* @file Couvre les remplacements de données et les onglets invalides du Goal Tree sous StrictMode.
*/
/* global window, document */
import { test, expect } from "@playwright/test";
import { fileURLToPath, URL } from "node:url";
const probeUrl = `/@fs/${fileURLToPath(new URL("./fixtures/goal-selection-probe.js", import.meta.url))}`;
test("goal selection remains valid through kind changes and data replacement", async ({ page }) => {
const errors = [];
page.on("pageerror", (error) => errors.push(error.message));
await page.goto("/");
await page.evaluate(async (url) => {
const { mountGoalSelectionProbe } = await import(url);
const element = document.createElement("div");
document.body.prepend(element);
window.goalProbe = mountGoalSelectionProbe(element);
}, probeUrl);
const first = { id: "first", title: "First", kind: "checklist" };
const second = { id: "second", title: "Second", kind: "checklist" };
async function updateAndCheck(nodes, selected, tab) {
const snapshots = await page.evaluate((nodes) => {
window.goalProbe.update(nodes);
return window.goalProbe.snapshots;
}, nodes);
expect(snapshots.length).toBeGreaterThan(0);
for (const snapshot of snapshots) {
expect(snapshot.selected).toBe(selected);
expect(snapshot.tab).toBe(tab);
expect(snapshot.tabs).toContain(snapshot.tab);
}
}
await updateAndCheck([first, second], "first", "base");
await page.evaluate(() => window.goalProbe.edit("second"));
expect(await page.evaluate(() => window.goalProbe.snapshots.at(-1).tab)).toBe("content");
await updateAndCheck([first, { ...second, kind: "step" }], "second", "base");
await updateAndCheck([first], "first", "base");
await updateAndCheck([first, second], "first", "base");
await updateAndCheck([], "", "base");
await updateAndCheck([second], "second", "base");
await page.evaluate(() => window.goalProbe.unmount());
expect(errors).toEqual([]);
});