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 { expect, vi } from 'vitest'
|
||||||
import { fireEvent } from '@testing-library/react'
|
import { fireEvent } from '@testing-library/react'
|
||||||
import type { UserEvent } from '@testing-library/user-event'
|
|
||||||
import type { EditCommand } from '@faunosteo/core-wasm/types'
|
import type { EditCommand } from '@faunosteo/core-wasm/types'
|
||||||
import * as supabase from '@faunosteo/supabase'
|
import * as supabase from '@faunosteo/supabase'
|
||||||
import { useEditorStore } from '@/editor/state/editorStore'
|
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.pointerDown(el, init)
|
||||||
fireEvent.pointerUp(el, { ...init, buttons: 0 })
|
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 { useLocaleStore } from '@/state/localeStore'
|
||||||
import { drawnText, insert, point } from '../helpers/editorFixtures'
|
import { drawnText, insert, point } from '../helpers/editorFixtures'
|
||||||
import { LayeredTab } from '../helpers/annotationLayer'
|
import { LayeredTab } from '../helpers/annotationLayer'
|
||||||
import {
|
import { addByKeyboard } from '../helpers/addByKeyboard'
|
||||||
addByKeyboard,
|
import { openReady, pressAt, resetStore } from '../helpers/editorHarness'
|
||||||
openReady,
|
|
||||||
pressAt,
|
|
||||||
resetStore,
|
|
||||||
} from '../helpers/editorHarness'
|
|
||||||
|
|
||||||
vi.mock('@/lib/supabase', () => ({ getSupabaseClient: () => ({}) }))
|
vi.mock('@/lib/supabase', () => ({ getSupabaseClient: () => ({}) }))
|
||||||
vi.mock('@faunosteo/supabase', async (orig) => ({
|
vi.mock('@faunosteo/supabase', async (orig) => ({
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import {
|
|||||||
svgBytes,
|
svgBytes,
|
||||||
} from '../helpers/editorFixtures'
|
} from '../helpers/editorFixtures'
|
||||||
import { LayeredTab } from '../helpers/annotationLayer'
|
import { LayeredTab } from '../helpers/annotationLayer'
|
||||||
|
import { addByKeyboard } from '../helpers/addByKeyboard'
|
||||||
import {
|
import {
|
||||||
USER,
|
USER,
|
||||||
VERSION,
|
VERSION,
|
||||||
@@ -38,7 +39,6 @@ import {
|
|||||||
sb,
|
sb,
|
||||||
store,
|
store,
|
||||||
versionAnswer,
|
versionAnswer,
|
||||||
addByKeyboard,
|
|
||||||
} from '../helpers/editorHarness'
|
} from '../helpers/editorHarness'
|
||||||
|
|
||||||
vi.mock('@/lib/supabase', () => ({ getSupabaseClient: () => ({}) }))
|
vi.mock('@/lib/supabase', () => ({ getSupabaseClient: () => ({}) }))
|
||||||
|
|||||||
@@ -29,13 +29,8 @@ import { guardDrawing } from '@/editor/annotations/drawingGuard'
|
|||||||
import { useLocaleStore } from '@/state/localeStore'
|
import { useLocaleStore } from '@/state/localeStore'
|
||||||
import { drawnText, insert, point } from '../helpers/editorFixtures'
|
import { drawnText, insert, point } from '../helpers/editorFixtures'
|
||||||
import { LayeredTab } from '../helpers/annotationLayer'
|
import { LayeredTab } from '../helpers/annotationLayer'
|
||||||
import {
|
import { addByKeyboard } from '../helpers/addByKeyboard'
|
||||||
addByKeyboard,
|
import { openReady, pressAt, resetStore, store } from '../helpers/editorHarness'
|
||||||
openReady,
|
|
||||||
pressAt,
|
|
||||||
resetStore,
|
|
||||||
store,
|
|
||||||
} from '../helpers/editorHarness'
|
|
||||||
|
|
||||||
vi.mock('@/lib/supabase', () => ({ getSupabaseClient: () => ({}) }))
|
vi.mock('@/lib/supabase', () => ({ getSupabaseClient: () => ({}) }))
|
||||||
vi.mock('@faunosteo/supabase', async (orig) => ({
|
vi.mock('@faunosteo/supabase', async (orig) => ({
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import {
|
|||||||
insert,
|
insert,
|
||||||
point,
|
point,
|
||||||
} from '../helpers/editorFixtures'
|
} from '../helpers/editorFixtures'
|
||||||
|
import { addByKeyboard } from '../helpers/addByKeyboard'
|
||||||
import {
|
import {
|
||||||
baseText,
|
baseText,
|
||||||
resetStore,
|
resetStore,
|
||||||
@@ -37,7 +38,6 @@ import {
|
|||||||
store,
|
store,
|
||||||
versionAnswer,
|
versionAnswer,
|
||||||
pressAt,
|
pressAt,
|
||||||
addByKeyboard,
|
|
||||||
} from '../helpers/editorHarness'
|
} from '../helpers/editorHarness'
|
||||||
import { testLayer } from '../helpers/findingsHost'
|
import { testLayer } from '../helpers/findingsHost'
|
||||||
import { mountDraft, setWidth } from '../helpers/editorRoute'
|
import { mountDraft, setWidth } from '../helpers/editorRoute'
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import userEvent from '@testing-library/user-event'
|
|||||||
import { useAuthStore } from '@/state/authStore'
|
import { useAuthStore } from '@/state/authStore'
|
||||||
import { useLocaleStore } from '@/state/localeStore'
|
import { useLocaleStore } from '@/state/localeStore'
|
||||||
import { drawnText, emptyText, insert, point } from '../helpers/editorFixtures'
|
import { drawnText, emptyText, insert, point } from '../helpers/editorFixtures'
|
||||||
|
import { addByKeyboard } from '../helpers/addByKeyboard'
|
||||||
import {
|
import {
|
||||||
SHEET,
|
SHEET,
|
||||||
USER,
|
USER,
|
||||||
@@ -23,7 +24,6 @@ import {
|
|||||||
storedCopy,
|
storedCopy,
|
||||||
store,
|
store,
|
||||||
sb,
|
sb,
|
||||||
addByKeyboard,
|
|
||||||
} from '../helpers/editorHarness'
|
} from '../helpers/editorHarness'
|
||||||
import {
|
import {
|
||||||
adminAnswer,
|
adminAnswer,
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import {
|
|||||||
point,
|
point,
|
||||||
svgBytes,
|
svgBytes,
|
||||||
} from '../helpers/editorFixtures'
|
} from '../helpers/editorFixtures'
|
||||||
|
import { addByKeyboard } from '../helpers/addByKeyboard'
|
||||||
import {
|
import {
|
||||||
USER,
|
USER,
|
||||||
VERSION,
|
VERSION,
|
||||||
@@ -32,7 +33,6 @@ import {
|
|||||||
sb,
|
sb,
|
||||||
store,
|
store,
|
||||||
versionAnswer,
|
versionAnswer,
|
||||||
addByKeyboard,
|
|
||||||
} from '../helpers/editorHarness'
|
} from '../helpers/editorHarness'
|
||||||
|
|
||||||
vi.mock('@/lib/supabase', () => ({ getSupabaseClient: () => ({}) }))
|
vi.mock('@/lib/supabase', () => ({ getSupabaseClient: () => ({}) }))
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import {
|
|||||||
import { targetOfKey } from '@/editor/navigation'
|
import { targetOfKey } from '@/editor/navigation'
|
||||||
import { useLocaleStore } from '@/state/localeStore'
|
import { useLocaleStore } from '@/state/localeStore'
|
||||||
import { drawnText, insert, point } from '../helpers/editorFixtures'
|
import { drawnText, insert, point } from '../helpers/editorFixtures'
|
||||||
|
import { addByKeyboard } from '../helpers/addByKeyboard'
|
||||||
import {
|
import {
|
||||||
baseText,
|
baseText,
|
||||||
openReady,
|
openReady,
|
||||||
@@ -25,7 +26,6 @@ import {
|
|||||||
serverHas,
|
serverHas,
|
||||||
store,
|
store,
|
||||||
pressAt,
|
pressAt,
|
||||||
addByKeyboard,
|
|
||||||
} from '../helpers/editorHarness'
|
} from '../helpers/editorHarness'
|
||||||
import { mountDraft, setWidth } from '../helpers/editorRoute'
|
import { mountDraft, setWidth } from '../helpers/editorRoute'
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user