feat(editor): drawing guard before navigations drop a started move (R-12)
The move mode lives in the work store with its document stamp. guardDrawing ends an unstarted mode at once and asks « Abandonner le déplacement ? » (DrawingGuardDialog, at workspace level) once work is started, before a tab, a section, « Aller à », Back and a history jump out of the editor; the leave guard and sign-out count started work. An undo from the header, Ctrl+Z or the message only cancels a pending mode or preview (R-13), and a document change drops a stale mode, keeping a started one to be said. ConfirmDialog takes an optional body. Strings for Task 4 added.
This commit is contained in:
1 parent
8cd1bda6c2
commit
2882821661
18 files changed
+465
-37
No files matched your search
@@ -10,6 +10,11 @@ import {
|
||||
store,
|
||||
} from '../helpers/editorHarness'
|
||||
import { mountDraft, setWidth } from '../helpers/editorRoute'
|
||||
import {
|
||||
setModePreview,
|
||||
startMove,
|
||||
useAnnotationWork,
|
||||
} from '@/editor/annotations/workStore'
|
||||
|
||||
vi.mock('@/lib/supabase', () => ({ getSupabaseClient: () => ({}) }))
|
||||
vi.mock('@faunosteo/supabase', async (orig) => ({
|
||||
@@ -83,3 +88,47 @@ describe('editor-wide undo', () => {
|
||||
expect(store.getState().unsaved).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe('undo with something pending (R-13)', () => {
|
||||
it('Ctrl+Z only cancels a move mode; the next one undoes', async () => {
|
||||
mountDraft()
|
||||
await ready()
|
||||
act(() => void commitMove(40))
|
||||
const stored = store.getState().previewState!.document.annotations[0]
|
||||
act(() => {
|
||||
startMove(stored.id, store.getState().documentText)
|
||||
setModePreview(
|
||||
{ type: 'circle', cx: 90, cy: 50, r: 10 },
|
||||
stored.geometry!,
|
||||
)
|
||||
})
|
||||
ctrlZ(document.body)
|
||||
expect(useAnnotationWork.getState().mode).toBeNull()
|
||||
expect(cx()).toMatchObject({ cx: 40 })
|
||||
ctrlZ(document.body)
|
||||
expect(cx()).toMatchObject({ cx: 50 })
|
||||
})
|
||||
|
||||
it('the header « Défaire » only cancels a pending size preview', async () => {
|
||||
mountDraft()
|
||||
await ready()
|
||||
act(() => void commitMove(40))
|
||||
const stored = store.getState().previewState!.document.annotations[0]
|
||||
act(() =>
|
||||
useAnnotationWork.setState({
|
||||
preview: {
|
||||
annotationId: stored.id,
|
||||
geometry: { type: 'circle', cx: 40, cy: 50, r: 20 },
|
||||
base: store.getState().documentText,
|
||||
source: 'size',
|
||||
},
|
||||
}),
|
||||
)
|
||||
const user = userEvent.setup()
|
||||
await user.click(screen.getByRole('button', { name: /Défaire/ }))
|
||||
expect(useAnnotationWork.getState().preview).toBeNull()
|
||||
expect(cx()).toMatchObject({ cx: 40 })
|
||||
await user.click(screen.getByRole('button', { name: /Défaire/ }))
|
||||
expect(cx()).toMatchObject({ cx: 50 })
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user