2023-10-24 22:29:29 +02:00
|
|
|
/**
|
|
|
|
|
* Copyright (c) Microsoft Corporation.
|
|
|
|
|
*
|
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
|
*
|
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
*
|
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
|
* limitations under the License.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import type {
|
2024-03-27 23:15:31 +01:00
|
|
|
Locator,
|
2023-10-24 22:29:29 +02:00
|
|
|
PlaywrightTestArgs,
|
|
|
|
|
PlaywrightTestOptions,
|
|
|
|
|
PlaywrightWorkerArgs,
|
|
|
|
|
PlaywrightWorkerOptions,
|
2024-03-27 23:15:31 +01:00
|
|
|
TestType,
|
2023-10-24 22:29:29 +02:00
|
|
|
} from '@playwright/test';
|
|
|
|
|
import type { JsonObject } from '@playwright/experimental-ct-core/types/component';
|
2024-02-23 18:01:11 +01:00
|
|
|
import type { Provider, Type } from '@angular/core';
|
2023-10-24 22:29:29 +02:00
|
|
|
|
2024-03-27 23:15:31 +01:00
|
|
|
export type { PlaywrightTestConfig } from '@playwright/experimental-ct-core';
|
2023-10-24 22:29:29 +02:00
|
|
|
|
|
|
|
|
type ComponentEvents = Record<string, Function>;
|
|
|
|
|
|
|
|
|
|
export interface MountOptions<HooksConfig extends JsonObject, Component> {
|
2024-02-23 17:44:58 +01:00
|
|
|
props?: Partial<Component> | Record<string, unknown>, // TODO: filter props and handle signals
|
2024-02-23 18:01:11 +01:00
|
|
|
providers?: Provider[],
|
2023-10-24 22:29:29 +02:00
|
|
|
on?: ComponentEvents;
|
|
|
|
|
hooksConfig?: HooksConfig;
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-23 16:22:45 +01:00
|
|
|
export interface MountTemplateOptions<HooksConfig extends JsonObject, Component> extends MountOptions<HooksConfig, Component> {
|
|
|
|
|
imports?: Type<unknown>[];
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-24 22:29:29 +02:00
|
|
|
interface MountResult<Component> extends Locator {
|
|
|
|
|
unmount(): Promise<void>;
|
|
|
|
|
update(options: {
|
|
|
|
|
props?: Partial<Component>,
|
|
|
|
|
on?: Partial<ComponentEvents>,
|
|
|
|
|
}): Promise<void>;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface ComponentFixtures {
|
2024-02-23 16:22:45 +01:00
|
|
|
mount<HooksConfig extends JsonObject, Component = unknown>(
|
|
|
|
|
template: string,
|
|
|
|
|
options?: MountTemplateOptions<HooksConfig, Component>
|
|
|
|
|
): Promise<MountResult<Component>>;
|
2023-10-24 22:29:29 +02:00
|
|
|
mount<HooksConfig extends JsonObject, Component = unknown>(
|
|
|
|
|
component: Type<Component>,
|
|
|
|
|
options?: MountOptions<HooksConfig, Component>
|
|
|
|
|
): Promise<MountResult<Component>>;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const test: TestType<
|
|
|
|
|
PlaywrightTestArgs & PlaywrightTestOptions & ComponentFixtures,
|
|
|
|
|
PlaywrightWorkerArgs & PlaywrightWorkerOptions
|
|
|
|
|
>;
|
|
|
|
|
|
|
|
|
|
export function defineConfig(config: PlaywrightTestConfig): PlaywrightTestConfig;
|
|
|
|
|
export function defineConfig<T>(config: PlaywrightTestConfig<T>): PlaywrightTestConfig<T>;
|
|
|
|
|
export function defineConfig<T, W>(config: PlaywrightTestConfig<T, W>): PlaywrightTestConfig<T, W>;
|
|
|
|
|
|
|
|
|
|
export { expect, devices } from '@playwright/test';
|