diff --git a/apps/app/e2e/shell/editor-leave-confirm.spec.ts b/apps/app/e2e/shell/editor-leave-confirm.spec.ts index f352cd08..545e983e 100644 --- a/apps/app/e2e/shell/editor-leave-confirm.spec.ts +++ b/apps/app/e2e/shell/editor-leave-confirm.spec.ts @@ -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)) + }) })