test(tests): working-copy dialog checks independent of the shared slot
admin.spec opened the working-copy dialog on the historical sheet, whose single slot was taken by a copy the sandbox suite leaked. The dialog checks move to an e2e:ui page on the real component; the suite archives its own copies.
This commit is contained in:
1 parent
da298cfab1
commit
2cdee42fe1
9 files changed
+304
-25
No files matched your search
@@ -163,7 +163,7 @@ pnpm e2e:avatar # = pnpm db:sandbox avatar-e2e: the worker container and
|
||||
```bash
|
||||
pnpm test:run # vitest run — all tests, single pass, CI-safe
|
||||
pnpm test # vitest watch — dev loop
|
||||
pnpm e2e:ui # Playwright Chromium, no backend: Dialog test page + local tool dialogs, desktop + 375 px, axe (in check:all when the pinned Chromium is installed)
|
||||
pnpm e2e:ui # Playwright Chromium, no backend: Dialog and working-copy test pages + local tool dialogs, desktop + 375 px, axe (in check:all when the pinned Chromium is installed)
|
||||
pnpm e2e:shell # Playwright Chromium against `pnpm db:sandbox` (must be up): sign-in, dashboard, photo confirmation, phone drawer, client, animal and relation journeys, administration (A0, A1, S1, MFA step-up, access per right) and catalogue (P1); never DEV (`pnpm db:sandbox e2e-shell <spec> [--grep]` for one file)
|
||||
```
|
||||
|
||||
@@ -266,7 +266,7 @@ faunosteo/
|
||||
├─ tests/
|
||||
│ ├─ setup.ts
|
||||
│ └─ unit/*.test.ts
|
||||
├─ e2e/ ← Playwright (V1-1.3): playwright.{ui,shell}.config.ts, support/{browser,sandbox,shell,records,admin,catalogue}.ts, ui/*.spec.ts, shell/*.spec.ts (V1-2.5: admin, catalogue), harness/dialog.{html,tsx} (dev server only, never built)
|
||||
├─ e2e/ ← Playwright (V1-1.3): playwright.{ui,shell}.config.ts, support/{browser,sandbox,shell,records,admin,catalogue}.ts, ui/*.spec.ts, shell/*.spec.ts (V1-2.5: admin, catalogue), harness/{dialog,working-copy}.{html,tsx} (dev server only, never built)
|
||||
├─ docker/
|
||||
│ ├─ entrypoint.sh ← injects env.js at container start
|
||||
│ └─ nginx.conf ← SPA fallback + PORT envsubst
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
<!doctype html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Working copy harness</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="module" src="./working-copy.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,60 @@
|
||||
/**
|
||||
* Test page for the real « Créer une copie de travail » action in a real
|
||||
* browser (e2e/ui/working-copy.spec.ts). Served by the Vite dev server only
|
||||
* (`/e2e/harness/working-copy.html`); the build has a single entry, index.html,
|
||||
* so this page never ships. The action is the application's own component,
|
||||
* rendered with the slot free and with the slot taken (the two states the
|
||||
* historical sheet page shows); no request is made unless the form is
|
||||
* submitted, which the spec never does. `?lang=en` picks the language.
|
||||
*/
|
||||
import { StrictMode } from 'react'
|
||||
import { createRoot } from 'react-dom/client'
|
||||
import { MemoryRouter } from 'react-router-dom'
|
||||
import '@/styles/index.css'
|
||||
import WorkingCopyAction from '@/components/admin/WorkingCopyAction'
|
||||
import { useLocaleStore } from '@/state/localeStore'
|
||||
import type { Locale } from '@/i18n/types'
|
||||
|
||||
const lang: Locale =
|
||||
new URLSearchParams(location.search).get('lang') === 'en' ? 'en' : 'fr'
|
||||
useLocaleStore.setState({ locale: lang })
|
||||
document.documentElement.lang = lang
|
||||
|
||||
const SLUG = 'faunosteo-cheval'
|
||||
const SOURCE_VERSION_ID = '00000000-0000-4000-8000-000000000001'
|
||||
|
||||
function Harness() {
|
||||
return (
|
||||
<main className="mx-auto max-w-2xl space-y-6 p-4">
|
||||
<h1 className="text-xl font-semibold">Working copy harness</h1>
|
||||
<section aria-labelledby="slot-free" className="space-y-2">
|
||||
<h2 id="slot-free" className="text-lg font-semibold">
|
||||
Slot free
|
||||
</h2>
|
||||
<WorkingCopyAction
|
||||
slug={SLUG}
|
||||
sourceVersionId={SOURCE_VERSION_ID}
|
||||
copyActive={false}
|
||||
/>
|
||||
</section>
|
||||
<section aria-labelledby="slot-taken" className="space-y-2">
|
||||
<h2 id="slot-taken" className="text-lg font-semibold">
|
||||
Slot taken
|
||||
</h2>
|
||||
<WorkingCopyAction
|
||||
slug={SLUG}
|
||||
sourceVersionId={SOURCE_VERSION_ID}
|
||||
copyActive={true}
|
||||
/>
|
||||
</section>
|
||||
</main>
|
||||
)
|
||||
}
|
||||
|
||||
createRoot(document.getElementById('root') as HTMLElement).render(
|
||||
<StrictMode>
|
||||
<MemoryRouter>
|
||||
<Harness />
|
||||
</MemoryRouter>
|
||||
</StrictMode>,
|
||||
)
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* `pnpm e2e:ui`: Chromium against a Vite dev server with no backend, on a
|
||||
* loopback port of its own (never the owner's `pnpm dev` on 5173, never
|
||||
* reused): the Dialog test page, the local tool and the canvas click proof (also on
|
||||
* reused): the Dialog and working-copy test pages, the local tool and the canvas click proof (also on
|
||||
* Firefox and WebKit when installed). docs/development/BROWSER_TESTS.md.
|
||||
*/
|
||||
import { defineConfig } from '@playwright/test'
|
||||
|
||||
@@ -750,20 +750,24 @@ for (const [locale, dict] of LANGUAGES) {
|
||||
await expectAccessible(page, `${path} at ${width} px`)
|
||||
await expectNoHorizontalOverflow(page, `${path} at ${width} px`)
|
||||
}
|
||||
// The working copy dialog on the historical sheet (W1 start), opened only.
|
||||
await page
|
||||
.getByRole('button', { name: dict['admin.working_copy.create'] })
|
||||
.first()
|
||||
.click()
|
||||
const copy = page.getByRole('dialog', {
|
||||
// The historical page is left on the page loop's last entry. Its working
|
||||
// copy button follows the single slot, shared database state: disabled
|
||||
// exactly when the reason is shown and linked to it. The dialog itself is
|
||||
// checked on the real component in e2e/ui/working-copy.spec.ts.
|
||||
const action = main(page).getByRole('button', {
|
||||
name: dict['admin.working_copy.create'],
|
||||
})
|
||||
await expect(copy).toBeVisible()
|
||||
await expectAccessible(page, `the working copy dialog at ${width} px`)
|
||||
await expectNoHorizontalOverflow(
|
||||
page,
|
||||
`the working copy dialog at ${width} px`,
|
||||
)
|
||||
await expect(action).toBeVisible()
|
||||
const reason = main(page).getByText(dict['admin.working_copy.active'])
|
||||
if ((await reason.count()) > 0) {
|
||||
await expect(action).toBeDisabled()
|
||||
await expect(action).toHaveAccessibleDescription(
|
||||
dict['admin.working_copy.active'],
|
||||
)
|
||||
} else {
|
||||
await expect(action).toBeEnabled()
|
||||
await expect(action).not.toHaveAttribute('aria-describedby')
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
import { en } from '@/i18n/en'
|
||||
import { fr } from '@/i18n/fr'
|
||||
import {
|
||||
expect,
|
||||
expectAccessible,
|
||||
expectNoHorizontalOverflow,
|
||||
focusOwner,
|
||||
focusedName,
|
||||
test,
|
||||
} from '../support/browser'
|
||||
import type { Page } from '@playwright/test'
|
||||
|
||||
// The real WorkingCopyAction (components/admin) on its test page
|
||||
// (e2e/harness/working-copy.tsx): the dialog's accessibility, layout and
|
||||
// keyboard checks that e2e/shell/admin.spec.ts cannot make on the historical
|
||||
// sheet, where the single working-copy slot is shared, mutable database state.
|
||||
|
||||
const SLUG_FIELD = 'working-copy-slug'
|
||||
|
||||
for (const [lang, dict] of [
|
||||
['fr', fr],
|
||||
['en', en],
|
||||
] as const) {
|
||||
const create = dict['admin.working_copy.create']
|
||||
const free = (page: Page) => page.getByRole('region', { name: 'Slot free' })
|
||||
const taken = (page: Page) => page.getByRole('region', { name: 'Slot taken' })
|
||||
|
||||
/** Opens the dialog from the keyboard, as the spec's own opener. */
|
||||
async function openDialog(page: Page) {
|
||||
await free(page).getByRole('button', { name: create }).focus()
|
||||
await page.keyboard.press('Enter')
|
||||
const dialog = page.getByRole('dialog', { name: create })
|
||||
await expect(dialog).toBeVisible()
|
||||
return dialog
|
||||
}
|
||||
|
||||
/** What the focus is on: the slug field by its id, else its accessible name. */
|
||||
async function focusStep(page: Page) {
|
||||
const owner = await focusOwner(page)
|
||||
if (owner !== 'dialog') return owner
|
||||
const onField = await page.evaluate(
|
||||
(id) => document.activeElement?.id === id,
|
||||
SLUG_FIELD,
|
||||
)
|
||||
return onField ? SLUG_FIELD : await focusedName(page)
|
||||
}
|
||||
|
||||
async function walk(page: Page, key: 'Tab' | 'Shift+Tab', count: number) {
|
||||
const visited: string[] = []
|
||||
for (let i = 0; i < count; i++) {
|
||||
await page.keyboard.press(key)
|
||||
visited.push(await focusStep(page))
|
||||
}
|
||||
return visited
|
||||
}
|
||||
|
||||
test.describe(lang, () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.goto(`/e2e/harness/working-copy.html?lang=${lang}`)
|
||||
await expect(
|
||||
page.getByRole('heading', { name: 'Working copy harness' }),
|
||||
).toBeVisible()
|
||||
})
|
||||
|
||||
test('the page passes axe with both states, no sideways scroll', async ({
|
||||
page,
|
||||
}) => {
|
||||
await expectAccessible(page, `the working copy page (${lang})`)
|
||||
await expectNoHorizontalOverflow(page, `the working copy page (${lang})`)
|
||||
})
|
||||
|
||||
test('slot taken: the button is disabled and gives its reason', async ({
|
||||
page,
|
||||
}) => {
|
||||
const button = taken(page).getByRole('button', { name: create })
|
||||
await expect(button).toBeDisabled()
|
||||
await expect(button).toHaveAccessibleDescription(
|
||||
dict['admin.working_copy.active'],
|
||||
)
|
||||
await expect(free(page).getByRole('button')).toBeEnabled()
|
||||
})
|
||||
|
||||
test('opens from the keyboard, named, described, slug proposed', async ({
|
||||
page,
|
||||
}) => {
|
||||
const dialog = await openDialog(page)
|
||||
await expect(dialog).toHaveAccessibleDescription(
|
||||
dict['admin.working_copy.body'],
|
||||
)
|
||||
await expect(dialog.locator(`#${SLUG_FIELD}`)).toHaveValue(
|
||||
'faunosteo-cheval-copie-de-travail',
|
||||
)
|
||||
expect(await focusOwner(page)).toBe('dialog')
|
||||
expect(await focusedName(page)).toBe(dict['common.close'])
|
||||
})
|
||||
|
||||
// Past either end the focus visits the browser's interface (one step) and
|
||||
// comes back into the dialog; it never reaches the page behind.
|
||||
test('Tab and Shift+Tab cycle through the dialog, never the page', async ({
|
||||
page,
|
||||
}) => {
|
||||
await openDialog(page)
|
||||
const order = [
|
||||
SLUG_FIELD,
|
||||
dict['common.cancel'],
|
||||
dict['admin.working_copy.confirm'],
|
||||
'browser',
|
||||
dict['common.close'],
|
||||
]
|
||||
expect(await walk(page, 'Tab', 10)).toEqual([...order, ...order])
|
||||
const back = [
|
||||
'browser',
|
||||
dict['admin.working_copy.confirm'],
|
||||
dict['common.cancel'],
|
||||
SLUG_FIELD,
|
||||
dict['common.close'],
|
||||
]
|
||||
expect(await walk(page, 'Shift+Tab', 10)).toEqual([...back, ...back])
|
||||
})
|
||||
|
||||
test('the open dialog passes axe and fits the viewport', async ({
|
||||
page,
|
||||
}) => {
|
||||
const dialog = await openDialog(page)
|
||||
await expectAccessible(page, `the working copy dialog (${lang})`)
|
||||
await expectNoHorizontalOverflow(
|
||||
page,
|
||||
`the working copy dialog (${lang})`,
|
||||
)
|
||||
const panel = dialog.locator('header').locator('..')
|
||||
const box = await panel.boundingBox()
|
||||
const viewport = page.viewportSize()
|
||||
expect(
|
||||
box &&
|
||||
viewport &&
|
||||
box.x >= 0 &&
|
||||
box.x + box.width <= viewport.width &&
|
||||
box.y >= 0 &&
|
||||
box.y + box.height <= viewport.height,
|
||||
'the panel inside the viewport',
|
||||
).toBe(true)
|
||||
const { scrollWidth, clientWidth } = await panel.evaluate((p) => ({
|
||||
scrollWidth: p.scrollWidth,
|
||||
clientWidth: p.clientWidth,
|
||||
}))
|
||||
expect(scrollWidth, 'the panel scrolls sideways').toBeLessThanOrEqual(
|
||||
clientWidth,
|
||||
)
|
||||
})
|
||||
|
||||
test('Escape closes and focus returns to the opener', async ({ page }) => {
|
||||
const dialog = await openDialog(page)
|
||||
await page.keyboard.press('Escape')
|
||||
await expect(dialog).toBeHidden()
|
||||
expect(await focusedName(page)).toBe(create)
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -9,7 +9,7 @@ engines are installed. The suites live in `apps/app/e2e`.
|
||||
|
||||
| Command | Backend | Dev server | Content |
|
||||
|---|---|---|---|
|
||||
| `pnpm e2e:ui` | none | Vite on `127.0.0.1:5191` | `e2e/ui/dialog.spec.ts`: the D13 contract of the shared Dialog on a test page; `e2e/ui/local-tool.spec.ts`: the disclaimer, edit and replace dialogs on the real local-tool routes |
|
||||
| `pnpm e2e:ui` | none | Vite on `127.0.0.1:5191` | `e2e/ui/dialog.spec.ts`: the D13 contract of the shared Dialog on a test page; `e2e/ui/working-copy.spec.ts`: the real `WorkingCopyAction` and its dialog on a test page (axe, layout, keyboard, fr and en, desktop and 375 px); `e2e/ui/local-tool.spec.ts`: the disclaimer, edit and replace dialogs on the real local-tool routes |
|
||||
| `pnpm e2e:shell` | the isolated stack of `pnpm db:sandbox` | Vite on `127.0.0.1:5192` | `e2e/shell/shell.spec.ts`: sign-in, dashboard, the account photo confirmation, the phone drawer; `e2e/shell/clients.spec.ts`: the client journeys (V1-1.5); `e2e/shell/animals.spec.ts`: the animal and relation journeys (V1-1.6, contract §11.8); `e2e/shell/responsive.spec.ts`: no sideways scroll on nine shell pages, the archive confirmations and the drawer at 320, 360, 375, 390 and 430 px (phone project) and 1280 px, long values, the dashboard e-mail shown whole (RESP-01); `e2e/shell/admin.spec.ts` (V1-2.5): A0 the owner's bootstrap (two TOTP factors from Sécurité, the step-up at `/app/admin` and inside a factor action, no second factor from `aal1`, refresh keeping `aal1` and `aal2`, rights granted and revoked with their reason), A1 a sheet created by an editor on a new inactive species, S1 a species created inactive then activated by the owner, the creation page when the own-grants read fails (« Impossible de vérifier vos autorisations » and « Réessayer », never the form; Retry brings the form back), access per right (a reviewer-only account refused on the creation page), axe and no sideways scroll on every admin page; `e2e/shell/catalogue.spec.ts` (V1-2.5): P1 a reader searches, opens a sheet, picks a zone, reads a retired version, drafts and archived sheets never listed, the same refusal for an existing and an unknown sheet without access, 320, 375 and 430 px with the whole drawing in the box at opening; at 320 and 375 px the zone panel's live region present before a pick and naming the picked zone, the « Références » card starting at or below the drawing's bottom; `e2e/shell/editor-*.spec.ts` (V1-2.6, the draft editor level 1, contract C16 to C34): `editor-drawings` (A2: a hostile file refused with no cleaning box, an Inkscape export cleaned after its preview, a valid file attached, a detail view by crop, the same bytes attached twice), `editor-annotations` (A3: points, zones and links by clicks and by keyboard only, move by drag, a click with jitter never moves, numeric edits, undo and redo, review and delete), `editor-geometry` (a click near a frame edge with the corrected position confirmed and cancelled, an inherited out-of-frame point repaired through the geometry group, a crop change refused when it would invalidate a point, an unmeasured view with its tools disabled, touch-action and a touch drag in real Chromium), `editor-structures` (A4: categories, references, regions, findings tree, reorder, mark reviewed, delete with dependents), `editor-journey` (the steps of `V1-2-6_OWNER_TRIAL.md` §4 with two editor accounts: creation, drawing, findings, annotations, save, reload with the beforeunload dialog and the recovery offer, conflict, submission, the round read back in SQL), `editor-recovery` (two sessions, an older local copy restored then saved over a newer revision, a pending offer blocking edits, an unreadable copy kept until « Ignorer », Escape on the conflict read, the editor grant revoked, the admin role removed and the grant expired under an open session), `editor-access` (a reviewer-only account read-only, the not-found screen for an editor without the admin role and for an admin without a capability, 320, 375 and 800 px read-only, 1 024 px editing, axe on every tab edit and read-only), `editor-deselect` (R1, D5 and D6b: « Désélectionner » with its live region, the focus on the list row and the document unchanged; Escape over the canvas, a field, the delete dialog, the references panel and a tracing; mouse clicks on empty parts deselecting, on annotations selecting; zoom, pan, marker drag and Ctrl+wheel keeping the selection; a typed value applied by the deselecting click; at 1 280 px with `hasTouch` and CDP touch taps near annotations and the canvas bottom deselecting once, drags, two-finger taps and pinch keeping the selection, with the pointer events counted by a recorder; the read-only twin at 375 px and Escape closing « Plus » before deselecting; the drawing's top unchanged when a point, a zone and a link are selected then deselected, on desktop and on the read-only twin at 375 px, with the selection tag out of the visual flow), `editor-equine` (the historical equine sheet opened as a working copy, a copy left active by an earlier run set aside and put back; commit latency on it and on a synthetic document near 2 MiB, printed as `LATENCY` lines and kept as test annotations, budget 500 ms per commit on the equine copy; one empty click on a bone of the horse drawing deselects, D6b). U1 shell (V1-2.6 U1, the four-tab shell): `editor-shell` (kept-mounted places, focus on a named element, the open panel leaving the header and the tab row clickable at 1 024 and 1 280 px, the sidebar from 1 280 px and the drawer, canvas widths), `editor-shell-journeys` (four tabs, cross-tab undo, typed text then the header undo, a refused field kept through a real Shift+Tab to « Défaire », Ctrl+ZLine truncated
|
||||
|
||||
Each suite runs on two Chromium projects: `chromium-desktop` (1280 × 800) and
|
||||
@@ -23,6 +23,19 @@ The test page `e2e/harness/dialog.html` is served by the dev server only
|
||||
never ships. It holds the D13 cases (basic, long content, refused close,
|
||||
vanishing opener) and no product journey.
|
||||
|
||||
The test page `e2e/harness/working-copy.html` (same rules) renders the
|
||||
application's own `WorkingCopyAction` twice, slot free and slot taken, under
|
||||
`StrictMode` and a `MemoryRouter`; no request is made. Coverage change
|
||||
(anomaly B, V1-2-6_U1_CORRECTIONS.md §5): the dialog's axe, layout and
|
||||
keyboard checks moved there from the « admin screens » test of
|
||||
`e2e/shell/admin.spec.ts`, because only the historical sheet offers the
|
||||
action and the single working-copy slot is shared, mutable database state.
|
||||
The shell test keeps the historical page in its axe and overflow loop and
|
||||
checks that the button is disabled exactly when its reason is shown and
|
||||
linked. Limit: the dialog is no longer checked in its real server context by
|
||||
this accessibility test; the server refusals stay covered by
|
||||
`packages/supabase/tests/sandbox/sheets-admin.sandbox.ts`.
|
||||
|
||||
The shell suite never reaches DEV. Its dev server is built with the Supabase
|
||||
URL `http://sandbox.faunosteo.invalid` (a name that resolves nowhere,
|
||||
RFC 6761); `e2e/support/sandbox.ts` replays `/auth/v1`, `/rest/v1` and
|
||||
|
||||
@@ -43,7 +43,7 @@ Companion: `TRIAL_STACK.md` (the dedicated manual trial stack, request §5).
|
||||
|
||||
Every lot: one commit or more per coherent change, pushed; gates in this order: `pnpm typecheck`, `pnpm lint`,
|
||||
`pnpm test:run`, `pnpm build`, `pnpm e2e:ui`, then the shell suite on the sandbox as it stands, with its exact result
|
||||
(the suite is not green today: four `admin.spec.ts:717` failures from the taken working-copy slot, anomaly B). Every
|
||||
(the four `admin.spec.ts:717` failures of the taken working-copy slot, anomaly B, are fixed: row B of section 5). Every
|
||||
removed or rewritten assertion is mapped to its replacement in the commit message (R-24). Design gates: the boards of
|
||||
R0 as validated, `impeccable detect` on the changed components, a fresh design review before the lot closes.
|
||||
|
||||
@@ -243,15 +243,15 @@ The criteria below are the contract as written.
|
||||
|
||||
R0 first (validation). R1 is independent of R2 and can ship first. R2 depends on the validated boards 23 to 27. R3
|
||||
ships search and name sort first; its date part waits for the SQL checkpoint (A7 ratified).
|
||||
R4 is independent and may run any time after its board (30) is validated. Anomaly B (section 5) should land before
|
||||
the gates of R2 and R3 are read, since its taken slot fails four admin specs on every run.
|
||||
R4 is independent and may run any time after its board (30) is validated. Anomaly B (section 5) is fixed: the admin specs no longer
|
||||
depend on the working-copy slot.
|
||||
|
||||
## 5. Test anomalies tracked apart (D9)
|
||||
|
||||
| Item | Cause | Constraint |
|
||||
|---|---|---|
|
||||
| A. Fictitious fingerprints | Worker stand-ins publish with `'a'.repeat(64)`: `packages/supabase/tests/sandbox/sheet-fixtures.ts:115` (`openRound`), `sheets-concurrency.sandbox.ts:168`, `sheets-perf.sandbox.ts:169`. Seven published or deprecated versions on the sandbox fail `check_published`; the owner opened three of them on 2026-11-09. | Compute the real fingerprint through the core as the catalogue e2e does (`fingerprintOf`), never weaken the publish gate or the reader's check. |
|
||||
| B. Working copy never archived | `packages/supabase/tests/sandbox/sheets-admin.sandbox.ts:181-195` creates the historical sheet's working copy (`8c315a12-…`, 2026-11-08 21:00:30) and never archives it; the single slot then disables « Créer une copie de travail » (`WorkingCopyAction.tsx:88`) and fails `admin.spec.ts:717` four times. | Make the suite independent (its own cleanup, or a precondition it creates and removes); the existing copy is not touched before the owner authorises it. |
|
||||
| B. Working copy never archived | (a) `packages/supabase/tests/sandbox/sheets-admin.sandbox.ts` created the historical sheet's working copy (`8c315a12-…`, 2026-11-08 21:00:30) and never archived it; the single slot then disables « Créer une copie de travail » (`WorkingCopyAction.tsx:88`). (b) Even on a fresh stack `editor-equine.spec.ts` flips the slot while `admin.spec.ts:717` runs in parallel. Only the historical sheet offers the action, so the test depended on shared state. | FIXED (owner, 2026-11-12, option 1): the dialog's axe, layout and keyboard checks run on the real component in `e2e/ui/working-copy.spec.ts`; `admin.spec.ts` keeps the historical page and checks the button state against its reason; the sandbox suite archives only the copies it created (`returning id` checked) and each cleanup step runs independently. Limit: the dialog is no longer checked in its real server context by this accessibility test. Open: the creation branch of the cleanup is not yet run on a fresh stack. `editor-equine.spec.ts` still archives and restores pre-existing copies on every run. |
|
||||
| C. Silent card failure | Section 3, R4. | Show the failure, never hide or route around it. |
|
||||
|
||||
## 6. Arbitrations
|
||||
|
||||
@@ -84,6 +84,8 @@ const wrongCode = (secret: string) =>
|
||||
|
||||
const created: string[] = []
|
||||
const species: string[] = []
|
||||
// Working copies created by this run (the slot is one per database): never anyone else's.
|
||||
const copies: string[] = []
|
||||
|
||||
async function account(tag: string, role: 'owner' | 'admin' | null = null): Promise<Account> {
|
||||
const a = await confirmedAccount(tag)
|
||||
@@ -92,9 +94,21 @@ async function account(tag: string, role: 'owner' | 'admin' | null = null): Prom
|
||||
return a
|
||||
}
|
||||
|
||||
afterAll(async () => {
|
||||
if (species.length > 0)
|
||||
await sql(`delete from public.species where id in (${species.map((id) => `'${id}'`).join(', ')})`)
|
||||
/** Archives the working copies this run created, and only them. */
|
||||
async function archiveOwnCopies() {
|
||||
if (copies.length === 0) return
|
||||
const ids = copies.map((id) => `'${id}'`).join(', ')
|
||||
const archived = await sql(`update public.anatomical_sheets set status = 'archived', archived_at = now()
|
||||
where id in (${ids}) returning id`)
|
||||
expect(archived.split('\n').sort()).toEqual([...copies].sort())
|
||||
}
|
||||
|
||||
async function dropOwnSpecies() {
|
||||
if (species.length === 0) return
|
||||
await sql(`delete from public.species where id in (${species.map((id) => `'${id}'`).join(', ')})`)
|
||||
}
|
||||
|
||||
async function dropOwnAccounts() {
|
||||
if (created.length === 0) return
|
||||
const ids = created.map((id) => `'${id}'`).join(', ')
|
||||
// Grants are never deleted by design (guard trigger): the run's own rows are
|
||||
@@ -105,6 +119,19 @@ afterAll(async () => {
|
||||
set local session_replication_role = origin;
|
||||
delete from auth.users where id in (${ids});
|
||||
commit;`)
|
||||
}
|
||||
|
||||
// Each step runs even when an earlier one fails; the first error is rethrown.
|
||||
afterAll(async () => {
|
||||
const failures: unknown[] = []
|
||||
for (const step of [archiveOwnCopies, dropOwnSpecies, dropOwnAccounts]) {
|
||||
try {
|
||||
await step()
|
||||
} catch (error) {
|
||||
failures.push(error)
|
||||
}
|
||||
}
|
||||
if (failures.length > 0) throw failures[0]
|
||||
})
|
||||
|
||||
describe('TOTP wrappers on real GoTrue', () => {
|
||||
@@ -183,9 +210,14 @@ describe('administration reads, species and account lookup', () => {
|
||||
order by version_number limit 1`)
|
||||
// A fresh sandbox has no working copy yet, so the first call may create it: both outcomes are valid.
|
||||
const name = () => `wc-${randomUUID().slice(0, 8)}`
|
||||
const first = await kindOf(createSheetWorkingCopy(editorAal2, source, name()))
|
||||
const attempt = async () => {
|
||||
const promise = createSheetWorkingCopy(editorAal2, source, name())
|
||||
promise.then((id) => copies.push(id), () => undefined)
|
||||
return kindOf(promise)
|
||||
}
|
||||
const first = await attempt()
|
||||
if (first === 'no failure') {
|
||||
expect(await kindOf(createSheetWorkingCopy(editorAal2, source, name()))).toBe('working_copy.exists')
|
||||
expect(await attempt()).toBe('working_copy.exists')
|
||||
} else {
|
||||
expect(['working_copy.exists', 'working_copy.assets_missing']).toContain(first)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user