diff --git a/packages/browser-playwright/src/commands/pointer.ts b/packages/browser-playwright/src/commands/pointer.ts index 9978f654f..4eabce266 100644 --- a/packages/browser-playwright/src/commands/pointer.ts +++ b/packages/browser-playwright/src/commands/pointer.ts @@ -1,10 +1,21 @@ -import type { UserEvent } from 'vitest/browser' +import type { SerializedLocator } from '@vitest/browser' +import type { Locator, UserEventPointerOptions } from 'vitest/browser' import type { UserEventCommand } from './utils' import { parseKeyDef } from '@vitest/browser' import { click } from './click' import { hover } from './hover' -export const pointer: UserEventCommand = async ( +type PointerEvent = ( + options: readonly ElementToSerializedLocator[], +) => Promise + +type ElementToSerializedLocator = T extends Element | Locator + ? SerializedLocator + : { + [K in keyof T]: ElementToSerializedLocator + } + +export const pointer: UserEventCommand = async ( context, options, ) => { diff --git a/packages/browser-playwright/src/commands/utils.ts b/packages/browser-playwright/src/commands/utils.ts index b2408fc97..1616fb840 100644 --- a/packages/browser-playwright/src/commands/utils.ts +++ b/packages/browser-playwright/src/commands/utils.ts @@ -7,7 +7,6 @@ export type UserEventCommand any> = BrowserCommand< > type ConvertElementToLocator = T extends Element | Locator ? SerializedLocator : T -// @todo: check if this could take care of nested locators (e.g., `{ target: Locator }[]`) type ConvertUserEventParameters = { [K in keyof T]: ConvertElementToLocator; }