feat(editor): creation on the drawing then the creation dialog
U2 Task 7 (A2, A4, A5, A7, A12, A15; R-3, R-4, R-12, R-13, R-14). The work store's `creation` owns the new shape, its form, its view and F: a click with the point tool, a closed tracing or a keyboard « Ajouter … » opens « Nouveau point / zone / accès », a modal without a history layer over the right column, mounted beside EditOnly so a read-only flip keeps it (« Créer », « Replacer », « Reprendre » off). A new zone or link is a creation from its first vertex. The ghost takes the form's category colour; the point tool previews under a mouse; the canvas carries data-creating (other markers dimmed, unselectable). « Replacer le point » / « Reprendre le tracé » hide the dialog and keep the form; the strip offers « Revenir aux propriétés », « Retirer le dernier sommet », « Abandonner ». « Créer »: one insert, tool back to « Sélectionner », the new element selected, « Point créé · Défaire », focus on its row. ✕, Échap, « Abandonner » and Back always ask « Abandonner la création ? » (DiscardConfirm inside the dialog; DrawingGuardDialog elsewhere); answerDrawing drops the creation. Undo, its shortcuts and the line's « Défaire » are inactive during a creation. missingFields replaces formProblem (MissingSummary shared with the edit form); the C26 notice has no numbers. CreationPanel, formProblem, withGeometry and the keys required.fields, required.names and create_cancel are gone; GeometryGroup is imported by RepairDialog only. Removed or rewritten assertions: - tab « holds a point at the frame centre »: « Centre x » = 50 -> the ghost circle cx = 50; plus tool back to Sélectionner, « Point créé », one undo step. - tab « refuses a creation without laterality »: the general line « Choisissez la catégorie et la latéralité » -> only « Choisissez une latéralité. » and « À compléter : Latéralité. », focus on it. - tab « applies the geometry group to a pending zone »: removed (A8, no coordinate field) -> « places a triangle at the centre: the ghost shows it, Créer inserts it »; vertex edits after Créer are the e2e keyboard test. - tab C26 « proposes C »: « x = 15, y = 15 » in the notice -> the R-4 text, the notice inside the dialog; cancel test « Centre x » = 0 -> ghost cx = 0. - tab « offers the correction when the core refuses a pending point » (typed cx 98): removed, no typed coordinate is possible; the verdict path stays covered by the C26 click tests and correctionFor units. - tab H5 « a typed radius shows the core issue »: removed (A8); the size refusal is the slider's (Task 4 tests). - tab H6 « a second click moves the pending point »: -> « Replacer le point », then the click moves the ghost, the form kept. - tab H7 « Centre x/y » = 30/50 -> ghost cx/cy. - tab tracing Enter: « x du sommet 3 » -> ghost points; « drops the tracing on Escape » -> Escape asks first (board 32 row 3), Continuer keeps, Abandonner drops; new « Annuler le tracé acts at once ». - keep-alive « a pending creation is kept and focused » and « a tracing … is kept and focused »: the tab now asks first (R-12) -> « Continuer » keeps the tracing / the form, « Abandonner » goes. - sections « its panel takes the focus » -> its dialog's [data-creation-focus] takes it. - no-loss « pending creation with its name » (hidden with the body) -> the dialog stays across the crossing, read-only, Créer off (R-14). - point-edit A5 « Rayon » = 7 / 9 -> ghost r = 7 / 9. - e2e editor-annotations keyboard test « numeric position » (cx field 250) -> UX_TESTS Keyboard: zone added, vertex added and removed, moved by the move mode, validated, saved. The « Fermer le tracé » step runs under expectNoShift again (shortcut removed). - e2e editor-geometry C26: the proposed x, y read from the notice text -> from the overlay's correction circle; the R-4 text checked in the dialog. - e2e editor-deselect « Escape cancels the tracing only » -> Escape asks, « Abandonner » cancels it, the selection kept. - e2e editor-shell-crossing « keeps its tool and its pending creation » (field hidden) -> the dialog stays read-only, Créer off, then editable on widening.
This commit is contained in:
1 parent
2d58da7d01
commit
4d2c64f57f
50 files changed
+3050
-1181
No files matched your search
@@ -207,6 +207,7 @@ describe('an edit on the drawing (U2 Task 5: the numeric group left the panel)',
|
||||
})
|
||||
})
|
||||
|
||||
/** The creation dialog's form (U2 Task 7: no side panel, no coordinate field, A8). */
|
||||
async function fillCreation(user: ReturnType<typeof userEvent.setup>) {
|
||||
const panel = await screen.findByTestId('annotation-creation')
|
||||
await user.type(within(panel).getByLabelText('Nom (FR)'), 'Nuque')
|
||||
@@ -218,6 +219,10 @@ async function fillCreation(user: ReturnType<typeof userEvent.setup>) {
|
||||
return panel
|
||||
}
|
||||
|
||||
/** The ghost of the new shape: its filled shape, drawn by the overlay. */
|
||||
const ghostShape = () =>
|
||||
screen.getByTestId('overlay-ghost').querySelector('circle, polygon')!
|
||||
|
||||
describe('the keyboard creation path', () => {
|
||||
it('holds a point at the frame centre, asks the required fields, then inserts once', async () => {
|
||||
await mount({ text: drawnText() })
|
||||
@@ -228,8 +233,11 @@ describe('the keyboard creation path', () => {
|
||||
).toBeEnabled(),
|
||||
)
|
||||
await user.click(screen.getByRole('button', { name: 'Ajouter un point' }))
|
||||
expect(
|
||||
await screen.findByRole('dialog', { name: 'Nouveau point' }),
|
||||
).toBeInTheDocument()
|
||||
const panel = await fillCreation(user)
|
||||
expect(within(panel).getByLabelText('Centre x')).toHaveValue('50')
|
||||
expect(ghostShape()).toHaveAttribute('cx', '50')
|
||||
expect(within(panel).getByLabelText('Latéralité')).toHaveValue('unpaired')
|
||||
expect(annotations()).toHaveLength(0)
|
||||
await user.click(within(panel).getByRole('button', { name: 'Créer' }))
|
||||
@@ -240,10 +248,16 @@ describe('the keyboard creation path', () => {
|
||||
laterality: 'unpaired',
|
||||
geometry: { type: 'circle', cx: 50, cy: 50 },
|
||||
})
|
||||
// A7: the new point selected (the strip offers its properties).
|
||||
// A7: back to « Sélectionner », the new point selected, « Point créé · Défaire ».
|
||||
expect(
|
||||
await screen.findByRole('button', { name: 'Propriétés' }),
|
||||
).toBeInTheDocument()
|
||||
expect(
|
||||
screen.getByRole('button', { name: 'Sélectionner et déplacer' }),
|
||||
).toHaveAttribute('aria-pressed', 'true')
|
||||
expect(screen.getByTestId('gesture-line')).toHaveTextContent('Point créé')
|
||||
await waitFor(() => expect(screen.queryByRole('dialog')).toBeNull())
|
||||
expect(store.getState().undo).toHaveLength(1)
|
||||
})
|
||||
|
||||
it('refuses a creation without laterality and creates nothing', async () => {
|
||||
@@ -259,13 +273,22 @@ describe('the keyboard creation path', () => {
|
||||
await user.type(within(panel).getByLabelText('Nom (FR)'), 'A')
|
||||
await user.type(within(panel).getByLabelText('Nom (EN)'), 'B')
|
||||
await user.click(within(panel).getByRole('button', { name: 'Créer' }))
|
||||
expect(within(panel).getByRole('alert')).toHaveTextContent(
|
||||
'Choisissez la catégorie et la latéralité',
|
||||
)
|
||||
// R-3, board 33 B: only the missing field is named, under it and in the summary.
|
||||
const alerts = within(panel).getAllByRole('alert')
|
||||
expect(alerts.map((a) => a.textContent)).toEqual([
|
||||
'Choisissez une latéralité.',
|
||||
'À compléter : Latéralité.',
|
||||
])
|
||||
expect(
|
||||
within(panel).getByText('Choisissez une latéralité.'),
|
||||
).toBeInTheDocument()
|
||||
expect(within(panel).queryByText(/Choisissez une catégorie/)).toBeNull()
|
||||
expect(within(panel).queryByText(/Saisissez/)).toBeNull()
|
||||
expect(within(panel).getByLabelText('Latéralité')).toHaveFocus()
|
||||
expect(annotations()).toHaveLength(0)
|
||||
})
|
||||
|
||||
it('applies the geometry group to a pending zone, the core deciding at « Créer »', async () => {
|
||||
it('places a triangle at the centre: the ghost shows it, « Créer » inserts it (A8: no field)', async () => {
|
||||
await mount({ text: drawnText() })
|
||||
const user = userEvent.setup()
|
||||
await waitFor(() =>
|
||||
@@ -275,14 +298,14 @@ describe('the keyboard creation path', () => {
|
||||
)
|
||||
await user.click(screen.getByRole('button', { name: 'Ajouter une zone' }))
|
||||
const panel = await fillCreation(user)
|
||||
const x = within(panel).getByLabelText('x du sommet 1')
|
||||
await user.clear(x)
|
||||
await user.type(x, '500{Enter}')
|
||||
expect(within(panel).getByLabelText('x du sommet 1')).toHaveValue('500')
|
||||
expect(within(panel).queryByLabelText('x du sommet 1')).toBeNull()
|
||||
expect(
|
||||
within(panel).getByText('Zone tracée, 3 sommets'),
|
||||
).toBeInTheDocument()
|
||||
expect(ghostShape().tagName).toBe('polygon')
|
||||
await user.click(within(panel).getByRole('button', { name: 'Créer' }))
|
||||
expect(annotations()).toHaveLength(0)
|
||||
expect(within(panel).getByRole('alert')).toBeInTheDocument()
|
||||
expect(within(panel).getByLabelText('x du sommet 1')).toHaveValue('500')
|
||||
expect(annotations()[0]).toMatchObject({ kind: 'zone' })
|
||||
expect(annotations()[0].geometry).toMatchObject({ type: 'polygon' })
|
||||
})
|
||||
})
|
||||
|
||||
@@ -301,8 +324,12 @@ describe('the point tool and the corrected position (C26)', () => {
|
||||
)
|
||||
const user = await clickCorner()
|
||||
const notice = await screen.findByTestId('correction-notice')
|
||||
// R-4: the notice is in the dialog, without numbers.
|
||||
expect(
|
||||
screen.getByRole('dialog', { name: 'Nouveau point' }),
|
||||
).toContainElement(notice)
|
||||
expect(notice).toHaveTextContent(
|
||||
'Position corrigée proposée : x = 15, y = 15.',
|
||||
"Le point ne tient pas à l'endroit choisi : la position corrigée est proposée sur le dessin.",
|
||||
)
|
||||
expect(screen.getByTestId('overlay-click-cross')).toBeInTheDocument()
|
||||
const panel = await fillCreation(user)
|
||||
@@ -316,7 +343,7 @@ describe('the point tool and the corrected position (C26)', () => {
|
||||
cy: 15,
|
||||
r: 15,
|
||||
})
|
||||
expect(panel).not.toBeInTheDocument()
|
||||
await waitFor(() => expect(panel).not.toBeInTheDocument())
|
||||
expect(screen.queryByTestId('overlay-click-cross')).toBeNull()
|
||||
await screen.findByRole('button', { name: 'Propriétés' })
|
||||
expect(shownCircle()).toHaveAttribute('cx', '15')
|
||||
@@ -332,28 +359,8 @@ describe('the point tool and the corrected position (C26)', () => {
|
||||
await user.click(within(notice).getByRole('button', { name: 'Annuler' }))
|
||||
expect(screen.queryByTestId('correction-notice')).toBeNull()
|
||||
expect(screen.queryByTestId('overlay-click-cross')).toBeNull()
|
||||
const panel = screen.getByTestId('annotation-creation')
|
||||
expect(within(panel).getByLabelText('Centre x')).toHaveValue('0')
|
||||
expect(annotations()).toHaveLength(0)
|
||||
})
|
||||
|
||||
it('offers the correction when the core refuses a pending point', async () => {
|
||||
await mount({ text: drawnText() })
|
||||
const user = userEvent.setup()
|
||||
await waitFor(() =>
|
||||
expect(
|
||||
screen.getByRole('button', { name: 'Ajouter un point' }),
|
||||
).toBeEnabled(),
|
||||
)
|
||||
await user.click(screen.getByRole('button', { name: 'Ajouter un point' }))
|
||||
const panel = await fillCreation(user)
|
||||
const cx = within(panel).getByLabelText('Centre x')
|
||||
await user.clear(cx)
|
||||
await user.type(cx, '98{Enter}')
|
||||
await user.click(within(panel).getByRole('button', { name: 'Créer' }))
|
||||
expect(await screen.findByTestId('correction-notice')).toHaveTextContent(
|
||||
'x = 85',
|
||||
)
|
||||
expect(screen.getByTestId('annotation-creation')).toBeInTheDocument()
|
||||
expect(ghostShape()).toHaveAttribute('cx', '0')
|
||||
expect(annotations()).toHaveLength(0)
|
||||
})
|
||||
|
||||
@@ -590,8 +597,11 @@ describe('tracing a zone or a link', () => {
|
||||
screen.getByRole('button', { name: 'Fermer le tracé' }),
|
||||
).toBeEnabled()
|
||||
fireEvent.keyDown(screen.getByTestId('annotation-canvas'), { key: 'Enter' })
|
||||
expect(
|
||||
await screen.findByRole('dialog', { name: 'Nouvelle zone' }),
|
||||
).toBeInTheDocument()
|
||||
const panel = await fillCreation(user)
|
||||
expect(within(panel).getByLabelText('x du sommet 3')).toHaveValue('50')
|
||||
expect(ghostShape()).toHaveAttribute('points', triangle.join(' '))
|
||||
await user.click(within(panel).getByRole('button', { name: 'Créer' }))
|
||||
expect(annotations()[0]).toMatchObject({
|
||||
kind: 'zone',
|
||||
@@ -599,21 +609,48 @@ describe('tracing a zone or a link', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('drops the tracing on Escape with nothing created', async () => {
|
||||
it('Escape on a tracing asks first (board 32 row 3); « Abandonner » drops it', async () => {
|
||||
await mount({ text: drawnText() })
|
||||
await waitFor(() =>
|
||||
expect(screen.getByRole('button', { name: 'Zone' })).toBeEnabled(),
|
||||
)
|
||||
await userEvent.setup().click(screen.getByRole('button', { name: 'Zone' }))
|
||||
const user = userEvent.setup()
|
||||
await user.click(screen.getByRole('button', { name: 'Zone' }))
|
||||
clickAt(20, 20)
|
||||
expect(screen.getByText('1 sommet posé')).toBeInTheDocument()
|
||||
fireEvent.keyDown(screen.getByTestId('annotation-canvas'), {
|
||||
key: 'Escape',
|
||||
})
|
||||
const ask = await screen.findByRole('dialog', {
|
||||
name: 'Abandonner la création ?',
|
||||
})
|
||||
await user.click(within(ask).getByRole('button', { name: 'Continuer' }))
|
||||
expect(screen.getByText('1 sommet posé')).toBeInTheDocument()
|
||||
fireEvent.keyDown(screen.getByTestId('annotation-canvas'), {
|
||||
key: 'Escape',
|
||||
})
|
||||
await user.click(
|
||||
within(
|
||||
await screen.findByRole('dialog', { name: 'Abandonner la création ?' }),
|
||||
).getByRole('button', { name: 'Abandonner' }),
|
||||
)
|
||||
expect(screen.queryByText('1 sommet posé')).toBeNull()
|
||||
expect(annotations()).toHaveLength(0)
|
||||
})
|
||||
|
||||
it('« Annuler le tracé » is an explicit cancel: it acts at once', async () => {
|
||||
await mount({ text: drawnText() })
|
||||
await waitFor(() =>
|
||||
expect(screen.getByRole('button', { name: 'Zone' })).toBeEnabled(),
|
||||
)
|
||||
const user = userEvent.setup()
|
||||
await user.click(screen.getByRole('button', { name: 'Zone' }))
|
||||
clickAt(20, 20)
|
||||
await user.click(screen.getByRole('button', { name: 'Annuler le tracé' }))
|
||||
expect(screen.queryByRole('dialog')).toBeNull()
|
||||
expect(screen.queryByText('1 sommet posé')).toBeNull()
|
||||
})
|
||||
|
||||
it('closes on a click at the first vertex once three are placed', async () => {
|
||||
await mount({ text: drawnText() })
|
||||
await waitFor(() =>
|
||||
@@ -792,42 +829,17 @@ describe('a second click with the point tool (H6)', () => {
|
||||
await user.click(screen.getByRole('button', { name: 'Point' }))
|
||||
pressAt(screen.getByTestId('annotation-canvas'), 50, 50)
|
||||
const panel = await fillCreation(user)
|
||||
// « Replacer le point »: the dialog hides, the next click moves the ghost and shows it.
|
||||
await user.click(
|
||||
within(panel).getByRole('button', { name: 'Replacer le point' }),
|
||||
)
|
||||
await waitFor(() => expect(screen.queryByRole('dialog')).toBeNull())
|
||||
expect(ghostShape()).toHaveAttribute('cx', '50')
|
||||
pressAt(screen.getByTestId('annotation-canvas'), 60, 40)
|
||||
await waitFor(() =>
|
||||
expect(within(panel).getByLabelText('Centre x')).toHaveValue('60'),
|
||||
)
|
||||
expect(within(panel).getByLabelText('Nom (FR)')).toHaveValue('Nuque')
|
||||
expect(within(panel).getByLabelText('Latéralité')).toHaveValue('unpaired')
|
||||
expect(screen.getByTestId('annotation-creation')).toBe(panel)
|
||||
})
|
||||
})
|
||||
|
||||
describe('a typed radius (H5)', () => {
|
||||
it('shows the core issue, not a corrected position', async () => {
|
||||
const drawing = svgBytes('0 0 5000 5000')
|
||||
sb.getSheetVersion.mockResolvedValue({
|
||||
...versionAnswer(drawnText(), 3),
|
||||
drawings: [{ asset_id: ASSET, sha256: drawing.sha256 }],
|
||||
} as never)
|
||||
sb.downloadSheetDrawing.mockResolvedValue(drawing.bytes)
|
||||
store.getState().open(VERSION, USER, { canEdit: true })
|
||||
await waitFor(() => expect(store.getState().status).toBe('ready'))
|
||||
render(<AnnotationsTab {...props} />)
|
||||
await waitFor(() =>
|
||||
expect(
|
||||
screen.getByRole('button', { name: 'Ajouter un point' }),
|
||||
).toBeEnabled(),
|
||||
)
|
||||
const user = userEvent.setup()
|
||||
await user.click(screen.getByRole('button', { name: 'Ajouter un point' }))
|
||||
const panel = await fillCreation(user)
|
||||
const r = within(panel).getByLabelText('Rayon')
|
||||
await user.clear(r)
|
||||
await user.type(r, '1{Enter}')
|
||||
await user.click(within(panel).getByRole('button', { name: 'Créer' }))
|
||||
expect(screen.queryByTestId('correction-notice')).toBeNull()
|
||||
expect(within(panel).getByRole('alert')).toBeInTheDocument()
|
||||
expect(annotations()).toHaveLength(0)
|
||||
const again = await screen.findByTestId('annotation-creation')
|
||||
expect(ghostShape()).toHaveAttribute('cx', '60')
|
||||
expect(within(again).getByLabelText('Nom (FR)')).toHaveValue('Nuque')
|
||||
expect(within(again).getByLabelText('Latéralité')).toHaveValue('unpaired')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -853,9 +865,9 @@ describe('the frame follows the view (H7)', () => {
|
||||
).toBeEnabled(),
|
||||
)
|
||||
await user.click(screen.getByRole('button', { name: 'Ajouter un point' }))
|
||||
const panel = await screen.findByTestId('annotation-creation')
|
||||
expect(within(panel).getByLabelText('Centre x')).toHaveValue('30')
|
||||
expect(within(panel).getByLabelText('Centre y')).toHaveValue('50')
|
||||
await screen.findByTestId('annotation-creation')
|
||||
expect(ghostShape()).toHaveAttribute('cx', '30')
|
||||
expect(ghostShape()).toHaveAttribute('cy', '50')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1870,6 +1882,7 @@ describe('the strip', () => {
|
||||
const { result } = renderHook(() =>
|
||||
usePlacement({
|
||||
ui: { ...initialUi, hint: 'Refusé' },
|
||||
tracing: null,
|
||||
dispatch,
|
||||
frame: null,
|
||||
doc,
|
||||
|
||||
Reference in new issue
Block a user