feat(editor): « Citer » button and family labels in references

This commit is contained in:
bchanot committed 2026-11-15 19:40:47 +01:00
1 parent 240c2ba0e7
commit 8c3fcca0b9
16 files changed
+507 -53

No files matched your search

+78 -4
View File
@@ -277,8 +277,9 @@ test.describe('references dialog, view mode', () => {
)
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'],
dict['editor.references.panel_empty_family'],
)
})
@@ -419,6 +420,33 @@ const removeRow = (page: Page, citation: string) =>
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<string, unknown>) {
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 })
@@ -438,9 +466,9 @@ test.describe('references dialog, edit mode', () => {
await editCitations(page)
await expectAccessible(page, 'the references dialog, edit mode')
await removeRow(page, 'Référence A')
await citationsDialog(page)
.getByLabel(dict['editor.findings.reference_add'])
.selectOption('ref-d')
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()
@@ -465,6 +493,40 @@ test.describe('references dialog, edit mode', () => {
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,
}) => {
@@ -718,6 +780,18 @@ test.describe('references dialog, read-only at 375 px', () => {
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,
}) => {