From 7a4392d569742fe1be01ab93c9384ce65a7ea54a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=B0nan=C3=A7=20G=C3=BCm=C3=BC=C5=9F?= Date: Tue, 23 Apr 2024 17:11:49 +0300 Subject: [PATCH 1/2] Add browser.Tap defs --- types/k6/experimental/browser.d.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/types/k6/experimental/browser.d.ts b/types/k6/experimental/browser.d.ts index 847e5d0db87088..83aa1616a2b125 100644 --- a/types/k6/experimental/browser.d.ts +++ b/types/k6/experimental/browser.d.ts @@ -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; /** * Returns the `node.textContent`. @@ -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; /** * Press the given key for the first element found that matches the selector. @@ -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; /** * Dispatches HTML DOM event types e.g. `click`. @@ -3129,7 +3129,7 @@ export interface Page { */ trial?: boolean; }, - ): void; + ): Promise; /** * **NOTE** Use locator-based locator.textContent([options]) instead. @@ -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; } /** From 07ca0405a80e4d4b178cf2f949108643ee808979 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=B0nan=C3=A7=20G=C3=BCm=C3=BC=C5=9F?= Date: Wed, 24 Apr 2024 13:20:43 +0300 Subject: [PATCH 2/2] Update browser.Tap tests to promise --- types/k6/test/browser.ts | 60 ++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/types/k6/test/browser.ts b/types/k6/test/browser.ts index dde0a7176a7124..36cca40340be87 100644 --- a/types/k6/test/browser.ts +++ b/types/k6/test/browser.ts @@ -677,21 +677,21 @@ page.setViewportSize({ width: 800, height: 600 }); // @ts-expect-error page.tap(); -// $ExpectType void +// $ExpectType Promise page.tap(selector); -// $ExpectType void +// $ExpectType Promise page.tap(selector, { force: true }); -// $ExpectType void +// $ExpectType Promise page.tap(selector, { modifiers: ["Alt", "Control", "Meta", "Shift"] }); -// $ExpectType void +// $ExpectType Promise page.tap(selector, { noWaitAfter: true }); -// $ExpectType void +// $ExpectType Promise page.tap(selector, { position: { x: 0, y: 0 } }); -// $ExpectType void +// $ExpectType Promise page.tap(selector, { strict: true }); -// $ExpectType void +// $ExpectType Promise page.tap(selector, { timeout: 10000 }); -// $ExpectType void +// $ExpectType Promise page.tap(selector, { trial: true }); // @ts-expect-error @@ -1109,17 +1109,17 @@ locator.hover({ timeout: 10000 }); // $ExpectType void locator.hover({ trial: true }); -// $ExpectType void +// $ExpectType Promise locator.tap(); -// $ExpectType void +// $ExpectType Promise locator.tap({ force: true }); -// $ExpectType void +// $ExpectType Promise locator.tap({ noWaitAfter: true }); -// $ExpectType void +// $ExpectType Promise locator.tap({ position: { x: 0, y: 0 } }); -// $ExpectType void +// $ExpectType Promise locator.tap({ timeout: 10000 }); -// $ExpectType void +// $ExpectType Promise locator.tap({ trial: true }); // @ts-expect-error @@ -1473,19 +1473,19 @@ elementHandle.setInputFiles({ name: "file.txt", mimeType: "text/plain", buffer: timeout: 1000, }); -// $ExpectType void +// $ExpectType Promise elementHandle.tap(); -// $ExpectType void +// $ExpectType Promise elementHandle.tap({ timeout: 10000 }); -// $ExpectType void +// $ExpectType Promise elementHandle.tap({ force: true }); -// $ExpectType void +// $ExpectType Promise elementHandle.tap({ noWaitAfter: true }); -// $ExpectType void +// $ExpectType Promise elementHandle.tap({ position: { x: 0, y: 0 } }); -// $ExpectType void +// $ExpectType Promise elementHandle.tap({ modifiers: ["Shift"] }); -// $ExpectType void +// $ExpectType Promise elementHandle.tap({ trial: true }); // $ExpectType string @@ -1664,21 +1664,21 @@ frame.hover("div", { noWaitAfter: true }); // @ts-expect-error frame.tap(); -// $ExpectType void +// $ExpectType Promise frame.tap("div"); -// $ExpectType void +// $ExpectType Promise frame.tap("div", { timeout: 10000 }); -// $ExpectType void +// $ExpectType Promise frame.tap("div", { force: true }); -// $ExpectType void +// $ExpectType Promise frame.tap("div", { position: { x: 0, y: 0 } }); -// $ExpectType void +// $ExpectType Promise frame.tap("div", { modifiers: ["Shift"] }); -// $ExpectType void +// $ExpectType Promise frame.tap("div", { strict: true }); -// $ExpectType void +// $ExpectType Promise frame.tap("div", { trial: true }); -// $ExpectType void +// $ExpectType Promise frame.tap("div", { noWaitAfter: true }); // @ts-expect-error @@ -2018,7 +2018,7 @@ frame.waitForTimeout(10000); // @ts-expect-error page.touchscreen.tap(); -// $ExpectType void +// $ExpectType Promise page.touchscreen.tap(1, 2); //