diff --git a/apps/app/e2e/shell/editor-access.spec.ts b/apps/app/e2e/shell/editor-access.spec.ts index 01761643..4671ad93 100644 --- a/apps/app/e2e/shell/editor-access.spec.ts +++ b/apps/app/e2e/shell/editor-access.spec.ts @@ -11,19 +11,18 @@ import { dropLateReplays, routeToSandbox } from '../support/sandbox' import { SECTIONS, TABS, - closeReferences, + closeCitations, draftPath, draftTitle, editorActor, makeActor, openEditor, - openReferences, + openCitations, openSection, pointOf, seedDraft, selectTab, shapeWith, - showDrawing, type Actor, } from '../support/editor' import { signIn } from '../support/shell' @@ -147,9 +146,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 openCitations(page, dict, 'Constat A') await expectNoHorizontalOverflow(page, `the panel at ${width} px`) - await expectAccessible(page, `the references panel at ${width} px`) + await expectAccessible(page, `the citations panel at ${width} px`) }) } @@ -187,11 +186,10 @@ test.describe('editor access, narrow screens and axe', () => { ) 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) + await openCitations(page, dict, 'Constat A') + await expectNoHorizontalOverflow(page, 'the citations panel at 1 024 px') + await expectAccessible(page, 'the citations panel (edit)') + await closeCitations(page, dict) }) test('axe on every tab of a read-only draft', async ({ page, requests }) => { @@ -215,8 +213,7 @@ test.describe('editor access, narrow screens and axe', () => { 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)') + await openCitations(page, dict, 'Constat A') + await expectAccessible(page, 'the citations panel (read-only)') }) }) diff --git a/apps/app/e2e/shell/editor-deselect.spec.ts b/apps/app/e2e/shell/editor-deselect.spec.ts index bdc31716..259637b8 100644 --- a/apps/app/e2e/shell/editor-deselect.spec.ts +++ b/apps/app/e2e/shell/editor-deselect.spec.ts @@ -11,7 +11,7 @@ import { geometryField, historyButton, openEditor, - openReferences, + openCitations, pickAnnotation, place, pointOf, @@ -192,7 +192,7 @@ test.describe('deselect and D6b (editor, mouse and keyboard)', () => { expect(saves).toEqual([]) }) - test('Escape: canvas, field, delete dialog, references panel, tracing', async ({ + test('Escape: canvas, field, delete dialog, citations panel, tracing', async ({ page, requests, }) => { @@ -223,10 +223,12 @@ test.describe('deselect and D6b (editor, mouse and keyboard)', () => { await expect(dialog).toHaveCount(0) await expectKept(page, POINT) - // The references panel: it closes, the selection stays, a second Escape deselects. - await openReferences(page, dict) + // The citations panel (over Constats): it closes, the selection stays, back on + // Annotations a second Escape deselects. + await openCitations(page, dict, 'Constat A') await page.keyboard.press('Escape') await expect(place(page, 'citations')).toHaveCount(0) + await selectTab(page, dict, 'annotations') await expectKept(page, POINT) await box(page).focus() await page.keyboard.press('Escape') diff --git a/apps/app/e2e/shell/editor-equine.spec.ts b/apps/app/e2e/shell/editor-equine.spec.ts index accf6e0a..1558ad13 100644 --- a/apps/app/e2e/shell/editor-equine.spec.ts +++ b/apps/app/e2e/shell/editor-equine.spec.ts @@ -14,10 +14,9 @@ import { place, type Actor, annotationList, - closeReferences, editorActor, openEditor, - openReferences, + openTab, openSection, SECTIONS, seedDraft, @@ -301,8 +300,7 @@ test.describe('equine working copy and commit latency', () => { 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) + await openTab(page, dict, 'references') expect(errors, 'page errors on the equine copy').toEqual([]) }) @@ -401,8 +399,7 @@ test.describe('equine working copy and commit latency', () => { for (const tab of ['general', 'findings', 'verification']) await selectTab(page, dict, tab) for (const section of SECTIONS) await openSection(page, dict, section) - await openReferences(page, dict) - await closeReferences(page, dict) + await openTab(page, dict, 'references') const renames = await measureRenames(page, 'equine, all places: rename') const additions = await measureAdditions(page, 'equine, all places: add') for (const line of [renames, additions]) diff --git a/apps/app/e2e/shell/editor-shell-crossing.spec.ts b/apps/app/e2e/shell/editor-shell-crossing.spec.ts index 9bd2324e..6fdb8c34 100644 --- a/apps/app/e2e/shell/editor-shell-crossing.spec.ts +++ b/apps/app/e2e/shell/editor-shell-crossing.spec.ts @@ -3,16 +3,16 @@ import type { Locator, Page, TestInfo } from '@playwright/test' import { expect, test } from '../support/browser' import { dropLateReplays, routeToSandbox } from '../support/sandbox' import { - INKSCAPE_EXPORT, clientOf, - closeReferences, + closeCitations, copyKeyOf, editorActor, geometryField, historyButton, libraryRoot, openEditor, - openReferences, + openCitations, + openTab, openSection, pickAnnotation, place, @@ -191,18 +191,17 @@ test.describe('editor shell, width crossing (H)', () => { ) }) - test('the references form keeps its typed text with the panel open', async ({ + test('the references form keeps its typed text, in the Références tab', async ({ page, }) => { await open(page) - await openReferences(page, dict) + await openTab(page, dict, 'references') await keepsTypedValue( page, - page.locator('#reference-new-citation'), + page.locator('#tab-reference-new-citation'), dict['editor.reference.add'], - 'annotations', + 'references', ) - await expect(place(page, 'citations')).toBeVisible() await expect(libraryRoot(page).getByRole('searchbox')).toBeVisible() }) @@ -260,25 +259,21 @@ test.describe('editor shell, width crossing (H)', () => { await expect(saveLine(page)).toHaveText(UNSAVED_LINE) }) - test('the panel open: read-only below the threshold, unsaved work kept, edit back on widening', async ({ + test('the citations panel open: read-only below the threshold, unsaved work kept, edit back on widening', async ({ page, }) => { await open(page) await commitName(page, 'Nom conservé') - await openReferences(page, dict) - await page.locator('#reference-new-citation').fill('Smith 1999') + await openCitations(page, dict, 'Constat A') await cross(page, NARROW) await expectReadOnly(page) await expect(place(page, 'citations')).toBeVisible() await expect(saveLine(page)).toHaveText(UNSAVED_LINE) await cross(page, WIDE) - await expect(page.locator('#reference-new-citation')).toHaveValue( - 'Smith 1999', - ) await expect( page.getByRole('button', { name: dict['common.save'], exact: true }), ).toBeEnabled() - await closeReferences(page, dict) + await closeCitations(page, dict) }) test('text typed without a blur is unsaved after the crossing and the copy is written', async ({ @@ -364,35 +359,4 @@ test.describe('editor shell, width crossing (H)', () => { await cross(page, WIDE) await expect(saveLine(page)).toHaveText(UNSAVED_LINE) }) - - test('a decision withheld while the panel was open waits for « Reprendre »; tabs keep the focus', async ({ - page, - }) => { - const actor = await editorActor('fr') - const seed = await seedDraft(actor, { drawing: null, shape: standardShape }) - await openEditor(page, dict, actor, seed.sheetId) - await openSection(page, dict, 'views') - await openReferences(page, dict) - await page.getByTestId('view-main-file').setInputFiles({ - name: 'inkscape.svg', - mimeType: 'image/svg+xml', - buffer: INKSCAPE_EXPORT, - }) - await expect( - page.getByText(dict['editor.views.pending.cleaning']), - ).toBeVisible() - await closeReferences(page, dict) - await expect(dialogs(page)).toHaveCount(0) - await selectTab(page, dict, 'general') - await page.getByRole('tab', { name: dict['editor.tab.general'] }).focus() - await page.keyboard.press('ArrowRight') - await expect(active(page)).toHaveAttribute('id', 'editor-tab-annotations') - await expect(dialogs(page)).toHaveCount(0) - await page - .getByRole('button', { name: dict['editor.views.pending.resume'] }) - .click() - await expect( - page.getByRole('dialog', { name: dict['editor.cleaning.title'] }), - ).toBeVisible() - }) }) diff --git a/apps/app/e2e/shell/editor-shell-journeys.spec.ts b/apps/app/e2e/shell/editor-shell-journeys.spec.ts index 0be1260b..e927c488 100644 --- a/apps/app/e2e/shell/editor-shell-journeys.spec.ts +++ b/apps/app/e2e/shell/editor-shell-journeys.spec.ts @@ -4,7 +4,6 @@ import { expect, test } from '../support/browser' import { dropLateReplays, routeToSandbox } from '../support/sandbox' import { TABS, - closeReferences, draftTitle, editorActor, historyButton, @@ -20,7 +19,7 @@ import { UNSAVED_LINE, } from '../support/editor' -// V1-2.6 U1 H (AC1, AC5, AC12, AC13, AC17): the journeys of the four-tab shell in a real +// V1-2.6 U1 H (AC1, AC5, AC12, AC13, AC17): the journeys of the five-tab shell in a real // browser. Every query is scoped to the visible place (`place()`) or goes by role, so a // hidden, kept-mounted copy never answers. @@ -111,16 +110,16 @@ test.describe('editor shell journeys (H)', () => { await dropLateReplays(context) }) - test('four tabs and no tab of the old layout', async ({ page }) => { + test('five tabs and no tab of the old layout', async ({ page }) => { await open(page) const tabs = page.getByRole('tablist').getByRole('tab') - await expect(tabs).toHaveCount(4) + await expect(tabs).toHaveCount(5) for (const [index, tab] of TABS.entries()) { await expect(tabs.nth(index)).toHaveText( new RegExp(`^${dict[`editor.tab.${tab}`]}`), ) } - for (const old of ['Vues et illustrations', 'Références', 'Vertèbres']) { + for (const old of ['Vues et illustrations', 'Vertèbres']) { await expect(page.getByRole('tab', { name: old })).toHaveCount(0) } }) @@ -244,9 +243,13 @@ test.describe('editor shell journeys (H)', () => { await selectTab(page, dict, 'verification') await goTo('Barone, Ostéologie') - await expect(place(page, 'citations')).toBeVisible() + await expect(place(page, 'references')).toBeVisible() + await expect( + page.getByRole('tab', { + name: new RegExp(`^${dict['editor.tab.references']}`), + }), + ).toHaveAttribute('aria-selected', 'true') await focusKey('ref-a') - await closeReferences(page, dict) }) test('the save line goes from the count to « Enregistrement… » to the time and the revision', async ({ diff --git a/apps/app/e2e/shell/editor-shell-layout.spec.ts b/apps/app/e2e/shell/editor-shell-layout.spec.ts index 9b852e51..7ec2f01c 100644 --- a/apps/app/e2e/shell/editor-shell-layout.spec.ts +++ b/apps/app/e2e/shell/editor-shell-layout.spec.ts @@ -11,15 +11,17 @@ import { dropLateReplays, routeToSandbox } from '../support/sandbox' import { SECTIONS, TABS, - closeReferences, + closeCitations, draftPath, draftTitle, editorActor, historyButton, openEditor, - openReferences, + openCitations, + openTab, openSection, pickAnnotation, + place, pointOf, seedDraft, selectTab, @@ -28,7 +30,7 @@ import { } from '../support/editor' import { signIn } from '../support/shell' -// V1-2.6 U1 H (AC10, AC11, AC17): the layout of the four-tab shell at every width, the +// V1-2.6 U1 H (AC10, AC11, AC17): the layout of the five-tab shell at every width, the // keyboard order of the editor, and axe on every place, edit and narrow read-only. const dict = fr @@ -50,18 +52,6 @@ async function open(page: Page) { return { ...seed, actor } } -/** Opens the tab, through « Plus » when the width keeps it out of the row. */ -async function goToTab(page: Page, tab: (typeof TABS)[number]) { - const direct = page.locator(`#editor-tab-${tab}`) - if ((await direct.count()) === 0) { - await page.getByRole('button', { name: dict['editor.tab.more'] }).click() - } - await direct.click() - await expect( - page.locator(`[data-place^="${tab}"]:visible`).first(), - ).toBeVisible() -} - async function settle(page: Page) { await page.evaluate( () => @@ -81,7 +71,7 @@ test.describe('editor shell layout (H)', () => { await dropLateReplays(context) }) - test('no horizontal scroll from 1 024 to 1 280 px on the four tabs, the three sections and the open panel', async ({ + test('no horizontal scroll from 1 024 to 1 280 px on the five tabs, the three sections and the open citations panel', async ({ page, }) => { test.setTimeout(150_000) @@ -96,14 +86,13 @@ test.describe('editor shell layout (H)', () => { await openSection(page, dict, section) await expectNoHorizontalOverflow(page, `${section} at ${width} px`) } - await showDrawing(page, dict) - await openReferences(page, dict) + await openCitations(page, dict, 'Constat A') await expectNoHorizontalOverflow(page, `the panel at ${width} px`) - await closeReferences(page, dict) + await closeCitations(page, dict) } }) - test('read-only at 320, 375 and 768 px: the four tabs fit and pass axe', async ({ + test('read-only at 320, 375 and 768 px: the five tabs fit and pass axe', async ({ page, requests, }) => { @@ -121,7 +110,7 @@ test.describe('editor shell layout (H)', () => { page.getByRole('heading', { level: 1, name: draftTitle(dict) }), ).toBeVisible() for (const tab of TABS) { - await goToTab(page, tab) + await openTab(page, dict, tab) await expectNoHorizontalOverflow(page, `${tab} at ${width} px`) await expect( page.getByRole('button', { name: dict['common.save'], exact: true }), @@ -137,28 +126,32 @@ test.describe('editor shell layout (H)', () => { } }) - test('the canvas width, the same measure without and with the references panel', async ({ + test('the canvas width is the same before the citations panel opens and after a tab switch closes it', async ({ page, }) => { test.setTimeout(150_000) await open(page) - for (const panel of [false, true]) { - for (const width of WIDTHS) { - await page.setViewportSize({ width, height: 800 }) - await showDrawing(page, dict) - await pickAnnotation(page, dict, 'Point libre') - if (panel) await openReferences(page, dict) - const canvas = await page.getByTestId('annotation-canvas').boundingBox() - test.info().annotations.push({ - type: panel ? 'canvas-width-panel' : 'canvas-width', - description: `${canvas?.width}px at ${width}px`, - }) - if (panel) await closeReferences(page, dict) - } + const measure = async () => + (await page.getByTestId('annotation-canvas').boundingBox())?.width + for (const width of WIDTHS) { + await page.setViewportSize({ width, height: 800 }) + await showDrawing(page, dict) + await pickAnnotation(page, dict, 'Point libre') + const before = await measure() + test.info().annotations.push({ + type: 'canvas-width', + description: `${before}px at ${width}px`, + }) + await openCitations(page, dict, 'Constat A') + // The panel exists on Constats only: leaving for Annotations closes it (P21). + await selectTab(page, dict, 'annotations') + await expect(place(page, 'citations')).toHaveCount(0) + await expect(page.getByTestId('annotation-canvas')).toBeVisible() + expect(await measure()).toBe(before) } }) - test('axe from the top on the four tabs, each section and the open panel', async ({ + test('axe from the top on the five tabs, each section and the open citations panel', async ({ page, }) => { test.setTimeout(150_000) @@ -179,13 +172,12 @@ test.describe('editor shell layout (H)', () => { await expect(page.locator('dialog[open]')).toHaveCount(0) await expectAccessible(page, `${name} at ${width} px`) } - await showDrawing(page, dict) - await openReferences(page, dict) + await openCitations(page, dict, 'Constat A') await settle(page) await page.evaluate(() => window.scrollTo(0, 0)) await expect(page.locator('dialog[open]')).toHaveCount(0) await expectAccessible(page, `the open panel at ${width} px`) - await closeReferences(page, dict) + await closeCitations(page, dict) } }) @@ -268,7 +260,9 @@ test.describe('editor shell keyboard order (H)', () => { await dropLateReplays(context) }) - test('header, tab list, Défaire, Refaire, then the tools, the canvas and the side column', async ({ + // The header holds no focusable control after the title while the draft is clean: its + // buttons (« Abandonner », « Enregistrer ») are disabled, and « Références » left it. + test('tab list, Défaire, Refaire, then the tools, the canvas and the side column', async ({ page, }) => { await open(page) @@ -280,7 +274,6 @@ test.describe('editor shell keyboard order (H)', () => { description: order.join(' > '), }) expect(order).toEqual([ - 'header', 'tab', 'undo', 'redo', @@ -290,23 +283,24 @@ test.describe('editor shell keyboard order (H)', () => { ]) }) - test('with the panel open: header, tab list, Défaire, Refaire, the panel, then the page content', async ({ + test('with the panel open: tab list, Défaire, Refaire, the panel, then the page content', async ({ page, }) => { await open(page) - await openReferences(page, dict) + await openCitations(page, dict, 'Constat A') const order = await walk(page, 'panel') test.info().annotations.push({ type: 'keyboard-order-panel', description: order.join(' > '), }) - expect(order).toEqual(['header', 'tab', 'undo', 'redo', 'panel']) + expect(order).toEqual(['tab', 'undo', 'redo', 'panel']) await page.keyboard.press('Escape') await expect(page.locator('[data-place="citations"]:visible')).toHaveCount( 0, ) + await selectTab(page, dict, 'annotations') const after = await walk(page, 'side') - expect(after.slice(0, 4)).toEqual(['header', 'tab', 'undo', 'redo']) + expect(after.slice(0, 3)).toEqual(['tab', 'undo', 'redo']) expect(after).not.toContain('panel') expect(after.at(-1)).toBe('side') }) diff --git a/apps/app/e2e/shell/editor-shell.spec.ts b/apps/app/e2e/shell/editor-shell.spec.ts index 767a7ee2..d3376872 100644 --- a/apps/app/e2e/shell/editor-shell.spec.ts +++ b/apps/app/e2e/shell/editor-shell.spec.ts @@ -6,10 +6,10 @@ import { backToDrawing, copyKeyOf, storedCopy, - closeReferences, + closeCitations, editorActor, openEditor, - openReferences, + openCitations, openSection, pickAnnotation, place, @@ -19,9 +19,10 @@ import { shapeWith, showDrawing, historyButton, + openTab, } from '../support/editor' -// V1-2.6 U1 B2a: tabs, Annotations sections and the references panel stay mounted. What +// V1-2.6 U1 B2a: tabs, Annotations sections and the Références tab stay mounted. What // was typed, the canvas zoom and the focus survive a change of place; focus lands on a // named element, never on `body`. happy-dom does not refuse focus on hidden elements, so // the focus rules are checked here with `document.activeElement`. @@ -92,53 +93,52 @@ test.describe('editor shell, kept places (B2a)', () => { expect(await layerTransform(page)).toBe(zoomed) }) - test('the references panel keeps its form text and no id repeats', async ({ + test('the Références tab keeps its form text and no id repeats, panel open included', async ({ page, }) => { await open(page) - await openReferences(page, dict) - await page.locator('#reference-new-citation').fill('Smith 1999') - await closeReferences(page, dict) - await openReferences(page, dict) - await expect(page.locator('#reference-new-citation')).toHaveValue( + await openTab(page, dict, 'references') + await page.locator('#tab-reference-new-citation').fill('Smith 1999') + await openTab(page, dict, 'general') + await openTab(page, dict, 'references') + await expect(page.locator('#tab-reference-new-citation')).toHaveValue( 'Smith 1999', ) - // The tab panels are inert while the panel is open (AC3): close it to reach them. - await closeReferences(page, dict) for (const tab of ['general', 'findings', 'verification']) { await selectTab(page, dict, tab) } for (const section of ['views', 'categories', 'regions'] as const) { await openSection(page, dict, section) } + // The tab bodies stay mounted under the panel: its card ids carry their own prefix. + await openCitations(page, dict, 'Constat A') const repeated = await page.evaluate(() => { const ids = [...document.querySelectorAll('[id]')].map((e) => e.id) return ids.filter((id, i) => ids.indexOf(id) !== i) }) expect(repeated).toEqual([]) + await closeCitations(page, dict) }) for (const width of [1024, 1280]) { - test(`the open references panel leaves the header and the tab row clickable at ${width} px`, async ({ + test(`the open citations panel leaves the header and the tab row clickable at ${width} px`, async ({ page, }) => { await page.setViewportSize({ width, height: 800 }) await open(page) - await openReferences(page, dict) - await page.locator('#reference-new-type').selectOption('book') - await page.locator('#reference-new-citation').fill('Smith 1999') + // An edit first, so « Enregistrer » is enabled: a reference added in its tab. + await openTab(page, dict, 'references') + await page.locator('#tab-reference-new-type').selectOption('book') + await page.locator('#tab-reference-new-citation').fill('Smith 1999') await page .getByRole('button', { name: dict['editor.reference.add'] }) .click() + await openCitations(page, dict, 'Constat A') const header = page.locator('main header').first() const tabs = page.getByRole('tablist') const panel = place(page, 'citations') const targets = [ page.getByRole('button', { name: dict['common.save'], exact: true }), - page.getByRole('button', { - name: dict['editor.references.open'], - exact: true, - }), page.getByRole('tab', { name: new RegExp(`^${dict['editor.tab.findings']}`), }), diff --git a/apps/app/e2e/shell/editor-structures.spec.ts b/apps/app/e2e/shell/editor-structures.spec.ts index fd1ac04c..ce765dd4 100644 --- a/apps/app/e2e/shell/editor-structures.spec.ts +++ b/apps/app/e2e/shell/editor-structures.spec.ts @@ -4,11 +4,10 @@ import { expect, expectAccessible, test } from '../support/browser' import { dropLateReplays, routeToSandbox } from '../support/sandbox' import { bareShape, - closeReferences, editorActor, libraryRoot, openEditor, - openReferences, + openTab, openSection, pickAnnotation, pointOf, @@ -77,23 +76,23 @@ test.describe('editor structures (A4)', () => { await expect(names.nth(1)).toHaveValue('Catégorie B bis') await expectAccessible(page, 'the categories section') - // Two references, the second moved up. - await openReferences(page, dict) + // Two references added in the Références tab, the second moved up (the shape's + // « Référence A » stays first: it is cited by « Constat A »). + await openTab(page, dict, 'references') 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) + await page.locator('#tab-reference-new-type').selectOption('book') + await page.locator('#tab-reference-new-citation').fill(citation) await page .getByRole('button', { name: dict['editor.reference.add'] }) .click() await expect(page.getByText(citation)).toBeVisible() } const citations = page.locator( - '[id^="reference-"][id$="-citation"]:not(#reference-new-citation)', + '[id^="tab-reference-"][id$="-citation"]:not(#tab-reference-new-citation)', ) - await expect(citations).toHaveCount(2) - await expect( - libraryRoot(page).getByText('citée 0 fois'), - ).toHaveCount(2) + await expect(citations).toHaveCount(3) + await expect(libraryRoot(page).getByText('citée 0 fois')).toHaveCount(2) + await expect(libraryRoot(page).getByText('citée 1 fois')).toHaveCount(1) await page .getByRole('searchbox', { name: dict['editor.references.search'] }) .fill('seconde') @@ -101,13 +100,13 @@ test.describe('editor structures (A4)', () => { await page .getByRole('searchbox', { name: dict['editor.references.search'] }) .fill('') - await expect(citations).toHaveCount(2) + await expect(citations).toHaveCount(3) await page .getByRole('listitem') .filter({ hasText: 'Seconde référence' }) .getByRole('button', { name: dict['editor.action.move_up'] }) .click() - await expect(citations.first()).toHaveValue('Seconde référence') + await expect(citations.nth(1)).toHaveValue('Seconde référence') await page .getByRole('listitem') .filter({ hasText: 'Première référence' }) @@ -116,10 +115,9 @@ test.describe('editor structures (A4)', () => { await dialog(page) .getByRole('button', { name: dict['editor.delete.confirm'] }) .click() - await expect(citations).toHaveCount(1) + await expect(citations).toHaveCount(2) // A region with its count. - 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') @@ -142,6 +140,7 @@ test.describe('editor structures (A4)', () => { 'Catégorie B bis', ]) expect(saved.references.map((r) => r.citation)).toEqual([ + 'Référence A', 'Seconde référence', ]) expect(saved.vertebral_config.regions).toEqual([ diff --git a/apps/app/e2e/support/editor.ts b/apps/app/e2e/support/editor.ts index c8565bcd..7fcdd3a4 100644 --- a/apps/app/e2e/support/editor.ts +++ b/apps/app/e2e/support/editor.ts @@ -236,6 +236,15 @@ export async function seedDraft( * `bareShape` below omits the defaulted fields (the loader fills them from the core). */ export function standardShape(document: Record) { + document.references = [ + { + id: 'ref-a', + type: 'book', + citation: 'Référence A', + url: null, + doi: null, + }, + ] document.categories = [ { id: 'cat-a', name: text('Catégorie A'), color: null }, ] @@ -257,7 +266,7 @@ export function standardShape(document: Record) { name: text('Constat A'), description: {}, requires_vet_referral: false, - reference_ids: [], + reference_ids: ['ref-a'], review_status: 'reviewed', children: [], }, @@ -323,11 +332,12 @@ 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. */ +/** The five tabs of the editor (R2.1), in the order of the row. */ export const TABS = [ 'general', 'annotations', 'findings', + 'references', 'verification', ] as const @@ -373,23 +383,56 @@ export async function openSection( await expect(place(page, `annotations.${section}`)).toBeVisible() } -/** Where the references library shows: today the citations panel (R2.1 moves it to its tab). */ +/** Where the references library shows: the Références tab. */ export function libraryRoot(page: Page): Locator { - return place(page, 'citations') + return place(page, 'references') } -/** 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() +/** Below this width the tabs other than Annotations and Vérification sit under « Plus ». */ +const SMALL_TIER_WIDTH = 640 + +/** + * Shows a tab whatever the width: the tab button from 640 px, below it « Plus » opened and + * the tab picked in its list. Waits for the body of a tab that has a `data-place` of its + * own (every one but Annotations, which names its sections). + */ +export async function openTab(page: Page, dict: Dict, tab: string) { + const width = page.viewportSize()?.width ?? SMALL_TIER_WIDTH + const name = new RegExp(`^${dict[`editor.tab.${tab}`]}( |$)`) + const listed = ['annotations', 'verification'].includes(tab) + if (width < SMALL_TIER_WIDTH && !listed) { + const more = page.getByRole('button', { + name: dict['editor.tab.more'], + exact: true, + }) + if ((await more.getAttribute('aria-expanded')) !== 'true') + await more.click() + await page.locator('#editor-tabs-more').getByRole('button', { name }).click() + } else { + await page.getByRole('tab', { name }).click() + } + if (tab !== 'annotations') await expect(place(page, tab)).toBeVisible() +} + +/** + * Opens the citations panel of the finding named `element`: the Constats tab, the tree + * expanded down to it, the element selected, its « n références » trigger pressed. + */ +export async function openCitations(page: Page, dict: Dict, element: string) { + await openTab(page, dict, 'findings') + const item = page.getByRole('treeitem', { name: element }) + for (let depth = 0; depth < 4 && (await item.count()) === 0; depth++) { + const closed = page.getByRole('treeitem', { expanded: false }).first() + await closed.focus() + await closed.press('ArrowRight') + } + await item.click() + await page.locator('[data-citations-trigger]:visible').click() await expect(place(page, 'citations')).toBeVisible() } -export async function closeReferences(page: Page, dict: Dict) { +/** Closes the citations panel with its ✕ button. */ +export async function closeCitations(page: Page, dict: Dict) { await page .getByRole('button', { name: dict['editor.references.close'] }) .click() diff --git a/apps/app/e2e/support/warm-up.ts b/apps/app/e2e/support/warm-up.ts index c244e674..a88c9c96 100644 --- a/apps/app/e2e/support/warm-up.ts +++ b/apps/app/e2e/support/warm-up.ts @@ -2,7 +2,7 @@ * 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, every tab, every Annotations section and the references panel once before the tests start, so the + * visits the editor routes, every tab, every Annotations section and the citations panel once before the tests start, so the * reload happens here and not in a test. */ import { chromium, type FullConfig } from '@playwright/test' @@ -10,10 +10,10 @@ import { fr } from '@/i18n/fr' import { stepUpAdmin } from './admin' import { TABS, - closeReferences, + closeCitations, draftPath, editorActor, - openReferences, + openCitations, openSection, secondSession, seedDraft, @@ -47,8 +47,8 @@ export default async function warmUp(config: FullConfig): Promise { await openSection(page, fr, section) await page.waitForLoadState('networkidle') } - await openReferences(page, fr) - await closeReferences(page, fr) + await openCitations(page, fr, 'Constat A') + await closeCitations(page, fr) await page.goto('/app/admin/sheets/new') await page.waitForLoadState('networkidle') await browser.close() diff --git a/apps/app/src/components/editor/DraftHeader.tsx b/apps/app/src/components/editor/DraftHeader.tsx index 7acc596c..7d3521b2 100644 --- a/apps/app/src/components/editor/DraftHeader.tsx +++ b/apps/app/src/components/editor/DraftHeader.tsx @@ -45,19 +45,15 @@ function Breadcrumb({ } /** - * The draft's header: breadcrumb, title and badges, then the actions (references, the - * save line, « Abandonner les modifications » and « Enregistrer » in edit mode). + * The draft's header: breadcrumb, title and badges, then the actions (the save line, + * « Abandonner les modifications » and « Enregistrer » in edit mode). */ export default function DraftHeader({ sheet, mode, - referencesOpen, - onToggleReferences, }: { sheet: OfficialSheetAdmin mode: EditorMode - referencesOpen: boolean - onToggleReferences: (opener: HTMLElement) => void }) { const t = useT() const heading = usePageHeading() @@ -85,12 +81,7 @@ export default function DraftHeader({ {t('editor.draft.read_only')} )} - + {failure && {failure}} diff --git a/apps/app/src/components/editor/EditorTabBody.tsx b/apps/app/src/components/editor/EditorTabBody.tsx index 79a96706..95c73038 100644 --- a/apps/app/src/components/editor/EditorTabBody.tsx +++ b/apps/app/src/components/editor/EditorTabBody.tsx @@ -11,6 +11,7 @@ import KeptPlace from './KeptPlace' import AnnotationsTab from './tabs/AnnotationsTab' import FindingsTab from './tabs/FindingsTab' import GeneralTab from './tabs/GeneralTab' +import ReferencesTab from './tabs/ReferencesTab' import VerificationTab from './tabs/VerificationTab' const BODIES: Record< @@ -19,6 +20,7 @@ const BODIES: Record< > = { general: GeneralTab, findings: FindingsTab, + references: ReferencesTab, verification: VerificationTab, } diff --git a/apps/app/src/components/editor/EditorTabs.tsx b/apps/app/src/components/editor/EditorTabs.tsx index 9ee21c14..fb6ec0c5 100644 --- a/apps/app/src/components/editor/EditorTabs.tsx +++ b/apps/app/src/components/editor/EditorTabs.tsx @@ -64,7 +64,7 @@ function TabList({ shown, active, onSelect }: TabListProps) { role="tablist" aria-label={t('editor.tab.list')} onKeyDown={onKeyDown} - className="flex gap-1" + className="flex flex-wrap gap-1" > {shown.map((tab) => ( -