fix(editor): resumed shape names and minor review fixes

- French fallback names: « cette nouvelle zone », « ce nouvel accès »
  (controller ruling: « Sommets de ce nouvel accès »); doc updated.
- useZoneHandle back to 5 locals.
- dropPending clears the strip hint as a kept stored change does.
- Tests: the chosen vertex cleared by finishCreation itself (document
  unchanged) and by a view change through the guard; both fail
  without their clearing.

Changed assertions, editor-creation-dialog.test.tsx:
- « Sommets de la nouvelle zone », « Sommet 1 de la nouvelle zone »
  -> « … de cette nouvelle zone » (ruling)
- « Sommets de le nouvel accès » -> « Sommets de ce nouvel accès »
- chosen null after « Créer » (cleared by the document change, not
  discriminating) -> « the chosen vertex ends with a finished
  creation, the document unchanged »
This commit is contained in:
bchanot committed 2026-11-19 09:49:27 +01:00
1 parent a5896710e5
commit c01c6f3145
5 files changed
+49 -22

No files matched your search

@@ -20,7 +20,11 @@ import {
} from '@/editor/annotations/workStore'
import DrawingGuardDialog from '@/components/editor/annotations/DrawingGuardDialog'
import { emptyForm } from '@/editor/annotations/creation'
import { dropCreation, placePending } from '@/editor/annotations/creationWork'
import {
dropCreation,
finishCreation,
placePending,
} from '@/editor/annotations/creationWork'
import { guardDrawing } from '@/editor/annotations/drawingGuard'
import { useLocaleStore } from '@/state/localeStore'
import { drawnText, insert, point } from '../helpers/editorFixtures'
@@ -259,8 +263,8 @@ describe('« Reprendre le tracé » edits the closed shape with its handles (boa
const strip = () => screen.getByTestId('edit-strip')
/** A traced square, its dialog, the name typed (unless empty), then « Reprendre le tracé ». */
async function resumed(name = 'Tibia', points = SQUARE) {
const user = await mount()
async function resumed(name = 'Tibia', points = SQUARE, text?: string) {
const user = await mount(text)
await user.click(screen.getByRole('button', { name: 'Zone' }))
points.forEach(([x, y]) => pressAt(canvas(), x, y))
await user.click(screen.getByRole('button', { name: 'Fermer le tracé' }))
@@ -404,7 +408,6 @@ describe('« Reprendre le tracé » edits the closed shape with its handles (boa
type: 'polygon',
points: [[20, 20], [50, 20], ...SQUARE.slice(1)],
})
expect(useAnnotationWork.getState().chosen).toBeNull()
})
it('the chosen vertex ends with the creation when it is dropped', async () => {
@@ -415,13 +418,37 @@ describe('« Reprendre le tracé » edits the closed shape with its handles (boa
expect(useAnnotationWork.getState().chosen).toBeNull()
})
it('names: « la nouvelle zone » while the name is empty; English: « the new zone »', async () => {
it('the chosen vertex ends with a finished creation, the document unchanged', async () => {
await resumed()
clickHandle('Sommet 2 de Tibia', [80, 20])
const text = store.getState().documentText
// No document change here: only finishCreation itself can clear the choice.
act(() => finishCreation('anno-new', 'zone'))
expect(store.getState().documentText).toBe(text)
expect(useAnnotationWork.getState().chosen).toBeNull()
})
it('the chosen vertex ends when a view change drops the creation', async () => {
const user = await resumed('Tibia', SQUARE, withDetail())
clickHandle('Sommet 2 de Tibia', [80, 20])
expect(useAnnotationWork.getState().chosen).not.toBeNull()
await user.click(screen.getByRole('button', { name: 'Tête' }))
await user.click(
within(
await screen.findByRole('dialog', { name: 'Abandonner la création ?' }),
).getByRole('button', { name: 'Abandonner' }),
)
expect(creation()).toBeNull()
expect(useAnnotationWork.getState().chosen).toBeNull()
})
it('names: « cette nouvelle zone » while unnamed; English: « the new zone »', async () => {
await resumed('')
expect(
screen.getByRole('group', { name: 'Sommets de la nouvelle zone' }),
screen.getByRole('group', { name: 'Sommets de cette nouvelle zone' }),
).toBeInTheDocument()
expect(
screen.getByRole('button', { name: 'Sommet 1 de la nouvelle zone' }),
screen.getByRole('button', { name: 'Sommet 1 de cette nouvelle zone' }),
).toBeInTheDocument()
act(() => useLocaleStore.setState({ locale: 'en' }))
expect(
@@ -429,7 +456,7 @@ describe('« Reprendre le tracé » edits the closed shape with its handles (boa
).toBeInTheDocument()
})
it('a keyboard link resumes with handles, « le nouvel accès » while unnamed', async () => {
it('a keyboard link resumes with handles, « ce nouvel accès » while unnamed', async () => {
const user = await mount(withDetail())
await user.click(screen.getByRole('button', { name: 'Ajouter un accès' }))
const shown = await dialog('Nouvel accès')
@@ -439,7 +466,7 @@ describe('« Reprendre le tracé » edits the closed shape with its handles (boa
await waitFor(() => expect(screen.queryByRole('dialog')).toBeNull())
expect(strip()).toHaveTextContent('Nouvel accès')
expect(
screen.getByRole('group', { name: 'Sommets de le nouvel accès' }),
screen.getByRole('group', { name: 'Sommets de ce nouvel accès' }),
).toBeInTheDocument()
expect(creation()).toMatchObject({ closed: true, dialog: false })
})