fix(editor): e2e for Back over the sheet and the leave over it

This commit is contained in:
bchanot committed 2026-11-14 19:09:09 +01:00
1 parent 254ad2b4aa
commit 96e301ab69
1 file changed
+35
@@ -207,4 +207,39 @@ test.describe('leaving the editor by a history jump', () => {
)
expect(await leftFlags(page)).toBe(0)
})
test('the sheet 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.
const sheetId = await open(page)
await openFinding(page, dict, 'Constat A')
const finding = findingDialog(page)
await finding
.getByRole('button', { name: dict['editor.findings.edit'], exact: true })
.click()
const name = finding.getByLabel(dict['editor.general.name_fr'])
await name.fill('Constat brouillon')
await showCitations(page)
await expect(page.locator('dialog[open]')).toHaveCount(2)
await page.goBack()
await expect(page.locator('dialog[open]')).toHaveCount(1)
await expect(page.getByText(confirmText)).toHaveCount(0)
await expect(name).toHaveValue('Constat brouillon')
await showCitations(page)
await expect(page.locator('dialog[open]')).toHaveCount(2)
await jumpToOverview(context, page, sheetId)
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 keep.click()
await expect(name).toHaveValue('Constat brouillon')
expect(new URL(page.url()).pathname).toBe(draftPath(sheetId))
})
})