test(tests): addByKeyboard in its own helper module
This commit is contained in:
1 parent
9d532fb23d
commit
97a0a25d61
9 files changed
+16
-25
No files matched your search
@@ -0,0 +1,7 @@
|
||||
import type { UserEvent } from '@testing-library/user-event'
|
||||
|
||||
/** 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}')
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
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'
|
||||
@@ -112,9 +111,3 @@ 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}')
|
||||
}
|
||||
@@ -15,12 +15,8 @@ import { fr } from '@/i18n/fr'
|
||||
import { useLocaleStore } from '@/state/localeStore'
|
||||
import { drawnText, insert, point } from '../helpers/editorFixtures'
|
||||
import { LayeredTab } from '../helpers/annotationLayer'
|
||||
import {
|
||||
addByKeyboard,
|
||||
openReady,
|
||||
pressAt,
|
||||
resetStore,
|
||||
} from '../helpers/editorHarness'
|
||||
import { addByKeyboard } from '../helpers/addByKeyboard'
|
||||
import { openReady, pressAt, resetStore } from '../helpers/editorHarness'
|
||||
|
||||
vi.mock('@/lib/supabase', () => ({ getSupabaseClient: () => ({}) }))
|
||||
vi.mock('@faunosteo/supabase', async (orig) => ({
|
||||
|
||||
@@ -28,6 +28,7 @@ import {
|
||||
svgBytes,
|
||||
} from '../helpers/editorFixtures'
|
||||
import { LayeredTab } from '../helpers/annotationLayer'
|
||||
import { addByKeyboard } from '../helpers/addByKeyboard'
|
||||
import {
|
||||
USER,
|
||||
VERSION,
|
||||
@@ -38,7 +39,6 @@ import {
|
||||
sb,
|
||||
store,
|
||||
versionAnswer,
|
||||
addByKeyboard,
|
||||
} from '../helpers/editorHarness'
|
||||
|
||||
vi.mock('@/lib/supabase', () => ({ getSupabaseClient: () => ({}) }))
|
||||
|
||||
@@ -29,13 +29,8 @@ import { guardDrawing } from '@/editor/annotations/drawingGuard'
|
||||
import { useLocaleStore } from '@/state/localeStore'
|
||||
import { drawnText, insert, point } from '../helpers/editorFixtures'
|
||||
import { LayeredTab } from '../helpers/annotationLayer'
|
||||
import {
|
||||
addByKeyboard,
|
||||
openReady,
|
||||
pressAt,
|
||||
resetStore,
|
||||
store,
|
||||
} from '../helpers/editorHarness'
|
||||
import { addByKeyboard } from '../helpers/addByKeyboard'
|
||||
import { openReady, pressAt, resetStore, store } from '../helpers/editorHarness'
|
||||
|
||||
vi.mock('@/lib/supabase', () => ({ getSupabaseClient: () => ({}) }))
|
||||
vi.mock('@faunosteo/supabase', async (orig) => ({
|
||||
|
||||
@@ -29,6 +29,7 @@ import {
|
||||
insert,
|
||||
point,
|
||||
} from '../helpers/editorFixtures'
|
||||
import { addByKeyboard } from '../helpers/addByKeyboard'
|
||||
import {
|
||||
baseText,
|
||||
resetStore,
|
||||
@@ -37,7 +38,6 @@ import {
|
||||
store,
|
||||
versionAnswer,
|
||||
pressAt,
|
||||
addByKeyboard,
|
||||
} from '../helpers/editorHarness'
|
||||
import { testLayer } from '../helpers/findingsHost'
|
||||
import { mountDraft, setWidth } from '../helpers/editorRoute'
|
||||
|
||||
@@ -12,6 +12,7 @@ import userEvent from '@testing-library/user-event'
|
||||
import { useAuthStore } from '@/state/authStore'
|
||||
import { useLocaleStore } from '@/state/localeStore'
|
||||
import { drawnText, emptyText, insert, point } from '../helpers/editorFixtures'
|
||||
import { addByKeyboard } from '../helpers/addByKeyboard'
|
||||
import {
|
||||
SHEET,
|
||||
USER,
|
||||
@@ -23,7 +24,6 @@ import {
|
||||
storedCopy,
|
||||
store,
|
||||
sb,
|
||||
addByKeyboard,
|
||||
} from '../helpers/editorHarness'
|
||||
import {
|
||||
adminAnswer,
|
||||
|
||||
@@ -23,6 +23,7 @@ import {
|
||||
point,
|
||||
svgBytes,
|
||||
} from '../helpers/editorFixtures'
|
||||
import { addByKeyboard } from '../helpers/addByKeyboard'
|
||||
import {
|
||||
USER,
|
||||
VERSION,
|
||||
@@ -32,7 +33,6 @@ import {
|
||||
sb,
|
||||
store,
|
||||
versionAnswer,
|
||||
addByKeyboard,
|
||||
} from '../helpers/editorHarness'
|
||||
|
||||
vi.mock('@/lib/supabase', () => ({ getSupabaseClient: () => ({}) }))
|
||||
|
||||
@@ -18,6 +18,7 @@ import {
|
||||
import { targetOfKey } from '@/editor/navigation'
|
||||
import { useLocaleStore } from '@/state/localeStore'
|
||||
import { drawnText, insert, point } from '../helpers/editorFixtures'
|
||||
import { addByKeyboard } from '../helpers/addByKeyboard'
|
||||
import {
|
||||
baseText,
|
||||
openReady,
|
||||
@@ -25,7 +26,6 @@ import {
|
||||
serverHas,
|
||||
store,
|
||||
pressAt,
|
||||
addByKeyboard,
|
||||
} from '../helpers/editorHarness'
|
||||
import { mountDraft, setWidth } from '../helpers/editorRoute'
|
||||
|
||||
|
||||
Reference in new issue
Block a user