fix(editor): creation question lapses, guard sites and flip tested
The creation's « Abandonner la création ? » no longer outlives it: « Replacer le point », « Reprendre le tracé », « Créer » (« Utiliser cette position » included) and « Annuler le tracé » clear a question still open, which would otherwise reappear over the page. Locals trimmed in the creation dialog and the tracing actions (5 max). Tests added (no assertion removed): the two lapses (RED without the fix, GREEN with it); a view chip and a tool ask during a tracing; the mode flip keeps the dialog, its form and the ghost; a history jump out of the editor waits for the creation's question; e2e: « Reprendre le tracé » and « Revenir aux propriétés » under expectNoShift at 1 024, 1 180 and 1 280 px, the strip's last command inside it, axe on the resumed state.
This commit is contained in:
1 parent
4d2c64f57f
commit
fe333c2bbd
6 files changed
+219
-37
No files matched your search
@@ -443,6 +443,32 @@ test.describe('editor annotations (A3)', () => {
|
|||||||
await button(page, 'editor.annotations.trace_close').click()
|
await button(page, 'editor.annotations.trace_close').click()
|
||||||
await expect(creationDialog(page, 'zone')).toBeVisible()
|
await expect(creationDialog(page, 'zone')).toBeVisible()
|
||||||
})
|
})
|
||||||
|
// « Reprendre le tracé » (board 04 C): the dialog hides, the strip offers its way
|
||||||
|
// back; nothing moves, the commands fit, then « Revenir aux propriétés ».
|
||||||
|
await expectNoShift(page, async () => {
|
||||||
|
await creationDialog(page, 'zone')
|
||||||
|
.getByRole('button', {
|
||||||
|
name: dict['editor.annotations.creation.resume'],
|
||||||
|
})
|
||||||
|
.click()
|
||||||
|
await expect(creationDialog(page, 'zone')).toHaveCount(0)
|
||||||
|
})
|
||||||
|
const strip = page.getByTestId('edit-strip')
|
||||||
|
await expect(strip).toContainText(
|
||||||
|
dict['editor.annotations.strip.resumed'],
|
||||||
|
)
|
||||||
|
const fence = (await strip.boundingBox())!
|
||||||
|
const last = (await strip
|
||||||
|
.getByRole('button', {
|
||||||
|
name: dict['editor.annotations.creation.discard'],
|
||||||
|
})
|
||||||
|
.boundingBox())!
|
||||||
|
expect(last.x + last.width).toBeLessThanOrEqual(fence.x + fence.width)
|
||||||
|
await expectAccessible(page, `a resumed tracing at ${width} px`)
|
||||||
|
await expectNoShift(page, async () => {
|
||||||
|
await button(page, 'editor.annotations.back_to_properties').click()
|
||||||
|
await expect(creationDialog(page, 'zone')).toBeVisible()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,8 +56,7 @@ const NONE: Outcome = { missing: [], messages: [] }
|
|||||||
* undo); a point lets the core's verdict offer C (C26); a success ends the creation.
|
* undo); a point lets the core's verdict offer C (C26); a success ends the creation.
|
||||||
*/
|
*/
|
||||||
function useCreate(work: Creation, created: { current: boolean }) {
|
function useCreate(work: Creation, created: { current: boolean }) {
|
||||||
const t = useT()
|
const context = { t: useT(), locale: useLocaleStore((s) => s.locale) }
|
||||||
const locale = useLocaleStore((s) => s.locale)
|
|
||||||
const [outcome, setOutcome] = useState<Outcome>(NONE)
|
const [outcome, setOutcome] = useState<Outcome>(NONE)
|
||||||
const settle = (attempt: Attempt) => {
|
const settle = (attempt: Attempt) => {
|
||||||
if (attempt.status === 'invalid') {
|
if (attempt.status === 'invalid') {
|
||||||
@@ -74,44 +73,43 @@ function useCreate(work: Creation, created: { current: boolean }) {
|
|||||||
if (attempt.id) finishCreation(attempt.id, work.pending.kind)
|
if (attempt.id) finishCreation(attempt.id, work.pending.kind)
|
||||||
else dropCreation()
|
else dropCreation()
|
||||||
}
|
}
|
||||||
const input = { ...work, context: { t, locale } }
|
|
||||||
return {
|
return {
|
||||||
outcome,
|
outcome,
|
||||||
create: () => settle(createAttempt(input, work.form)),
|
create: () => settle(createAttempt({ ...work, context }, work.form)),
|
||||||
confirm: () => {
|
confirm: () => {
|
||||||
const { correction } = work.pending
|
const { correction } = work.pending
|
||||||
if (correction) settle(confirmAttempt(input, work.form, correction))
|
if (!correction) return
|
||||||
|
settle(confirmAttempt({ ...work, context }, work.form, correction))
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** « Point placé · Replacer le point », « Zone tracée, 5 sommets · Reprendre le tracé ». */
|
/** « Point placé · Replacer le point », « Zone tracée, 5 sommets · Reprendre le tracé ». */
|
||||||
function ShapeLine({ work, readOnly }: { work: Creation; readOnly: boolean }) {
|
const GLYPH = { point: 'point', zone: 'zone', detail_trigger: 'link' } as const
|
||||||
|
|
||||||
|
/** « Point placé », « Zone tracée, 5 sommets », « Accès tracé, 3 sommets ». */
|
||||||
|
function useShapeText(pending: Creation['pending']): string {
|
||||||
const t = useT()
|
const t = useT()
|
||||||
const locale = useLocaleStore((s) => s.locale)
|
const locale = useLocaleStore((s) => s.locale)
|
||||||
const { kind, geometry } = work.pending
|
const { kind, geometry } = pending
|
||||||
const count = geometry.type === 'polygon' ? geometry.points.length : 0
|
if (geometry.type !== 'polygon')
|
||||||
const text =
|
return t('editor.annotations.creation.placed')
|
||||||
kind === 'point'
|
const count = geometry.points.length
|
||||||
? t('editor.annotations.creation.placed')
|
const key = `editor.annotations.creation.traced.${kind}`
|
||||||
: t(
|
return t(pluralKey(locale, key, count)).replace('{count}', String(count))
|
||||||
pluralKey(
|
}
|
||||||
locale,
|
|
||||||
`editor.annotations.creation.traced.${kind}`,
|
function ShapeLine({ work, readOnly }: { work: Creation; readOnly: boolean }) {
|
||||||
count,
|
const t = useT()
|
||||||
),
|
const text = useShapeText(work.pending)
|
||||||
).replace('{count}', String(count))
|
const point = work.pending.kind === 'point'
|
||||||
const point = kind === 'point'
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
data-creation-focus=""
|
data-creation-focus=""
|
||||||
tabIndex={-1}
|
tabIndex={-1}
|
||||||
className="flex flex-wrap items-center gap-x-2 gap-y-1 rounded-lg bg-[var(--color-surface-strong)] px-3 py-2 text-sm outline-none"
|
className="flex flex-wrap items-center gap-x-2 gap-y-1 rounded-lg bg-[var(--color-surface-strong)] px-3 py-2 text-sm outline-none"
|
||||||
>
|
>
|
||||||
<EditorGlyph
|
<EditorGlyph name={GLYPH[work.pending.kind]} size={16} />
|
||||||
name={point ? 'point' : kind === 'zone' ? 'zone' : 'link'}
|
|
||||||
size={16}
|
|
||||||
/>
|
|
||||||
<span>{text}</span>
|
<span>{text}</span>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
@@ -257,14 +255,12 @@ export default function CreationDialog(props: CreationDialogProps) {
|
|||||||
const visible = usePlaceVisible()
|
const visible = usePlaceVisible()
|
||||||
const work = useAnnotationWork((s) => s.creation)
|
const work = useAnnotationWork((s) => s.creation)
|
||||||
const back = useCreationReturn(work)
|
const back = useCreationReturn(work)
|
||||||
const shown = visible && work !== null && work.dialog
|
|
||||||
const title = work ? t(`editor.annotations.new.${work.pending.kind}`) : ''
|
|
||||||
return (
|
return (
|
||||||
<Dialog
|
<Dialog
|
||||||
open={shown}
|
open={visible && work !== null && work.dialog}
|
||||||
anchor={props.anchor}
|
anchor={props.anchor}
|
||||||
veilCloses={false}
|
veilCloses={false}
|
||||||
title={title}
|
title={work ? t(`editor.annotations.new.${work.pending.kind}`) : ''}
|
||||||
returnFocus={back.returnFocus}
|
returnFocus={back.returnFocus}
|
||||||
onClose={() => (askDiscard() ? undefined : 'kept')}
|
onClose={() => (askDiscard() ? undefined : 'kept')}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -15,6 +15,15 @@ export interface CreationStart {
|
|||||||
|
|
||||||
const creation = () => useAnnotationWork.getState().creation
|
const creation = () => useAnnotationWork.getState().creation
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The creation's own question (« Abandonner la création ? ») lapses once the creation ends
|
||||||
|
* or its dialog hides: it would otherwise reappear over the page with nothing to ask.
|
||||||
|
*/
|
||||||
|
const lapsed = () => {
|
||||||
|
const { question } = useAnnotationWork.getState()
|
||||||
|
return question?.work === 'creation' ? null : question
|
||||||
|
}
|
||||||
|
|
||||||
function patch(change: Partial<Creation>): void {
|
function patch(change: Partial<Creation>): void {
|
||||||
const current = creation()
|
const current = creation()
|
||||||
if (current)
|
if (current)
|
||||||
@@ -93,11 +102,13 @@ export function closeTrace(): boolean {
|
|||||||
|
|
||||||
/** « Reprendre le tracé »: the dialog hides, the vertices and the form are kept. */
|
/** « Reprendre le tracé »: the dialog hides, the vertices and the form are kept. */
|
||||||
export function resumeTrace(): void {
|
export function resumeTrace(): void {
|
||||||
|
useAnnotationWork.setState({ question: lapsed() })
|
||||||
patch({ closed: false, dialog: false, resumed: true })
|
patch({ closed: false, dialog: false, resumed: true })
|
||||||
}
|
}
|
||||||
|
|
||||||
/** « Replacer le point »: the dialog hides; the next click moves the ghost. */
|
/** « Replacer le point »: the dialog hides; the next click moves the ghost. */
|
||||||
export function replacePoint(): void {
|
export function replacePoint(): void {
|
||||||
|
useAnnotationWork.setState({ question: lapsed() })
|
||||||
patch({ dialog: false, resumed: true })
|
patch({ dialog: false, resumed: true })
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,12 +136,16 @@ export function setCorrection(correction: Correction | null): void {
|
|||||||
|
|
||||||
/** « Abandonner », or a guard's « Abandonner »: nothing of the creation is left. */
|
/** « Abandonner », or a guard's « Abandonner »: nothing of the creation is left. */
|
||||||
export function dropCreation(): void {
|
export function dropCreation(): void {
|
||||||
useAnnotationWork.setState({ creation: null })
|
useAnnotationWork.setState({ creation: null, question: lapsed() })
|
||||||
}
|
}
|
||||||
|
|
||||||
/** « Créer » succeeded: the creation ends, the drawing selects `id` (A7). */
|
/** « Créer » succeeded: the creation ends, the drawing selects `id` (A7). */
|
||||||
export function finishCreation(id: string, kind: NewKind): void {
|
export function finishCreation(id: string, kind: NewKind): void {
|
||||||
useAnnotationWork.setState({ creation: null, created: { id, kind } })
|
useAnnotationWork.setState({
|
||||||
|
creation: null,
|
||||||
|
created: { id, kind },
|
||||||
|
question: lapsed(),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The open tracing of a new shape on `viewId`, as the drawing reads a tracing. */
|
/** The open tracing of a new shape on `viewId`, as the drawing reads a tracing. */
|
||||||
|
|||||||
@@ -82,6 +82,12 @@ export const creationStart = (
|
|||||||
|
|
||||||
const isRedraw = (tracing: Tracing | null) => tracing?.target === 'replace'
|
const isRedraw = (tracing: Tracing | null) => tracing?.target === 'replace'
|
||||||
|
|
||||||
|
/** Backspace or « Retirer le dernier sommet »: the redraw's vertex, or the creation's. */
|
||||||
|
function popTrace({ tracing, dispatch }: PlacementInput): void {
|
||||||
|
if (isRedraw(tracing)) dispatch({ type: 'trace_pop' })
|
||||||
|
else popVertex()
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tracing with the zone and link tools: vertices, closing, Enter, Backspace and Escape. A
|
* Tracing with the zone and link tools: vertices, closing, Enter, Backspace and Escape. A
|
||||||
* redraw's tracing is the reducer's; a new shape's is the creation's (A12): its Escape
|
* redraw's tracing is the reducer's; a new shape's is the creation's (A12): its Escape
|
||||||
@@ -104,14 +110,12 @@ function tracingActions(input: PlacementInput) {
|
|||||||
return dispatch({ type: 'trace_add', point: asPoint(at) })
|
return dispatch({ type: 'trace_add', point: asPoint(at) })
|
||||||
traceVertex(creationStart(input, 'tool'), TOOL_TARGET[tool], asPoint(at))
|
traceVertex(creationStart(input, 'tool'), TOOL_TARGET[tool], asPoint(at))
|
||||||
}
|
}
|
||||||
const pop = () =>
|
|
||||||
isRedraw(tracing) ? dispatch({ type: 'trace_pop' }) : popVertex()
|
|
||||||
const onTraceKey = (event: KeyboardEvent) => {
|
const onTraceKey = (event: KeyboardEvent) => {
|
||||||
if (!tracing) return
|
if (!tracing) return
|
||||||
if (event.key === 'Enter') closeTracing()
|
if (event.key === 'Enter') closeTracing()
|
||||||
if (event.key === 'Backspace') {
|
if (event.key === 'Backspace') {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
pop()
|
popTrace(input)
|
||||||
}
|
}
|
||||||
if (event.key === 'Escape') {
|
if (event.key === 'Escape') {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
@@ -119,7 +123,7 @@ function tracingActions(input: PlacementInput) {
|
|||||||
else askCreation()
|
else askCreation()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return { closeTracing, trace, onTraceKey, pop }
|
return { closeTracing, trace, onTraceKey }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -202,6 +206,6 @@ export function usePlacement(input: PlacementInput) {
|
|||||||
onDrop: dropAction(input),
|
onDrop: dropAction(input),
|
||||||
onTraceKey: tracing.onTraceKey,
|
onTraceKey: tracing.onTraceKey,
|
||||||
closeTracing: tracing.closeTracing,
|
closeTracing: tracing.closeTracing,
|
||||||
popVertex: tracing.pop,
|
popVertex: () => popTrace(input),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -65,19 +65,21 @@ function twoCategories(): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** The tab with the header's history controls, as the workspace shows them. */
|
/** The tab with the header's history controls, as the workspace shows them. */
|
||||||
function Page() {
|
function Page({ readOnly = false }: { readOnly?: boolean }) {
|
||||||
useUndoShortcuts(true)
|
useUndoShortcuts(true)
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<HistoryButtons />
|
<HistoryButtons />
|
||||||
<LayeredTab {...props} />
|
<LayeredTab {...props} readOnly={readOnly} />
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let view: ReturnType<typeof render>
|
||||||
|
|
||||||
async function mount(text = twoCategories()) {
|
async function mount(text = twoCategories()) {
|
||||||
await openReady({ text })
|
await openReady({ text })
|
||||||
render(<Page />)
|
view = render(<Page />)
|
||||||
await waitFor(() =>
|
await waitFor(() =>
|
||||||
expect(screen.getByRole('button', { name: 'Point' })).toBeEnabled(),
|
expect(screen.getByRole('button', { name: 'Point' })).toBeEnabled(),
|
||||||
)
|
)
|
||||||
@@ -85,6 +87,18 @@ async function mount(text = twoCategories()) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const canvas = () => screen.getByTestId('annotation-canvas')
|
const canvas = () => screen.getByTestId('annotation-canvas')
|
||||||
|
const withDetail = () =>
|
||||||
|
insert(twoCategories(), {
|
||||||
|
kind: 'view',
|
||||||
|
value: {
|
||||||
|
kind: 'detail',
|
||||||
|
id: 'view-det',
|
||||||
|
name: { fr: 'Tête', en: 'Head' },
|
||||||
|
svg_asset_id: null,
|
||||||
|
view_box: { min_x: 10, min_y: 10, width: 80, height: 80 },
|
||||||
|
parent_view_id: 'view-main',
|
||||||
|
},
|
||||||
|
} as never)
|
||||||
const ghost = () => screen.getByTestId('overlay-ghost')
|
const ghost = () => screen.getByTestId('overlay-ghost')
|
||||||
const creation = () => useAnnotationWork.getState().creation
|
const creation = () => useAnnotationWork.getState().creation
|
||||||
const annotations = () => store.getState().previewState!.document.annotations
|
const annotations = () => store.getState().previewState!.document.annotations
|
||||||
@@ -312,3 +326,103 @@ describe('during a creation (A12, R-13)', () => {
|
|||||||
).toBeInTheDocument()
|
).toBeInTheDocument()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('the question never outlives its creation', () => {
|
||||||
|
it('Escape, then « Replacer le point »: no question left over the page', async () => {
|
||||||
|
const user = await mount()
|
||||||
|
const shown = await placePoint(user)
|
||||||
|
await user.keyboard('{Escape}')
|
||||||
|
expect(useAnnotationWork.getState().question?.work).toBe('creation')
|
||||||
|
await user.click(
|
||||||
|
within(shown).getByRole('button', { name: 'Replacer le point' }),
|
||||||
|
)
|
||||||
|
expect(useAnnotationWork.getState().question).toBeNull()
|
||||||
|
await waitFor(() => expect(screen.queryByRole('dialog')).toBeNull())
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Escape, then « Utiliser cette position » (C26): created, nothing asked', async () => {
|
||||||
|
const user = await mount()
|
||||||
|
await user.click(screen.getByRole('button', { name: 'Point' }))
|
||||||
|
pressAt(canvas(), 0, 0)
|
||||||
|
const shown = await dialog()
|
||||||
|
await user.type(within(shown).getByLabelText('Nom (FR)'), 'A')
|
||||||
|
await user.type(within(shown).getByLabelText('Nom (EN)'), 'B')
|
||||||
|
await user.selectOptions(within(shown).getByLabelText('Latéralité'), 'left')
|
||||||
|
await user.click(within(shown).getByRole('button', { name: 'Créer' }))
|
||||||
|
const notice = await screen.findByTestId('correction-notice')
|
||||||
|
await user.keyboard('{Escape}')
|
||||||
|
await user.click(
|
||||||
|
within(notice).getByRole('button', { name: 'Utiliser cette position' }),
|
||||||
|
)
|
||||||
|
expect(creation()).toBeNull()
|
||||||
|
expect(useAnnotationWork.getState().question).toBeNull()
|
||||||
|
await waitFor(() => expect(screen.queryByRole('dialog')).toBeNull())
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('the guard sites of the drawing during a tracing (R-12)', () => {
|
||||||
|
async function tracing() {
|
||||||
|
const user = await mount(withDetail())
|
||||||
|
await user.click(screen.getByRole('button', { name: 'Zone' }))
|
||||||
|
pressAt(canvas(), 20, 20)
|
||||||
|
return user
|
||||||
|
}
|
||||||
|
const answer = async (
|
||||||
|
user: ReturnType<typeof userEvent.setup>,
|
||||||
|
name: 'Continuer' | 'Abandonner',
|
||||||
|
) =>
|
||||||
|
user.click(
|
||||||
|
within(
|
||||||
|
await screen.findByRole('dialog', { name: 'Abandonner la création ?' }),
|
||||||
|
).getByRole('button', { name }),
|
||||||
|
)
|
||||||
|
|
||||||
|
it('a view chip asks; « Continuer » keeps the tracing, « Abandonner » shows the view', async () => {
|
||||||
|
const user = await tracing()
|
||||||
|
const chip = screen.getByRole('button', { name: 'Tête' })
|
||||||
|
await user.click(chip)
|
||||||
|
await answer(user, 'Continuer')
|
||||||
|
expect(screen.getByText('1 sommet posé')).toBeInTheDocument()
|
||||||
|
await user.click(chip)
|
||||||
|
await answer(user, 'Abandonner')
|
||||||
|
expect(creation()).toBeNull()
|
||||||
|
expect(chip).toHaveAttribute('aria-pressed', 'true')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('a tool asks the same way', async () => {
|
||||||
|
const user = await tracing()
|
||||||
|
await user.click(screen.getByRole('button', { name: 'Point' }))
|
||||||
|
await answer(user, 'Continuer')
|
||||||
|
expect(screen.getByRole('button', { name: 'Zone' })).toHaveAttribute(
|
||||||
|
'aria-pressed',
|
||||||
|
'true',
|
||||||
|
)
|
||||||
|
await user.click(screen.getByRole('button', { name: 'Point' }))
|
||||||
|
await answer(user, 'Abandonner')
|
||||||
|
expect(screen.getByRole('button', { name: 'Point' })).toHaveAttribute(
|
||||||
|
'aria-pressed',
|
||||||
|
'true',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('the mode flip (R-14, Review Focus 3)', () => {
|
||||||
|
it('read-only by a mode change, then back: the dialog, its form and the ghost stay', async () => {
|
||||||
|
const user = await mount()
|
||||||
|
const shown = await placePoint(user)
|
||||||
|
await user.type(within(shown).getByLabelText('Nom (FR)'), 'Gardé')
|
||||||
|
view.rerender(<Page readOnly />)
|
||||||
|
const kept = screen.getByRole('dialog', { name: 'Nouveau point' })
|
||||||
|
expect(within(kept).getByLabelText('Nom (FR)')).toHaveValue('Gardé')
|
||||||
|
expect(within(kept).getByRole('button', { name: 'Créer' })).toBeDisabled()
|
||||||
|
expect(
|
||||||
|
within(kept).getByRole('button', { name: 'Replacer le point' }),
|
||||||
|
).toBeDisabled()
|
||||||
|
expect(screen.getByTestId('overlay-ghost')).toBeInTheDocument()
|
||||||
|
view.rerender(<Page />)
|
||||||
|
const back = screen.getByRole('dialog', { name: 'Nouveau point' })
|
||||||
|
expect(within(back).getByLabelText('Nom (FR)')).toHaveValue('Gardé')
|
||||||
|
expect(within(back).getByRole('button', { name: 'Créer' })).toBeEnabled()
|
||||||
|
expect(annotations()).toHaveLength(1)
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -14,6 +14,8 @@ import {
|
|||||||
} from '@/editor/useEditorNavigation'
|
} from '@/editor/useEditorNavigation'
|
||||||
import { useLocaleStore } from '@/state/localeStore'
|
import { useLocaleStore } from '@/state/localeStore'
|
||||||
import { answerDrawing } from '@/editor/annotations/drawingGuard'
|
import { answerDrawing } from '@/editor/annotations/drawingGuard'
|
||||||
|
import { emptyForm } from '@/editor/annotations/creation'
|
||||||
|
import { traceVertex } from '@/editor/annotations/creationWork'
|
||||||
import {
|
import {
|
||||||
resetWork,
|
resetWork,
|
||||||
setModePreview,
|
setModePreview,
|
||||||
@@ -160,6 +162,31 @@ describe('the drawing guard on a history jump out of the editor (R-12)', () => {
|
|||||||
expect(api.traverseTo).toHaveBeenCalledWith('list')
|
expect(api.traverseTo).toHaveBeenCalledWith('list')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('during a creation (A12): the jump waits for « Abandonner la création ? », then goes', () => {
|
||||||
|
cleanup()
|
||||||
|
render(
|
||||||
|
<MemoryRouter initialEntries={[path]}>
|
||||||
|
<DrawingOnly />
|
||||||
|
</MemoryRouter>,
|
||||||
|
)
|
||||||
|
traceVertex(
|
||||||
|
{
|
||||||
|
viewId: 'v',
|
||||||
|
frame: null,
|
||||||
|
origin: 'tool',
|
||||||
|
form: emptyForm({ categories: [] } as never),
|
||||||
|
},
|
||||||
|
'zone',
|
||||||
|
[1, 1],
|
||||||
|
)
|
||||||
|
expect(jump().defaultPrevented).toBe(true)
|
||||||
|
expect(useAnnotationWork.getState().question?.work).toBe('creation')
|
||||||
|
expect(api.traverseTo).not.toHaveBeenCalled()
|
||||||
|
act(() => answerDrawing(true))
|
||||||
|
expect(useAnnotationWork.getState().creation).toBeNull()
|
||||||
|
expect(api.traverseTo).toHaveBeenCalledWith('list')
|
||||||
|
})
|
||||||
|
|
||||||
it('with nothing started: the jump is not held and the mode ends', () => {
|
it('with nothing started: the jump is not held and the mode ends', () => {
|
||||||
cleanup()
|
cleanup()
|
||||||
render(
|
render(
|
||||||
|
|||||||
Reference in new issue
Block a user