fix(editor): no silent move loss, no empty commit, focus kept
- « Toutes les annotations » in the properties panel asks the drawing
guard before it drops a started move (R-12); tests also cover a tool
and « Ajouter un point ».
- A keyboard series back on its place, or a slider pinned at its stop,
commits nothing.
- Escape that deselects from the handle or the slider moves the focus to
the row (or the drawing) instead of losing it.
- A link circle keeps its handle, named « Accès {nom} », with no slider
and no move mode (no label for it in REVUE).
- The move-mode drop notice waits until the body is shown (R-14).
- No layout shift: the strip's lead has a fixed width, the commands and
the message pill get a new box per set or message.
- Doc: hit shapes use pointer-events auto; the fine « − » bubble is
board 05's size.
- Tests: R-14 flip, A5 through the Point tool click, the repair e2e
wrapped in expectNoShift.
This commit is contained in:
1 parent
91e94952f0
commit
44de465c6d
10 files changed
+240
-35
No files matched your search
@@ -26,6 +26,7 @@ import {
|
||||
USER,
|
||||
VERSION,
|
||||
openReady,
|
||||
pressAt,
|
||||
resetStore,
|
||||
sb,
|
||||
store,
|
||||
@@ -88,22 +89,53 @@ afterEach(() => {
|
||||
resetWork()
|
||||
})
|
||||
|
||||
/** A link circle on the main view, opening the detail view `view-det` it adds first. */
|
||||
const withLink = (text: string, id: string) => {
|
||||
const withView = insert(text, {
|
||||
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',
|
||||
},
|
||||
})
|
||||
const value = {
|
||||
id,
|
||||
view_id: 'view-main',
|
||||
category_id: 'cat-a',
|
||||
laterality: 'unpaired',
|
||||
geometry: { type: 'circle', cx: 70, cy: 70, r: 6 },
|
||||
review_status: 'to_confirm',
|
||||
color: null,
|
||||
kind: 'detail_trigger',
|
||||
name: null,
|
||||
opens_view_id: 'view-det',
|
||||
} as Annotation
|
||||
return insert(withView, { kind: 'annotation', value })
|
||||
}
|
||||
|
||||
const withPoints = (...points: ReturnType<typeof point>[]) =>
|
||||
points.reduce((text, p) => insert(text, p), drawnText())
|
||||
|
||||
const tab = (readOnly = false) => (
|
||||
// The Escape listener acts inside the editor workspace only.
|
||||
<div data-editor-workspace>
|
||||
<AnnotationsTab {...props} readOnly={readOnly} />
|
||||
</div>
|
||||
)
|
||||
|
||||
async function mount(text: string) {
|
||||
await openReady({ text })
|
||||
// The Escape listener acts inside the editor workspace only.
|
||||
render(
|
||||
<div data-editor-workspace>
|
||||
<AnnotationsTab {...props} />
|
||||
</div>,
|
||||
)
|
||||
const view = render(tab())
|
||||
await waitFor(() =>
|
||||
expect(
|
||||
screen.getByTestId('annotation-canvas-drawing').querySelector('svg'),
|
||||
).not.toBeNull(),
|
||||
)
|
||||
return view
|
||||
}
|
||||
|
||||
/** The same tab on a 4000 × 3000 drawing: the core gives the main view a minimum radius. */
|
||||
@@ -435,3 +467,122 @@ describe('A5: a new point takes the most used size', () => {
|
||||
expect(slider()).toHaveValue('9')
|
||||
})
|
||||
})
|
||||
|
||||
describe('review fixes: no silent loss, no empty commit, no lost focus', () => {
|
||||
const two = () => withPoints(point('a', 50, 50, 5), point('b', 20, 20, 5))
|
||||
const started = async () => {
|
||||
const view = await mount(two())
|
||||
await select()
|
||||
await userEvent.setup().click(moveButton())
|
||||
fireEvent.click(arrow('la droite'))
|
||||
return view
|
||||
}
|
||||
const question = () => useAnnotationWork.getState().question?.work ?? null
|
||||
|
||||
it('« Tout afficher », a tool and « Ajouter un point » ask before a started move goes', async () => {
|
||||
await started()
|
||||
const panel = screen.getByTestId('annotation-properties')
|
||||
fireEvent.click(
|
||||
within(panel).getByRole('button', { name: 'Toutes les annotations' }),
|
||||
)
|
||||
expect(question()).toBe('move')
|
||||
expect(useAnnotationWork.getState().mode?.started).toBe(true)
|
||||
expect(screen.getByTestId('annotation-properties')).toBeInTheDocument()
|
||||
act(() => useAnnotationWork.setState({ question: null }))
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Point' }))
|
||||
expect(question()).toBe('move')
|
||||
expect(screen.getByTestId('move-mode-bar')).toBeInTheDocument()
|
||||
act(() => useAnnotationWork.setState({ question: null }))
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Ajouter un point' }))
|
||||
expect(question()).toBe('move')
|
||||
expect(screen.queryByTestId('annotation-creation')).toBeNull()
|
||||
})
|
||||
|
||||
it('an unstarted mode ends at once on a tool change', async () => {
|
||||
await mount(two())
|
||||
await select()
|
||||
await userEvent.setup().click(moveButton())
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Point' }))
|
||||
expect(question()).toBeNull()
|
||||
expect(useAnnotationWork.getState().mode).toBeNull()
|
||||
})
|
||||
|
||||
it('a series back on its place and a slider pinned at its stop commit nothing', async () => {
|
||||
await mount(two())
|
||||
await select()
|
||||
const before = depth()
|
||||
fireEvent.keyDown(handle(), { key: 'ArrowRight' })
|
||||
fireEvent.keyDown(handle(), { key: 'ArrowLeft' })
|
||||
fireEvent.keyDown(handle(), { key: 'Enter' })
|
||||
fireEvent.keyDown(slider(), { key: 'PageUp' })
|
||||
fireEvent.blur(slider())
|
||||
expect(depth()).toBe(before)
|
||||
expect(message()).not.toHaveTextContent('Défaire')
|
||||
})
|
||||
|
||||
it('Escape that deselects from the handle or the slider keeps the focus on the page', async () => {
|
||||
await mount(two())
|
||||
await select()
|
||||
handle().focus()
|
||||
fireEvent.keyDown(handle(), { key: 'Escape' })
|
||||
expect(screen.queryByTestId('annotation-properties')).toBeNull()
|
||||
expect(document.activeElement).not.toBe(document.body)
|
||||
await select()
|
||||
slider().focus()
|
||||
fireEvent.keyDown(slider(), { key: 'Escape' })
|
||||
expect(screen.queryByTestId('annotation-properties')).toBeNull()
|
||||
expect(document.activeElement).not.toBe(document.body)
|
||||
})
|
||||
|
||||
it('R-14: a read-only flip suspends a started mode; it resumes and commits after', async () => {
|
||||
const view = await started()
|
||||
const before = depth()
|
||||
view.rerender(tab(true))
|
||||
expect(useAnnotationWork.getState().mode?.started).toBe(true)
|
||||
view.rerender(tab(false))
|
||||
expect(screen.getByTestId('move-mode-bar')).toBeInTheDocument()
|
||||
fireEvent.click(
|
||||
within(bar()).getByRole('button', { name: 'Valider la position' }),
|
||||
)
|
||||
expect(geometryOf('a')).toMatchObject({ cx: 50.5 })
|
||||
expect(depth()).toBe(before + 1)
|
||||
})
|
||||
|
||||
it('a link circle keeps its handle (« Accès … ») but gets no size and no move mode', async () => {
|
||||
await mount(withLink(two(), 'l'))
|
||||
await select(2)
|
||||
expect(screen.getByTestId('point-handle')).toHaveAccessibleName(/^Accès /)
|
||||
expect(screen.queryByTestId('size-slider')).toBeNull()
|
||||
expect(
|
||||
screen.queryByRole('button', { name: 'Déplacer le point' }),
|
||||
).toBeNull()
|
||||
})
|
||||
})
|
||||
|
||||
describe('A5 through the Point tool click', () => {
|
||||
const sized = () =>
|
||||
withPoints(
|
||||
point('a', 20, 20, 7),
|
||||
point('b', 40, 40, 7),
|
||||
point('c', 60, 60, 9),
|
||||
)
|
||||
|
||||
it('a click places the point at the most used size, or at the size the slider chose', async () => {
|
||||
await mount(sized())
|
||||
const user = userEvent.setup()
|
||||
await user.click(screen.getByRole('button', { name: 'Point' }))
|
||||
pressAt(screen.getByTestId('annotation-canvas'), 50, 80)
|
||||
const panel = await screen.findByTestId('annotation-creation')
|
||||
expect(within(panel).getByLabelText('Rayon')).toHaveValue('7')
|
||||
})
|
||||
|
||||
it('a size chosen on the slider before the click feeds it', async () => {
|
||||
await mount(sized())
|
||||
const user = userEvent.setup()
|
||||
await user.click(screen.getByRole('button', { name: 'Point' }))
|
||||
fireEvent.change(slider(), { target: { value: '9' } })
|
||||
pressAt(screen.getByTestId('annotation-canvas'), 50, 80)
|
||||
const panel = await screen.findByTestId('annotation-creation')
|
||||
expect(within(panel).getByLabelText('Rayon')).toHaveValue('9')
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user