test(editor): e2e on the references dialog instead of the sheet

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.
This commit is contained in:
bchanot committed 2026-11-15 16:15:43 +01:00
1 parent abc781df52
commit 2c4c771269
10 files changed
+260 -323

No files matched your search

+13 -25
View File
@@ -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)