sokko-g/e2e/grouped-reorder.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

76 lines
4.1 KiB
JavaScript

/**
* @file Vérifie les contraintes de groupes, de parents et d'orientation avec de vrais gestes pointeur.
*/
/* 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 }) => {
await page.goto("/");
await page.evaluate(async (url) => {
const { mountGroupedReorderProbe } = await import(url);
document.getElementById("app").style.display = "none";
const element = document.createElement("div");
document.body.prepend(element);
window.groupedProbe = mountGroupedReorderProbe(element);
}, probeUrl);
});
async function configure(page, options) {
await page.evaluate((options) => window.groupedProbe.update(options), options);
}
async function drop(page, source, target, x = 0.2, y = 0.8) {
await startPointerDrag(page, page.getByRole("button", { name: source, exact: true }));
await expect(page.getByLabel("Dragging")).toHaveText("active");
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));
}
test("item moves obey parent boundaries, group changes, namespace isolation and custom vetoes", async ({ page }) => {
expect(await drop(page, "Item a", "b")).toEqual([{
type: "item", sourceId: "a", targetId: "b", targetType: "item", placement: "after",
sourceGroup: "A", targetGroup: "A", sourceParentId: "p", targetParentId: "p"
}]);
expect(await drop(page, "Item a", "d")).toEqual([]);
expect(await drop(page, "Item a", "alien")).toEqual([]);
await configure(page, { reorderFeatures: { item: { groupChange: false } } });
expect(await drop(page, "Item a", "c")).toEqual([]);
await configure(page, { reorderFeatures: { item: { groupChange: true } } });
expect(await drop(page, "Item a", "c")).toMatchObject([{ targetId: "c", targetGroup: "B" }]);
await configure(page, { hierarchy: { enabled: true, stickyParents: false } });
expect(await drop(page, "Item a", "d")).toMatchObject([{ sourceParentId: "p", targetParentId: "q" }]);
await configure(page, { veto: true });
expect(await drop(page, "Item a", "b")).toEqual([]);
});
test("orientation changes placement while explicit boundaries and ungrouped drops require permission", async ({ page }) => {
expect(await drop(page, "Item a", "b")).toMatchObject([{ placement: "after" }]);
await configure(page, { orientation: "horizontal" });
expect(await drop(page, "Item a", "b")).toMatchObject([{ placement: "before" }]);
expect(await drop(page, "Item a", "b", 0.8, 0.2)).toMatchObject([{ placement: "after" }]);
expect(await drop(page, "Item a", "boundary")).toEqual([]);
expect(await drop(page, "Item a", "ungrouped")).toEqual([]);
await configure(page, { reorderFeatures: { item: { boundaryDrop: true, ungroupedDrop: true } } });
expect(await drop(page, "Item a", "boundary", 0.1, 0.1)).toMatchObject([{ targetType: "boundary", targetGroup: "B", placement: "after" }]);
expect(await drop(page, "Item a", "ungrouped")).toMatchObject([{ targetType: "ungrouped", targetGroup: "" }]);
});
test("group dragging rejects itself, disabled and root-only moves and respects custom vetoes", async ({ page }) => {
expect(await drop(page, "Group A", "group-A")).toEqual([]);
expect(await drop(page, "Group A", "group-B")).toEqual([{
type: "group", sourceId: "A", targetId: "B", targetType: "group", placement: "after",
sourceGroup: "A", targetGroup: "B", sourceParentId: "p", targetParentId: "p"
}]);
await configure(page, { reorderFeatures: { group: { reorder: false } } });
expect(await drop(page, "Group A", "group-B")).toEqual([]);
await configure(page, { reorderFeatures: { group: { reorder: true, rootOnly: true } } });
expect(await drop(page, "Group A", "group-B")).toEqual([]);
await configure(page, { reorderFeatures: { group: { reorder: true } }, veto: true });
expect(await drop(page, "Group A", "group-B")).toEqual([]);
});