From 4cb6487f8586989c5334a3bd4bb2a980da7a9b87 Mon Sep 17 00:00:00 2001 From: Shinuwa Date: Fri, 30 Oct 2026 14:14:23 +0100 Subject: [PATCH] Stabilize Playwright pointer interactions after lazy loading --- .beads/interactions.jsonl | 3 +++ e2e/AGENTS.md | 4 ++++ e2e/calculator.spec.js | 8 +++----- e2e/form-reorder.spec.js | 4 ++-- e2e/grouped-reorder.spec.js | 7 +++---- e2e/helpers/pointer.js | 24 ++++++++++++++++++++++++ e2e/module-order.spec.js | 9 ++++----- e2e/table.spec.js | 6 +++--- e2e/task-planner.spec.js | 7 +++---- e2e/toolbox-drawer-layout.spec.js | 5 ++--- e2e/toolbox-list.spec.js | 7 +++---- e2e/toolbox-spaces.spec.js | 13 +++++-------- 12 files changed, 59 insertions(+), 38 deletions(-) create mode 100644 e2e/helpers/pointer.js diff --git a/.beads/interactions.jsonl b/.beads/interactions.jsonl index 761547d..301234a 100644 --- a/.beads/interactions.jsonl +++ b/.beads/interactions.jsonl @@ -117,3 +117,6 @@ {"id":"int-ab0701939544da9e60d2bcebabfe4a30","kind":"field_change","created_at":"2026-10-29T17:32:17.237817908Z","actor":"Shinuwa","issue_id":"sokko-g-dvt","extra":{"field":"status","new_value":"closed","old_value":"in_progress","reason":"Region options now use a checkbox/text grid when no icon is present. Added browser assertions proving all three labels fit at 768 and 1440 px; reproduced failure before the fix and verified screenshots afterward. Three targeted Playwright scenarios and npm run check passed."}} {"id":"int-ec3b9e7e64de36eabf102280ec9ab31e","kind":"field_change","created_at":"2026-10-29T22:32:54.124522733Z","actor":"Shinuwa","issue_id":"sokko-g-alg","extra":{"field":"status","new_value":"closed","old_value":"in_progress","reason":"Completed 33 official French Aniimo name mappings from wiki.aniimo.com FR/EN pages, including Sparkelf → Elfe solidaire. Removed obsolete Little Fire Spirit translation aliases, search/checklist compatibility, and two old portrait files. Catalog rendering and region choices now keep special entries last. npm run check passed with 177 Node tests and build; targeted Playwright passed for regional order at 768/1440 px, catalogue navigation, and checklist round-trip."}} {"id":"int-b25ed60e10c23bf5f03fc20699e4f4a1","kind":"field_change","created_at":"2026-10-30T11:03:05.509945623Z","actor":"Shinuwa","issue_id":"sokko-g-xnm","extra":{"field":"status","new_value":"closed","old_value":"in_progress","reason":"Étude utilisateur abandonnée faute de participants ; arbitrage de bureau documenté sans nouvelle fonctionnalité, avec pistes différées et conditions de réexamen."}} +{"id":"int-6226671effacd330ce9b863270839c98","kind":"field_change","created_at":"2026-10-30T12:57:10.175823112Z","actor":"Shinuwa","issue_id":"sokko-g-2gj","extra":{"field":"status","new_value":"closed","old_value":"in_progress","reason":"Le test attend le chargement lazy stable et déclenche le geste aux coordonnées réelles ; 20 répétitions ciblées et check:full réussis."}} +{"id":"int-5f04344a759a5f822ac1c55320dabfcf","kind":"field_change","created_at":"2026-10-30T13:00:48.471198857Z","actor":"Shinuwa","issue_id":"sokko-g-2gj","extra":{"field":"status","new_value":"open","old_value":"closed"}} +{"id":"int-738633fa3740487a9b8bb0ff05de3b5a","kind":"field_change","created_at":"2026-10-30T13:10:47.886359117Z","actor":"Shinuwa","issue_id":"sokko-g-2gj","extra":{"field":"status","new_value":"closed","old_value":"in_progress","reason":"Shared pointer helper adopted by all existing left-button drag scenarios; repeated and full validation pass."}} diff --git a/e2e/AGENTS.md b/e2e/AGENTS.md index 1d51683..e4dea74 100644 --- a/e2e/AGENTS.md +++ b/e2e/AGENTS.md @@ -6,6 +6,10 @@ Cette zone contient les parcours Playwright de développement et de production. - Attendre un état observable de l'interface ou du stockage avec les assertions Playwright ; ne pas stabiliser un scénario avec un délai arbitraire. +- Pour les gestes pointeur sur l'application, utiliser les helpers partagés de + `helpers/pointer.js`. Ils attendent la fin du chargement différé des modules et + recalculent la géométrie juste avant `mouse.down()` ; ne pas enchaîner + `locator.hover()` et `mouse.down()` sur un contenu susceptible de se déplacer. - Cibler les rôles, noms accessibles et états ARIA quand ils font partie du contrat utilisateur. Après un changement de libellé ou de focus, rechercher et mettre à jour les parcours qui utilisent ce nom. diff --git a/e2e/calculator.spec.js b/e2e/calculator.spec.js index a941542..df4c163 100644 --- a/e2e/calculator.spec.js +++ b/e2e/calculator.spec.js @@ -1,5 +1,6 @@ // Rôle : vérifie les calculs hiérarchiques et les actions du calculateur dans une toolbox réelle. import { expect, test } from "@playwright/test"; +import { movePointerTo, startPointerDrag } from "./helpers/pointer.js"; import { readStoredModuleData } from "./helpers/storage.js"; async function setup(page) { @@ -156,12 +157,9 @@ test("reordering roots keeps descendants attached and rejects moving a child to await tool.getByLabel("Libellé", { exact: true }).fill("Child"); await tool.getByRole("button", { name: "Mettre à jour", exact: true }).click(); async function drag(label, targetLabel) { - await tool.getByRole("button", { name: `Déplacer ${label}`, exact: true }).hover(); - await page.mouse.down(); + await startPointerDrag(page, tool.getByRole("button", { name: `Déplacer ${label}`, exact: true })); const target = entry(tool, targetLabel); - await target.scrollIntoViewIfNeeded(); - const box = await target.boundingBox(); - await page.mouse.move(box.x + box.width / 2, box.y + box.height * 0.2, { steps: 5 }); + await movePointerTo(page, target, { y: 0.2 }); await page.mouse.up(); } await drag("Second", "First"); diff --git a/e2e/form-reorder.spec.js b/e2e/form-reorder.spec.js index 8118467..4386fbf 100644 --- a/e2e/form-reorder.spec.js +++ b/e2e/form-reorder.spec.js @@ -2,6 +2,7 @@ /* global window, document */ import { test, expect } from "@playwright/test"; import { fileURLToPath, URL } from "node:url"; +import { startPointerDrag } from "./helpers/pointer.js"; const probeUrl = `/@fs/${fileURLToPath(new URL("./fixtures/form-reorder-probe.js", import.meta.url))}`; async function setup(page, kind) { @@ -43,8 +44,7 @@ test("draft forms retain edits, report validation, prevent navigation and reset }); async function start(page) { - await page.getByRole("button", { name: "a", exact: true }).hover(); - await page.mouse.down(); + await startPointerDrag(page, page.getByRole("button", { name: "a", exact: true })); await expect(page.getByLabel("Dragging")).toHaveText("a"); } diff --git a/e2e/grouped-reorder.spec.js b/e2e/grouped-reorder.spec.js index 97d0c9a..8d29beb 100644 --- a/e2e/grouped-reorder.spec.js +++ b/e2e/grouped-reorder.spec.js @@ -2,6 +2,7 @@ /* global window, document */ import { test, expect } from "@playwright/test"; import { fileURLToPath, URL } from "node:url"; +import { movePointerTo, startPointerDrag } from "./helpers/pointer.js"; const probeUrl = `/@fs/${fileURLToPath(new URL("./fixtures/grouped-reorder-probe.js", import.meta.url))}`; test.beforeEach(async ({ page }) => { @@ -20,11 +21,9 @@ async function configure(page, options) { } async function drop(page, source, target, x = 0.2, y = 0.8) { - await page.getByRole("button", { name: source, exact: true }).hover(); - await page.mouse.down(); + await startPointerDrag(page, page.getByRole("button", { name: source, exact: true })); await expect(page.getByLabel("Dragging")).toHaveText("active"); - const box = await page.getByTestId(target).boundingBox(); - await page.mouse.move(box.x + box.width * x, box.y + box.height * y, { steps: 3 }); + await movePointerTo(page, page.getByTestId(target), { x, y, steps: 3 }); await page.mouse.up(); await expect(page.getByLabel("Dragging")).toBeEmpty(); return page.evaluate(() => window.groupedProbe.events.splice(0)); diff --git a/e2e/helpers/pointer.js b/e2e/helpers/pointer.js new file mode 100644 index 0000000..0fa8286 --- /dev/null +++ b/e2e/helpers/pointer.js @@ -0,0 +1,24 @@ +// Rôle : stabilise les gestes pointeur Playwright face aux chargements différés et aux déplacements de mise en page. +import { expect } from "@playwright/test"; + +export async function waitForLazyModules(page) { + await expect(page.locator(".module-loading-fallback")).toHaveCount(0); +} + +export async function startPointerDrag(page, source) { + await expect(source).toBeVisible(); + await waitForLazyModules(page); + await source.scrollIntoViewIfNeeded(); + const box = await source.boundingBox(); + expect(box).not.toBeNull(); + await page.mouse.move(box.x + box.width / 2, box.y + box.height / 2); + await page.mouse.down(); + return box; +} + +export async function movePointerTo(page, target, { x = 0.5, y = 0.5, steps = 5 } = {}) { + await target.scrollIntoViewIfNeeded(); + const box = await target.boundingBox(); + expect(box).not.toBeNull(); + await page.mouse.move(box.x + box.width * x, box.y + box.height * y, { steps }); +} diff --git a/e2e/module-order.spec.js b/e2e/module-order.spec.js index b971a0b..df1620e 100644 --- a/e2e/module-order.spec.js +++ b/e2e/module-order.spec.js @@ -1,5 +1,6 @@ // Rôle : vérifie les ordres indépendants une/deux colonnes et leur persistance après déplacement réel. import { test, expect } from "@playwright/test"; +import { movePointerTo, startPointerDrag } from "./helpers/pointer.js"; import { resetSokkoStorage } from "./helpers/storage.js"; async function setup(page, columns) { @@ -25,12 +26,10 @@ async function savedOrder(page) { } async function drag(page, title, target, after = false) { - await page.getByRole("button", { name: `Déplacer ${title}`, exact: true }).hover(); - await page.mouse.down(); + const handle = page.getByRole("button", { name: `Déplacer ${title}`, exact: true }); + await startPointerDrag(page, handle); await expect(page.locator("article.module.is-dragging")).toHaveCount(1); - await target.scrollIntoViewIfNeeded(); - const box = await target.boundingBox(); - await page.mouse.move(box.x + box.width / 2, box.y + box.height * (after ? 0.8 : 0.2), { steps: 5 }); + await movePointerTo(page, target, { y: after ? 0.8 : 0.2 }); await page.mouse.up(); await expect(page.locator("article.module.is-dragging")).toHaveCount(0); } diff --git a/e2e/table.spec.js b/e2e/table.spec.js index c8d0647..13eb81b 100644 --- a/e2e/table.spec.js +++ b/e2e/table.spec.js @@ -1,6 +1,7 @@ // Rôle : vérifie les dimensions, sélections et échanges de cellules du tableau réel. import { expect, test } from "@playwright/test"; import { Buffer } from "node:buffer"; +import { movePointerTo, startPointerDrag } from "./helpers/pointer.js"; import { createToolboxImportPayload } from "./helpers/toolboxImport.js"; import { readStoredModuleData } from "./helpers/storage.js"; @@ -26,9 +27,8 @@ function cell(table, address) { } async function drag(page, from, to) { - await from.hover(); - await page.mouse.down(); - await to.hover(); + await startPointerDrag(page, from); + await movePointerTo(page, to); await page.mouse.up(); } diff --git a/e2e/task-planner.spec.js b/e2e/task-planner.spec.js index fc63c77..76abe88 100644 --- a/e2e/task-planner.spec.js +++ b/e2e/task-planner.spec.js @@ -2,6 +2,7 @@ /* global document, window */ import { expect, test } from "@playwright/test"; import { Buffer } from "node:buffer"; +import { movePointerTo, startPointerDrag } from "./helpers/pointer.js"; import { createToolboxImportPayload } from "./helpers/toolboxImport.js"; import { readStoredModuleData } from "./helpers/storage.js"; @@ -246,10 +247,8 @@ test("reordering a parent moves its subtree and rejects detaching a child", asyn await tool.getByRole("combobox", { name: "Définir un parent", exact: true }).selectOption({ label: "Parent" }); await tool.getByRole("button", { name: "Réglages de la tâche Child", exact: true }).click(); async function drag(source, target) { - await tool.getByRole("button", { name: `Déplacer ${source}`, exact: true }).hover(); - await page.mouse.down(); - const box = await tool.getByRole("button", { name: `Déplacer ${target}`, exact: true }).boundingBox(); - await page.mouse.move(box.x + box.width / 2, box.y + box.height * 0.2, { steps: 5 }); + await startPointerDrag(page, tool.getByRole("button", { name: `Déplacer ${source}`, exact: true })); + await movePointerTo(page, tool.getByRole("button", { name: `Déplacer ${target}`, exact: true }), { y: 0.2 }); await page.mouse.up(); } const titles = () => tool.locator(".task-planner-title-input").evaluateAll((inputs) => inputs.map((input) => input.value)); diff --git a/e2e/toolbox-drawer-layout.spec.js b/e2e/toolbox-drawer-layout.spec.js index dc6ee0a..4a82924 100644 --- a/e2e/toolbox-drawer-layout.spec.js +++ b/e2e/toolbox-drawer-layout.spec.js @@ -1,5 +1,6 @@ // Rôle : vérifie le panneau large et la bascule guide/toolbox en fenêtre compacte. import { test, expect } from "@playwright/test"; +import { startPointerDrag } from "./helpers/pointer.js"; async function openDrawer(page) { await page.locator(".topbar-actions").waitFor(); @@ -18,9 +19,7 @@ async function openDrawer(page) { async function resizeDrawer(page, deltaX) { const handle = page.locator(".drawer-resize-handle"); - const bounds = await handle.boundingBox(); - await page.mouse.move(bounds.x + bounds.width / 2, bounds.y + bounds.height / 2); - await page.mouse.down(); + const bounds = await startPointerDrag(page, handle); await page.mouse.move(bounds.x + bounds.width / 2 + deltaX, bounds.y + bounds.height / 2); await page.mouse.up(); } diff --git a/e2e/toolbox-list.spec.js b/e2e/toolbox-list.spec.js index 4422bf2..250deb6 100644 --- a/e2e/toolbox-list.spec.js +++ b/e2e/toolbox-list.spec.js @@ -1,6 +1,7 @@ // Rôle : valide l’accès immédiat aux toolboxes et aux réglages locaux de la collection. /* global document, Buffer */ import { expect, test } from "@playwright/test"; +import { movePointerTo, startPointerDrag } from "./helpers/pointer.js"; import { readStoredSnapshot, resetSokkoStorage } from "./helpers/storage.js"; function toolbox(id, name) { @@ -169,10 +170,8 @@ test("renders ten toolboxes without overflow and persists card reordering", asyn const sourceHandle = cards.nth(0).getByRole("button", { name: /Déplacer Collection 1/ }); const target = cards.nth(1); - const [sourceBox, targetBox] = await Promise.all([sourceHandle.boundingBox(), target.boundingBox()]); - await page.mouse.move(sourceBox.x + sourceBox.width / 2, sourceBox.y + sourceBox.height / 2); - await page.mouse.down(); - await page.mouse.move(targetBox.x + targetBox.width * 0.8, targetBox.y + targetBox.height / 2, { steps: 8 }); + await startPointerDrag(page, sourceHandle); + await movePointerTo(page, target, { x: 0.8, steps: 8 }); await page.mouse.up(); await expect(cards.nth(0).getByRole("heading")).toHaveText(/Collection 2/); diff --git a/e2e/toolbox-spaces.spec.js b/e2e/toolbox-spaces.spec.js index 9e89017..496d8a8 100644 --- a/e2e/toolbox-spaces.spec.js +++ b/e2e/toolbox-spaces.spec.js @@ -1,5 +1,6 @@ // Rôle : vérifie la gestion, la limite et les déplacements entre espaces toolbox. import { expect, test } from "@playwright/test"; +import { movePointerTo, startPointerDrag } from "./helpers/pointer.js"; import { resetSokkoStorage } from "./helpers/storage.js"; async function seedToolbox(page, toolbox, links = {}) { @@ -20,10 +21,8 @@ async function addSpace(page, name) { } async function dragModuleToTab(page, title, tab, hoverMs = 0) { - await page.getByRole("button", { name: `Déplacer ${title}`, exact: true }).hover(); - await page.mouse.down(); - const box = await tab.boundingBox(); - await page.mouse.move(box.x + box.width / 2, box.y + box.height / 2, { steps: 4 }); + await startPointerDrag(page, page.getByRole("button", { name: `Déplacer ${title}`, exact: true })); + await movePointerTo(page, tab, { steps: 4 }); if (hoverMs) await page.waitForTimeout(hoverMs); await page.mouse.up(); } @@ -143,12 +142,10 @@ test("shows the tab insertion indicator on the correct side while reordering", a }); const farmTabWrap = page.getByRole("tab", { name: "Farm" }).locator(".."); - const farmBox = await farmTabWrap.boundingBox(); const bossDragHandle = page.getByRole("button", { name: "Réordonner l’espace Boss" }); await expect.poll(() => bossDragHandle.evaluate((element) => globalThis.getComputedStyle(element).marginLeft)).toBe("4px"); - await bossDragHandle.hover(); - await page.mouse.down(); - await page.mouse.move(farmBox.x + farmBox.width - 2, farmBox.y + farmBox.height / 2, { steps: 4 }); + await startPointerDrag(page, bossDragHandle); + await movePointerTo(page, farmTabWrap, { x: 0.98, steps: 4 }); await expect(farmTabWrap).toHaveClass(/is-drop-target/); await expect(farmTabWrap).toHaveClass(/drop-after/); await expect.poll(() => farmTabWrap.evaluate((element) => globalThis.getComputedStyle(element, "::before").right)).toBe("0px");