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.
|
|
|
|
|
*/
|
|
|
|
|
|
2024-05-07 21:47:48 +02:00
|
|
|
import type { Locator } from 'playwright/test';
|
2023-10-24 22:29:29 +02:00
|
|
|
import type { JsonObject } from '@playwright/experimental-ct-core/types/component';
|
2024-05-07 21:47:48 +02:00
|
|
|
import type { TestType } from '@playwright/experimental-ct-core';
|
2023-10-24 22:29:29 +02:00
|
|
|
import type { Type } from '@angular/core';
|
|
|
|
|
|
2024-05-07 21:47:48 +02:00
|
|
|
export type ComponentEvents = Record<string, Function>;
|
2023-10-24 22:29:29 +02:00
|
|
|
|
|
|
|
|
export interface MountOptions<HooksConfig extends JsonObject, Component> {
|
2024-05-07 21:47:48 +02:00
|
|
|
props?: Partial<Component> | Record<string, unknown>, // TODO: filter props and handle signals
|
2023-10-24 22:29:29 +02:00
|
|
|
on?: ComponentEvents;
|
|
|
|
|
hooksConfig?: HooksConfig;
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-07 21:47:48 +02:00
|
|
|
export interface MountResult<Component> extends Locator {
|
2023-10-24 22:29:29 +02:00
|
|
|
unmount(): Promise<void>;
|
|
|
|
|
update(options: {
|
|
|
|
|
props?: Partial<Component>,
|
|
|
|
|
on?: Partial<ComponentEvents>,
|
|
|
|
|
}): Promise<void>;
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-09 18:26:59 +02:00
|
|
|
export const test: TestType<{
|
2023-10-24 22:29:29 +02:00
|
|
|
mount<HooksConfig extends JsonObject, Component = unknown>(
|
|
|
|
|
component: Type<Component>,
|
|
|
|
|
options?: MountOptions<HooksConfig, Component>
|
|
|
|
|
): Promise<MountResult<Component>>;
|
2024-05-09 18:26:59 +02:00
|
|
|
}>;
|
2023-10-24 22:29:29 +02:00
|
|
|
|
2024-05-07 21:47:48 +02:00
|
|
|
export { defineConfig, PlaywrightTestConfig } from '@playwright/experimental-ct-core';
|
|
|
|
|
export { expect, devices } from 'playwright/test';
|