import { fr } from '@/i18n/fr' import type { Locator, Page, TestInfo } from '@playwright/test' import { expect, expectAccessible, expectNoHorizontalOverflow, test, } from '../support/browser' import { dropLateReplays, routeToSandbox } from '../support/sandbox' import { citationsDialog, closeCitations, closeFinding, editorActor, expectNoDialog, findingDialog, historyButton, libraryRoot, openCitations, openEditor, openFinding, openTab, place, referenceDialog, saveDraft, seedDraft, serverDocument, showCitations, standardShape, } from '../support/editor' // 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 list outgrows the screen), the family none. */ function longShape(document: Record) { shape(document) const refs = Array.from({ length: 12 }, (_, index) => ({ id: `ref-${index}`, type: 'book', citation: `Ouvrage numéro ${index + 1}`, url: null, doi: null, })) document.references = refs const zone = (document.finding_zones as { categories: unknown[] }[])[0] const family = zone.categories[0] as { reference_ids: string[] children: { reference_ids: string[] }[] } family.reference_ids = [] family.children[0].reference_ids = refs.map((ref) => ref.id) } /** « Constat A » cites A, B and C; the family cites B; D is cited by nobody. */ function shape(document: Record) { standardShape(document) const reference = (id: string, citation: string, type = 'book') => ({ id, type, citation, url: null, doi: null, }) document.references = [ reference('ref-a', 'Référence A'), reference('ref-b', 'Source B', 'web'), reference('ref-c', 'Source C', 'journal'), reference('ref-d', 'Source libre', 'manual'), ] const zone = (document.finding_zones as { categories: unknown[] }[])[0] const family = zone.categories[0] as { reference_ids: string[] children: { reference_ids: string[] }[] } family.reference_ids = ['ref-b'] family.children[0].reference_ids = ['ref-a', 'ref-b', 'ref-c'] } async function open(page: Page, seedShape = shape) { const actor = await editorActor('fr') const seed = await seedDraft(actor, { shape: seedShape }) await openEditor(page, dict, actor, seed.sheetId) return { actor, seed } } const panel = (page: Page) => page.getByTestId('editor-citations-panel') const heads = (page: Page) => panel(page).locator('button[aria-controls][id$="-header"]') const trigger = (page: Page) => page.locator('[data-citations-trigger]') const link = (page: Page) => panel(page).getByRole('button', { name: dict['editor.references.panel_show_all'], }) const modify = (page: Page) => findingDialog(page).getByRole('button', { name: dict['editor.findings.edit'], }) const saveForm = (page: Page) => findingDialog(page).getByRole('button', { name: dict['editor.findings.save'], }) type Node = { reference_ids: string[] review_status: string description: { fr?: string } } const nodeOf = (document: Record) => ( document.finding_zones as { categories: { children: Node[] }[] }[] )[0].categories[0].children[0] test.describe('references dialog, view mode', () => { test.use({ locale: 'fr-FR', actionTimeout: 15_000 }) test.beforeEach(async ({ context }, info) => { test.skip( isPhone(info), 'editing needs >= 1 024 px; the read-only twin at 375 px is below', ) // floor-guard: allow C16 editing needs >= 1024 px; read-only twin in this file await routeToSandbox(context) }) test.afterEach(async ({ context }) => { await dropLateReplays(context) }) test('opens over its finding dialog, read only; the finding form cites nothing and its save keeps them', async ({ page, requests, }) => { test.setTimeout(150_000) const { actor, seed } = await open(page) requests.forbid(actor.account.email, actor.account.password) await openCitations(page, dict, 'Constat A') await expect(trigger(page)).toHaveAttribute('aria-haspopup', 'dialog') await expect(trigger(page)).not.toHaveAttribute('aria-expanded') 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', ) await expect(panel(page)).toContainText( dict['editor.references.panel_count_other'].replace('{count}', '3'), ) 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 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() // The tiles are read only; the dialog's own « Modifier » is the way to its edit mode. for (const name of [ dict['editor.references.edit'], dict['editor.action.delete'], dict['editor.action.move_up'], dict['editor.action.remove'], ]) { await expect(tile.getByRole('button', { name, exact: true })).toHaveCount( 0, ) } await expect( citationsDialog(page).getByRole('button', { name: dict['editor.action.remove'], exact: true, }), ).toHaveCount(0) await expectAccessible(page, 'the references dialog, an open tile') // 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 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('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-b', 'ref-c']) expect(nodeOf(saved).description.fr).toBe('Texte') expect((saved.references as unknown[]).length).toBe(4) }) 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 family: « Tout afficher » filters the library by it, Back returns to its dialog', async ({ page, }) => { test.setTimeout(150_000) await open(page) await openCitations(page, dict, 'Dysfonction A') await link(page).click() await expectNoDialog(page) const root = libraryRoot(page) await expect( root.locator('button[aria-controls][id$="-header"]'), ).toHaveCount(1) await expect(root.getByRole('button', { name: /Source B/ })).toBeVisible() await expect(root.getByTestId('editor-references-filter')).toContainText( 'Dysfonction A', ) await page.goBack() await expect(page.locator('dialog[open]')).toHaveCount(2) await expect(panel(page)).toContainText('Zone A › Dysfonction A') await expect( findingDialog(page).getByRole('heading', { name: 'Dysfonction A' }), ).toBeVisible() }) test('a long list scrolls inside the dialog; « 0 référence » opens the empty one', async ({ page, }) => { test.setTimeout(150_000) await open(page, longShape) await openCitations(page, dict, 'Constat A') await expect(heads(page)).toHaveCount(12) expect(await page.evaluate(() => window.scrollY)).toBe(0) 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 }) 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) // Rev 6: « Dysfonction A » is a family, its empty line says so. await expect(panel(page)).toContainText( dict['editor.references.panel_empty_family'], ) }) 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) await open(page) await openTab(page, dict, 'references') const root = libraryRoot(page) await root.getByRole('searchbox').fill('Source') await root .getByLabel(dict['editor.references.sort_by']) .selectOption('citation') await root.getByRole('button', { name: /Source B/ }).click() await openCitations(page, dict, 'Constat A') await link(page).click() await expectNoDialog(page) await expect(page.locator('#editor-references-title')).toBeFocused() await expect(root.getByRole('searchbox')).toHaveValue('') await expect( root.getByLabel(dict['editor.references.sort_by']), ).toHaveValue('citation') await expect( root.getByRole('button', { name: /Source B/ }), ).toHaveAttribute('aria-expanded', 'true') // 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, its dialog on top. await page.goBack() await expect(place(page, 'citations')).toBeVisible() await expect(findingDialog(page)).toBeVisible() await expect(page.locator('dialog[open]')).toHaveCount(2) await page.goForward() await expectNoDialog(page) await expect(place(page, 'references')).toBeVisible() }) test('the exiting dialog is inert, and a second close finds nothing to close', async ({ page, }) => { test.setTimeout(150_000) await open(page) await openCitations(page, dict, 'Constat A') await page.evaluate(() => { const samples: boolean[] = [] Object.assign(window, { samples }) const tick = () => { const layer = document.querySelector('[data-place="citations"]') if (layer === null) return samples.push(layer.closest('dialog')?.hasAttribute('inert') ?? false) requestAnimationFrame(tick) } tick() }) const closeButton = citationsDialog(page).getByRole('button', { name: dict['common.close'], }) await closeButton.dispatchEvent('click') await closeButton.dispatchEvent('click').catch(() => undefined) await expect(panel(page)).toHaveCount(0) const samples = await page.evaluate( () => (window as unknown as { samples: boolean[] }).samples, ) expect(samples.some((inert) => inert)).toBe(true) // 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 dialog, Tab reaches each control in order, Escape closes only it', async ({ page, }) => { test.setTimeout(150_000) await open(page) await openFinding(page, dict, 'Constat A') await trigger(page).focus() await page.keyboard.press('Enter') await expect(place(page, 'citations')).toBeVisible() await expect(page.locator('dialog[open]')).toHaveCount(2) // The tab order of the dialog, in the document's order, each control tagged. const count = await panel(page).evaluate((root) => { const dialog = root.closest('dialog')! const tabbable = [ ...dialog.querySelectorAll( 'button:not([disabled]), [href], input:not([disabled]), select, textarea', ), ] tabbable.forEach((el, index) => el.setAttribute('data-kb', String(index))) return tabbable.length }) expect(count).toBeGreaterThanOrEqual(5) const at = () => page.evaluate(() => document.activeElement?.getAttribute('data-kb')) // On open the first control (✕) holds the focus; Tab then walks the rest. expect(await at()).toBe('0') for (let index = 1; index < count; index++) { await page.keyboard.press('Tab') expect(await at(), `Tab to control ${index}`).toBe(String(index)) } await page.keyboard.press('Escape') await expect(panel(page)).toHaveCount(0) await expect(findingDialog(page)).toBeVisible() await expect(trigger(page)).toBeFocused() }) }) const editButton = (page: Page) => citationsDialog(page).getByRole('button', { name: dict['editor.citations.edit'], exact: true, }) const inDialog = (page: Page, name: string | RegExp) => citationsDialog(page).getByRole('button', { name, exact: typeof name === 'string', }) const draftRows = (page: Page) => citationsDialog(page).locator('[data-citation-row]') const confirmText = dict['editor.findings.discard_ask'] /** Constat A's references dialog in its edit mode. */ async function editCitations(page: Page) { await openCitations(page, dict, 'Constat A') await editButton(page).click() await expect( citationsDialog(page).getByRole('heading', { level: 2 }), ).toHaveText(dict['editor.citations.edit_title']) } const removeRow = (page: Page, citation: string) => inDialog( page, new RegExp(`^${dict['editor.action.remove']} ${citation}`), ).click() const citeSelect = (page: Page) => citationsDialog(page).getByLabel(dict['editor.findings.reference_add']) /** « Constat A » carries a name long enough to wrap in a dialog title at 320 px. */ const LONG_NAME = 'Constat A au nom particulièrement long, qui ne tient pas sur une seule ligne du titre' function longNameShape(document: Record) { shape(document) const zone = (document.finding_zones as { categories: unknown[] }[])[0] const family = zone.categories[0] as { children: { name: unknown }[] } family.children[0].name = { fr: LONG_NAME, en: LONG_NAME } } /** The ✕ of `dialog`: a box of at least 44 × 44 px, inside the viewport (Rev 6). */ async function expectCloseBox(page: Page, dialog: Locator, at: string) { const close = dialog.getByRole('button', { name: dict['common.close'] }) const box = async () => (await close.boundingBox())! // Polled: the panel scales in (0.96 to 1) right after it opens. await expect .poll(async () => (await box()).width, { message: `✕ width at ${at}` }) .toBeGreaterThanOrEqual(44) expect((await box()).height, `✕ height at ${at}`).toBeGreaterThanOrEqual(44) const { x, width } = await box() expect(x + width, `✕ inside at ${at}`).toBeLessThanOrEqual( page.viewportSize()!.width + 0.5, ) } test.describe('references dialog, edit mode', () => { test.use({ locale: 'fr-FR', actionTimeout: 15_000 }) test.beforeEach(async ({ context }, info) => { test.skip(isPhone(info), 'editing needs >= 1 024 px') // floor-guard: allow C16 editing needs >= 1024 px; read-only twin at 375 px below await routeToSandbox(context) }) test.afterEach(async ({ context }) => { await dropLateReplays(context) }) test('cite and remove, one save, one header « Défaire » restores; axe on the edit mode', async ({ page, }) => { test.setTimeout(150_000) const { seed } = await open(page) await editCitations(page) await expectAccessible(page, 'the references dialog, edit mode') await removeRow(page, 'Référence A') await citeSelect(page).selectOption('ref-d') await expect(draftRows(page)).toHaveCount(2) await inDialog(page, dict['editor.citations.cite']).click() await expect(draftRows(page)).toHaveCount(3) await inDialog(page, dict['editor.findings.save']).click() await expect(editButton(page)).toBeFocused() await expect(citationsDialog(page).getByRole('status')).toHaveText( dict['editor.findings.saved'], ) await expect( citationsDialog(page).getByRole('button', { name: dict['editor.references.panel_show_all'], }), ).toBeVisible() await closeCitations(page, dict) await closeFinding(page, dict) await saveDraft(page, dict, seed.revision + 1) let saved = await serverDocument>(seed.draftId) expect(nodeOf(saved).reference_ids).toEqual(['ref-b', 'ref-c', 'ref-d']) const undo = historyButton(page, dict, 'undo') await undo.click() await expect(undo).toHaveAttribute('aria-disabled', 'true') await saveDraft(page, dict, seed.revision + 2) saved = await serverDocument>(seed.draftId) expect(nodeOf(saved).reference_ids).toEqual(['ref-a', 'ref-b', 'ref-c']) }) test('keyboard: ArrowDown on the select only chooses, ✕ closes without asking; axe', async ({ page, }) => { test.setTimeout(150_000) await open(page) await editCitations(page) const cite = inDialog(page, dict['editor.citations.cite']) await expect(cite).toBeDisabled() await citeSelect(page).focus() await page.keyboard.press('ArrowDown') await expect(citeSelect(page)).not.toHaveValue('') await expect(cite).toBeEnabled() await expect(draftRows(page)).toHaveCount(3) await expectAccessible(page, 'the edit mode with a choice not cited') await inDialog(page, dict['common.close']).click() await expect(page.locator('dialog[open]')).toHaveCount(1) await expect(citationsDialog(page).getByText(confirmText)).toHaveCount(0) await expect(historyButton(page, dict, 'undo')).toHaveAttribute( 'aria-disabled', 'true', ) }) test('the ✕ is a 44 px box beside a long title at 1280 px', async ({ page, }) => { test.setTimeout(150_000) await open(page, longNameShape) await openFinding(page, dict, 'Constat A') await expectCloseBox(page, findingDialog(page), '1280 px') await showCitations(page) await expectCloseBox(page, citationsDialog(page), '1280 px, references') }) test('a dirty draft: ✕ and Back ask, « Abandonner » writes nothing', async ({ page, }) => { test.setTimeout(150_000) await open(page) await editCitations(page) await removeRow(page, 'Référence A') await inDialog(page, dict['common.close']).click() await expect(citationsDialog(page).getByText(confirmText)).toBeVisible() await expect(page.locator('dialog[open]')).toHaveCount(2) await inDialog(page, dict['editor.findings.keep_typing']).click() await page.goBack() await expect(citationsDialog(page).getByText(confirmText)).toBeVisible() await expect(page.locator('dialog[open]')).toHaveCount(2) await expect(draftRows(page)).toHaveCount(2) await inDialog(page, dict['editor.findings.discard']).click() await expect(page.locator('dialog[open]')).toHaveCount(1) await expect(trigger(page)).toContainText('3') await closeFinding(page, dict) await expect(historyButton(page, dict, 'undo')).toHaveAttribute( 'aria-disabled', 'true', ) }) test('« Modifier la référence » stacks the reference dialog; closed, the draft is back', async ({ page, }) => { test.setTimeout(150_000) const { seed } = await open(page) await editCitations(page) await removeRow(page, 'Source C') const opener = inDialog( page, new RegExp(`^${dict['editor.citations.edit_reference']} Référence A`), ) await opener.click() await expect(referenceDialog(page)).toBeVisible() await expect(page.locator('dialog[open]')).toHaveCount(3) await referenceDialog(page) .locator('#reference-form-citation') .fill('Référence A2') await referenceDialog(page) .getByRole('button', { name: dict['editor.findings.save'] }) .click() await expect(page.locator('dialog[open]')).toHaveCount(2) await expect(opener).toBeFocused() await expect(draftRows(page)).toHaveCount(2) await expect(draftRows(page).first()).toContainText('Référence A2') await inDialog(page, dict['editor.findings.save']).click() await expect(editButton(page)).toBeFocused() await closeCitations(page, dict) 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-b']) }) /** « Nouvelle référence » over the edit mode, typed, then « Ajouter la référence ». */ async function createPending(page: Page) { const create = inDialog(page, dict['editor.citations.new_reference']) await create.click() const form = referenceDialog(page) await expect(form).toBeVisible() await expect(page.locator('dialog[open]')).toHaveCount(3) await expect( form.getByRole('heading', { name: dict['editor.reference.new'] }), ).toBeVisible() await form.locator('#reference-form-type').selectOption('manual') await form.locator('#reference-form-citation').fill('Source nouvelle') await form .getByRole('button', { name: dict['editor.reference.add'] }) .click() await expect(page.locator('dialog[open]')).toHaveCount(2) await expect(create).toBeFocused() await expect(draftRows(page)).toHaveCount(4) await expect(draftRows(page).last()).toContainText('Source nouvelle') await expect(draftRows(page).last()).toContainText( dict['editor.citations.pending'], ) await expect(citationsDialog(page).getByRole('status')).toContainText( 'Source nouvelle', ) } test('« Nouvelle référence » then « Abandonner »: the library is unchanged', async ({ page, }) => { test.setTimeout(150_000) await open(page) await editCitations(page) await createPending(page) await inDialog(page, dict['common.cancel']).click() await inDialog(page, dict['editor.findings.discard']).click() await expect(editButton(page)).toBeFocused() await closeCitations(page, dict) await closeFinding(page, dict) await expect(historyButton(page, dict, 'undo')).toHaveAttribute( 'aria-disabled', 'true', ) await expect( page.locator('p.sr-only[aria-live="polite"]'), ).not.toContainText('sera enregistrée') await openTab(page, dict, 'references') await expect(libraryRoot(page)).toContainText('Source libre') await expect(libraryRoot(page)).not.toContainText('Source nouvelle') }) test('« Nouvelle référence » then « Enregistrer »: one « Défaire » removes both', async ({ page, }) => { test.setTimeout(150_000) const { seed } = await open(page) await editCitations(page) await createPending(page) await inDialog(page, dict['editor.findings.save']).click() await expect(editButton(page)).toBeFocused() await closeCitations(page, dict) await closeFinding(page, dict) await saveDraft(page, dict, seed.revision + 1) let saved = await serverDocument>(seed.draftId) const added = (saved.references as { id: string; citation: string }[]).find( (ref) => ref.citation === 'Source nouvelle', ) expect(added).toBeDefined() expect(nodeOf(saved).reference_ids).toEqual([ 'ref-a', 'ref-b', 'ref-c', added!.id, ]) const undo = historyButton(page, dict, 'undo') await undo.click() await expect(undo).toHaveAttribute('aria-disabled', 'true') await saveDraft(page, dict, seed.revision + 2) saved = await serverDocument>(seed.draftId) const citations = (saved.references as { citation: string }[]).map( (ref) => ref.citation, ) expect(citations).not.toContain('Source nouvelle') expect(nodeOf(saved).reference_ids).toEqual(['ref-a', 'ref-b', 'ref-c']) }) }) /** Every way out of the dialog, the focus read from the document after the exit. */ for (const reduced of [false, true]) { 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 await routeToSandbox(context) await page.emulateMedia({ reducedMotion: reduced ? 'reduce' : 'no-preference', }) }) test.afterEach(async ({ context }) => { await dropLateReplays(context) }) test('✕, Escape, the backdrop and Back give the focus back to the trigger', async ({ page, }) => { test.setTimeout(150_000) await open(page) await openCitations(page, dict, 'Constat A') await closeCitations(page, dict) await expect(trigger(page)).toBeFocused() await showCitations(page) await page.keyboard.press('Escape') await expect(panel(page)).toHaveCount(0) await expect(trigger(page)).toBeFocused() await showCitations(page) await citationsDialog(page) .getByTestId('dialog-backdrop') .click({ position: { x: 12, y: 40 } }) await expect(panel(page)).toHaveCount(0) await expect(trigger(page)).toBeFocused() await showCitations(page) await page.goBack() await expect(panel(page)).toHaveCount(0) await expect(findingDialog(page)).toBeVisible() await expect(trigger(page)).toBeFocused() await page.goForward() await expect(panel(page)).toBeVisible() await expect(page.locator('dialog[open]')).toHaveCount(2) }) test('« Tout afficher » and « Aller à » land where the move says', async ({ page, }) => { test.setTimeout(150_000) await open(page) await openCitations(page, dict, 'Constat A') await link(page).click() await expectNoDialog(page) await expect(page.locator('#editor-references-title')).toBeFocused() await openCitations(page, dict, 'Constat A') await heads(page).nth(1).click() await panel(page) .getByRole('button', { name: dict['editor.references.go_to'] }) .first() .click() // 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 dialog open. await page.goBack() await expect(page.locator('dialog[open]')).toHaveCount(2) await expect(place(page, 'citations')).toBeVisible() await expect( findingDialog(page).getByRole('heading', { name: 'Constat A' }), ).toBeVisible() await page.goForward() await expect(place(page, 'citations')).toHaveCount(0) await expect(family).toBeVisible() await closeFinding(page, dict) await expect( page.getByRole('treeitem', { name: /Dysfonction A/ }), ).toBeFocused() }) 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') await page.evaluate(() => { const seen: string[] = [] Object.assign(window, { seen }) new MutationObserver(() => { 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, attributes: true, attributeFilter: ['style'], }) }) await trigger(page).click() await expect(place(page, 'citations')).toBeVisible() await expect(page.locator('dialog[open]')).toHaveCount(2) const seen = await page.evaluate( () => (window as unknown as { seen: string[] }).seen, ) const scaled = seen.some((value) => /scale\(0\.9/.test(value)) expect(scaled).toBe(!reduced) }) }) } 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') await routeToSandbox(context) }) test.afterEach(async ({ context }) => { await dropLateReplays(context) }) 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') 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!.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 references dialog at 375 px') await heads(page).first().click() for (const name of [ dict['editor.references.edit'], dict['editor.action.remove'], ]) { await expect( citationsDialog(page).getByRole('button', { name, exact: true }), ).toHaveCount(0) } await expect(panel(page).getByRole('textbox')).toHaveCount(0) 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('the ✕ is a 44 px box beside a long title at 375 and 320 px @phone', async ({ page, }) => { test.setTimeout(150_000) await open(page, longNameShape) await openFinding(page, dict, 'Constat A') await expectCloseBox(page, findingDialog(page), '375 px') await page.setViewportSize({ width: 320, height: 640 }) await expectCloseBox(page, findingDialog(page), '320 px') await expectNoHorizontalOverflow(page, 'the finding dialog at 320 px') }) test('by touch: taps act on the references dialog only, the finding dialog under it stays @phone', async ({ page, }) => { test.setTimeout(150_000) await open(page) await openFinding(page, dict, 'Constat A') const center = async (target: Locator) => { const box = await target.boundingBox() return { x: box!.x + box!.width / 2, y: box!.y + box!.height / 2 } } const tap = async (target: Locator) => { const at = await center(target) await page.touchscreen.tap(at.x, at.y) } await tap(trigger(page)) await expect(place(page, 'citations')).toBeVisible() // 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(citationsDialog(page)).toBeVisible() // Its ✕ closes it only; the trigger holds the focus. await tap( 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'] }), ) await expectNoDialog(page) }) })