diff --git a/.claude/memory/decisions.md b/.claude/memory/decisions.md index 1c4e6055..b0f55365 100644 --- a/.claude/memory/decisions.md +++ b/.claude/memory/decisions.md @@ -576,3 +576,9 @@ Status: active. M1-M3 not on DEV; procedure SUPABASE.md §3.3 (owner runs). Decision (owner brief « Validation V1-1.4 et autorisation V1-1.5 Interface Clients »): V1-1.4 accepted (species_filter + replay order in scope). Owner choices asked before UI: U1 « Afficher plus » keyset (25 + 1 probe row, no count), U2 one « Afficher les archivés » switch, client page animals read-only (list_client_animals, no link/add), « premier animal » section → V1-1.6. Built: access layer `packages/supabase/src/{records,workspaces,clients,species}.ts` (closed RecordFailure = §9.4 kinds + session_expired + network; Zod on RPC answers; read by id explicit columns, non-uuid → null w/o request); personal workspace in authStore (loading/ready/inactive/unconfirmed/missing/error; account change resets profile+roles+avatar+workspace in one set; late answers of previous user dropped; ready kept during same-user re-read); RequireWorkspace remounts routes per workspace; leave guard = beforeunload + AppLayout capture on in-app links (ModalDialog), back/forward not interceptable (documented); heading focus on open (callback ref, waits drawer close); request id per form mount via generateUuid (getRandomValues; LAN http has no randomUUID). Shell suite: no HTML reporter (kept typed passwords). Alt: numbered pages (needs count), tabs for archived, data-router migration for blocking, global data cache lib, storing search term (PII) to survive back nav. Status: active. Client screens not checked on DEV (M1-M3 not applied; owner). + +## BDR-079 | 2026-10-26 | V1-1.5 validated; V1-1.6 animal screens: D11 drawer only, first animal from client page, no default role, in-page link panel + +Decision (owner brief « Validation V1-1.5 et autorisation V1-1.6 Interface Animaux et clôture »): V1-1.5 accepted; reserves kept as product follow-up (search not kept on back, E.164 display, back/forward not guarded); no complex navigation manager for them. D11 = drawer only for V1-1, mockup tab bar not reproduced (later UX subject, mockup unchanged). Owner answers before UI: first animal from client page (« Ajouter un (premier) animal » → /app/animals/new, client id in navigation state, never URL, re-read and checked active; one atomic create_animal with relation; client form untouched); no relation role preselected (like sex N8); link client/animal = in-page panel (no modal form, contract §11.4), end/dates/void = ModalDialog confirmations pending until write + reload; U3 = full date fills and locks year. D12 tiles outside brief → not built, stays open. Built: access `animals.ts`, `relations.ts` (relations read by one select with client embedded via `animal_client_relations_client_fk`, `voided_at is null`, limit 200); one RequireWorkspace above clients + animals holding SpeciesProvider (species read once per workspace, dropped on account change); conflict/not_found on a relation write → reload + stale message (voided elsewhere surfaces as conflict: lock order archived → revision → voided). No new business rule in TS or Rust: RPCs decide, TS = D-R7 checks + display. +Alt: section in client create form with two-call resume (contract §11.1 text; changes client form); role owner preselected; relation forms in modal or new routes; client id in query string; per-component species fetch; new `voided` failure kind (needs M3 change). +Status: active. Not checked on DEV (M1-M3 pending, owner). diff --git a/.claude/memory/learnings.md b/.claude/memory/learnings.md index ff400828..ee2809c3 100644 --- a/.claude/memory/learnings.md +++ b/.claude/memory/learnings.md @@ -609,3 +609,18 @@ Apply: any focus-on-navigation or focus handoff next to a modal with exit animat Context: V1-1.5 report check. `locator.fill(value)` step titles hold the value; the shell suite's HTML report (embedded base64 zip) held the throwaway accounts' passwords, contrary to BROWSER_TESTS.md ("no trace" was thought enough). Found by decoding the zip in memory and counting fixture patterns. Apply: suites typing secrets → `reporter: [['list']]` (no html, no trace); audit reports by decoding the embedded zip, not by grepping the html. Also: never run Prettier on a whole src tree here (EVAL-037 repeat) — format new files only. + +## LRN-087 | 2026-10-26 | TS does not type-check hyphenated props on components: Card dropped aria-labelledby silently + +Context: V1-1.6 e2e locator `section[aria-labelledby=…]` found nothing. `Card` (props children/className/as) ignored `aria-labelledby`; TypeScript accepts any `aria-*`/`data-*` attribute on a component without declaring it, so every V1-1.5 section card shipped unnamed; axe never flags an unnamed section (no violation), unit tests queried by heading text. Fixed by declaring and passing the prop. +Apply: wrapper components that render landmarks must declare and forward `aria-*` explicitly; test named regions by role + name (`getByRole('region', {name})` or the attribute selector), not only by heading text. + +## LRN-088 | 2026-10-26 | useT() returns a new function each render: never a dependency of a data effect + +Context: V1-1.6 record picker. A search callback formatting rows with `t` would change every render → effect re-runs → request loop. Fix: search callbacks depend on ids only (`useCallback([workspaceId])`) and return raw rows; a `toItem(row)` prop formats at render (a language switch needs no new search). +Apply: in this app, keep `t`/dict out of `useCallback`/`useEffect` deps of anything that fetches; format at render. Same for any hook returning fresh functions. + +## LRN-089 | 2026-10-26 | Playwright on the sandbox: late replays fail after the test; axe target-size flags controls under a sticky bar + +Context: V1-1.6 e2e. (1) `routeToSandbox` replays with `route.fetch` then `fulfill`; a request still in flight when the last assertion passed hit « Fetch response has been disposed » at context close → test failed after success. Fix: `afterEach(context.unrouteAll({ behavior: 'ignoreErrors' }))`; and end tests on a state that needs the last reload (e.g. relations reloaded). (2) At 375 px, axe `target-size` failed on 44 px buttons partly under the sticky top bar when the page was scrolled to the bottom state under test; scanning after `scrollTo(0,0)` passes; documented as a limit, not hidden. +Apply: suites that proxy requests in route handlers → unrouteAll ignoreErrors per test; phone axe scans of bottom-of-page states → scan from top and say why in BROWSER_TESTS. diff --git a/.claude/tasks/contracts/2026-10-26-v1-1-6-animals-ui.md b/.claude/tasks/contracts/2026-10-26-v1-1-6-animals-ui.md index 7578f637..e8da0e40 100644 --- a/.claude/tasks/contracts/2026-10-26-v1-1-6-animals-ui.md +++ b/.claude/tasks/contracts/2026-10-26-v1-1-6-animals-ui.md @@ -76,3 +76,21 @@ BROWSER_TESTS, TEST_STRATEGY, FRONTEND_ARCHITECTURE, design README, CLAUDE.md up C12. **Technology boundary.** No business rule re-implemented in TypeScript that PostgreSQL already enforces beyond the D-R7 form checks; no artificial Rust/wasm call; the boundary choice written in §11.8. + +## CLARIFICATIONS + +- Owner brief §17 (not on disk), items 1 to 24, and where `e2e/shell/animals.spec.ts` covers them: 1 sign-in and + workspace (every test's `signIn` + `openAnimals`); 2 empty list, 3 creation without owner, 5 search, 6 species + filter, 7 consultation, 8 edit, 10 archive and restore (test « empty list, an « Autre » … restore »); 4 creation with + an initial relation, 11 creation from a client page, 12 linking an existing animal (« from a client page … »); 13 + several owners, 14 normal end, 15 voiding, 16 duplicate refused (« animal page: co-owners … »); 17 two accounts, 18 + change of session (« two accounts and a change of session »); 19 keyboard (« keyboard only »); 9 revision conflict + (« a concurrent edit »); 23 retry after a lost answer (« a lost answer »); 24 network errors (« failures … »); 20 + FR/EN (every test in both languages, plus « the animal pages follow a change of language »); 21 desktop and 375 + (both projects); 22 axe on the new pages (every state). Pagination: « pages of 25 ». +- Restore of an archived animal is one button with no confirmation, as on the validated client page (V1-1.5); only + archiving is confirmed. +- Verifier round 1 (ECARTS C10): the client journey failed intermittently on a late replay after its restore (the + client page now reloads its animals). Fixed: `dropLateReplays` in `e2e/support/sandbox.ts`, called after each test + by the three shell specs; the client journey ends on the reloaded animal section; `e2e:shell` 82/82 three runs in a + row. diff --git a/apps/app/e2e/shell/animals.spec.ts b/apps/app/e2e/shell/animals.spec.ts index 89a9c3fa..a5884d48 100644 --- a/apps/app/e2e/shell/animals.spec.ts +++ b/apps/app/e2e/shell/animals.spec.ts @@ -11,7 +11,12 @@ import { expectNoHorizontalOverflow, test, } from '../support/browser' -import { createAccount, routeToSandbox, sandboxUrl } from '../support/sandbox' +import { + createAccount, + dropLateReplays, + routeToSandbox, + sandboxUrl, +} from '../support/sandbox' import { literal, seedAnimal, @@ -120,10 +125,8 @@ for (const [locale, dict] of LANGUAGES) { test.beforeEach(async ({ context }) => { await routeToSandbox(context) }) - // A page may still be reading (a list, the relations) when its last check - // passed: the replay of that answer is dropped with the context, not failed. test.afterEach(async ({ context }) => { - await context.unrouteAll({ behavior: 'ignoreErrors' }) + await dropLateReplays(context) }) test('empty list, an « Autre » with no owner, search, species filter, edit, archive, archived filter, restore', async ({ diff --git a/apps/app/e2e/shell/clients.spec.ts b/apps/app/e2e/shell/clients.spec.ts index f89feb25..57307757 100644 --- a/apps/app/e2e/shell/clients.spec.ts +++ b/apps/app/e2e/shell/clients.spec.ts @@ -12,6 +12,7 @@ import { } from '../support/browser' import { createAccount, + dropLateReplays, routeToSandbox, sandboxUrl, workspaceOf, @@ -75,6 +76,9 @@ for (const [locale, dict] of LANGUAGES) { test.beforeEach(async ({ context }) => { await routeToSandbox(context) }) + test.afterEach(async ({ context }) => { + await dropLateReplays(context) + }) test('empty list, create, find, open, edit, archive, archived filter, restore', async ({ page, @@ -255,7 +259,8 @@ for (const [locale, dict] of LANGUAGES) { ).toBeVisible() await expect( page.getByRole('link', { name: dict['clients.detail.edit'] }), - ).toBeVisible() + ).toBeVisible() // The animal section is read again for the restored client. + await expect(page.getByText(dict['clients.animals.none'])).toBeVisible() }) test('pages of 25 with « Afficher plus », in name order', async ({ diff --git a/apps/app/e2e/shell/shell.spec.ts b/apps/app/e2e/shell/shell.spec.ts index 5cf63dbf..497919b2 100644 --- a/apps/app/e2e/shell/shell.spec.ts +++ b/apps/app/e2e/shell/shell.spec.ts @@ -9,7 +9,11 @@ import { focusedName, test, } from '../support/browser' -import { createAccount, routeToSandbox } from '../support/sandbox' +import { + createAccount, + dropLateReplays, + routeToSandbox, +} from '../support/sandbox' import { signIn } from '../support/shell' // The authenticated shell on the isolated stack: sign-in, dashboard, the @@ -37,6 +41,9 @@ for (const [locale, dict] of LANGUAGES) { test.beforeEach(async ({ context }) => { await routeToSandbox(context) }) + test.afterEach(async ({ context }) => { + await dropLateReplays(context) + }) test('sign-in, dashboard, then the photo confirmation of the account', async ({ page, diff --git a/apps/app/e2e/support/sandbox.ts b/apps/app/e2e/support/sandbox.ts index c333264e..8bfb6c94 100644 --- a/apps/app/e2e/support/sandbox.ts +++ b/apps/app/e2e/support/sandbox.ts @@ -39,6 +39,15 @@ export async function routeToSandbox(context: BrowserContext): Promise { }) } +/** + * After a test: removes the replay without waiting for it. A page may still be + * reading (a list, a section reloaded after a change) when the last check + * passed; that answer is dropped with the context instead of failing the test. + */ +export async function dropLateReplays(context: BrowserContext): Promise { + await context.unrouteAll({ behavior: 'ignoreErrors' }) +} + /** 1 × 1 lossless WebP: a real image for the clean avatar the account starts with. */ const AVATAR_WEBP = Buffer.from( 'UklGRhoAAABXRUJQVlA4TA0AAAAvAAAAEAcQERGIiP4HAA==', diff --git a/docs/development/BROWSER_TESTS.md b/docs/development/BROWSER_TESTS.md index a934bbd9..9b567149 100644 --- a/docs/development/BROWSER_TESTS.md +++ b/docs/development/BROWSER_TESTS.md @@ -33,9 +33,11 @@ object with the service key). Rows around the subject of a test (clients, animals, relations) are written as postgres by `e2e/support/records.ts`, every value quoted as an SQL literal. `pnpm db:sandbox down` removes all of it. `pnpm db:sandbox e2e-shell ` passes its arguments to Playwright: one -spec file, `--project`, `--grep`. The animal suite removes its routes after -each test without waiting for them, so an answer still in flight when the last -check passed is dropped with the context instead of failing the test. +spec file, `--project`, `--grep`. Every shell suite removes its routes after +each test without waiting for them (`dropLateReplays`), so an answer still in +flight when the last check passed is dropped with the context instead of +failing the test (the V1-1.6 verifier saw the client journey fail that way once +the client page reloads its animals after a restore). ## 2. Prerequisites