chore(memory): anomaly B fixed, contract and plan

This commit is contained in:
bchanot committed 2026-11-12 17:06:53 +01:00
1 parent 2cdee42fe1
commit f873e06413
3 files changed
+188 -1

No files matched your search

@@ -0,0 +1,73 @@
# 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-…` (slug `faunosteo-cheval`). The working
copy exists ONLY for that sheet (`private.historical_sheet_id()` fixed id; `create_sheet_working_copy` refuses
any other source `working_copy.source_invalid`; `AdminSheetRoute.tsx:294` renders `WorkingCopyAction` only when
`sheet.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 by `8c315a12-…`, leaked by `packages/supabase/tests/sandbox/sheets-admin.sandbox.ts`
« the working copy and the catalogue reads answer their closed kinds » (`kindOf` discards the created id; `afterAll`
deletes 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 while `admin.spec` runs in parallel (`fullyParallel`, 8
workers). Fixing (a) alone would not fix the test.
- `seedOfficialSheet` cannot help (random id, never historical). Owner: business rule unchanged, no SQL.
- Note for the owner (not fixed here, out of scope): `editor-equine.spec.ts` set-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
1. NEW `apps/app/e2e/harness/working-copy.html` + `working-copy.tsx` (dev server only, never built, like `dialog.tsx`):
`?lang=en` picks the language (localeStore + `documentElement.lang`); under `<StrictMode>` [R] and `MemoryRouter`,
renders the REAL `@/components/admin/WorkingCopyAction` twice, each in its own `<section>` with its own heading
[R]: slot free (`slug="faunosteo-cheval"`, `sourceVersionId` a fixed fake uuid, `copyActive={false}`) and slot taken
(same, `copyActive={true}`); page `<h1>`, `@/styles/index.css`. No network (`getSupabaseClient` only on submit,
never triggered; e2e:ui server has empty Supabase env).
2. 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`, description
`admin.working_copy.body`, slug input prefilled `faunosteo-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 id `working-copy-slug`, `focusedName` is empty for inputs) →
Cancel → Submit → one `'browser'` step → back to ✕, and Shift+Tab the reverse; never `outside:*`;
- axe + no horizontal overflow on the open dialog, plus the dialog panel inside the viewport and panel
`scrollWidth <= clientWidth` at both widths [R];
- Escape closes, focus returns to the opener.
3. `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 the `admin.working_copy.active` reason is shown and linked
through aria-describedby (enabled with no reason otherwise). Comment points to `e2e/ui/working-copy.spec.ts`.
4. `packages/supabase/tests/sandbox/sheets-admin.sandbox.ts` [R][C]: every successful `createSheetWorkingCopy` result
(both calls) is pushed to a run-owned `copies` list before `kindOf` classification; `afterAll`: when `copies` is
non-empty, `update public.anatomical_sheets set status = 'archived', archived_at = now() where id in (<copies>)
returning id` as postgres and assert the returned ids equal `copies`; 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.
5. 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.ts` header; root `CLAUDE.md` e2e:ui line + folder map harness
list. TODO lines in the memory commit.
## Verification (sandbox only; db:trial and DEV never)
- Snapshot BEFORE (read-only `select` through `pnpm db:sandbox sql`): every pre-existing `anatomical_sheets` row
(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:ui` full (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.exists` path); 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.