test(tests): centre-path add presses go through the keyboard (C7)
This commit is contained in:
1 parent
c469b474cc
commit
0acf8bc22e
7 files changed
+75
-15
No files matched your search
@@ -1,5 +1,6 @@
|
||||
import { expect, vi } from 'vitest'
|
||||
import { fireEvent } from '@testing-library/react'
|
||||
import type { UserEvent } from '@testing-library/user-event'
|
||||
import type { EditCommand } from '@faunosteo/core-wasm/types'
|
||||
import * as supabase from '@faunosteo/supabase'
|
||||
import { useEditorStore } from '@/editor/state/editorStore'
|
||||
@@ -111,3 +112,9 @@ export function pressAt(el: Element, x = 0, y = 0): void {
|
||||
fireEvent.pointerDown(el, init)
|
||||
fireEvent.pointerUp(el, { ...init, buttons: 0 })
|
||||
}
|
||||
|
||||
/** C7: « Ajouter … » by keyboard (Enter), the shape at the centre with its dialog at once. */
|
||||
export async function addByKeyboard(user: UserEvent, button: HTMLElement) {
|
||||
button.focus()
|
||||
await user.keyboard('{Enter}')
|
||||
}
|
||||
@@ -38,6 +38,7 @@ import {
|
||||
sb,
|
||||
store,
|
||||
versionAnswer,
|
||||
addByKeyboard,
|
||||
} from '../helpers/editorHarness'
|
||||
|
||||
vi.mock('@/lib/supabase', () => ({ getSupabaseClient: () => ({}) }))
|
||||
@@ -232,7 +233,10 @@ describe('the keyboard creation path', () => {
|
||||
screen.getByRole('button', { name: 'Ajouter un point' }),
|
||||
).toBeEnabled(),
|
||||
)
|
||||
await user.click(screen.getByRole('button', { name: 'Ajouter un point' }))
|
||||
await addByKeyboard(
|
||||
user,
|
||||
screen.getByRole('button', { name: 'Ajouter un point' }),
|
||||
)
|
||||
expect(
|
||||
await screen.findByRole('dialog', { name: 'Nouveau point' }),
|
||||
).toBeInTheDocument()
|
||||
@@ -268,7 +272,10 @@ describe('the keyboard creation path', () => {
|
||||
screen.getByRole('button', { name: 'Ajouter une zone' }),
|
||||
).toBeEnabled(),
|
||||
)
|
||||
await user.click(screen.getByRole('button', { name: 'Ajouter une zone' }))
|
||||
await addByKeyboard(
|
||||
user,
|
||||
screen.getByRole('button', { name: 'Ajouter une zone' }),
|
||||
)
|
||||
const panel = await screen.findByTestId('annotation-creation')
|
||||
await user.type(within(panel).getByLabelText('Nom (FR)'), 'A')
|
||||
await user.type(within(panel).getByLabelText('Nom (EN)'), 'B')
|
||||
@@ -296,7 +303,10 @@ describe('the keyboard creation path', () => {
|
||||
screen.getByRole('button', { name: 'Ajouter une zone' }),
|
||||
).toBeEnabled(),
|
||||
)
|
||||
await user.click(screen.getByRole('button', { name: 'Ajouter une zone' }))
|
||||
await addByKeyboard(
|
||||
user,
|
||||
screen.getByRole('button', { name: 'Ajouter une zone' }),
|
||||
)
|
||||
const panel = await fillCreation(user)
|
||||
expect(within(panel).queryByLabelText('x du sommet 1')).toBeNull()
|
||||
expect(
|
||||
@@ -681,7 +691,10 @@ describe('tracing a zone or a link', () => {
|
||||
screen.getByRole('button', { name: 'Accès à une vue détaillée' }),
|
||||
).toBeEnabled(),
|
||||
)
|
||||
await user.click(screen.getByRole('button', { name: 'Ajouter un accès' }))
|
||||
await addByKeyboard(
|
||||
user,
|
||||
screen.getByRole('button', { name: 'Ajouter un accès' }),
|
||||
)
|
||||
const panel = await fillCreation(user)
|
||||
const opens = within(panel).getByLabelText('Vue ouverte')
|
||||
expect(
|
||||
@@ -864,7 +877,10 @@ describe('the frame follows the view (H7)', () => {
|
||||
screen.getByRole('button', { name: 'Ajouter un point' }),
|
||||
).toBeEnabled(),
|
||||
)
|
||||
await user.click(screen.getByRole('button', { name: 'Ajouter un point' }))
|
||||
await addByKeyboard(
|
||||
user,
|
||||
screen.getByRole('button', { name: 'Ajouter un point' }),
|
||||
)
|
||||
await screen.findByTestId('annotation-creation')
|
||||
expect(ghostShape()).toHaveAttribute('cx', '30')
|
||||
expect(ghostShape()).toHaveAttribute('cy', '50')
|
||||
@@ -1350,7 +1366,10 @@ describe('a tap on the drawing (D6b)', () => {
|
||||
screen.getByRole('button', { name: 'Ajouter un point' }),
|
||||
).toBeEnabled(),
|
||||
)
|
||||
await user.click(screen.getByRole('button', { name: 'Ajouter un point' }))
|
||||
await addByKeyboard(
|
||||
user,
|
||||
screen.getByRole('button', { name: 'Ajouter un point' }),
|
||||
)
|
||||
const panel = await screen.findByTestId('annotation-creation')
|
||||
await user.type(within(panel).getByLabelText('Nom (FR)'), 'Nuque')
|
||||
tap(rect())
|
||||
|
||||
@@ -29,7 +29,13 @@ import { guardDrawing } from '@/editor/annotations/drawingGuard'
|
||||
import { useLocaleStore } from '@/state/localeStore'
|
||||
import { drawnText, insert, point } from '../helpers/editorFixtures'
|
||||
import { LayeredTab } from '../helpers/annotationLayer'
|
||||
import { openReady, pressAt, resetStore, store } from '../helpers/editorHarness'
|
||||
import {
|
||||
addByKeyboard,
|
||||
openReady,
|
||||
pressAt,
|
||||
resetStore,
|
||||
store,
|
||||
} from '../helpers/editorHarness'
|
||||
|
||||
vi.mock('@/lib/supabase', () => ({ getSupabaseClient: () => ({}) }))
|
||||
vi.mock('@faunosteo/supabase', async (orig) => ({
|
||||
@@ -167,7 +173,10 @@ describe('the creation dialog asks before leaving, always (A12)', () => {
|
||||
|
||||
it('a keyboard creation abandoned gives the focus back to its « Ajouter … » button', async () => {
|
||||
const user = await mount()
|
||||
await user.click(screen.getByRole('button', { name: 'Ajouter une zone' }))
|
||||
await addByKeyboard(
|
||||
user,
|
||||
screen.getByRole('button', { name: 'Ajouter une zone' }),
|
||||
)
|
||||
const shown = await dialog('Nouvelle zone')
|
||||
await user.click(within(shown).getByRole('button', { name: 'Abandonner' }))
|
||||
await user.click(
|
||||
@@ -223,7 +232,10 @@ describe('placing and the form (A4, A5)', () => {
|
||||
},
|
||||
} as never)
|
||||
const user = await mount(text)
|
||||
await user.click(screen.getByRole('button', { name: 'Ajouter un accès' }))
|
||||
await addByKeyboard(
|
||||
user,
|
||||
screen.getByRole('button', { name: 'Ajouter un accès' }),
|
||||
)
|
||||
const shown = await dialog('Nouvel accès')
|
||||
expect(within(shown).getByLabelText('Vue ouverte')).toBeInTheDocument()
|
||||
expect(
|
||||
@@ -521,7 +533,10 @@ describe('« Reprendre le tracé » edits the closed shape with its handles (boa
|
||||
|
||||
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' }))
|
||||
await addByKeyboard(
|
||||
user,
|
||||
screen.getByRole('button', { name: 'Ajouter un accès' }),
|
||||
)
|
||||
const shown = await dialog('Nouvel accès')
|
||||
await user.click(
|
||||
within(shown).getByRole('button', { name: 'Reprendre le tracé' }),
|
||||
@@ -758,7 +773,10 @@ describe('fix round 1: a creation whose view leaves the document (no silent loss
|
||||
screen.getByRole('button', { name: 'Ajouter une zone' }),
|
||||
).toBeEnabled(),
|
||||
)
|
||||
await user.click(screen.getByRole('button', { name: 'Ajouter une zone' }))
|
||||
await addByKeyboard(
|
||||
user,
|
||||
screen.getByRole('button', { name: 'Ajouter une zone' }),
|
||||
)
|
||||
const shown = await dialog('Nouvelle zone')
|
||||
await user.type(within(shown).getByLabelText('Nom (FR)'), 'Perdue')
|
||||
act(
|
||||
|
||||
@@ -37,6 +37,7 @@ import {
|
||||
store,
|
||||
versionAnswer,
|
||||
pressAt,
|
||||
addByKeyboard,
|
||||
} from '../helpers/editorHarness'
|
||||
import { testLayer } from '../helpers/findingsHost'
|
||||
import { mountDraft, setWidth } from '../helpers/editorRoute'
|
||||
@@ -556,7 +557,10 @@ describe('a tab while a creation or a tracing is in progress', () => {
|
||||
drawing.getByRole('button', { name: 'Ajouter un point' }),
|
||||
).toBeEnabled(),
|
||||
)
|
||||
await user.click(drawing.getByRole('button', { name: 'Ajouter un point' }))
|
||||
await addByKeyboard(
|
||||
user,
|
||||
drawing.getByRole('button', { name: 'Ajouter un point' }),
|
||||
)
|
||||
const dialog = await screen.findByRole('dialog', { name: 'Nouveau point' })
|
||||
await user.type(within(dialog).getByLabelText('Nom (FR)'), 'Nuque')
|
||||
await user.click(
|
||||
|
||||
@@ -23,6 +23,7 @@ import {
|
||||
storedCopy,
|
||||
store,
|
||||
sb,
|
||||
addByKeyboard,
|
||||
} from '../helpers/editorHarness'
|
||||
import {
|
||||
adminAnswer,
|
||||
@@ -223,7 +224,10 @@ describe('typed values come back after a 1 024 px crossing', () => {
|
||||
expect(drawing.getByRole('button', { name: 'Zone' })).toBeEnabled(),
|
||||
)
|
||||
await user.click(drawing.getByRole('button', { name: 'Zone' }))
|
||||
await user.click(drawing.getByRole('button', { name: 'Ajouter un point' }))
|
||||
await addByKeyboard(
|
||||
user,
|
||||
drawing.getByRole('button', { name: 'Ajouter un point' }),
|
||||
)
|
||||
const dialog = await screen.findByRole('dialog', { name: 'Nouveau point' })
|
||||
const name = within(dialog).getByLabelText('Nom (FR)')
|
||||
await user.type(name, 'Futur point')
|
||||
|
||||
@@ -32,6 +32,7 @@ import {
|
||||
sb,
|
||||
store,
|
||||
versionAnswer,
|
||||
addByKeyboard,
|
||||
} from '../helpers/editorHarness'
|
||||
|
||||
vi.mock('@/lib/supabase', () => ({ getSupabaseClient: () => ({}) }))
|
||||
@@ -505,7 +506,10 @@ describe('A5: a new point takes the most used size', () => {
|
||||
it('the keyboard point and the Point tool click', async () => {
|
||||
await mount(sized())
|
||||
const user = userEvent.setup()
|
||||
await user.click(screen.getByRole('button', { name: 'Ajouter un point' }))
|
||||
await addByKeyboard(
|
||||
user,
|
||||
screen.getByRole('button', { name: 'Ajouter un point' }),
|
||||
)
|
||||
await screen.findByTestId('annotation-creation')
|
||||
// A8: no « Rayon » field; the ghost under the dialog has the size.
|
||||
expect(
|
||||
|
||||
@@ -25,6 +25,7 @@ import {
|
||||
serverHas,
|
||||
store,
|
||||
pressAt,
|
||||
addByKeyboard,
|
||||
} from '../helpers/editorHarness'
|
||||
import { mountDraft, setWidth } from '../helpers/editorRoute'
|
||||
|
||||
@@ -195,7 +196,10 @@ const addPoint = async (user: ReturnType<typeof userEvent.setup>) => {
|
||||
screen.getByRole('button', { name: 'Ajouter un point' }),
|
||||
).toBeEnabled(),
|
||||
)
|
||||
await user.click(screen.getByRole('button', { name: 'Ajouter un point' }))
|
||||
await addByKeyboard(
|
||||
user,
|
||||
screen.getByRole('button', { name: 'Ajouter un point' }),
|
||||
)
|
||||
}
|
||||
|
||||
describe('the shown view disappears (undo)', () => {
|
||||
|
||||
Reference in new issue
Block a user