From ec314af00960dccd7657d148e089592313dd0663 Mon Sep 17 00:00:00 2001 From: bchanot Date: Sat, 14 Nov 2026 19:04:56 +0100 Subject: [PATCH] fix(editor): prove one Back reopens the sheet after the leave cascade --- .../tests/unit/editor-finding-dialog.test.tsx | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/apps/app/tests/unit/editor-finding-dialog.test.tsx b/apps/app/tests/unit/editor-finding-dialog.test.tsx index 3b9a4604..58d43a27 100644 --- a/apps/app/tests/unit/editor-finding-dialog.test.tsx +++ b/apps/app/tests/unit/editor-finding-dialog.test.tsx @@ -1064,6 +1064,39 @@ describe('the citations sheet over a dirty edit form (final review rev 4, item 1 draftKept() }) + it('after the cascade keeps the form, one Back reopens the sheet (docs, limit 6)', async () => { + const user = await sheetOverDirtyForm() + const sheet = within(panelOpen()!) + const head = sheet.getByRole('button', { name: /^Alpha/ }) + if (head.getAttribute('aria-expanded') === 'false') await user.click(head) + const tile = within(head.closest('li')!) + await user.click(tile.getByRole('button', { name: 'Modifier' })) + await waitFor(() => expect(refForm()).toBeDefined()) + await user.type(within(refForm()!).getByLabelText('Citation'), ' x') + const url = new URL('/app/admin/sheets', window.location.origin).href + const event = Object.assign(new Event('navigate', { cancelable: true }), { + navigationType: 'traverse', + destination: { url, key: 'list', sameDocument: true }, + }) + act(() => { + api.dispatchEvent(event) + }) + await user.click( + within(refForm()!).getByRole('button', { name: 'Abandonner' }), + ) + await waitFor(() => expect(panelOpen()).toBeNull()) + // The reference dialog plays its exit, then leaves: only the finding dialog stays. + await waitFor(() => expect(dialogs()).toHaveLength(1)) + await user.click( + inDialog().getByRole('button', { name: 'Continuer la saisie' }), + ) + await back() + await waitFor(() => expect(panelOpen()).not.toBeNull()) + expect(screen.queryByText(question)).toBeNull() + expect(api.traverseTo).not.toHaveBeenCalled() + draftKept() + }) + it('a jump out of the editor closes the sheet, then the form asks in view', async () => { await sheetOverDirtyForm() const url = new URL('/app/admin/sheets', window.location.origin).href