fix(editor): slider while replacing, announced drop, review minors

Task 7 fix round 1 (review task-7-review.md).
- Important 1: « Taille » shows beside « Revenir aux propriétés » while
  a point is replaced (still hidden under the modal dialog); it feeds
  the hover preview and the re-placed point (R-10).
- Important 2: a creation whose view leaves the document is dropped
  and said, « Création abandonnée : la fiche a changé. » (dropped:
  'creation', read by useDroppedNotice).
- Minor 3: DrawingGuardDialog leaves a creation question to the
  creation dialog only while that dialog is really on screen
  (creationShown, set by the dialog).
- Minor 7: the dialog's long className strings split into constants.
- Minor 8: dead TOOL_OF removed; trace_start is a redraw's only.

Tests added (no assertion removed): slider while replacing (unit,
RED then GREEN; e2e under expectNoShift at three widths, last strip
command inside the strip); view removed during a creation (RED then
GREEN); question shown by the workspace when the dialog is not on
screen (RED then GREEN); « Abandonner » while read-only; R-13 with a
restored copy during a started move; leaving the route resets the
work (fails with the session reset removed). The unit Back test's
comment is corrected: it does pin the modal branch.
This commit is contained in:
bchanot committed 2026-11-18 00:06:16 +01:00
1 parent fe333c2bbd
commit 837ec9f436
14 files changed
+315 -29

No files matched your search

@@ -12,7 +12,11 @@ import {
import userEvent from '@testing-library/user-event'
import HistoryButtons from '@/components/editor/HistoryButtons'
import { useUndoShortcuts } from '@/editor/useUndoShortcuts'
import { useAnnotationWork } from '@/editor/annotations/workStore'
import { resetWork, useAnnotationWork } from '@/editor/annotations/workStore'
import DrawingGuardDialog from '@/components/editor/annotations/DrawingGuardDialog'
import { emptyForm } from '@/editor/annotations/creation'
import { placePending } from '@/editor/annotations/creationWork'
import { guardDrawing } from '@/editor/annotations/drawingGuard'
import { useLocaleStore } from '@/state/localeStore'
import { drawnText, insert, point } from '../helpers/editorFixtures'
import { LayeredTab } from '../helpers/annotationLayer'
@@ -426,3 +430,109 @@ describe('the mode flip (R-14, Review Focus 3)', () => {
expect(annotations()).toHaveLength(1)
})
})
describe('fix round 1: the size while a point is replaced (board 02, R-10)', () => {
const sized = () =>
[
point('a', 20, 20, 7),
point('b', 40, 40, 7),
point('c', 60, 60, 9),
].reduce((text, p) => insert(text, p), drawnText())
const slider = () =>
within(screen.getByTestId('size-slider')).getByRole('slider')
it('hidden under the dialog, shown beside « Revenir aux propriétés »; it sizes the re-placed point', async () => {
const user = await mount(sized())
const shown = await placePoint(user)
const strip = screen.getByTestId('edit-strip')
// The modal makes the strip inert: no slider while the dialog shows.
expect(within(strip).queryByTestId('size-slider')).toBeNull()
await user.click(
within(shown).getByRole('button', { name: 'Replacer le point' }),
)
await waitFor(() => expect(screen.queryByRole('dialog')).toBeNull())
expect(
within(strip).getByRole('button', { name: 'Revenir aux propriétés' }),
).toBeInTheDocument()
expect(slider()).toHaveValue('7')
fireEvent.change(slider(), { target: { value: '9' } })
fireEvent.pointerMove(canvas(), {
clientX: 30,
clientY: 70,
pointerType: 'mouse',
})
expect(
screen.getByTestId('overlay-point-preview').querySelector('circle'),
).toHaveAttribute('r', '9')
pressAt(canvas(), 30, 70)
await dialog()
expect(ghost().querySelector('circle')).toHaveAttribute('r', '9')
})
})
describe('fix round 1: a creation whose view leaves the document (no silent loss)', () => {
it('a document change removes the view: the creation goes and the line says so', async () => {
const user = await mount(withDetail())
await user.click(screen.getByRole('button', { name: 'Tête' }))
await waitFor(() =>
expect(
screen.getByRole('button', { name: 'Ajouter une zone' }),
).toBeEnabled(),
)
await user.click(screen.getByRole('button', { name: 'Ajouter une zone' }))
const shown = await dialog('Nouvelle zone')
await user.type(within(shown).getByLabelText('Nom (FR)'), 'Perdue')
act(
() =>
void store
.getState()
.commit({ op: 'remove', key: { kind: 'view', id: 'view-det' } }),
)
await waitFor(() => expect(creation()).toBeNull())
expect(
await screen.findByText('Création abandonnée : la fiche a changé.'),
).toBeInTheDocument()
await waitFor(() => expect(screen.queryByRole('dialog')).toBeNull())
})
})
describe('fix round 1: the question is never hidden behind a dialog not shown', () => {
afterEach(() => act(() => resetWork()))
it('a creation whose dialog is not on screen (its place hidden): the workspace asks', () => {
render(<DrawingGuardDialog />)
act(() =>
placePending(
{
viewId: 'view-main',
frame: null,
origin: 'tool',
form: emptyForm(JSON.parse(drawnText())),
},
{ kind: 'point', geometry: { type: 'circle', cx: 5, cy: 5, r: 2 } },
),
)
act(() => void guardDrawing(() => undefined))
expect(
screen.getByRole('dialog', { name: 'Abandonner la création ?' }),
).toBeInTheDocument()
})
})
describe('fix round 1: « Abandonner » while read-only (R-14)', () => {
it('asks, then drops the creation', async () => {
const user = await mount()
await placePoint(user)
view.rerender(<Page readOnly />)
const kept = screen.getByRole('dialog', { name: 'Nouveau point' })
await user.click(within(kept).getByRole('button', { name: 'Abandonner' }))
expect(creation()).not.toBeNull()
const ask = within(kept).getByRole('group', {
name: 'Abandonner la création ?',
})
await user.click(within(ask).getByRole('button', { name: 'Abandonner' }))
expect(creation()).toBeNull()
await waitFor(() => expect(screen.queryByRole('dialog')).toBeNull())
expect(annotations()).toHaveLength(1)
})
})