From c132756306993bb14ef931ac6375469e949afe19 Mon Sep 17 00:00:00 2001 From: Yury Semikhatsky Date: Tue, 28 Mar 2023 15:50:55 -0700 Subject: [PATCH] cherry-pick(#22005): fix(ct): vue revert json object as prop (#22039) Original PR: https://github.com/microsoft/playwright/pull/22005 References https://github.com/microsoft/playwright/issues/22003 --- packages/playwright-ct-vue/index.d.ts | 16 +++++++++++----- packages/playwright-ct-vue2/index.d.ts | 16 +++++++++++----- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/packages/playwright-ct-vue/index.d.ts b/packages/playwright-ct-vue/index.d.ts index f9a937719f..e3cd55a7f1 100644 --- a/packages/playwright-ct-vue/index.d.ts +++ b/packages/playwright-ct-vue/index.d.ts @@ -41,14 +41,17 @@ type JsonObject = { [Key in string]?: JsonValue }; type Slot = string | string[]; -export interface MountOptions { +export interface MountOptions< + HooksConfig extends JsonObject, + Props extends Record +> { props?: Props; slots?: Record & { default?: Slot }; on?: Record; hooksConfig?: HooksConfig; } -interface MountResult extends Locator { +interface MountResult> extends Locator { unmount(): Promise; update(options: Omit, 'hooksConfig'>): Promise; } @@ -62,9 +65,12 @@ export interface ComponentFixtures { mount(component: JSX.Element): Promise; mount( component: any, - options?: MountOptions - ): Promise>; - mount( + options?: MountOptions> + ): Promise>>; + mount< + HooksConfig extends JsonObject, + Props extends Record = Record + >( component: any, options: MountOptions & { props: Props } ): Promise>; diff --git a/packages/playwright-ct-vue2/index.d.ts b/packages/playwright-ct-vue2/index.d.ts index f9a937719f..5f338cef3b 100644 --- a/packages/playwright-ct-vue2/index.d.ts +++ b/packages/playwright-ct-vue2/index.d.ts @@ -41,14 +41,17 @@ type JsonObject = { [Key in string]?: JsonValue }; type Slot = string | string[]; -export interface MountOptions { +export interface MountOptions< + HooksConfig extends JsonObject, + Props extends Record +> { props?: Props; slots?: Record & { default?: Slot }; on?: Record; hooksConfig?: HooksConfig; } -interface MountResult extends Locator { +interface MountResult> extends Locator { unmount(): Promise; update(options: Omit, 'hooksConfig'>): Promise; } @@ -62,9 +65,12 @@ export interface ComponentFixtures { mount(component: JSX.Element): Promise; mount( component: any, - options?: MountOptions - ): Promise>; - mount( + options?: MountOptions> + ): Promise>>; + mount< + HooksConfig extends JsonObject, + Props extends Record = Record + >( component: any, options: MountOptions & { props: Props } ): Promise>;