feat(editor): four tabs, Annotations sections, references from the header

U1 Lot B1. Four tabs (Général, Annotations, Constats, Vérification); views,
categories and regions become full-width Annotations sections opened from the
overview panel; references move to a header-toggled panel (minimal, Lot D
completes it); « Aller à » goes through EditorTarget and the navigation hook.
EditorWorkspace owns the navigation; DraftHeader split in HeaderActions and
SaveLine; EditorTabs split in TabList and MoreTabs.

R-24, assertions removed or rewritten (file: old -> new):
unit
- editor-route.test: seven tab names -> four; « Plus » at 800 px with
  Références clicked -> no « Plus »; below 640 px five others -> Général,
  Constats, and Constats opens the findings tab; + references panel cases
- editor-route-recovery.test: tab Références + editor-tab-references label ->
  header button + editor-references-panel labelled by its heading
- editor-mode.test: small tier `more` of five -> [general, findings]
- editor-focus-request.test: {key,serial} -> {target,serial}; ReferencesTab and
  VertebraeTab -> ReferencesPanel and RegionsSection; issueTarget tab/key ->
  target place/section/key (vertebrae tab -> annotations/regions); consumed
  context (serial) -> (serial, outcome); annotation case adds heading focus
- editor-verification.test: onGoTo('annotations', key) -> navigate(targetOfKey
  (key), opener); props onSelectTab/onGoTo -> navigate
- editor-annotations-tab.test: props onSelectTab -> navigate + section props;
  no_category text « (onglet Général) » -> « (Annotations, section
  Catégories) »
- editor-tabs-general.test: categories cases render GeneralTab ->
  CategoriesSection(doc); + Général holds no categories editor
- editor-tabs-lists.test: tab imports -> panel and section; read-only
  references « no button » -> only « Fermer les références »
- editor-tabs-views, editor-drawing-upload, editor-repair.test: ViewsTab ->
  ViewsSection import, assertions kept; editor-findings.test: navigate prop
e2e
- support/editor selectTab: exact name -> pattern (error badge in the name);
  + place, openSection, showDrawing, backToDrawing, openReferences, TABS
- support/warm-up: seven tabs -> four + sections + references panel
- editor-access: seven-tab axe loops -> four tabs + three sections + panel
  (edit and read-only); narrow widths add panel overflow and axe
- editor-drawings: tab Vues -> openSection views; tab Annotations ->
  showDrawing
- editor-structures: tab Général (categories) -> openSection categories, axe
  label « general tab » -> « categories section »; tab Références ->
  openReferences/closeReferences; tab Vertèbres -> openSection regions; tab
  Annotations -> showDrawing
- editor-geometry: three tab Vues -> openSection views
- editor-equine: tab Général (categories add) -> openSection categories; five
  tabs loop -> two tabs + sections + panel; tab Annotations -> showDrawing
- editor-journey: tab Vues, tab Général (category), tab Annotations ->
  openSection views/categories, showDrawing; frozen axe scrolls to the header
- lan/trial-lan (not run): tab Vues -> Annotations tab + views entry

Verified: typecheck, lint, vitest 107 files / 1125 tests, whole shell suite on
the sandbox 151 passed, 49 skipped, 0 failed.
This commit is contained in:
bchanot committed 2026-11-06 20:25:35 +01:00
1 parent 95b1b7e461
commit bc2dba7c14
56 files changed
+2419 -699

No files matched your search

+10 -6
View File
@@ -99,6 +99,14 @@ async function createNonEquineSheet(page: Page, tag: string) {
await expect(page).toHaveURL(/\/app\/admin\/sheets\/[0-9a-f-]{36}\/draft$/)
}
/** The views section: the Annotations tab, then the overview entry (U1 moved the views). */
async function openViews(page: Page) {
await page
.getByRole('tab', { name: dict['editor.tab.annotations'], exact: true })
.click()
await page.locator('[data-section-entry="views"]').click()
}
test('trial through the LAN origin: MFA, new sheet, SVG import, save, reload', async ({
page,
}) => {
@@ -121,9 +129,7 @@ test('trial through the LAN origin: MFA, new sheet, SVG import, save, reload', a
await signIn(page)
await challenge(page, secret)
await createNonEquineSheet(page, tag)
await page
.getByRole('tab', { name: dict['editor.tab.views'], exact: true })
.click()
await openViews(page)
await page
.locator('[data-testid$="-file"]')
.first()
@@ -144,9 +150,7 @@ test('trial through the LAN origin: MFA, new sheet, SVG import, save, reload', a
await page.getByRole('button', { name: dict['common.save'] }).click()
await expect(revisionLine(page)).toHaveText(`Révision ${before + 1}`)
await page.reload()
await page
.getByRole('tab', { name: dict['editor.tab.views'], exact: true })
.click()
await openViews(page)
await expect(
page.getByRole('tabpanel').getByText(dict['editor.views.drawing.ok']),
).toBeVisible()
+30 -9
View File
@@ -9,15 +9,21 @@ import {
import { stepUpAdmin } from '../support/admin'
import { dropLateReplays, routeToSandbox } from '../support/sandbox'
import {
SECTIONS,
TABS,
closeReferences,
draftPath,
draftTitle,
editorActor,
makeActor,
openEditor,
openReferences,
openSection,
pointOf,
seedDraft,
selectTab,
shapeWith,
showDrawing,
type Actor,
} from '../support/editor'
import { signIn } from '../support/shell'
@@ -31,15 +37,6 @@ import { signIn } from '../support/shell'
const dict = fr
const isPhone = (info: TestInfo) => info.project.name === 'chromium-375'
const TABS = [
'general',
'views',
'annotations',
'findings',
'references',
'vertebrae',
'verification',
] as const
const seedShape = shapeWith(
pointOf('p1', 'main', { cx: 500, cy: 400, r: 40 }, 'Point un'),
@@ -150,6 +147,9 @@ test.describe('editor access, narrow screens and axe', () => {
).toHaveCount(0)
await expectNoHorizontalOverflow(page, `the draft at ${width} px`)
await expectAccessible(page, `the draft at ${width} px`)
await openReferences(page, dict)
await expectNoHorizontalOverflow(page, `the panel at ${width} px`)
await expectAccessible(page, `the references panel at ${width} px`)
})
}
@@ -178,6 +178,20 @@ test.describe('editor access, narrow screens and axe', () => {
await expectNoHorizontalOverflow(page, `the ${tab} tab at 1 024 px`)
await expectAccessible(page, `the ${tab} tab (edit)`)
}
for (const section of SECTIONS) {
await openSection(page, dict, section)
await page.waitForLoadState('networkidle')
await expectNoHorizontalOverflow(
page,
`the ${section} section at 1 024 px`,
)
await expectAccessible(page, `the ${section} section (edit)`)
}
await showDrawing(page, dict)
await openReferences(page, dict)
await expectNoHorizontalOverflow(page, 'the references panel at 1 024 px')
await expectAccessible(page, 'the references panel (edit)')
await closeReferences(page, dict)
})
test('axe on every tab of a read-only draft', async ({ page, requests }) => {
@@ -197,5 +211,12 @@ test.describe('editor access, narrow screens and axe', () => {
await page.waitForLoadState('networkidle')
await expectAccessible(page, `the ${tab} tab (read-only)`)
}
for (const section of SECTIONS) {
await openSection(page, dict, section)
await expectAccessible(page, `the ${section} section (read-only)`)
}
await showDrawing(page, dict)
await openReferences(page, dict)
await expectAccessible(page, 'the references panel (read-only)')
})
})
+10 -9
View File
@@ -4,14 +4,15 @@ import { expect, expectAccessible, test } from '../support/browser'
import { dropLateReplays, routeToSandbox } from '../support/sandbox'
import {
DRAWING_SVG,
INKSCAPE_EXPORT,
editorActor,
INKSCAPE_EXPORT,
openEditor,
seedDraft,
selectTab,
standardShape,
serverDocument,
openSection,
saveDraft,
seedDraft,
serverDocument,
showDrawing,
standardShape,
} from '../support/editor'
// V1-2.6 A2 (contract C16, C20): a drawing imported into a view. A hostile file is
@@ -54,7 +55,7 @@ test.describe('editor drawings (A2)', () => {
requests.forbid(actor.account.email, actor.account.password)
const seed = await seedDraft(actor, { drawing: null })
await openEditor(page, dict, actor, seed.sheetId)
await selectTab(page, dict, 'views')
await openSection(page, dict, 'views')
await expect(
mainDrawing(page).getByText(dict['editor.views.drawing.none']),
).toBeVisible()
@@ -81,7 +82,7 @@ test.describe('editor drawings (A2)', () => {
requests.forbid(actor.account.email, actor.account.password)
const seed = await seedDraft(actor, { drawing: null })
await openEditor(page, dict, actor, seed.sheetId)
await selectTab(page, dict, 'views')
await openSection(page, dict, 'views')
await mainFile(page).setInputFiles(
file(INKSCAPE_EXPORT, 'inkscape-1.4.3.svg'),
@@ -130,7 +131,7 @@ test.describe('editor drawings (A2)', () => {
requests.forbid(actor.account.email, actor.account.password)
const seed = await seedDraft(actor, { drawing: null, shape: standardShape })
await openEditor(page, dict, actor, seed.sheetId)
await selectTab(page, dict, 'views')
await openSection(page, dict, 'views')
await mainFile(page).setInputFiles(file(DRAWING_SVG, 'valide.svg'))
await expect(page.getByText(dict['editor.upload.done'])).toBeVisible()
@@ -164,7 +165,7 @@ test.describe('editor drawings (A2)', () => {
detail.getByText(dict['editor.views.drawing.inherited']),
).toBeVisible()
await selectTab(page, dict, 'annotations')
await showDrawing(page, dict)
await page
.getByRole('group', { name: dict['editor.annotations.views'] })
.getByRole('button', { name: 'Détail A' })
+12 -10
View File
@@ -11,14 +11,19 @@ import { stepUpAdmin } from '../support/admin'
import { expect, expectAccessible, test } from '../support/browser'
import { dropLateReplays, routeToSandbox } from '../support/sandbox'
import {
type Actor,
closeReferences,
editorActor,
openEditor,
openReferences,
openSection,
SECTIONS,
seedDraft,
selectTab,
serverDocument,
showDrawing,
standardShape,
toolButton,
type Actor,
} from '../support/editor'
import { signIn } from '../support/shell'
@@ -121,7 +126,7 @@ async function measureRenames(page: Page, label: string) {
}
async function measureAdditions(page: Page, label: string) {
await selectTab(page, dict, 'general')
await openSection(page, dict, 'categories')
await startProbe(page)
for (let round = 0; round <= SAMPLES; round++) {
await page.locator('#category-new-fr').fill(`Catégorie ${round}`)
@@ -287,14 +292,11 @@ test.describe('equine working copy and commit latency', () => {
// once blanked the page on nodes that omit their defaulted fields).
await selectTab(page, dict, 'findings')
await expect(page.getByTestId('finding-item').first()).toBeVisible()
for (const tab of [
'general',
'views',
'references',
'vertebrae',
'verification',
])
for (const tab of ['general', 'verification'])
await selectTab(page, dict, tab)
for (const section of SECTIONS) await openSection(page, dict, section)
await openReferences(page, dict)
await closeReferences(page, dict)
expect(errors, 'page errors on the equine copy').toEqual([])
})
@@ -314,7 +316,7 @@ test.describe('equine working copy and commit latency', () => {
'equine: add category (insert)',
)
// A geometry edit: the first annotation's centre, through the geometry group.
await selectTab(page, dict, 'annotations')
await showDrawing(page, dict)
await page
.getByRole('list', { name: dict['editor.annotations.list'] })
.getByRole('button')
+5 -4
View File
@@ -8,11 +8,12 @@ import {
editorActor,
geometryField,
openEditor,
openSection,
pointOf,
saveDraft,
seedDraft,
serverDocument,
selectTab,
serverDocument,
shapeWith,
standardShape,
} from '../support/editor'
@@ -201,7 +202,7 @@ test.describe('editor geometry (adversarial)', () => {
),
)
requests.forbid(actor.account.email, actor.account.password)
await selectTab(page, dict, 'views')
await openSection(page, dict, 'views')
const detail = page.getByRole('listitem', { name: 'Détail A' })
await detail
.getByRole('button', { name: dict['editor.views.crop.toggle'] })
@@ -257,7 +258,7 @@ test.describe('editor geometry (adversarial)', () => {
},
})
await openEditor(page, dict, actor, seed.sheetId)
await selectTab(page, dict, 'views')
await openSection(page, dict, 'views')
await page.getByTestId('view-main-file').setInputFiles({
name: 'petit.svg',
mimeType: 'image/svg+xml',
@@ -344,7 +345,7 @@ test.describe('editor geometry (adversarial)', () => {
},
})
await openEditor(page, dict, actor, seed.sheetId)
await selectTab(page, dict, 'views')
await openSection(page, dict, 'views')
await page.getByTestId('view-main-file').setInputFiles({
name: 'petit.svg',
mimeType: 'image/svg+xml',
+13 -6
View File
@@ -9,16 +9,18 @@ import {
clickDrawing,
createFromPanel,
creationPanel,
INKSCAPE_EXPORT,
editorActor,
fillCreation,
geometryField,
INKSCAPE_EXPORT,
openDraft,
openSection,
saveDraft,
serverDocument,
secondSession,
selectTab,
serverDocument,
showDrawing,
toolButton,
openDraft,
} from '../support/editor'
import { signIn } from '../support/shell'
@@ -79,7 +81,7 @@ async function createSheetFromAdmin(page: Page, tag: string): Promise<string> {
}
async function importDrawing(page: Page) {
await selectTab(page, dict, 'views')
await openSection(page, dict, 'views')
// The real Inkscape 1.4.3 export, cleaned by the core in the page (viewBox 0 0 200 150).
await page.getByTestId('view-view-main-file').setInputFiles({
name: 'inkscape-1.4.3.svg',
@@ -105,7 +107,7 @@ async function importDrawing(page: Page) {
}
async function createFindings(page: Page) {
await selectTab(page, dict, 'general')
await openSection(page, dict, 'categories')
await page.locator('#category-new-fr').fill('Catégorie essai')
await page.locator('#category-new-en').fill('Trial category')
await clickButton(page, dict['editor.general.category_add'])
@@ -132,7 +134,7 @@ async function createFindings(page: Page) {
}
async function createAnnotations(page: Page) {
await selectTab(page, dict, 'annotations')
await showDrawing(page, dict)
const trace = async (points: number[][]) => {
for (const [x, y] of points) await clickDrawing(page, x, y)
await clickButton(page, dict['editor.annotations.trace_close'])
@@ -420,6 +422,11 @@ test.describe('editor journey (owner trial steps)', () => {
`select status from public.anatomical_sheet_reviews where version_id = '${draftId}'`,
),
).toBe('verifying')
// The submit button sits at the page's end: back at the header, whose « Références »
// button the sticky top bar covers while the page is scrolled.
await page
.getByRole('heading', { level: 1, name: 'Brouillon, version 1' })
.evaluate((heading) => heading.scrollIntoView({ block: 'center' }))
await expectAccessible(page, 'the frozen draft')
})
})
+11 -6
View File
@@ -4,8 +4,11 @@ import { expect, expectAccessible, test } from '../support/browser'
import { dropLateReplays, routeToSandbox } from '../support/sandbox'
import {
bareShape,
closeReferences,
editorActor,
openEditor,
openReferences,
openSection,
pointOf,
saveDraft,
seedDraft,
@@ -13,6 +16,7 @@ import {
serverDocument,
serverRevision,
shapeWith,
showDrawing,
} from '../support/editor'
// V1-2.6 A4 (contract C9 to C12, C19): the structures around the drawing. Annotation
@@ -56,7 +60,7 @@ test.describe('editor structures (A4)', () => {
requests.forbid(actor.account.email, actor.account.password)
// A category added, then renamed in place.
await selectTab(page, dict, 'general')
await openSection(page, dict, 'categories')
await page.locator('#category-new-fr').fill('Catégorie B')
await page.locator('#category-new-en').fill('Category B')
await page
@@ -67,10 +71,10 @@ test.describe('editor structures (A4)', () => {
await expect(names).toHaveCount(2)
await commitText(names.nth(1), 'Catégorie B bis')
await expect(names.nth(1)).toHaveValue('Catégorie B bis')
await expectAccessible(page, 'the general tab')
await expectAccessible(page, 'the categories section')
// Two references, the second moved up.
await selectTab(page, dict, 'references')
await openReferences(page, dict)
for (const citation of ['Première référence', 'Seconde référence']) {
await page.locator('#reference-new-type').selectOption('book')
await page.locator('#reference-new-citation').fill(citation)
@@ -100,7 +104,8 @@ test.describe('editor structures (A4)', () => {
await expect(citations).toHaveCount(1)
// A region with its count.
await selectTab(page, dict, 'vertebrae')
await closeReferences(page, dict)
await openSection(page, dict, 'regions')
await page.locator('#region-new-code').fill('T')
await page.locator('#region-new-fr').fill('Thoracique')
await page.locator('#region-new-en').fill('Thoracic')
@@ -245,7 +250,7 @@ test.describe('editor structures (A4)', () => {
requests.forbid(actor.account.email, actor.account.password)
// The category is used by the point: the dialog lists it and offers no deletion.
await selectTab(page, dict, 'general')
await openSection(page, dict, 'categories')
await page
.getByRole('listitem')
.filter({ has: page.locator('#category-cat-a-name-fr') })
@@ -283,7 +288,7 @@ test.describe('editor structures (A4)', () => {
.click()
// The point goes first; the zone then deletes with its descendants named.
await selectTab(page, dict, 'annotations')
await showDrawing(page, dict)
await page
.getByRole('list', { name: dict['editor.annotations.list'] })
.getByRole('button', { name: /Point lié/ })
+64 -2
View File
@@ -9,7 +9,7 @@ import { createHash, randomUUID } from 'node:crypto'
import { readFileSync } from 'node:fs'
import { join } from 'node:path'
import type { Dict } from '@/i18n/types'
import type { Browser, BrowserContext, Page } from '@playwright/test'
import type { Browser, BrowserContext, Locator, Page } from '@playwright/test'
import {
enrolTotp,
refusal,
@@ -323,10 +323,72 @@ export async function openDraft(page: Page, dict: Dict, sheetId: string) {
await expect(page.getByRole('tablist')).toBeVisible()
}
/** The four tabs of the editor (U1): the references moved to a panel, the rest to Annotations. */
export const TABS = [
'general',
'annotations',
'findings',
'verification',
] as const
/** The Annotations sections and the panel, in the order the overview offers them. */
export const SECTIONS = ['views', 'categories', 'regions'] as const
/**
* Clicks a tab by role. The name is a pattern: the Vérification tab adds « n erreur(s) »
* to its name while the in-page check has errors.
*/
export async function selectTab(page: Page, dict: Dict, tab: string) {
const name = dict[`editor.tab.${tab}`]
await page.getByRole('tab', { name: new RegExp(`^${name}( |$)`) }).click()
}
/** The visible place with this `data-place` name; a hidden copy never answers. */
export function place(page: Page, name: string): Locator {
return page.locator(`[data-place="${name}"]:visible`)
}
/** « Retour au dessin »: leaves an Annotations section for the drawing. */
export async function backToDrawing(page: Page, dict: Dict) {
await page.getByRole('button', { name: dict['editor.section.back'] }).click()
await expect(place(page, 'annotations.drawing')).toBeVisible()
}
/** The Annotations tab on its drawing, whatever section it was left on. */
export async function showDrawing(page: Page, dict: Dict) {
await selectTab(page, dict, 'annotations')
const back = page.getByRole('button', { name: dict['editor.section.back'] })
if (await back.isVisible()) await backToDrawing(page, dict)
await expect(place(page, 'annotations.drawing')).toBeVisible()
}
/** Opens an Annotations section through its overview entry. */
export async function openSection(
page: Page,
dict: Dict,
section: (typeof SECTIONS)[number],
) {
await showDrawing(page, dict)
await page.locator(`[data-section-entry="${section}"]`).click()
await expect(place(page, `annotations.${section}`)).toBeVisible()
}
/** Opens the references panel from the header button. */
export async function openReferences(page: Page, dict: Dict) {
const toggle = page.getByRole('button', {
name: dict['editor.references.open'],
exact: true,
})
if ((await toggle.getAttribute('aria-expanded')) !== 'true')
await toggle.click()
await expect(place(page, 'references')).toBeVisible()
}
export async function closeReferences(page: Page, dict: Dict) {
await page
.getByRole('tab', { name: dict[`editor.tab.${tab}`], exact: true })
.getByRole('button', { name: dict['editor.references.close'] })
.click()
await expect(place(page, 'references')).toHaveCount(0)
}
/** The revision the server holds for the draft. */
+15 -12
View File
@@ -2,31 +2,26 @@
* Global setup of the shell suite (V1-2.6): the Vite dev server discovers some
* dependencies only when a route first loads them and answers with a full page
* reload, which wiped a form a test had begun to fill. One throwaway session
* visits the editor routes and every tab once before the tests start, so the
* visits the editor routes, every tab, every Annotations section and the references panel once before the tests start, so the
* reload happens here and not in a test.
*/
import { chromium, type FullConfig } from '@playwright/test'
import { fr } from '@/i18n/fr'
import { stepUpAdmin } from './admin'
import {
TABS,
closeReferences,
draftPath,
editorActor,
openReferences,
openSection,
secondSession,
seedDraft,
SECTIONS,
standardShape,
} from './editor'
import { signIn } from './shell'
const TABS = [
'general',
'views',
'annotations',
'findings',
'references',
'vertebrae',
'verification',
] as const
export default async function warmUp(config: FullConfig): Promise<void> {
const baseURL = config.projects[0].use.baseURL ?? ''
const actor = await editorActor('fr')
@@ -42,10 +37,18 @@ export default async function warmUp(config: FullConfig): Promise<void> {
}
for (const tab of TABS) {
await page
.getByRole('tab', { name: fr[`editor.tab.${tab}`], exact: true })
.getByRole('tab', {
name: new RegExp(`^${fr[`editor.tab.${tab}`]}( |$)`),
})
.click()
await page.waitForLoadState('networkidle')
}
for (const section of SECTIONS) {
await openSection(page, fr, section)
await page.waitForLoadState('networkidle')
}
await openReferences(page, fr)
await closeReferences(page, fr)
await page.goto('/app/admin/sheets/new')
await page.waitForLoadState('networkidle')
await browser.close()