fix(editor): sign-out and shell links ask the drawing guard first

With a started move, sign-out and an in-app link now ask « Abandonner
le déplacement ? » (R-12) through the page's own question, registered by
the draft route in leaveGuardStore (`ask`; the shell imports no editor
module). The generic leave and sign-out dialogs cover only sheet-level
unsaved work; with both pending the drawing asks first, then the sheet
question, as useLeaveConfirm orders them. A move with nothing started
arms nothing (it ends); a started one still guards a reload.

Tests: sign-out and link with a started move (alone and with sheet
changes), the history jump with only a move and after dirty layers, a
section entry and « Tout afficher ».
This commit is contained in:
bchanot committed 2026-11-17 19:25:04 +01:00
1 parent 44de465c6d
commit e01d8519ea
8 files changed
+311 -26

No files matched your search

@@ -67,6 +67,7 @@ function Page({ guard }: { guard?: () => { allowed: boolean } }) {
<button onClick={() => nav.closeFinding()}>close</button>
<button onClick={() => nav.showAllReferences(finding)}>show all</button>
<button onClick={() => nav.navigate(targetOfKey(other))}>go to</button>
<button onClick={() => nav.openSection('views')}>section</button>
<button onClick={() => nav.guards.register('finding', guard ?? null)}>
guard
</button>
@@ -423,6 +424,22 @@ describe('the drawing guard (R-12): a move mode and the navigations', () => {
expect(useAnnotationWork.getState().mode).toBeNull()
})
it('a section entry and « Tout afficher » ask the same way', async () => {
useLocaleStore.setState({ locale: 'fr' })
const user = userEvent.setup()
mount()
started()
await user.click(screen.getByRole('button', { name: 'section' }))
expect(useAnnotationWork.getState().question?.work).toBe('move')
expect(tabShown()).toHaveTextContent('Général')
await user.click(screen.getByRole('button', { name: 'Continuer' }))
await user.click(screen.getByRole('button', { name: 'show all' }))
expect(useAnnotationWork.getState().question?.work).toBe('move')
expect(tabShown()).toHaveTextContent('Général')
await user.click(screen.getByRole('button', { name: 'Abandonner' }))
expect(tabShown()).toHaveTextContent('Références')
})
it('« Aller à » asks the same way', async () => {
useLocaleStore.setState({ locale: 'fr' })
const user = userEvent.setup()