Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update tap to async for k6 browser module #36

Merged
merged 2 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions types/k6/experimental/browser.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1207,7 +1207,7 @@ export interface ElementHandle extends JSHandle {
* or at the specified position.
* @param options Tap options.
*/
tap(options?: MouseMoveOptions): void;
tap(options?: MouseMoveOptions): Promise<void>;

/**
* Returns the `node.textContent`.
Expand Down Expand Up @@ -1321,7 +1321,7 @@ export interface Frame {
* @param selector The selector to use.
* @param options The options to use.
*/
tap(selector: string, options?: ElementClickOptions & KeyboardModifierOptions & StrictnessOptions): void;
tap(selector: string, options?: ElementClickOptions & KeyboardModifierOptions & StrictnessOptions): Promise<void>;

/**
* Press the given key for the first element found that matches the selector.
Expand Down Expand Up @@ -1893,7 +1893,7 @@ export interface Locator {
* Tap on the chosen element.
* @param options Options to use.
*/
tap(options?: MouseMoveOptions): void;
tap(options?: MouseMoveOptions): Promise<void>;

/**
* Dispatches HTML DOM event types e.g. `click`.
Expand Down Expand Up @@ -3129,7 +3129,7 @@ export interface Page {
*/
trial?: boolean;
},
): void;
): Promise<void>;

/**
* **NOTE** Use locator-based locator.textContent([options]) instead.
Expand Down Expand Up @@ -3737,7 +3737,7 @@ export interface Touchscreen {
* @param x The x position.
* @param y The y position.
*/
tap(x: number, y: number): void;
tap(x: number, y: number): Promise<void>;
}

/**
Expand Down
60 changes: 30 additions & 30 deletions types/k6/test/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -677,21 +677,21 @@ page.setViewportSize({ width: 800, height: 600 });

// @ts-expect-error
page.tap();
// $ExpectType void
// $ExpectType Promise<void>
page.tap(selector);
// $ExpectType void
// $ExpectType Promise<void>
page.tap(selector, { force: true });
// $ExpectType void
// $ExpectType Promise<void>
page.tap(selector, { modifiers: ["Alt", "Control", "Meta", "Shift"] });
// $ExpectType void
// $ExpectType Promise<void>
page.tap(selector, { noWaitAfter: true });
// $ExpectType void
// $ExpectType Promise<void>
page.tap(selector, { position: { x: 0, y: 0 } });
// $ExpectType void
// $ExpectType Promise<void>
page.tap(selector, { strict: true });
// $ExpectType void
// $ExpectType Promise<void>
page.tap(selector, { timeout: 10000 });
// $ExpectType void
// $ExpectType Promise<void>
page.tap(selector, { trial: true });

// @ts-expect-error
Expand Down Expand Up @@ -1109,17 +1109,17 @@ locator.hover({ timeout: 10000 });
// $ExpectType void
locator.hover({ trial: true });

// $ExpectType void
// $ExpectType Promise<void>
locator.tap();
// $ExpectType void
// $ExpectType Promise<void>
locator.tap({ force: true });
// $ExpectType void
// $ExpectType Promise<void>
locator.tap({ noWaitAfter: true });
// $ExpectType void
// $ExpectType Promise<void>
locator.tap({ position: { x: 0, y: 0 } });
// $ExpectType void
// $ExpectType Promise<void>
locator.tap({ timeout: 10000 });
// $ExpectType void
// $ExpectType Promise<void>
locator.tap({ trial: true });

// @ts-expect-error
Expand Down Expand Up @@ -1473,19 +1473,19 @@ elementHandle.setInputFiles({ name: "file.txt", mimeType: "text/plain", buffer:
timeout: 1000,
});

// $ExpectType void
// $ExpectType Promise<void>
elementHandle.tap();
// $ExpectType void
// $ExpectType Promise<void>
elementHandle.tap({ timeout: 10000 });
// $ExpectType void
// $ExpectType Promise<void>
elementHandle.tap({ force: true });
// $ExpectType void
// $ExpectType Promise<void>
elementHandle.tap({ noWaitAfter: true });
// $ExpectType void
// $ExpectType Promise<void>
elementHandle.tap({ position: { x: 0, y: 0 } });
// $ExpectType void
// $ExpectType Promise<void>
elementHandle.tap({ modifiers: ["Shift"] });
// $ExpectType void
// $ExpectType Promise<void>
elementHandle.tap({ trial: true });

// $ExpectType string
Expand Down Expand Up @@ -1664,21 +1664,21 @@ frame.hover("div", { noWaitAfter: true });

// @ts-expect-error
frame.tap();
// $ExpectType void
// $ExpectType Promise<void>
frame.tap("div");
// $ExpectType void
// $ExpectType Promise<void>
frame.tap("div", { timeout: 10000 });
// $ExpectType void
// $ExpectType Promise<void>
frame.tap("div", { force: true });
// $ExpectType void
// $ExpectType Promise<void>
frame.tap("div", { position: { x: 0, y: 0 } });
// $ExpectType void
// $ExpectType Promise<void>
frame.tap("div", { modifiers: ["Shift"] });
// $ExpectType void
// $ExpectType Promise<void>
frame.tap("div", { strict: true });
// $ExpectType void
// $ExpectType Promise<void>
frame.tap("div", { trial: true });
// $ExpectType void
// $ExpectType Promise<void>
frame.tap("div", { noWaitAfter: true });

// @ts-expect-error
Expand Down Expand Up @@ -2018,7 +2018,7 @@ frame.waitForTimeout(10000);

// @ts-expect-error
page.touchscreen.tap();
// $ExpectType void
// $ExpectType Promise<void>
page.touchscreen.tap(1, 2);

//
Expand Down