test(editor): reference dialog, filter and the owner journey, specs follow the dialog

This commit is contained in:
bchanot committed 2026-11-13 20:27:01 +01:00
1 parent 7a64daf251
commit 8b42816270
20 files changed
+1546 -1171

No files matched your search

+63 -31
View File
@@ -19,6 +19,8 @@ import {
openFinding,
openTab,
place,
referenceDialog,
referenceSettled,
saveDraft,
seedDraft,
serverDocument,
@@ -251,9 +253,13 @@ 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).
await expect(
root.locator('button[aria-controls][id$="-header"]'),
).toHaveCount(4)
).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.
await page.goBack()
await expect(place(page, 'citations')).toBeVisible()
@@ -264,26 +270,42 @@ test.describe('citations sheet, editing', () => {
await expect(place(page, 'references')).toBeVisible()
})
test('Escape in a field of a tile neither closes the sheet nor commits; ✕ then commits', async ({
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()
await panel(page)
.getByRole('button', { name: dict['editor.references.edit'] })
.click()
const field = panel(page).getByLabel(dict['editor.reference.citation'])
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(panel(page)).toBeVisible()
await expect(field).toHaveValue('Référence A, révisée')
// A user close applies a valid draft first (P22''), then the sheet exits.
await panel(page)
.getByRole('button', { name: dict['editor.references.close'] })
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(panel(page)).toHaveCount(0)
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)
@@ -293,7 +315,7 @@ test.describe('citations sheet, editing', () => {
expect(saved.references[0].citation).toBe('Référence A, révisée')
})
test('a refused draft cancels every move that unmounts the sheet: ✕, scrim, Back, « Tout afficher »', async ({
test('a dirty reference dialog keeps its draft on ✕ and on Back; « Abandonner » leaves the sheet open', async ({
page,
}) => {
test.setTimeout(150_000)
@@ -303,28 +325,38 @@ test.describe('citations sheet, editing', () => {
await panel(page)
.getByRole('button', { name: dict['editor.references.edit'] })
.click()
const field = panel(page).getByLabel(dict['editor.reference.citation'])
await field.fill('')
await panel(page)
.getByRole('button', { name: dict['editor.references.close'] })
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(panel(page)).toBeVisible()
await expect(field).toBeFocused()
await expect(panel(page).getByRole('alert')).toBeVisible()
await page
.getByTestId('references-scrim')
.click({ position: { x: 4, y: 40 } })
await expect(panel(page)).toBeVisible()
await link(page).click()
await expect(panel(page)).toBeVisible()
await expect(page.getByRole('tab', { selected: true })).toHaveText(
new RegExp(`^${dict['editor.tab.findings']}`),
)
// Back: the page stays, the view is pushed again, the refusal shows.
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(panel(page).getByRole('alert')).toBeVisible()
await expect(undo(page)).toHaveAttribute('aria-disabled', 'true')
})
test('the exiting sheet is inert, and a second close finds nothing to close', async ({