diff --git a/apps/app/tests/unit/editor-add-buttons.test.tsx b/apps/app/tests/unit/editor-add-buttons.test.tsx index a5e2a7f8..d69845d8 100644 --- a/apps/app/tests/unit/editor-add-buttons.test.tsx +++ b/apps/app/tests/unit/editor-add-buttons.test.tsx @@ -237,6 +237,37 @@ describe('the keyboard keeps the centre path (C7)', () => { }) }) +describe('a keyboard point re-placed by pointer', () => { + it('keeps its keyboard origin: abandoning focuses « Ajouter un point »', async () => { + const user = await mount() + await addByKeyboard(user, add('un point')) + const shown = await dialog('Nouveau point') + await user.click( + within(shown).getByRole('button', { name: 'Replacer le point' }), + ) + await waitFor(noDialog) + pressAt(canvas(), 60, 60) + await dialog('Nouveau point') + expect(ghost()).toHaveAttribute('cx', '60') + await user.click( + within(screen.getByTestId('annotation-creation')).getByRole('button', { + name: 'Replacer le point', + }), + ) + await waitFor(noDialog) + await user.click( + within(screen.getByTestId('edit-strip')).getByRole('button', { + name: 'Abandonner', + }), + ) + const ask = await screen.findByRole('dialog', { + name: 'Abandonner la création ?', + }) + await user.click(within(ask).getByRole('button', { name: 'Abandonner' })) + await waitFor(() => expect(add('un point')).toHaveFocus()) + }) +}) + describe('the screen-reader path', () => { it('announces the armed tool, then Enter in the drawing places at the centre', async () => { const user = await mount() @@ -271,6 +302,15 @@ describe('the screen-reader path', () => { noDialog() expect(useAnnotationWork.getState().creation).toBeNull() }) + + it('with a tool armed, Shift+Enter on the drawing creates nothing', async () => { + const user = await mount() + await user.click(add('un point')) + canvas().focus() + await user.keyboard('{Shift>}{Enter}{/Shift}') + noDialog() + expect(useAnnotationWork.getState().creation).toBeNull() + }) }) describe('a redraw lends the zone tool', () => {