6.5 KiB
6.5 KiB
PLAN — anomaly B: working-copy dialog checks out of the shared slot (bugfix) — rev 2
Owner brief 2026-11-12 « Décision sur l'anomalie E2E »: OPTION 1 approved. Rev 2 after challenge (correctness SOLID, robustness CONCERNS(1), simplicity CONCERNS(1)); changes marked [C], [R], [S].
Diagnosis
- Symptom:
apps/app/e2e/shell/admin.spec.ts« admin screens: axe and no sideways scroll on every page, desktop and 375 px » fails 4 times (fr/en × chromium-desktop/chromium-375): the click on « Créer une copie de travail » times out. - Root cause: the test opens the dialog on the historical sheet
503dc301-…(slugfaunosteo-cheval). The working copy exists ONLY for that sheet (private.historical_sheet_id()fixed id;create_sheet_working_copyrefuses any other sourceworking_copy.source_invalid;AdminSheetRoute.tsx:294rendersWorkingCopyActiononly whensheet.historical) and ONE active copy is allowed for the whole database. The test depends on shared, mutable state: (a) on this sandbox the slot is taken by8c315a12-…, leaked bypackages/supabase/tests/sandbox/sheets-admin.sandbox.ts« the working copy and the catalogue reads answer their closed kinds » (kindOfdiscards the created id;afterAlldeletes the run's accounts, not their sheets); (b) [C] even on a fresh stack,editor-equine.spec.ts(beforeAll set-aside + own copy, afterAll restore) flips the slot whileadmin.specruns in parallel (fullyParallel, 8 workers). Fixing (a) alone would not fix the test. seedOfficialSheetcannot help (random id, never historical). Owner: business rule unchanged, no SQL.- Note for the owner (not fixed here, out of scope):
editor-equine.spec.tsset-aside archives and restores pre-existing active copies of the historical sheet (8c315a12 included) on every run; it ran during the R1 follow-up e2e runs today. Not run in this fix. - RELATED MEMORY: LRN-089, LRN-076 (stub vs real service: coverage change documented), LRN-082 (native modal: Tab past last control reaches the browser UI), BDR-114 (decision C). No BLK bears.
Fix plan
- NEW
apps/app/e2e/harness/working-copy.html+working-copy.tsx(dev server only, never built, likedialog.tsx):?lang=enpicks the language (localeStore +documentElement.lang); under<StrictMode>[R] andMemoryRouter, renders the REAL@/components/admin/WorkingCopyActiontwice, each in its own<section>with its own heading [R]: slot free (slug="faunosteo-cheval",sourceVersionIda fixed fake uuid,copyActive={false}) and slot taken (same,copyActive={true}); page<h1>,@/styles/index.css. No network (getSupabaseClientonly on submit, never triggered; e2e:ui server has empty Supabase env). - NEW
apps/app/e2e/ui/working-copy.spec.ts(chromium-desktop 1 280 and chromium-375; fr and en via?lang):- page: axe + no horizontal overflow with both states shown; taken button
toBeDisabled()with accessible description =admin.working_copy.active(aria-describedby) [S: no « does not open » click]; - free button opened by keyboard (focus + Enter): dialog named
admin.working_copy.create, descriptionadmin.working_copy.body, slug input prefilledfaunosteo-cheval-copie-de-travail(proof it is the real component's proposal); - focus: initial focus inside the dialog; keyboard walk written explicitly like
dialog.spec.ts[C][R]: Tab order close ✕ → slug input (identified by idworking-copy-slug,focusedNameis empty for inputs) → Cancel → Submit → one'browser'step → back to ✕, and Shift+Tab the reverse; neveroutside:*; - axe + no horizontal overflow on the open dialog, plus the dialog panel inside the viewport and panel
scrollWidth <= clientWidthat both widths [R]; - Escape closes, focus returns to the opener.
- page: axe + no horizontal overflow with both states shown; taken button
apps/app/e2e/shell/admin.spec.ts: historical page stays in the axe / overflow loop unchanged; the click + dialog block is removed; replaced by a state-consistent check on the historical page [C]: the « Créer une copie de travail » button is visible, and it is disabled exactly when theadmin.working_copy.activereason is shown and linked through aria-describedby (enabled with no reason otherwise). Comment points toe2e/ui/working-copy.spec.ts.packages/supabase/tests/sandbox/sheets-admin.sandbox.ts[R][C]: every successfulcreateSheetWorkingCopyresult (both calls) is pushed to a run-ownedcopieslist beforekindOfclassification;afterAll: whencopiesis non-empty,update public.anatomical_sheets set status = 'archived', archived_at = now() where id in (<copies>) returning idas postgres and assert the returned ids equalcopies; each cleanup step (copies, species, grants + accounts) runs even if an earlier one throws, the first error rethrown at the end. Never touches other rows.- Docs (same commit) [C]:
docs/development/BROWSER_TESTS.md(e2e:ui row and harness paragraph: new page and spec; coverage change: the dialog's axe / layout / keyboard checks run in e2e:ui on the real component, no longer in its real server context; the shell keeps the historical page and the button state);V1-2-6_U1_CORRECTIONS.md§5 row B (cause (b), fix, limit, « creation branch of the cleanup not yet run on a fresh stack » open check) and the lines saying four admin failures;playwright.ui.config.tsheader; rootCLAUDE.mde2e:ui line + folder map harness list. TODO lines in the memory commit.
Verification (sandbox only; db:trial and DEV never)
- Snapshot BEFORE (read-only
selectthroughpnpm db:sandbox sql): every pre-existinganatomical_sheetsrow (id, status, archived_at, updated_at) [R][C] incl. 8c315a12 and the historical sheet, saved to scratchpad. - BEFORE fix:
pnpm db:sandbox e2e-shell e2e/shell/admin.spec.ts --grep "admin screens"→ 4 failed (expected). - AFTER, pass 1 and pass 2: same grep → 4 passed;
pnpm e2e:uifull (new spec included). - AFTER once: full
admin.spec.ts;pnpm db:sandbox test tests/sandbox/sheets-admin.sandbox.ts(server refusals still covered;working_copy.existspath); typecheck, lint, test:run. - Snapshot AFTER: every pre-existing row identical per id (new rows allowed: A1 creates sheets).
- Not run:
editor-equine.spec.ts(its set-aside touches pre-existing copies).
Risks
- The creation branch of the cleanup (copies non-empty) is not exercised on this sandbox (slot taken): recorded open.
- The dialog is no longer axe-checked inside the admin page chrome; it is a top-layer modal; page chrome stays covered by the shell loop.