From 2c4c7712694c39991c378ac8b3e7eac1a3aa079e Mon Sep 17 00:00:00 2001 From: bchanot Date: Sun, 15 Nov 2026 16:15:43 +0100 Subject: [PATCH] test(editor): e2e on the references dialog instead of the sheet MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Helpers citationsDialog, closeCitations by the dialog's ✕. Owner journey with tap at 375, keyboard and axe; geometry checks now dialog in viewport with focus inside; refused « Tout afficher » over a dirty form. --- apps/app/e2e/shell/editor-access.spec.ts | 13 +- apps/app/e2e/shell/editor-citations.spec.ts | 339 +++++++----------- apps/app/e2e/shell/editor-deselect.spec.ts | 6 +- .../e2e/shell/editor-finding-dialog.spec.ts | 14 +- .../e2e/shell/editor-leave-confirm.spec.ts | 38 +- .../shell/editor-reference-journey.spec.ts | 71 ++-- .../e2e/shell/editor-shell-crossing.spec.ts | 2 +- .../app/e2e/shell/editor-shell-layout.spec.ts | 76 ++-- apps/app/e2e/shell/editor-shell.spec.ts | 2 +- apps/app/e2e/support/editor.ts | 22 +- 10 files changed, 260 insertions(+), 323 deletions(-) diff --git a/apps/app/e2e/shell/editor-access.spec.ts b/apps/app/e2e/shell/editor-access.spec.ts index b7ce65f3..ac41a00c 100644 --- a/apps/app/e2e/shell/editor-access.spec.ts +++ b/apps/app/e2e/shell/editor-access.spec.ts @@ -151,8 +151,11 @@ test.describe('editor access, narrow screens and axe', () => { await openFinding(page, dict, 'Constat A') await expectAccessible(page, `the finding dialog at ${width} px`) await showCitations(page) - await expectNoHorizontalOverflow(page, `the sheet at ${width} px`) - await expectAccessible(page, `the citations sheet at ${width} px`) + await expectNoHorizontalOverflow( + page, + `the references dialog at ${width} px`, + ) + await expectAccessible(page, `the references dialog at ${width} px`) }) } @@ -193,8 +196,8 @@ test.describe('editor access, narrow screens and axe', () => { await openFinding(page, dict, 'Constat A') await expectAccessible(page, 'the finding dialog (edit)') await showCitations(page) - await expectNoHorizontalOverflow(page, 'the citations sheet at 1 024 px') - await expectAccessible(page, 'the citations sheet (edit)') + await expectNoHorizontalOverflow(page, 'the references dialog at 1 024 px') + await expectAccessible(page, 'the references dialog (edit)') await closeCitations(page, dict) await closeFinding(page, dict) }) @@ -223,6 +226,6 @@ test.describe('editor access, narrow screens and axe', () => { await openFinding(page, dict, 'Constat A') await expectAccessible(page, 'the finding dialog (read-only)') await showCitations(page) - await expectAccessible(page, 'the citations sheet (read-only)') + await expectAccessible(page, 'the references dialog (read-only)') }) }) diff --git a/apps/app/e2e/shell/editor-citations.spec.ts b/apps/app/e2e/shell/editor-citations.spec.ts index 5698ffb2..35960ee5 100644 --- a/apps/app/e2e/shell/editor-citations.spec.ts +++ b/apps/app/e2e/shell/editor-citations.spec.ts @@ -8,6 +8,7 @@ import { } from '../support/browser' import { dropLateReplays, routeToSandbox } from '../support/sandbox' import { + citationsDialog, closeCitations, closeFinding, editorActor, @@ -19,8 +20,6 @@ import { openFinding, openTab, place, - referenceDialog, - referenceSettled, saveDraft, seedDraft, serverDocument, @@ -28,18 +27,19 @@ import { standardShape, } from '../support/editor' -// V1-2.6 R2 finish: the citations of one finding as a modal side sheet over its dialog -// (R2F-4): its contents (no removal: that is the edit form's), « Défaire », « Tout afficher », -// every close path with the focus checked after the exit (motion and reduced motion), -// Escape in a tile field, the exiting sheet inert, the keyboard and touch proofs, axe open -// (edit, read-only at 375 px), Back and Forward over the layers. The spec seeds its own -// sheet and never touches another. +// V1-2.6 R2 finish, Rev 5: the citations of a family or a finding node as a modal +// references dialog over the finding dialog. View mode: its contents (no edit control), +// the finding's edit form that cites nothing and keeps the citations, « Tout afficher », +// every close path with the focus checked after the exit (motion and reduced motion), the +// exiting dialog inert, the keyboard and touch proofs, axe open (desktop, read-only at +// 375 px), Back and Forward over the layers. The spec seeds its own sheet and never +// touches another. const dict = fr const isPhone = (info: TestInfo) => info.project.name === 'chromium-375' -/** « Constat A » cites twelve references: its panel list outgrows the screen. */ +/** « Constat A » cites twelve references (its list outgrows the screen), the family none. */ function longShape(document: Record) { shape(document) const refs = Array.from({ length: 12 }, (_, index) => ({ @@ -99,12 +99,6 @@ const link = (page: Page) => panel(page).getByRole('button', { name: dict['editor.references.panel_show_all'], }) -const undo = (page: Page) => page.getByRole('button', { name: /Défaire/ }) -/** The edit form's « Retirer » of a cited reference, by its citation. */ -const retire = (page: Page, citation: string) => - findingDialog(page).getByRole('button', { - name: `${dict['editor.action.remove']} ${citation}`, - }) const modify = (page: Page) => findingDialog(page).getByRole('button', { name: dict['editor.findings.edit'], @@ -114,7 +108,11 @@ const saveForm = (page: Page) => name: dict['editor.findings.save'], }) -type Node = { reference_ids: string[]; review_status: string } +type Node = { + reference_ids: string[] + review_status: string + description: { fr?: string } +} const nodeOf = (document: Record) => ( document.finding_zones as { @@ -122,7 +120,7 @@ const nodeOf = (document: Record) => }[] )[0].categories[0].children[0] -test.describe('citations sheet, editing', () => { +test.describe('references dialog, view mode', () => { test.use({ locale: 'fr-FR', actionTimeout: 15_000 }) test.beforeEach(async ({ context }, info) => { test.skip( @@ -135,7 +133,7 @@ test.describe('citations sheet, editing', () => { await dropLateReplays(context) }) - test('opens over its finding dialog, read-only; the edit form removes, one « Défaire », saved status', async ({ + test('opens over its finding dialog, read only; the finding form cites nothing and its save keeps them', async ({ page, requests, }) => { @@ -144,9 +142,9 @@ test.describe('citations sheet, editing', () => { requests.forbid(actor.account.email, actor.account.password) await openCitations(page, dict, 'Constat A') await expect(trigger(page)).toHaveAttribute('aria-expanded', 'true') - await expect(panel(page).getByRole('heading')).toHaveText( - dict['editor.references.panel_title'], - ) + await expect( + citationsDialog(page).getByRole('heading', { level: 2 }), + ).toHaveText(dict['editor.references.dialog_title']) await expect(panel(page)).toContainText( 'Zone A › Dysfonction A › Constat A', ) @@ -156,55 +154,70 @@ test.describe('citations sheet, editing', () => { await expect(heads(page)).toHaveCount(3) await expect(panel(page).getByText('Source libre')).toHaveCount(0) await expect(panel(page).getByRole('searchbox')).toHaveCount(0) - await expectAccessible(page, 'the citations sheet, closed tiles') + await expectAccessible(page, 'the references dialog, closed tiles') await heads(page).nth(1).click() const tile = heads(page).nth(1).locator('xpath=ancestor::li[1]') await expect( tile.getByText(dict['editor.references.this_finding'], { exact: true }), ).toBeVisible() - await expect( - tile.getByRole('button', { name: dict['editor.references.edit'] }), - ).toBeVisible() for (const name of [ + dict['editor.references.edit'], dict['editor.action.delete'], dict['editor.action.move_up'], dict['editor.action.remove'], ]) { - await expect(panel(page).getByRole('button', { name })).toHaveCount(0) + await expect( + citationsDialog(page).getByRole('button', { name, exact: true }), + ).toHaveCount(0) } - await expectAccessible(page, 'the citations sheet, an open tile') + await expectAccessible(page, 'the references dialog, an open tile') - // The sheet removes nothing: « Modifier » on the dialog stages the removal, the sheet - // opened from the form lists the draft, and « Enregistrer » writes it as one entry. + // The finding's « Modifier » edits its properties only: no citation control, and its + // save keeps the citations the document holds. await closeCitations(page, dict) await modify(page).click() - await retire(page, 'Source B').click() - await expect(trigger(page)).toContainText('2') - await showCitations(page) - await expect(heads(page)).toHaveCount(2) - await closeCitations(page, dict) + await expect( + findingDialog(page).getByText(dict['editor.findings.references'], { + exact: true, + }), + ).toBeVisible() + await expect(trigger(page)).toContainText('3') + await expect( + findingDialog(page).getByLabel(dict['editor.findings.reference_add']), + ).toHaveCount(0) + await expect( + findingDialog(page).getByRole('button', { + name: new RegExp(`^${dict['editor.action.remove']}`), + }), + ).toHaveCount(0) + await findingDialog(page) + .getByLabel(dict['editor.findings.description_fr']) + .fill('Texte') await saveForm(page).click() - await expect(trigger(page)).toContainText('2') - await closeFinding(page, dict) - // one « Défaire » restores the citation and the status together - await undo(page).click() - await openCitations(page, dict, 'Constat A') - await expect(heads(page)).toHaveCount(3) - await closeCitations(page, dict) - await modify(page).click() - await retire(page, 'Source B').click() - await saveForm(page).click() - await expect(trigger(page)).toContainText('2') + await expect(trigger(page)).toContainText('3') await closeFinding(page, dict) await saveDraft(page, dict, seed.revision + 1) const saved = await serverDocument>(seed.draftId) - expect(nodeOf(saved).reference_ids).toEqual(['ref-a', 'ref-c']) - expect(nodeOf(saved).review_status).toBe('to_confirm') + expect(nodeOf(saved).reference_ids).toEqual(['ref-a', 'ref-b', 'ref-c']) + expect(nodeOf(saved).description.fr).toBe('Texte') expect((saved.references as unknown[]).length).toBe(4) }) - test('a long list scrolls inside the sheet: the last tile is reachable from scroll 0, the page never moves', async ({ + test('a family opens the same dialog with its own citations', async ({ + page, + }) => { + test.setTimeout(150_000) + await open(page) + await openCitations(page, dict, 'Dysfonction A') + await expect(panel(page)).toContainText('Zone A › Dysfonction A') + await expect(heads(page)).toHaveCount(1) + await expect(heads(page).first()).toContainText('Source B') + await closeCitations(page, dict) + await expect(trigger(page)).toBeFocused() + }) + + test('a long list scrolls inside the dialog; « 0 référence » opens the empty one', async ({ page, }) => { test.setTimeout(150_000) @@ -212,40 +225,30 @@ test.describe('citations sheet, editing', () => { await openCitations(page, dict, 'Constat A') await expect(heads(page)).toHaveCount(12) expect(await page.evaluate(() => window.scrollY)).toBe(0) - const list = panel(page).locator('div.overflow-y-auto') + const list = citationsDialog(page).locator('div.overflow-y-auto') await list.evaluate((node) => { node.scrollTop = node.scrollHeight }) const last = heads(page).last() await expect(last).toBeInViewport({ ratio: 1 }) - const view = await page.evaluate(() => window.innerHeight) - const box = await last.boundingBox() - expect(box!.y + box!.height).toBeLessThanOrEqual(view + 1) expect(await page.evaluate(() => window.scrollY)).toBe(0) await last.click() await expect(last).toHaveAttribute('aria-expanded', 'true') + await closeCitations(page, dict) + await closeFinding(page, dict) + + await openFinding(page, dict, 'Dysfonction A') + await expect(trigger(page)).toHaveText( + dict['editor.findings.references_open_one'].replace('{count}', '0'), + ) + await showCitations(page) + await expect(heads(page)).toHaveCount(0) + await expect(panel(page)).toContainText( + dict['editor.references.panel_empty'], + ) }) - test('the form drops every citation: the trigger goes with the count, nothing is written before « Enregistrer »', async ({ - page, - }) => { - test.setTimeout(150_000) - await open(page) - await openFinding(page, dict, 'Constat A') - await modify(page).click() - for (const citation of ['Référence A', 'Source B', 'Source C']) { - await retire(page, citation).click() - } - await expect(trigger(page)).toHaveCount(0) - await expect( - findingDialog(page).getByText(dict['editor.findings.references_none']), - ).toBeVisible() - await saveForm(page).click() - await expect(trigger(page)).toHaveCount(0) - await expect(findingDialog(page)).toBeVisible() - }) - - test('« Tout afficher » closes both layers, clears the search, keeps the sort and the open tiles; Back returns to the sheet', async ({ + test('« Tout afficher » closes both layers, clears the search, keeps the sort and the open tiles; Back returns to the dialog', async ({ page, }) => { test.setTimeout(150_000) @@ -268,14 +271,14 @@ test.describe('citations sheet, editing', () => { await expect( root.getByRole('button', { name: /Source B/ }), ).toHaveAttribute('aria-expanded', 'true') - // Filtered by the finding the sheet belonged to: its three citations (R2F-6). + // Filtered by the finding the dialog belonged to: its three citations (R2F-6). await expect( root.locator('button[aria-controls][id$="-header"]'), ).toHaveCount(3) await expect(root.getByTestId('editor-references-filter')).toContainText( 'Constat A', ) - // The move is an entry of its own: Back returns to the finding with its sheet on top. + // The move is an entry of its own: Back returns to the finding, its dialog on top. await page.goBack() await expect(place(page, 'citations')).toBeVisible() await expect(findingDialog(page)).toBeVisible() @@ -285,96 +288,7 @@ test.describe('citations sheet, editing', () => { await expect(place(page, 'references')).toBeVisible() }) - test('« Modifier » opens the reference dialog over the sheet; « Enregistrer » closes it only, one undo', async ({ - page, - }) => { - test.setTimeout(150_000) - const { seed } = await open(page) - await openCitations(page, dict, 'Constat A') - await heads(page).first().click() - const modify = panel(page).getByRole('button', { - name: dict['editor.references.edit'], - }) - await modify.click() - await expect(referenceDialog(page)).toBeVisible() - await expect(page.locator('dialog[open]')).toHaveCount(3) - const field = referenceDialog(page).getByLabel( - dict['editor.reference.citation'], - ) - await field.fill('Référence A, révisée') - // Escape asks (the draft is kept), it neither closes the sheet nor writes. - await field.press('Escape') - await expect( - referenceDialog(page).getByText(dict['editor.findings.discard_ask']), - ).toBeVisible() - await expect(page.locator('dialog[open]')).toHaveCount(3) - await referenceDialog(page) - .getByRole('button', { name: dict['editor.findings.keep_typing'] }) - .click() - await expect(field).toHaveValue('Référence A, révisée') - await referenceDialog(page) - .getByRole('button', { name: dict['editor.findings.save'] }) - .click() - await expect(referenceDialog(page)).toHaveCount(0) - await referenceSettled(page) - await expect(panel(page)).toBeVisible() - await expect(page.locator('dialog[open]')).toHaveCount(2) - await expect(modify).toBeFocused() - await closeCitations(page, dict) - await closeFinding(page, dict) - await expect(undo(page)).toBeEnabled() - await saveDraft(page, dict, seed.revision + 1) - const saved = await serverDocument<{ references: { citation: string }[] }>( - seed.draftId, - ) - expect(saved.references[0].citation).toBe('Référence A, révisée') - }) - - test('a dirty reference dialog keeps its draft on ✕ and on Back; « Abandonner » leaves the sheet open', async ({ - page, - }) => { - test.setTimeout(150_000) - await open(page) - await openCitations(page, dict, 'Constat A') - await heads(page).first().click() - await panel(page) - .getByRole('button', { name: dict['editor.references.edit'] }) - .click() - const form = referenceDialog(page) - const field = form.getByLabel(dict['editor.reference.citation']) - await field.fill('Brouillon') - await form - .getByRole('button', { name: dict['common.close'], exact: true }) - .click() - await expect( - form.getByText(dict['editor.findings.discard_ask']), - ).toBeVisible() - await form - .getByRole('button', { name: dict['editor.findings.keep_typing'] }) - .click() - // Back: the dialog stays, the view is pushed again, the confirmation shows. - await page.goBack() - await expect(form).toBeVisible() - await expect( - form.getByText(dict['editor.findings.discard_ask']), - ).toBeVisible() - await expect(field).toHaveValue('Brouillon') - await form - .getByRole('button', { name: dict['editor.findings.keep_typing'] }) - .click() - await form - .getByRole('button', { name: dict['editor.findings.cancel'] }) - .click() - await form - .getByRole('button', { name: dict['editor.findings.discard'] }) - .click() - await expect(referenceDialog(page)).toHaveCount(0) - await expect(panel(page)).toBeVisible() - await expect(findingDialog(page)).toBeVisible() - await expect(undo(page)).toHaveAttribute('aria-disabled', 'true') - }) - - test('the exiting sheet is inert, and a second close finds nothing to close', async ({ + test('the exiting dialog is inert, and a second close finds nothing to close', async ({ page, }) => { test.setTimeout(150_000) @@ -391,8 +305,8 @@ test.describe('citations sheet, editing', () => { } tick() }) - const closeButton = panel(page).getByRole('button', { - name: dict['editor.references.close'], + const closeButton = citationsDialog(page).getByRole('button', { + name: dict['common.close'], }) await closeButton.dispatchEvent('click') await closeButton.dispatchEvent('click').catch(() => undefined) @@ -401,12 +315,12 @@ test.describe('citations sheet, editing', () => { () => (window as unknown as { samples: boolean[] }).samples, ) expect(samples.some((inert) => inert)).toBe(true) - // The dialog under the sheet is still open: the second click closed nothing more. + // The finding dialog under it is still open: the second click closed nothing more. await expect(findingDialog(page)).toBeVisible() await expect(page.locator('dialog[open]')).toHaveCount(1) }) - test('keyboard: Enter opens the sheet, Tab reaches each control in order, Escape from one closes only the sheet', async ({ + test('keyboard: Enter opens the dialog, Tab reaches each control in order, Escape closes only it', async ({ page, }) => { test.setTimeout(150_000) @@ -416,11 +330,11 @@ test.describe('citations sheet, editing', () => { await page.keyboard.press('Enter') await expect(place(page, 'citations')).toBeVisible() await expect(page.locator('dialog[open]')).toHaveCount(2) - // The tab order of the sheet, in the document's order, each control tagged. + // The tab order of the dialog, in the document's order, each control tagged. const count = await panel(page).evaluate((root) => { - const sheet = root.closest('dialog')! + const dialog = root.closest('dialog')! const tabbable = [ - ...sheet.querySelectorAll( + ...dialog.querySelectorAll( 'button:not([disabled]), [href], input:not([disabled]), select, textarea', ), ] @@ -443,9 +357,9 @@ test.describe('citations sheet, editing', () => { }) }) -/** Every way out of the sheet, the focus read from the document after the exit. */ +/** Every way out of the dialog, the focus read from the document after the exit. */ for (const reduced of [false, true]) { - test.describe(`citations sheet closes, ${reduced ? 'reduced motion' : 'motion'}`, () => { + test.describe(`references dialog closes, ${reduced ? 'reduced motion' : 'motion'}`, () => { test.use({ locale: 'fr-FR', actionTimeout: 15_000 }) test.beforeEach(async ({ context, page }, info) => { test.skip(isPhone(info), 'the paths are walked on desktop') // floor-guard: allow C16 editing needs >= 1 024 px @@ -458,7 +372,7 @@ for (const reduced of [false, true]) { await dropLateReplays(context) }) - test('✕, Escape, the scrim and Back give the focus back to the trigger', async ({ + test('✕, Escape, the backdrop and Back give the focus back to the trigger', async ({ page, }) => { test.setTimeout(150_000) @@ -472,8 +386,8 @@ for (const reduced of [false, true]) { await expect(panel(page)).toHaveCount(0) await expect(trigger(page)).toBeFocused() await showCitations(page) - await page - .getByTestId('references-scrim') + await citationsDialog(page) + .getByTestId('dialog-backdrop') .click({ position: { x: 12, y: 40 } }) await expect(panel(page)).toHaveCount(0) await expect(trigger(page)).toBeFocused() @@ -503,14 +417,14 @@ for (const reduced of [false, true]) { .getByRole('button', { name: dict['editor.references.go_to'] }) .first() .click() - // The sheet closes and the family opens in the dialog (view mode); closed, the - // row holds the focus. + // The dialog closes and the family opens in the finding dialog (view mode); + // closed, the row holds the focus. await expect(place(page, 'citations')).toHaveCount(0) const family = findingDialog(page).getByRole('heading', { name: 'Dysfonction A', }) await expect(family).toBeVisible() - // Back returns to the place « Aller à » left: Constat A with its sheet open. + // Back returns to the place « Aller à » left: Constat A with its dialog open. await page.goBack() await expect(page.locator('dialog[open]')).toHaveCount(2) await expect(place(page, 'citations')).toBeVisible() @@ -526,7 +440,9 @@ for (const reduced of [false, true]) { ).toBeFocused() }) - test('the sheet slides only when motion is allowed', async ({ page }) => { + test('the dialog scales in only when motion is allowed', async ({ + page, + }) => { test.setTimeout(150_000) await open(page) await openFinding(page, dict, 'Constat A') @@ -534,10 +450,9 @@ for (const reduced of [false, true]) { const seen: string[] = [] Object.assign(window, { seen }) new MutationObserver(() => { - const slider = document.querySelector( - '[data-place="citations"]', - ) as HTMLElement | null - if (slider) seen.push(slider.style.transform) + const panel = document.querySelector('[data-place="citations"]') + const surface = panel?.closest('dialog > div:last-child') + if (surface instanceof HTMLElement) seen.push(surface.style.transform) }).observe(document.body, { subtree: true, childList: true, @@ -551,13 +466,13 @@ for (const reduced of [false, true]) { const seen = await page.evaluate( () => (window as unknown as { seen: string[] }).seen, ) - const slid = seen.some((value) => /translateX\((?!0)[1-9]/.test(value)) - expect(slid).toBe(!reduced) + const scaled = seen.some((value) => /scale\(0\.9/.test(value)) + expect(scaled).toBe(!reduced) }) }) } -test.describe('citations sheet, read-only at 375 px', () => { +test.describe('references dialog, read-only at 375 px', () => { test.use({ locale: 'fr-FR', actionTimeout: 15_000 }) test.beforeEach(async ({ context }, info) => { test.skip(!isPhone(info), 'the read-only twin runs at 375 px only') @@ -567,41 +482,40 @@ test.describe('citations sheet, read-only at 375 px', () => { await dropLateReplays(context) }) - test('full width through « Plus » then Constats, no edit control, axe open @phone', async ({ + test('inside the viewport through « Plus » then Constats, no edit control, axe open @phone', async ({ page, }) => { test.setTimeout(150_000) await open(page) await openCitations(page, dict, 'Constat A') - // Full width: the sheet is min(34 rem, 100 vw), so the whole phone screen. - const layer = page.locator('[data-place="citations"]') - const box = await layer.boundingBox() + const box = await citationsDialog(page) + .locator('div.overflow-y-auto') + .boundingBox() + expect(box!.x).toBeGreaterThanOrEqual(0) // Sub-pixel layout rounding (375.00001…): the tolerance of editor-shell-layout (3a7ffa2). - expect(box?.width ?? 0).toBeLessThanOrEqual(375 + 0.5) - expect(Math.abs((box?.width ?? 0) - 375)).toBeLessThan(1) + expect(box!.x + box!.width).toBeLessThanOrEqual(375 + 0.5) + expect(box!.y).toBeGreaterThanOrEqual(0) + expect(box!.y + box!.height).toBeLessThanOrEqual(667 + 0.5) await expect(heads(page)).toHaveCount(3) - await expectNoHorizontalOverflow(page, 'the sheet at 375 px') + await expectNoHorizontalOverflow(page, 'the references dialog at 375 px') await heads(page).first().click() for (const name of [ dict['editor.references.edit'], dict['editor.action.remove'], ]) { - await expect(panel(page).getByRole('button', { name })).toHaveCount(0) + await expect( + citationsDialog(page).getByRole('button', { name, exact: true }), + ).toHaveCount(0) } await expect(panel(page).getByRole('textbox')).toHaveCount(0) - const close = await panel(page) - .getByRole('button', { name: dict['editor.references.close'] }) - .boundingBox() - expect(close?.width ?? 0).toBeGreaterThanOrEqual(44) - expect(close?.height ?? 0).toBeGreaterThanOrEqual(44) - await expectAccessible(page, 'the citations sheet, read-only at 375 px') + await expectAccessible(page, 'the references dialog, read-only at 375 px') await closeCitations(page, dict) await expect(trigger(page)).toBeFocused() await closeFinding(page, dict) await expect(place(page, 'findings')).toBeVisible() }) - test('by touch: taps act on the sheet only, the dialog under it is never activated @phone', async ({ + test('by touch: taps act on the references dialog only, the finding dialog under it stays @phone', async ({ page, }) => { test.setTimeout(150_000) @@ -617,25 +531,24 @@ test.describe('citations sheet, read-only at 375 px', () => { } await tap(trigger(page)) await expect(place(page, 'citations')).toBeVisible() - // A tile opens by a tap; the dialog's own controls underneath stay as they were. + // A tile opens by a tap; the finding dialog's controls underneath stay as they were. await tap(heads(page).first()) await expect(heads(page).first()).toHaveAttribute('aria-expanded', 'true') await expect(trigger(page)).toHaveAttribute('aria-expanded', 'true') - // A tap where the dialog's close button lies (it is under the sheet) hits the sheet. - const under = await center( - findingDialog(page).getByRole('button', { name: dict['common.close'] }), - ) - await page.touchscreen.tap(under.x, under.y) - await expect(findingDialog(page)).toBeVisible() - // The sheet's ✕ closes the sheet only; the trigger holds the focus. + // Its ✕ closes it only; the trigger holds the focus. await tap( - panel(page).getByRole('button', { - name: dict['editor.references.close'], - }), + citationsDialog(page).getByRole('button', { name: dict['common.close'] }), ) await expect(panel(page)).toHaveCount(0) await expect(findingDialog(page)).toBeVisible() await expect(trigger(page)).toBeFocused() + // A tap on its backdrop, outside its panel, closes it only as well. + await tap(trigger(page)) + await expect(place(page, 'citations')).toBeVisible() + await page.touchscreen.tap(4, 4) + await expect(panel(page)).toHaveCount(0) + await expect(findingDialog(page)).toBeVisible() + await expect(trigger(page)).toBeFocused() await tap( findingDialog(page).getByRole('button', { name: dict['common.close'] }), ) diff --git a/apps/app/e2e/shell/editor-deselect.spec.ts b/apps/app/e2e/shell/editor-deselect.spec.ts index 85a5a610..118bde68 100644 --- a/apps/app/e2e/shell/editor-deselect.spec.ts +++ b/apps/app/e2e/shell/editor-deselect.spec.ts @@ -195,7 +195,7 @@ test.describe('deselect and D6b (editor, mouse and keyboard)', () => { expect(saves).toEqual([]) }) - test('Escape: canvas, field, delete dialog, citations panel, tracing', async ({ + test('Escape: canvas, field, delete dialog, references dialog, tracing', async ({ page, requests, }) => { @@ -226,8 +226,8 @@ test.describe('deselect and D6b (editor, mouse and keyboard)', () => { await expect(dialog).toHaveCount(0) await expectKept(page, POINT) - // The citations sheet (over the finding dialog over Constats): Escape closes the - // sheet only, a second one the dialog, the selection stays, back on Annotations a + // The references dialog (over the finding dialog over Constats): Escape closes it + // only, a second one the finding dialog, the selection stays, back on Annotations a // third Escape deselects. await openCitations(page, dict, 'Constat A') await page.keyboard.press('Escape') diff --git a/apps/app/e2e/shell/editor-finding-dialog.spec.ts b/apps/app/e2e/shell/editor-finding-dialog.spec.ts index 8fd89555..f86690b0 100644 --- a/apps/app/e2e/shell/editor-finding-dialog.spec.ts +++ b/apps/app/e2e/shell/editor-finding-dialog.spec.ts @@ -54,8 +54,8 @@ async function layerWritten(page: Page, layer: 'finding' | 'none') { }, layer) } -/** Whether the sheet is the dialog on top at the right edge of the viewport. */ -const sheetOnTop = (page: Page) => +/** Whether the references dialog is on top at the right edge of the viewport. */ +const citationsOnTop = (page: Page) => page.evaluate(() => { const top = document.elementFromPoint(window.innerWidth - 40, 100) return !!top?.closest('dialog')?.querySelector('[data-place="citations"]') @@ -300,16 +300,16 @@ test.describe('finding dialog', () => { ) }) - test('Back and Forward walk the layers, the sheet is on top each time (owner steps 1 to 4)', async ({ + test('Back and Forward walk the layers, the references dialog is on top each time (owner steps 1 to 4)', async ({ page, }) => { test.setTimeout(150_000) await open(page) - // 1. the finding dialog, 2. its sheet, 3. « Tout afficher », 4. the references tab. + // 1. the finding dialog, 2. its references dialog, 3. « Tout afficher », 4. the references tab. await openFinding(page, dict, 'Constat A') await layerWritten(page, 'finding') await showCitations(page) - expect(await sheetOnTop(page)).toBe(true) + expect(await citationsOnTop(page)).toBe(true) await page .getByRole('button', { name: dict['editor.references.panel_show_all'] }) .click() @@ -320,7 +320,7 @@ test.describe('finding dialog', () => { ) await page.goBack() await expect(page.locator('dialog[open]')).toHaveCount(2) - expect(await sheetOnTop(page)).toBe(true) + expect(await citationsOnTop(page)).toBe(true) await page.goBack() await expect(page.locator('dialog[open]')).toHaveCount(1) await expect(dialog(page)).toBeVisible() @@ -334,7 +334,7 @@ test.describe('finding dialog', () => { await expect(page.locator('dialog[open]')).toHaveCount(1) await page.goForward() await expect(page.locator('dialog[open]')).toHaveCount(2) - expect(await sheetOnTop(page)).toBe(true) + expect(await citationsOnTop(page)).toBe(true) await page.goForward() await expectNoDialog(page) await expect(place(page, 'references')).toBeVisible() diff --git a/apps/app/e2e/shell/editor-leave-confirm.spec.ts b/apps/app/e2e/shell/editor-leave-confirm.spec.ts index 545e983e..c3130082 100644 --- a/apps/app/e2e/shell/editor-leave-confirm.spec.ts +++ b/apps/app/e2e/shell/editor-leave-confirm.spec.ts @@ -11,6 +11,7 @@ import { findingDialog, openFinding, openTab, + place, referenceDialog, seedDraft, showCitations, @@ -164,9 +165,8 @@ test.describe('leaving the editor by a history jump', () => { await expect(page.getByText(leftNotice)).toHaveCount(0) }) - test('a dirty reference over the sheet of a dirty finding: both ask in turn', async ({ + test('« Tout afficher » from the references dialog over a dirty finding: it closes, the form asks in view', async ({ page, - context, }) => { test.setTimeout(150_000) const sheetId = await open(page) @@ -178,42 +178,30 @@ test.describe('leaving the editor by a history jump', () => { const name = finding.getByLabel(dict['editor.general.name_fr']) await name.fill('Constat brouillon') await showCitations(page) - const panel = page.getByTestId('editor-citations-panel') - await panel.locator('button[aria-controls][id$="-header"]').first().click() - await panel - .getByRole('button', { name: dict['editor.references.edit'] }) - .click() - const form = referenceDialog(page) - await form.getByLabel(dict['editor.reference.citation']).fill('Brouillon') - await expect(page.locator('dialog[open]')).toHaveCount(3) - - await jumpToOverview(context, page, sheetId) - await expect(form.getByText(confirmText)).toBeVisible() - await form - .getByRole('button', { name: dict['editor.findings.discard'] }) + await page + .getByTestId('editor-citations-panel') + .getByRole('button', { name: dict['editor.references.panel_show_all'] }) .click() + // Refused by the dirty form under it: the clean references dialog closes first, so + // the question is the one in view and holds the focus; nothing moved. await expect(page.locator('dialog[open]')).toHaveCount(1) await expect(finding.getByText(confirmText)).toBeVisible() const keep = finding.getByRole('button', { name: dict['editor.findings.keep_typing'], }) await expect(keep).toBeFocused() + await expect(place(page, 'references')).toBeHidden() + await keep.click() + await expect(name).toHaveValue('Constat brouillon') expect(new URL(page.url()).pathname).toBe(draftPath(sheetId)) - await finding - .getByRole('button', { name: dict['editor.findings.discard'] }) - .click() - await expect(page).toHaveURL( - (url) => url.pathname === overviewPath(sheetId), - ) - expect(await leftFlags(page)).toBe(0) }) - test('the sheet over a dirty finding form: Back closes it alone, a jump asks in view', async ({ + test('the references dialog over a dirty finding form: Back closes it alone, a jump asks in view', async ({ page, context, }) => { - // Final review rev 4, item 1: the sheet is no form, so a Back that closes it asks - // nothing; a jump that leaves closes it first, so the finding's question is seen. + // Final review rev 4, item 1: the references dialog is no form, so a Back that closes + // it asks nothing; a jump that leaves closes it first, so the finding's question is seen. const sheetId = await open(page) await openFinding(page, dict, 'Constat A') const finding = findingDialog(page) diff --git a/apps/app/e2e/shell/editor-reference-journey.spec.ts b/apps/app/e2e/shell/editor-reference-journey.spec.ts index 6c4d1fe2..4becad22 100644 --- a/apps/app/e2e/shell/editor-reference-journey.spec.ts +++ b/apps/app/e2e/shell/editor-reference-journey.spec.ts @@ -1,6 +1,6 @@ import { fr } from '@/i18n/fr' import type { Page, TestInfo } from '@playwright/test' -import { expect, test } from '../support/browser' +import { expect, expectAccessible, test } from '../support/browser' import { dropLateReplays, routeToSandbox } from '../support/sandbox' import { editorActor, @@ -22,7 +22,7 @@ import { // R2 UX finish, task 3 (R2F-5, R2F-6): the reference dialog, the reading tiles, the // references filtered by a finding, and the owner's journey through the browser history: -// finding A, its sheet, « Tout afficher », the filtered tab, a reference edited, Back, +// finding A, its references dialog, « Tout afficher », the filtered tab, a reference edited, Back, // Forward, « Revenir au constat », then every Back down to the first entry. The top // layer, the focus and the history rules are the browser's, so they are proved here. @@ -34,7 +34,7 @@ const chip = (page: Page) => libraryRoot(page).getByTestId('editor-references-filter') const headers = (page: Page) => libraryRoot(page).locator('button[aria-controls][id$="-header"]') -const sheetHeaders = (page: Page) => +const citedHeaders = (page: Page) => panel(page).locator('button[aria-controls][id$="-header"]') const undo = (page: Page) => historyButton(page, dict, 'undo') const dialogs = (page: Page) => page.locator('dialog[open]') @@ -105,14 +105,14 @@ async function expectScrollNear(page: Page, y: number) { .toBeLessThanOrEqual(SCROLL_SLACK) } -/** Whether the sheet is the dialog on top at the right edge of the viewport. */ -const sheetOnTop = (page: Page) => +/** Whether the references dialog is on top at the right edge of the viewport. */ +const citationsOnTop = (page: Page) => page.evaluate(() => { const top = document.elementFromPoint(window.innerWidth - 40, 100) return !!top?.closest('dialog')?.querySelector('[data-place="citations"]') }) -/** Finding A, its sheet, then « Tout afficher »: the References tab filtered by Constat A. */ +/** Finding A, its references dialog, then « Tout afficher »: the References tab filtered by Constat A. */ async function filteredTab(page: Page) { await openFinding(page, dict, 'Constat A') await entryHolds(page, 'view.finding !== null') @@ -135,9 +135,9 @@ test.describe('the owner journey through the history', () => { await dropLateReplays(context) }) - test("the owner's eight steps, nothing in between: Back returns to finding A with its sheet open", async ({ + test("the owner's eight steps, nothing in between: Back returns to finding A with its dialog open", async ({ page, - }) => { + }, info) => { test.setTimeout(240_000) await open(page) // 1. the Constats tab; 2. finding A opens. @@ -145,12 +145,13 @@ test.describe('the owner journey through the history', () => { await (await revealFinding(page, 'Constat A')).click() await expect(findingDialog(page)).toBeVisible() await entryHolds(page, 'view.finding !== null') - // 3. « 2 références »; 4. the sheet opens and lists the two references. + // 3. « 2 références » (a tap at 375 px); 4. the references dialog lists the two. const trigger = page.locator('[data-citations-trigger]:visible') await expect(trigger).toContainText('2 références') - await trigger.click() + await (isPhone(info) ? trigger.tap() : trigger.click()) await expect(place(page, 'citations')).toBeVisible() - await expect(sheetHeaders(page)).toHaveCount(2) + await expect(citedHeaders(page)).toHaveCount(2) + await expectAccessible(page, 'the references dialog over finding A') await entryHolds(page, 'view.finding && view.finding.citations') // The tree behind the dialogs sits at an offset of its own (the page is padded so it // can scroll whatever the viewport): Back must return to it. @@ -170,28 +171,50 @@ test.describe('the owner journey through the history', () => { libraryRoot(page).getByText('2 références', { exact: true }), ).toBeVisible() expect(Math.abs((await scrollY(page)) - left)).toBeGreaterThan(SCROLL_SLACK) - // 7. browser Back; 8. finding A with its sheet on top, as left. + // 7. browser Back; 8. finding A with its references dialog on top, as left. await page.goBack() await expect(dialogs(page)).toHaveCount(2) await expect(findingDialog(page)).toBeVisible() await expect(findingDialog(page)).toContainText('Constat A') - expect(await sheetOnTop(page)).toBe(true) - await expect(sheetHeaders(page)).toHaveCount(2) + expect(await citationsOnTop(page)).toBe(true) + await expect(citedHeaders(page)).toHaveCount(2) await expectScrollNear(page, left) - // Closed by Escape (sheet, then dialog): the tree stays where it was left. + // Keyboard: from its ✕, Tab reaches « Tout afficher » and both tiles inside the + // references dialog; Escape closes it only, « 2 références » takes the focus back; then + // the finding dialog. The tree stays where it was left. + const reached = new Set() + for (let step = 0; step < 3; step++) { + await page.keyboard.press('Tab') + const inside = await page.evaluate( + () => + !!document.activeElement + ?.closest('dialog') + ?.querySelector('[data-place="citations"]'), + ) + expect(inside).toBe(true) + reached.add( + await page.evaluate(() => document.activeElement?.textContent ?? ''), + ) + } + expect([...reached].join('|')).toContain( + dict['editor.references.panel_show_all'], + ) + expect([...reached].join('|')).toContain('Référence A') + expect([...reached].join('|')).toContain('Référence B') await page.keyboard.press('Escape') await expect(dialogs(page)).toHaveCount(1) + await expect(trigger).toBeFocused() await page.keyboard.press('Escape') await expectNoDialog(page) await expectScrollNear(page, left) }) - test('eight steps: finding, sheet, filter, edit, Back, Forward, Revenir au constat, every Back', async ({ + test('eight steps: finding, references, filter, edit, Back, Forward, Revenir au constat, every Back', async ({ page, }, info) => { test.setTimeout(240_000) await open(page) - // 1 to 3: the finding dialog, its sheet, « Tout afficher »; 4: the filtered tab. + // 1 to 3: the finding dialog, its references, « Tout afficher »; 4: the filtered tab. await filteredTab(page) await expect(headers(page)).toHaveCount(2) await expect( @@ -221,23 +244,23 @@ test.describe('the owner journey through the history', () => { expect(await entryId(page)).toBe(filteredId) await expect(chip(page)).toBeVisible() } - // 6: Back lands on finding A with its sheet open and on top; Forward, on the filter. + // 6: Back lands on finding A with its references dialog on top; Forward, on the filter. await page.goBack() await expect(dialogs(page)).toHaveCount(2) - expect(await sheetOnTop(page)).toBe(true) + expect(await citationsOnTop(page)).toBe(true) await expect(findingDialog(page)).toBeVisible() await page.goForward() await expectNoDialog(page) await expect(chip(page)).toBeVisible() await expect(headers(page)).toHaveCount(2) - // 7: « Revenir au constat » pops to the dialog with its sheet (the entry below shows it). + // 7: « Revenir au constat » pops to the dialogs (the entry below shows them). await page .getByRole('button', { name: dict['editor.references.filter_back'] }) .click() await expect(dialogs(page)).toHaveCount(2) - expect(await sheetOnTop(page)).toBe(true) + expect(await citationsOnTop(page)).toBe(true) await entryHolds(page, 'view.finding && view.finding.citations') - // 8: every Back down to the first entry: sheet, dialog, tab, drawing, then it leaves. + // 8: every Back down to the first entry: references, finding, tab, drawing, then out. await page.goBack() await expect(dialogs(page)).toHaveCount(1) await expect(findingDialog(page)).toBeVisible() @@ -253,7 +276,7 @@ test.describe('the owner journey through the history', () => { await expect.poll(() => page.url()).not.toBe(here) }) - test('a reload keeps the filtered tab and the chip, never a form; Back then returns to the sheet', async ({ + test('a reload keeps the filtered tab and the chip, never a form; Back then returns to the dialog', async ({ page, }) => { test.setTimeout(150_000) @@ -265,7 +288,7 @@ test.describe('the owner journey through the history', () => { await expect(headers(page)).toHaveCount(2) await page.goBack() await expect(dialogs(page)).toHaveCount(2) - expect(await sheetOnTop(page)).toBe(true) + expect(await citationsOnTop(page)).toBe(true) }) test('the × removes the filter by replace; the search text is not in the history', async ({ diff --git a/apps/app/e2e/shell/editor-shell-crossing.spec.ts b/apps/app/e2e/shell/editor-shell-crossing.spec.ts index cc50d3bc..2c254b1f 100644 --- a/apps/app/e2e/shell/editor-shell-crossing.spec.ts +++ b/apps/app/e2e/shell/editor-shell-crossing.spec.ts @@ -305,7 +305,7 @@ test.describe('editor shell, width crossing (H)', () => { await expect(saveLine(page)).toHaveText(UNSAVED_LINE) }) - test('the citations sheet open: read-only below the threshold, unsaved work kept, edit back on widening', async ({ + test('the references dialog open: read-only below the threshold, unsaved work kept, edit back on widening', async ({ page, }) => { await open(page) diff --git a/apps/app/e2e/shell/editor-shell-layout.spec.ts b/apps/app/e2e/shell/editor-shell-layout.spec.ts index 1ae7222c..bdc03105 100644 --- a/apps/app/e2e/shell/editor-shell-layout.spec.ts +++ b/apps/app/e2e/shell/editor-shell-layout.spec.ts @@ -84,30 +84,33 @@ async function watchDocumentSize(page: Page) { }) } -const REM = 16 - /** - * The sheet is a modal at the right edge: at most 34 rem and no wider than the viewport, - * as tall as the window whatever the page's scroll (it is in the top layer). + * The references dialog lies inside the viewport whatever the page's scroll (it is in + * the top layer), and the focus is inside it. */ -async function expectSheetWithin(page: Page, viewportWidth: number) { - const layer = page.locator('[data-place="citations"]') - const box = await layer.boundingBox() - expect(box!.width).toBeLessThanOrEqual(34 * REM + 0.5) - // Sub-pixel layout rounding (375.00001…): the same tolerance as the line above. - expect(box!.width).toBeLessThanOrEqual(viewportWidth + 0.5) - const edges = await page.evaluate(() => { - const sheet = document.querySelector('[data-place="citations"]')! - const rect = sheet.getBoundingClientRect() - return { top: rect.top, bottom: rect.bottom, right: rect.right } +async function expectCitationsWithin(page: Page) { + const box = await page.evaluate(() => { + const panel = document.querySelector('[data-place="citations"]')! + const rect = panel + .closest('dialog > div:last-child')! + .getBoundingClientRect() + const focused = document.activeElement?.closest('dialog') + return { + left: rect.left, + top: rect.top, + right: rect.right, + bottom: rect.bottom, + width: window.innerWidth, + height: window.innerHeight, + focusInside: !!focused?.contains(panel), + } }) - expect(edges.top, 'sheet top').toBeLessThanOrEqual(1) - expect( - Math.abs(edges.right - viewportWidth), - 'sheet right edge', - ).toBeLessThan(1) - const height = await page.evaluate(() => window.innerHeight) - expect(Math.abs(edges.bottom - height), 'sheet bottom').toBeLessThanOrEqual(1) + // Sub-pixel layout rounding (375.00001…): the tolerance of 3a7ffa2. + expect(box.left, 'dialog left edge').toBeGreaterThanOrEqual(0) + expect(box.top, 'dialog top edge').toBeGreaterThanOrEqual(0) + expect(box.right, 'dialog right edge').toBeLessThanOrEqual(box.width + 0.5) + expect(box.bottom, 'dialog bottom edge').toBeLessThanOrEqual(box.height + 0.5) + expect(box.focusInside, 'focus inside the references dialog').toBe(true) } async function settle(page: Page) { @@ -129,7 +132,7 @@ test.describe('editor shell layout (H)', () => { await dropLateReplays(context) }) - test('no horizontal scroll from 1 024 to 1 280 px on the five tabs, the three sections and the open citations sheet', async ({ + test('no horizontal scroll from 1 024 to 1 280 px on the five tabs, the three sections and the open references dialog', async ({ page, }) => { test.setTimeout(150_000) @@ -145,7 +148,7 @@ test.describe('editor shell layout (H)', () => { await expectNoHorizontalOverflow(page, `${section} at ${width} px`) } await openCitations(page, dict, 'Constat A') - await expectNoHorizontalOverflow(page, `the sheet at ${width} px`) + await expectNoHorizontalOverflow(page, `the references at ${width} px`) await closeCitations(page, dict) await closeFinding(page, dict) // The walk is a script: about 20 history entries per width would pass the adapter's @@ -154,7 +157,7 @@ test.describe('editor shell layout (H)', () => { } }) - test('the open sheet is at most 34 rem and the viewport wide, and the document never changes size, before, during and after', async ({ + test('the open references dialog lies inside the viewport, focus inside, and the document never changes size', async ({ page, }) => { test.setTimeout(150_000) @@ -164,8 +167,8 @@ test.describe('editor shell layout (H)', () => { await openFinding(page, dict, 'Constat A') const stop = await watchDocumentSize(page) await showCitations(page) - await expectSheetWithin(page, width) - await expectNoHorizontalOverflow(page, `the open sheet at ${width} px`) + await expectCitationsWithin(page) + await expectNoHorizontalOverflow(page, `the references at ${width} px`) await closeCitations(page, dict) await closeFinding(page, dict) const sizes = await stop() @@ -210,7 +213,7 @@ test.describe('editor shell layout (H)', () => { } }) - test('the canvas width is the same before the citations sheet opens and after both layers close', async ({ + test('the canvas width is the same before the references dialog opens and after both layers close', async ({ page, }) => { test.setTimeout(150_000) @@ -239,7 +242,7 @@ test.describe('editor shell layout (H)', () => { } }) - test('axe from the top on the five tabs, each section and the open dialog and sheet', async ({ + test('axe from the top on the five tabs, each section and the two open dialogs', async ({ page, }) => { test.setTimeout(150_000) @@ -265,7 +268,7 @@ test.describe('editor shell layout (H)', () => { await expectAccessible(page, `the finding dialog at ${width} px`) await showCitations(page) await settle(page) - await expectAccessible(page, `the open sheet at ${width} px`) + await expectAccessible(page, `the references dialog at ${width} px`) await closeCitations(page, dict) await closeFinding(page, dict) } @@ -313,7 +316,8 @@ function focusKind(page: Page): Promise { return page.evaluate((undoName) => { const el = document.activeElement if (!el) return 'other' - if (el.closest('[data-place="citations"]')) return 'panel' + const dialog = el.closest('dialog') + if (dialog?.querySelector('[data-place="citations"]')) return 'panel' if (el.getAttribute('role') === 'tab') return 'tab' if (el.closest('[data-testid="history-buttons"]')) { return el.getAttribute('aria-label') === undoName ? 'undo' : 'redo' @@ -366,7 +370,7 @@ test.describe('editor shell keyboard order (H)', () => { expect(order).toEqual(['tab', 'undo', 'redo', 'tools', 'canvas', 'side']) }) - test('with the sheet open: Tab stays in the sheet; closed, the order is the page again', async ({ + test('with the references dialog open: Tab stays in it; closed, the order is the page again', async ({ page, }) => { await open(page) @@ -401,7 +405,7 @@ test.describe('editor shell keyboard order (H)', () => { }) }) -test.describe('citations sheet at 375 px, read-only (O4-2)', () => { +test.describe('references dialog at 375 px, read-only (O4-2)', () => { test.use({ locale: 'fr-FR', actionTimeout: 15_000 }) test.beforeEach(async ({ context }, info) => { test.skip(!isPhone(info), 'the phone sizes are set by the test itself') @@ -411,7 +415,7 @@ test.describe('citations sheet at 375 px, read-only (O4-2)', () => { await dropLateReplays(context) }) - test('the whole screen, never wider than it, as tall as the window through a height change and a rotation, the drawing box unchanged @phone', async ({ + test('inside the screen through a height change and a rotation, focus inside, the drawing box unchanged @phone', async ({ page, }) => { test.setTimeout(150_000) @@ -430,10 +434,10 @@ test.describe('citations sheet at 375 px, read-only (O4-2)', () => { await page.evaluate( () => new Promise((done) => requestAnimationFrame(() => done(null))), ) - await expectSheetWithin(page, size.width) + await expectCitationsWithin(page) await expectNoHorizontalOverflow( page, - `the sheet at ${size.width} x ${size.height}`, + `the references at ${size.width} x ${size.height}`, ) } await page.setViewportSize({ width: 375, height: 667 }) @@ -444,7 +448,7 @@ test.describe('citations sheet at 375 px, read-only (O4-2)', () => { expect(await drawingBox()).toEqual(drawing) }) - test('the document size does not change while the dialog and the sheet open and close @phone', async ({ + test('the document size does not change while the two dialogs open and close @phone', async ({ page, }) => { test.setTimeout(150_000) diff --git a/apps/app/e2e/shell/editor-shell.spec.ts b/apps/app/e2e/shell/editor-shell.spec.ts index 296a7a8f..95348bb7 100644 --- a/apps/app/e2e/shell/editor-shell.spec.ts +++ b/apps/app/e2e/shell/editor-shell.spec.ts @@ -125,7 +125,7 @@ test.describe('editor shell, kept places (B2a)', () => { }) for (const width of [1024, 1280]) { - test(`the open citations sheet is modal: the header and the tab row are out of reach at ${width} px`, async ({ + test(`the open references dialog is modal: the header and the tab row are out of reach at ${width} px`, async ({ page, }) => { await page.setViewportSize({ width, height: 800 }) diff --git a/apps/app/e2e/support/editor.ts b/apps/app/e2e/support/editor.ts index e4e53f0e..7b736df4 100644 --- a/apps/app/e2e/support/editor.ts +++ b/apps/app/e2e/support/editor.ts @@ -429,12 +429,18 @@ export async function openTab(page: Page, dict: Dict, tab: string) { ).toBeVisible() } -/** The open finding dialog: the layer dialog that is neither the sheet nor the reference form. */ +/** The open finding dialog: the layer dialog that holds neither citations nor a reference form. */ export const findingDialog = (page: Page): Locator => page.locator('dialog[open][data-layer]').filter({ hasNot: page.locator('[data-place="citations"], #reference-form-citation'), }) +/** The open references dialog of a finding (Rev 5): the layer dialog that holds its citations. */ +export const citationsDialog = (page: Page): Locator => + page + .locator('dialog[open][data-layer]') + .filter({ has: page.locator('[data-place="citations"]') }) + /** The open reference dialog (R2F-5): the layer dialog that holds the reference form. */ export const referenceDialog = (page: Page): Locator => page @@ -523,7 +529,7 @@ export async function openFinding( /** * Waits for the history to settle on a view without the finding layer (or without its - * sheet): a close pops its entry from an effect, and a move made before the pop lands + * references dialog): a close pops its entry from an effect, and a move made before the pop lands * would be undone by it (a user cannot be that quick, a script can). */ export async function layersSettled(page: Page, keepDialog = false) { @@ -545,8 +551,8 @@ export async function closeFinding(page: Page, dict: Dict) { } /** - * Opens the citations sheet of the finding named `element`: its dialog, then its - * « n références » trigger. The sheet lies over the dialog and holds the focus. + * Opens the references dialog of the family or node named `element`: its finding dialog, + * then its « n références » trigger. The references dialog lies over it, focus inside. */ export async function openCitations( page: Page, @@ -558,17 +564,17 @@ export async function openCitations( await showCitations(page) } -/** From the open finding dialog: « n références » opens the sheet over it. */ +/** From the open finding dialog: « n références » opens the references dialog over it. */ export async function showCitations(page: Page) { await page.locator('[data-citations-trigger]:visible').click() await expect(place(page, 'citations')).toBeVisible() await expect(page.locator('dialog[open]')).toHaveCount(2) } -/** Closes the citations sheet with its ✕: the finding dialog under it stays open. */ +/** Closes the references dialog with its ✕: the finding dialog under it stays open. */ export async function closeCitations(page: Page, dict: Dict) { - await page - .getByRole('button', { name: dict['editor.references.close'] }) + await citationsDialog(page) + .getByRole('button', { name: dict['common.close'] }) .click() await expect(place(page, 'citations')).toHaveCount(0) await expect(page.locator('dialog[open]')).toHaveCount(1)