@vitest/browser 3.0.8 → 3.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { Plugin } from 'vitest/config';
2
2
  import { CDPSession, BrowserServerState as BrowserServerState$1, ProjectBrowser as ProjectBrowser$1, TestProject, BrowserProvider, Vitest, ResolvedConfig, Vite, BrowserCommand, BrowserScript, ProcessPool } from 'vitest/node';
3
+ import { StackTraceParserOptions } from '@vitest/utils/source-map';
3
4
  import { ViteDevServer, HtmlTagDescriptor } from 'vite';
4
5
  import { CancelReason, RunnerTestFile, AfterSuiteRunMeta, UserConsoleLog, SnapshotResult, SerializedConfig, ErrorWithDiff, ParsedStack } from 'vitest';
5
- import { StackTraceParserOptions } from '@vitest/utils/source-map';
6
6
  import { ServerIdResolution, ServerMockResolution } from '@vitest/mocker/node';
7
7
  import { TaskResultPack, TaskEventPack } from '@vitest/runner';
8
8
 
@@ -23,125 +23,125 @@ type BirpcReturn<RemoteFunctions, LocalFunctions = Record<string, never>> = {
23
23
  };
24
24
 
25
25
  interface WebSocketBrowserHandlers {
26
- resolveSnapshotPath: (testPath: string) => string;
27
- resolveSnapshotRawPath: (testPath: string, rawPath: string) => string;
28
- onUnhandledError: (error: unknown, type: string) => Promise<void>;
29
- onQueued: (file: RunnerTestFile) => void;
30
- onCollected: (files: RunnerTestFile[]) => Promise<void>;
31
- onTaskUpdate: (packs: TaskResultPack[], events: TaskEventPack[]) => void;
32
- onAfterSuiteRun: (meta: AfterSuiteRunMeta) => void;
33
- onCancel: (reason: CancelReason) => void;
34
- getCountOfFailedTests: () => number;
35
- readSnapshotFile: (id: string) => Promise<string | null>;
36
- saveSnapshotFile: (id: string, content: string) => Promise<void>;
37
- removeSnapshotFile: (id: string) => Promise<void>;
38
- sendLog: (log: UserConsoleLog) => void;
39
- finishBrowserTests: (sessionId: string) => void;
40
- snapshotSaved: (snapshot: SnapshotResult) => void;
41
- debug: (...args: string[]) => void;
42
- resolveId: (id: string, importer?: string) => Promise<ServerIdResolution | null>;
43
- triggerCommand: <T>(sessionId: string, command: string, testPath: string | undefined, payload: unknown[]) => Promise<T>;
44
- resolveMock: (id: string, importer: string, options: {
45
- mock: 'spy' | 'factory' | 'auto';
46
- }) => Promise<ServerMockResolution>;
47
- invalidate: (ids: string[]) => void;
48
- getBrowserFileSourceMap: (id: string) => SourceMap | null | {
49
- mappings: '';
50
- } | undefined;
51
- wdioSwitchContext: (direction: 'iframe' | 'parent') => void;
52
- sendCdpEvent: (sessionId: string, event: string, payload?: Record<string, unknown>) => unknown;
53
- trackCdpEvent: (sessionId: string, type: 'on' | 'once' | 'off', event: string, listenerId: string) => void;
26
+ resolveSnapshotPath: (testPath: string) => string;
27
+ resolveSnapshotRawPath: (testPath: string, rawPath: string) => string;
28
+ onUnhandledError: (error: unknown, type: string) => Promise<void>;
29
+ onQueued: (file: RunnerTestFile) => void;
30
+ onCollected: (files: RunnerTestFile[]) => Promise<void>;
31
+ onTaskUpdate: (packs: TaskResultPack[], events: TaskEventPack[]) => void;
32
+ onAfterSuiteRun: (meta: AfterSuiteRunMeta) => void;
33
+ onCancel: (reason: CancelReason) => void;
34
+ getCountOfFailedTests: () => number;
35
+ readSnapshotFile: (id: string) => Promise<string | null>;
36
+ saveSnapshotFile: (id: string, content: string) => Promise<void>;
37
+ removeSnapshotFile: (id: string) => Promise<void>;
38
+ sendLog: (log: UserConsoleLog) => void;
39
+ finishBrowserTests: (sessionId: string) => void;
40
+ snapshotSaved: (snapshot: SnapshotResult) => void;
41
+ debug: (...args: string[]) => void;
42
+ resolveId: (id: string, importer?: string) => Promise<ServerIdResolution | null>;
43
+ triggerCommand: <T>(sessionId: string, command: string, testPath: string | undefined, payload: unknown[]) => Promise<T>;
44
+ resolveMock: (id: string, importer: string, options: {
45
+ mock: "spy" | "factory" | "auto"
46
+ }) => Promise<ServerMockResolution>;
47
+ invalidate: (ids: string[]) => void;
48
+ getBrowserFileSourceMap: (id: string) => SourceMap | null | {
49
+ mappings: ""
50
+ } | undefined;
51
+ wdioSwitchContext: (direction: "iframe" | "parent") => void;
52
+ sendCdpEvent: (sessionId: string, event: string, payload?: Record<string, unknown>) => unknown;
53
+ trackCdpEvent: (sessionId: string, type: "on" | "once" | "off", event: string, listenerId: string) => void;
54
54
  }
55
55
  interface WebSocketBrowserEvents {
56
- onCancel: (reason: CancelReason) => void;
57
- createTesters: (files: string[]) => Promise<void>;
58
- cdpEvent: (event: string, payload: unknown) => void;
56
+ onCancel: (reason: CancelReason) => void;
57
+ createTesters: (files: string[]) => Promise<void>;
58
+ cdpEvent: (event: string, payload: unknown) => void;
59
59
  }
60
60
  type WebSocketBrowserRPC = BirpcReturn<WebSocketBrowserEvents, WebSocketBrowserHandlers>;
61
61
  interface SourceMap {
62
- file: string;
63
- mappings: string;
64
- names: string[];
65
- sources: string[];
66
- sourcesContent?: string[];
67
- version: number;
68
- toString: () => string;
69
- toUrl: () => string;
62
+ file: string;
63
+ mappings: string;
64
+ names: string[];
65
+ sources: string[];
66
+ sourcesContent?: string[];
67
+ version: number;
68
+ toString: () => string;
69
+ toUrl: () => string;
70
70
  }
71
71
 
72
72
  declare class BrowserServerCDPHandler {
73
- private session;
74
- private tester;
75
- private listenerIds;
76
- private listeners;
77
- constructor(session: CDPSession, tester: WebSocketBrowserRPC);
78
- send(method: string, params?: Record<string, unknown>): Promise<unknown>;
79
- on(event: string, id: string, once?: boolean): void;
80
- off(event: string, id: string): void;
81
- once(event: string, listener: string): void;
73
+ private session;
74
+ private tester;
75
+ private listenerIds;
76
+ private listeners;
77
+ constructor(session: CDPSession, tester: WebSocketBrowserRPC);
78
+ send(method: string, params?: Record<string, unknown>): Promise<unknown>;
79
+ on(event: string, id: string, once?: boolean): void;
80
+ off(event: string, id: string): void;
81
+ once(event: string, listener: string): void;
82
82
  }
83
83
 
84
84
  declare class BrowserServerState implements BrowserServerState$1 {
85
- readonly orchestrators: Map<string, WebSocketBrowserRPC>;
86
- readonly testers: Map<string, WebSocketBrowserRPC>;
85
+ readonly orchestrators: Map<string, WebSocketBrowserRPC>;
86
+ readonly testers: Map<string, WebSocketBrowserRPC>;
87
87
  }
88
88
 
89
89
  declare class ProjectBrowser implements ProjectBrowser$1 {
90
- project: TestProject;
91
- base: string;
92
- testerHtml: Promise<string> | string;
93
- testerFilepath: string;
94
- locatorsUrl: string | undefined;
95
- provider: BrowserProvider;
96
- vitest: Vitest;
97
- config: ResolvedConfig;
98
- children: Set<ProjectBrowser>;
99
- parent: ParentBrowserProject;
100
- state: BrowserServerState;
101
- constructor(project: TestProject, base: string);
102
- get vite(): ViteDevServer;
103
- wrapSerializedConfig(): SerializedConfig;
104
- initBrowserProvider(project: TestProject): Promise<void>;
105
- parseErrorStacktrace(e: ErrorWithDiff, options?: StackTraceParserOptions): ParsedStack[];
106
- parseStacktrace(trace: string, options?: StackTraceParserOptions): ParsedStack[];
107
- close(): Promise<void>;
90
+ project: TestProject;
91
+ base: string;
92
+ testerHtml: Promise<string> | string;
93
+ testerFilepath: string;
94
+ locatorsUrl: string | undefined;
95
+ provider: BrowserProvider;
96
+ vitest: Vitest;
97
+ config: ResolvedConfig;
98
+ children: Set<ProjectBrowser>;
99
+ parent: ParentBrowserProject;
100
+ state: BrowserServerState;
101
+ constructor(project: TestProject, base: string);
102
+ get vite(): ViteDevServer;
103
+ wrapSerializedConfig(): SerializedConfig;
104
+ initBrowserProvider(project: TestProject): Promise<void>;
105
+ parseErrorStacktrace(e: ErrorWithDiff, options?: StackTraceParserOptions): ParsedStack[];
106
+ parseStacktrace(trace: string, options?: StackTraceParserOptions): ParsedStack[];
107
+ close(): Promise<void>;
108
108
  }
109
109
 
110
110
  declare class ParentBrowserProject {
111
- project: TestProject;
112
- base: string;
113
- orchestratorScripts: string | undefined;
114
- testerScripts: HtmlTagDescriptor[] | undefined;
115
- faviconUrl: string;
116
- prefixTesterUrl: string;
117
- manifest: Promise<Vite.Manifest> | Vite.Manifest;
118
- vite: Vite.ViteDevServer;
119
- private stackTraceOptions;
120
- orchestratorHtml: Promise<string> | string;
121
- injectorJs: Promise<string> | string;
122
- errorCatcherUrl: string;
123
- locatorsUrl: string | undefined;
124
- stateJs: Promise<string> | string;
125
- commands: Record<string, BrowserCommand<any>>;
126
- children: Set<ProjectBrowser>;
127
- vitest: Vitest;
128
- config: ResolvedConfig;
129
- private sourceMapCache;
130
- constructor(project: TestProject, base: string);
131
- setServer(vite: Vite.ViteDevServer): void;
132
- spawn(project: TestProject): ProjectBrowser;
133
- parseErrorStacktrace(e: ErrorWithDiff, options?: StackTraceParserOptions): ParsedStack[];
134
- parseStacktrace(trace: string, options?: StackTraceParserOptions): ParsedStack[];
135
- readonly cdps: Map<string, BrowserServerCDPHandler>;
136
- private cdpSessionsPromises;
137
- ensureCDPHandler(sessionId: string, rpcId: string): Promise<BrowserServerCDPHandler>;
138
- removeCDPHandler(sessionId: string): void;
139
- formatScripts(scripts: BrowserScript[] | undefined): Promise<HtmlTagDescriptor[]>;
140
- resolveTesterUrl(pathname: string): {
141
- sessionId: string;
142
- testFile: string;
143
- };
144
- private retrieveSourceMapURL;
111
+ project: TestProject;
112
+ base: string;
113
+ orchestratorScripts: string | undefined;
114
+ testerScripts: HtmlTagDescriptor[] | undefined;
115
+ faviconUrl: string;
116
+ prefixTesterUrl: string;
117
+ manifest: Promise<Vite.Manifest> | Vite.Manifest;
118
+ vite: Vite.ViteDevServer;
119
+ private stackTraceOptions;
120
+ orchestratorHtml: Promise<string> | string;
121
+ injectorJs: Promise<string> | string;
122
+ errorCatcherUrl: string;
123
+ locatorsUrl: string | undefined;
124
+ stateJs: Promise<string> | string;
125
+ commands: Record<string, BrowserCommand<any>>;
126
+ children: Set<ProjectBrowser>;
127
+ vitest: Vitest;
128
+ config: ResolvedConfig;
129
+ private sourceMapCache;
130
+ constructor(project: TestProject, base: string);
131
+ setServer(vite: Vite.ViteDevServer): void;
132
+ spawn(project: TestProject): ProjectBrowser;
133
+ parseErrorStacktrace(e: ErrorWithDiff, options?: StackTraceParserOptions): ParsedStack[];
134
+ parseStacktrace(trace: string, options?: StackTraceParserOptions): ParsedStack[];
135
+ readonly cdps: Map<string, BrowserServerCDPHandler>;
136
+ private cdpSessionsPromises;
137
+ ensureCDPHandler(sessionId: string, rpcId: string): Promise<BrowserServerCDPHandler>;
138
+ removeCDPHandler(sessionId: string): void;
139
+ formatScripts(scripts: BrowserScript[] | undefined): Promise<HtmlTagDescriptor[]>;
140
+ resolveTesterUrl(pathname: string): {
141
+ sessionId: string
142
+ testFile: string
143
+ };
144
+ private retrieveSourceMapURL;
145
145
  }
146
146
 
147
147
  declare const distRoot: string;
package/dist/index.js CHANGED
@@ -16,7 +16,7 @@ import { resolve as resolve$1, dirname as dirname$1, basename as basename$1, nor
16
16
  import { WebSocketServer } from 'ws';
17
17
  import * as nodeos from 'node:os';
18
18
 
19
- var version = "3.0.8";
19
+ var version = "3.0.9";
20
20
 
21
21
  const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
22
22
  function normalizeWindowsPath(input = "") {
@@ -776,7 +776,8 @@ var BrowserPlugin = (parentServer, base = "/") => {
776
776
  "vitest > chai",
777
777
  "vitest > chai > loupe",
778
778
  "vitest > @vitest/utils > loupe",
779
- "@vitest/browser > @testing-library/user-event"
779
+ "@vitest/browser > @testing-library/user-event",
780
+ "@vitest/browser > @testing-library/dom"
780
781
  ];
781
782
  const fileRoot = browserTestFiles[0] ? dirname(browserTestFiles[0]) : project.config.root;
782
783
  const svelte = isPackageExists("vitest-browser-svelte", fileRoot);
@@ -1191,7 +1192,7 @@ const tripleClick = async (context, selector, options = {}) => {
1191
1192
  });
1192
1193
  } else if (provider instanceof WebdriverBrowserProvider) {
1193
1194
  const browser = context.browser;
1194
- await browser.action("pointer", { parameters: { pointerType: "mouse" } }).move({ origin: await browser.$(selector) }).down().up().pause(50).down().up().pause(50).down().up().pause(50).perform();
1195
+ await browser.action("pointer", { parameters: { pointerType: "mouse" } }).move({ origin: browser.$(selector) }).down().up().pause(50).down().up().pause(50).down().up().pause(50).perform();
1195
1196
  } else {
1196
1197
  throw new TypeError(`Provider "${provider.name}" doesn't support tripleClick command`);
1197
1198
  }
@@ -1225,7 +1226,7 @@ const fill = async (context, selector, text, options = {}) => {
1225
1226
  const browser = context.browser;
1226
1227
  await browser.$(selector).setValue(text);
1227
1228
  } else {
1228
- throw new TypeError(`Provider "${context.provider.name}" does not support clearing elements`);
1229
+ throw new TypeError(`Provider "${context.provider.name}" does not support filling inputs`);
1229
1230
  }
1230
1231
  };
1231
1232
 
@@ -2165,7 +2166,7 @@ function focusIframe() {
2165
2166
  }
2166
2167
  function selectAll() {
2167
2168
  const element = document.activeElement;
2168
- if (element && element.select) {
2169
+ if (element && typeof element.select === "function") {
2169
2170
  element.select();
2170
2171
  }
2171
2172
  }
@@ -2311,7 +2312,7 @@ const type = async (context, selector, text, options = {}) => {
2311
2312
  text,
2312
2313
  () => browser.execute(() => {
2313
2314
  const element2 = document.activeElement;
2314
- if (element2) {
2315
+ if (element2 && typeof element2.select === "function") {
2315
2316
  element2.select();
2316
2317
  }
2317
2318
  }),
@@ -1,4 +1,4 @@
1
- import { UserEventClickOptions, UserEventHoverOptions, UserEventFillOptions, UserEventDragAndDropOptions, LocatorScreenshotOptions, LocatorByRoleOptions, LocatorOptions } from '@vitest/browser/context';
1
+ import { UserEventClickOptions, UserEventClearOptions, UserEventHoverOptions, UserEventFillOptions, UserEventUploadOptions, UserEventDragAndDropOptions, UserEventSelectOptions, LocatorScreenshotOptions, LocatorByRoleOptions, LocatorOptions } from '@vitest/browser/context';
2
2
 
3
3
  type ClauseCombinator = '' | '>' | '+' | '~' | '>=';
4
4
  type CSSFunctionArgument = CSSComplexSelector | number | string;
@@ -219,46 +219,46 @@ interface SelectorEngine {
219
219
 
220
220
  declare const selectorEngine: Ivya;
221
221
  declare abstract class Locator {
222
- abstract selector: string;
223
- private _parsedSelector;
224
- protected _container?: Element | undefined;
225
- protected _pwSelector?: string | undefined;
226
- click(options?: UserEventClickOptions): Promise<void>;
227
- dblClick(options?: UserEventClickOptions): Promise<void>;
228
- tripleClick(options?: UserEventClickOptions): Promise<void>;
229
- clear(): Promise<void>;
230
- hover(options: UserEventHoverOptions): Promise<void>;
231
- unhover(options: UserEventHoverOptions): Promise<void>;
232
- fill(text: string, options?: UserEventFillOptions): Promise<void>;
233
- upload(files: string | string[] | File | File[]): Promise<void>;
234
- dropTo(target: Locator, options?: UserEventDragAndDropOptions): Promise<void>;
235
- selectOptions(value: HTMLElement | HTMLElement[] | Locator | Locator[] | string | string[]): Promise<void>;
236
- screenshot(options: Omit<LocatorScreenshotOptions, 'base64'> & {
237
- base64: true;
238
- }): Promise<{
239
- path: string;
240
- base64: string;
241
- }>;
242
- screenshot(options?: LocatorScreenshotOptions): Promise<string>;
243
- protected abstract locator(selector: string): Locator;
244
- protected abstract elementLocator(element: Element): Locator;
245
- getByRole(role: string, options?: LocatorByRoleOptions): Locator;
246
- getByAltText(text: string | RegExp, options?: LocatorOptions): Locator;
247
- getByLabelText(text: string | RegExp, options?: LocatorOptions): Locator;
248
- getByPlaceholder(text: string | RegExp, options?: LocatorOptions): Locator;
249
- getByTestId(testId: string | RegExp): Locator;
250
- getByText(text: string | RegExp, options?: LocatorOptions): Locator;
251
- getByTitle(title: string | RegExp, options?: LocatorOptions): Locator;
252
- query(): Element | null;
253
- element(): Element;
254
- elements(): Element[];
255
- all(): Locator[];
256
- nth(index: number): Locator;
257
- first(): Locator;
258
- last(): Locator;
259
- toString(): string;
260
- toJSON(): string;
261
- protected triggerCommand<T>(command: string, ...args: any[]): Promise<T>;
222
+ abstract selector: string;
223
+ private _parsedSelector;
224
+ protected _container?: Element | undefined;
225
+ protected _pwSelector?: string | undefined;
226
+ click(options?: UserEventClickOptions): Promise<void>;
227
+ dblClick(options?: UserEventClickOptions): Promise<void>;
228
+ tripleClick(options?: UserEventClickOptions): Promise<void>;
229
+ clear(options?: UserEventClearOptions): Promise<void>;
230
+ hover(options?: UserEventHoverOptions): Promise<void>;
231
+ unhover(options?: UserEventHoverOptions): Promise<void>;
232
+ fill(text: string, options?: UserEventFillOptions): Promise<void>;
233
+ upload(files: string | string[] | File | File[], options?: UserEventUploadOptions): Promise<void>;
234
+ dropTo(target: Locator, options?: UserEventDragAndDropOptions): Promise<void>;
235
+ selectOptions(value: HTMLElement | HTMLElement[] | Locator | Locator[] | string | string[], options?: UserEventSelectOptions): Promise<void>;
236
+ screenshot(options: Omit<LocatorScreenshotOptions, "base64"> & {
237
+ base64: true
238
+ }): Promise<{
239
+ path: string
240
+ base64: string
241
+ }>;
242
+ screenshot(options?: LocatorScreenshotOptions): Promise<string>;
243
+ protected abstract locator(selector: string): Locator;
244
+ protected abstract elementLocator(element: Element): Locator;
245
+ getByRole(role: string, options?: LocatorByRoleOptions): Locator;
246
+ getByAltText(text: string | RegExp, options?: LocatorOptions): Locator;
247
+ getByLabelText(text: string | RegExp, options?: LocatorOptions): Locator;
248
+ getByPlaceholder(text: string | RegExp, options?: LocatorOptions): Locator;
249
+ getByTestId(testId: string | RegExp): Locator;
250
+ getByText(text: string | RegExp, options?: LocatorOptions): Locator;
251
+ getByTitle(title: string | RegExp, options?: LocatorOptions): Locator;
252
+ query(): Element | null;
253
+ element(): Element;
254
+ elements(): Element[];
255
+ all(): Locator[];
256
+ nth(index: number): Locator;
257
+ first(): Locator;
258
+ last(): Locator;
259
+ toString(): string;
260
+ toJSON(): string;
261
+ protected triggerCommand<T>(command: string, ...args: any[]): Promise<T>;
262
262
  }
263
263
 
264
264
  export { Locator, selectorEngine };
@@ -1,4 +1,4 @@
1
1
  import '@vitest/browser/context';
2
2
  import '../public-utils-J4vwTaki.js';
3
- export { L as Locator, s as selectorEngine } from '../index-fqTesRIH.js';
3
+ export { L as Locator, s as selectorEngine } from '../index-DrTP5i7N.js';
4
4
  import 'vitest/utils';
@@ -1,6 +1,7 @@
1
1
  import { page, server } from '@vitest/browser/context';
2
2
  import { g as getByTitleSelector, a as getByTextSelector, b as getByPlaceholderSelector, c as getByAltTextSelector, d as getByTestIdSelector, e as getByRoleSelector, f as getByLabelSelector } from '../public-utils-J4vwTaki.js';
3
- import { s as selectorEngine, L as Locator } from '../index-fqTesRIH.js';
3
+ import { s as selectorEngine, L as Locator, g as getBrowserState } from '../index-DrTP5i7N.js';
4
+ import { p as processTimeoutOptions, g as getIframeScale } from '../utils-VCysLhWp.js';
4
5
  import 'vitest/utils';
5
6
 
6
7
  page.extend({
@@ -38,6 +39,35 @@ class PlaywrightLocator extends Locator {
38
39
  this.selector = selector;
39
40
  this._container = _container;
40
41
  }
42
+ click(options) {
43
+ return super.click(processTimeoutOptions(processClickOptions(options)));
44
+ }
45
+ dblClick(options) {
46
+ return super.dblClick(processTimeoutOptions(processClickOptions(options)));
47
+ }
48
+ tripleClick(options) {
49
+ return super.tripleClick(processTimeoutOptions(processClickOptions(options)));
50
+ }
51
+ selectOptions(value, options) {
52
+ return super.selectOptions(value, processTimeoutOptions(options));
53
+ }
54
+ clear(options) {
55
+ return super.clear(processTimeoutOptions(options));
56
+ }
57
+ hover(options) {
58
+ return super.hover(processTimeoutOptions(processHoverOptions(options)));
59
+ }
60
+ upload(files, options) {
61
+ return super.upload(files, processTimeoutOptions(options));
62
+ }
63
+ fill(text, options) {
64
+ return super.fill(text, processTimeoutOptions(options));
65
+ }
66
+ dropTo(target, options) {
67
+ return super.dropTo(target, processTimeoutOptions(
68
+ processDragAndDropOptions(options)
69
+ ));
70
+ }
41
71
  locator(selector) {
42
72
  return new PlaywrightLocator(`${this.selector} >> ${selector}`, this._container);
43
73
  }
@@ -48,3 +78,46 @@ class PlaywrightLocator extends Locator {
48
78
  );
49
79
  }
50
80
  }
81
+ function processDragAndDropOptions(options_) {
82
+ if (!options_ || !getBrowserState().config.browser.ui) {
83
+ return options_;
84
+ }
85
+ const options = options_;
86
+ if (options.sourcePosition) {
87
+ options.sourcePosition = processPlaywrightPosition(options.sourcePosition);
88
+ }
89
+ if (options.targetPosition) {
90
+ options.targetPosition = processPlaywrightPosition(options.targetPosition);
91
+ }
92
+ return options_;
93
+ }
94
+ function processHoverOptions(options_) {
95
+ if (!options_ || !getBrowserState().config.browser.ui) {
96
+ return options_;
97
+ }
98
+ const options = options_;
99
+ if (options.position) {
100
+ options.position = processPlaywrightPosition(options.position);
101
+ }
102
+ return options_;
103
+ }
104
+ function processClickOptions(options_) {
105
+ if (!options_ || !getBrowserState().config.browser.ui) {
106
+ return options_;
107
+ }
108
+ const options = options_;
109
+ if (options.position) {
110
+ options.position = processPlaywrightPosition(options.position);
111
+ }
112
+ return options;
113
+ }
114
+ function processPlaywrightPosition(position) {
115
+ const scale = getIframeScale();
116
+ if (position.x != null) {
117
+ position.x *= scale;
118
+ }
119
+ if (position.y != null) {
120
+ position.y *= scale;
121
+ }
122
+ return position;
123
+ }
@@ -1,6 +1,7 @@
1
1
  import { page, server, userEvent } from '@vitest/browser/context';
2
2
  import { g as getByTitleSelector, a as getByTextSelector, b as getByPlaceholderSelector, c as getByAltTextSelector, d as getByTestIdSelector, e as getByRoleSelector, f as getByLabelSelector, h as getElementError } from '../public-utils-J4vwTaki.js';
3
- import { s as selectorEngine, L as Locator, c as convertElementToCssSelector } from '../index-fqTesRIH.js';
3
+ import { c as convertElementToCssSelector } from '../utils-VCysLhWp.js';
4
+ import { s as selectorEngine, L as Locator } from '../index-DrTP5i7N.js';
4
5
  import 'vitest/utils';
5
6
 
6
7
  page.extend({
@@ -1,6 +1,7 @@
1
1
  import { page, server } from '@vitest/browser/context';
2
2
  import { g as getByTitleSelector, a as getByTextSelector, b as getByPlaceholderSelector, c as getByAltTextSelector, d as getByTestIdSelector, e as getByRoleSelector, f as getByLabelSelector, h as getElementError } from '../public-utils-J4vwTaki.js';
3
- import { s as selectorEngine, L as Locator, c as convertElementToCssSelector } from '../index-fqTesRIH.js';
3
+ import { s as selectorEngine, L as Locator, g as getBrowserState } from '../index-DrTP5i7N.js';
4
+ import { c as convertElementToCssSelector, g as getIframeScale } from '../utils-VCysLhWp.js';
4
5
  import 'vitest/utils';
5
6
 
6
7
  page.extend({
@@ -42,9 +43,24 @@ class WebdriverIOLocator extends Locator {
42
43
  }
43
44
  return selectors.join(", ");
44
45
  }
45
- selectOptions(value) {
46
+ click(options) {
47
+ return super.click(processClickOptions(options));
48
+ }
49
+ dblClick(options) {
50
+ return super.dblClick(processClickOptions(options));
51
+ }
52
+ tripleClick(options) {
53
+ return super.tripleClick(processClickOptions(options));
54
+ }
55
+ selectOptions(value, options) {
46
56
  const values = getWebdriverioSelectOptions(this.element(), value);
47
- return this.triggerCommand("__vitest_selectOptions", this.selector, values);
57
+ return this.triggerCommand("__vitest_selectOptions", this.selector, values, options);
58
+ }
59
+ hover(options) {
60
+ return super.hover(processHoverOptions(options));
61
+ }
62
+ dropTo(target, options) {
63
+ return super.dropTo(target, processDragAndDropOptions(options));
48
64
  }
49
65
  locator(selector) {
50
66
  return new WebdriverIOLocator(`${this._pwSelector} >> ${selector}`, this._container);
@@ -83,3 +99,59 @@ function getWebdriverioSelectOptions(element, value) {
83
99
  }
84
100
  return [{ index: labelIndex }];
85
101
  }
102
+ function processClickOptions(options_) {
103
+ if (!options_ || !getBrowserState().config.browser.ui) {
104
+ return options_;
105
+ }
106
+ const options = options_;
107
+ if (options.x != null || options.y != null) {
108
+ const cache = {};
109
+ if (options.x != null) {
110
+ options.x = scaleCoordinate(options.x, cache);
111
+ }
112
+ if (options.y != null) {
113
+ options.y = scaleCoordinate(options.y, cache);
114
+ }
115
+ }
116
+ return options_;
117
+ }
118
+ function processHoverOptions(options_) {
119
+ if (!options_ || !getBrowserState().config.browser.ui) {
120
+ return options_;
121
+ }
122
+ const options = options_;
123
+ const cache = {};
124
+ if (options.xOffset != null) {
125
+ options.xOffset = scaleCoordinate(options.xOffset, cache);
126
+ }
127
+ if (options.yOffset != null) {
128
+ options.yOffset = scaleCoordinate(options.yOffset, cache);
129
+ }
130
+ return options_;
131
+ }
132
+ function processDragAndDropOptions(options_) {
133
+ if (!options_ || !getBrowserState().config.browser.ui) {
134
+ return options_;
135
+ }
136
+ const cache = {};
137
+ const options = options_;
138
+ if (options.sourceX != null) {
139
+ options.sourceX = scaleCoordinate(options.sourceX, cache);
140
+ }
141
+ if (options.sourceY != null) {
142
+ options.sourceY = scaleCoordinate(options.sourceY, cache);
143
+ }
144
+ if (options.targetX != null) {
145
+ options.targetX = scaleCoordinate(options.targetX, cache);
146
+ }
147
+ if (options.targetY != null) {
148
+ options.targetY = scaleCoordinate(options.targetY, cache);
149
+ }
150
+ return options_;
151
+ }
152
+ function scaleCoordinate(coordinate, cache) {
153
+ return Math.round(coordinate * getCachedScale(cache));
154
+ }
155
+ function getCachedScale(cache) {
156
+ return cache.scale ??= getIframeScale();
157
+ }