test(editor): e2e on the references dialog's edit mode

This commit is contained in:
bchanot committed 2026-11-15 16:46:05 +01:00
1 parent 3dc5820e3a
commit 2579d4c7ae
2 files changed
+227 -3

No files matched your search

@@ -11,6 +11,7 @@ import {
findingDialog,
openFinding,
openTab,
citationsDialog,
place,
referenceDialog,
seedDraft,
@@ -230,4 +231,48 @@ test.describe('leaving the editor by a history jump', () => {
await expect(name).toHaveValue('Constat brouillon')
expect(new URL(page.url()).pathname).toBe(draftPath(sheetId))
})
test('a dirty references draft asks before the jump goes', async ({
page,
context,
}) => {
test.setTimeout(150_000)
const sheetId = await open(page)
await openFinding(page, dict, 'Constat A')
await showCitations(page)
const dialog = citationsDialog(page)
await dialog
.getByRole('button', { name: dict['editor.citations.edit'], exact: true })
.click()
await dialog
.getByRole('button', {
name: new RegExp(`^${dict['editor.action.remove']} Référence A`),
})
.click()
const rows = dialog.locator('[data-citation-row]')
await expect(rows).toHaveCount(0)
await jumpToOverview(context, page, sheetId)
await expect(dialog.getByText(confirmText)).toBeVisible()
expect(new URL(page.url()).pathname).toBe(draftPath(sheetId))
const keep = dialog.getByRole('button', {
name: dict['editor.findings.keep_typing'],
})
await expect(keep).toBeFocused()
await keep.click()
await expect(rows).toHaveCount(0)
expect(new URL(page.url()).pathname).toBe(draftPath(sheetId))
await jumpToOverview(context, page, sheetId)
await expect(dialog.getByText(confirmText)).toBeVisible()
await dialog
.getByRole('button', { name: dict['editor.findings.discard'] })
.click()
await expect(page).toHaveURL(
(url) => url.pathname === overviewPath(sheetId),
)
expect(await leftFlags(page)).toBe(0)
await reopenDraft(page)
await expect(page.getByText(leftNotice)).toHaveCount(0)
})
})