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

+14 -8
View File
@@ -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)