Preserve memo drafts and stabilize goal tree selection
Some checks failed
Deploy Sokko G / deploy (push) Failing after 2s
Some checks failed
Deploy Sokko G / deploy (push) Failing after 2s
This commit is contained in:
parent
b9cc77a4d1
commit
4f644ca116
8 changed files with 158 additions and 49 deletions
44
e2e/goal-selection.spec.js
Normal file
44
e2e/goal-selection.spec.js
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
// Rôle : 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([]);
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue