Skip to content

docs(cdk/testing): cleanup apis for landing on adev #31013

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
53 changes: 13 additions & 40 deletions goldens/cdk/testing/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

```ts

// @public
// @public @deprecated
export type AsyncFactoryFn<T> = () => Promise<T>;

// @public
Expand Down Expand Up @@ -33,9 +33,9 @@ export abstract class ComponentHarness {
host(): Promise<TestElement>;
// (undocumented)
protected readonly locatorFactory: LocatorFactory;
protected locatorFor<T extends (HarnessQuery<any> | string)[]>(...queries: T): AsyncFactoryFn<LocatorFnResult<T>>;
protected locatorForAll<T extends (HarnessQuery<any> | string)[]>(...queries: T): AsyncFactoryFn<LocatorFnResult<T>[]>;
protected locatorForOptional<T extends (HarnessQuery<any> | string)[]>(...queries: T): AsyncFactoryFn<LocatorFnResult<T> | null>;
protected locatorFor<T extends (HarnessQuery<any> | string)[]>(...queries: T): () => Promise<LocatorFnResult<T>>;
protected locatorForAll<T extends (HarnessQuery<any> | string)[]>(...queries: T): () => Promise<LocatorFnResult<T>[]>;
protected locatorForOptional<T extends (HarnessQuery<any> | string)[]>(...queries: T): () => Promise<LocatorFnResult<T> | null>;
protected waitForTasksOutsideAngular(): Promise<void>;
}

Expand All @@ -48,30 +48,20 @@ export interface ComponentHarnessConstructor<T extends ComponentHarness> {

// @public
export abstract class ContentContainerComponentHarness<S extends string = string> extends ComponentHarness implements HarnessLoader {
// (undocumented)
getAllChildLoaders(selector: S): Promise<HarnessLoader[]>;
// (undocumented)
getAllHarnesses<T extends ComponentHarness>(query: HarnessQuery<T>): Promise<T[]>;
// (undocumented)
getChildLoader(selector: S): Promise<HarnessLoader>;
// (undocumented)
getHarness<T extends ComponentHarness>(query: HarnessQuery<T>): Promise<T>;
// (undocumented)
getHarnessOrNull<T extends ComponentHarness>(query: HarnessQuery<T>): Promise<T | null>;
protected getRootHarnessLoader(): Promise<HarnessLoader>;
// (undocumented)
hasHarness<T extends ComponentHarness>(query: HarnessQuery<T>): Promise<boolean>;
}

// @public
export interface ElementDimensions {
// (undocumented)
height: number;
// (undocumented)
left: number;
// (undocumented)
top: number;
// (undocumented)
width: number;
}

Expand All @@ -91,48 +81,31 @@ export function handleAutoChangeDetectionStatus(handler: (status: AutoChangeDete

// @public
export abstract class HarnessEnvironment<E> implements HarnessLoader, LocatorFactory {
protected constructor(rawRootElement: E);
protected constructor(
rawRootElement: E);
protected createComponentHarness<T extends ComponentHarness>(harnessType: ComponentHarnessConstructor<T>, element: E): T;
protected abstract createEnvironment(element: E): HarnessEnvironment<E>;
protected abstract createTestElement(element: E): TestElement;
// (undocumented)
documentRootLocatorFactory(): LocatorFactory;
// (undocumented)
abstract forceStabilize(): Promise<void>;
// (undocumented)
getAllChildLoaders(selector: string): Promise<HarnessLoader[]>;
// (undocumented)
getAllHarnesses<T extends ComponentHarness>(query: HarnessQuery<T>): Promise<T[]>;
protected abstract getAllRawElements(selector: string): Promise<E[]>;
// (undocumented)
getChildLoader(selector: string): Promise<HarnessLoader>;
protected abstract getDocumentRoot(): E;
// (undocumented)
getHarness<T extends ComponentHarness>(query: HarnessQuery<T>): Promise<T>;
// (undocumented)
getHarnessOrNull<T extends ComponentHarness>(query: HarnessQuery<T>): Promise<T | null>;
// (undocumented)
harnessLoaderFor(selector: string): Promise<HarnessLoader>;
// (undocumented)
harnessLoaderForAll(selector: string): Promise<HarnessLoader[]>;
// (undocumented)
harnessLoaderForOptional(selector: string): Promise<HarnessLoader | null>;
// (undocumented)
hasHarness<T extends ComponentHarness>(query: HarnessQuery<T>): Promise<boolean>;
// (undocumented)
locatorFor<T extends (HarnessQuery<any> | string)[]>(...queries: T): AsyncFactoryFn<LocatorFnResult<T>>;
// (undocumented)
locatorForAll<T extends (HarnessQuery<any> | string)[]>(...queries: T): AsyncFactoryFn<LocatorFnResult<T>[]>;
// (undocumented)
locatorForOptional<T extends (HarnessQuery<any> | string)[]>(...queries: T): AsyncFactoryFn<LocatorFnResult<T> | null>;
// (undocumented)
locatorFor<T extends (HarnessQuery<any> | string)[]>(...queries: T): () => Promise<LocatorFnResult<T>>;
locatorForAll<T extends (HarnessQuery<any> | string)[]>(...queries: T): () => Promise<LocatorFnResult<T>[]>;
locatorForOptional<T extends (HarnessQuery<any> | string)[]>(...queries: T): () => Promise<LocatorFnResult<T> | null>;
protected rawRootElement: E;
// (undocumented)
get rootElement(): TestElement;
set rootElement(element: TestElement);
// (undocumented)
rootHarnessLoader(): Promise<HarnessLoader>;
// (undocumented)
abstract waitForTasksOutsideAngular(): Promise<void>;
}

Expand Down Expand Up @@ -170,9 +143,9 @@ export interface LocatorFactory {
harnessLoaderFor(selector: string): Promise<HarnessLoader>;
harnessLoaderForAll(selector: string): Promise<HarnessLoader[]>;
harnessLoaderForOptional(selector: string): Promise<HarnessLoader | null>;
locatorFor<T extends (HarnessQuery<any> | string)[]>(...queries: T): AsyncFactoryFn<LocatorFnResult<T>>;
locatorForAll<T extends (HarnessQuery<any> | string)[]>(...queries: T): AsyncFactoryFn<LocatorFnResult<T>[]>;
locatorForOptional<T extends (HarnessQuery<any> | string)[]>(...queries: T): AsyncFactoryFn<LocatorFnResult<T> | null>;
locatorFor<T extends (HarnessQuery<any> | string)[]>(...queries: T): () => Promise<LocatorFnResult<T>>;
locatorForAll<T extends (HarnessQuery<any> | string)[]>(...queries: T): () => Promise<LocatorFnResult<T>[]>;
locatorForOptional<T extends (HarnessQuery<any> | string)[]>(...queries: T): () => Promise<LocatorFnResult<T> | null>;
rootElement: TestElement;
rootHarnessLoader(): Promise<HarnessLoader>;
waitForTasksOutsideAngular(): Promise<void>;
Expand Down Expand Up @@ -322,7 +295,7 @@ export enum TestKey {
UP_ARROW = 12
}

// @public (undocumented)
// @public
export interface TextOptions {
exclude?: string;
}
Expand Down
2 changes: 1 addition & 1 deletion goldens/material/checkbox/testing/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class MatCheckboxHarness extends ComponentHarness {
// (undocumented)
static hostSelector: string;
// (undocumented)
_input: _angular_cdk_testing.AsyncFactoryFn<_angular_cdk_testing.TestElement>;
_input: () => Promise<_angular_cdk_testing.TestElement>;
isChecked(): Promise<boolean>;
isDisabled(): Promise<boolean>;
isFocused(): Promise<boolean>;
Expand Down
2 changes: 1 addition & 1 deletion goldens/material/chips/testing/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export class MatChipHarness extends ContentContainerComponentHarness {
static hostSelector: string;
isDisabled(): Promise<boolean>;
// (undocumented)
protected _primaryAction: _angular_cdk_testing.AsyncFactoryFn<_angular_cdk_testing.TestElement>;
protected _primaryAction: () => Promise<_angular_cdk_testing.TestElement>;
remove(): Promise<void>;
static with<T extends MatChipHarness>(this: ComponentHarnessConstructor<T>, options?: ChipHarnessFilters): HarnessPredicate<T>;
}
Expand Down
6 changes: 3 additions & 3 deletions goldens/material/dialog/testing/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ export interface DialogHarnessFilters extends BaseHarnessFilters {
// @public
export class MatDialogHarness extends ContentContainerComponentHarness<MatDialogSection | string> {
// (undocumented)
protected _actions: _angular_cdk_testing.AsyncFactoryFn<_angular_cdk_testing.TestElement | null>;
protected _actions: () => Promise<_angular_cdk_testing.TestElement | null>;
close(): Promise<void>;
// (undocumented)
protected _content: _angular_cdk_testing.AsyncFactoryFn<_angular_cdk_testing.TestElement | null>;
protected _content: () => Promise<_angular_cdk_testing.TestElement | null>;
getActionsText(): Promise<string>;
getAriaDescribedby(): Promise<string | null>;
getAriaLabel(): Promise<string | null>;
Expand All @@ -49,7 +49,7 @@ export class MatDialogHarness extends ContentContainerComponentHarness<MatDialog
getTitleText(): Promise<string>;
static hostSelector: string;
// (undocumented)
protected _title: _angular_cdk_testing.AsyncFactoryFn<_angular_cdk_testing.TestElement | null>;
protected _title: () => Promise<_angular_cdk_testing.TestElement | null>;
static with<T extends MatDialogHarness>(this: ComponentHarnessConstructor<T>, options?: DialogHarnessFilters): HarnessPredicate<T>;
}

Expand Down
4 changes: 2 additions & 2 deletions goldens/material/paginator/testing/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ export class MatPaginatorHarness extends ComponentHarness {
// (undocumented)
isPreviousPageDisabled(): Promise<boolean>;
// (undocumented)
_rangeLabel: _angular_cdk_testing.AsyncFactoryFn<_angular_cdk_testing.TestElement>;
_rangeLabel: () => Promise<_angular_cdk_testing.TestElement>;
// (undocumented)
_select: _angular_cdk_testing.AsyncFactoryFn<MatSelectHarness | null>;
_select: () => Promise<MatSelectHarness | null>;
setPageSize(size: number): Promise<void>;
static with<T extends MatPaginatorHarness>(this: ComponentHarnessConstructor<T>, options?: PaginatorHarnessFilters): HarnessPredicate<T>;
}
Expand Down
4 changes: 2 additions & 2 deletions goldens/material/radio/testing/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class MatRadioButtonHarness extends ComponentHarness {
blur(): Promise<void>;
check(): Promise<void>;
// (undocumented)
protected _clickLabel: _angular_cdk_testing.AsyncFactoryFn<_angular_cdk_testing.TestElement>;
protected _clickLabel: () => Promise<_angular_cdk_testing.TestElement>;
focus(): Promise<void>;
getId(): Promise<string | null>;
getLabelText(): Promise<string>;
Expand All @@ -27,7 +27,7 @@ export class MatRadioButtonHarness extends ComponentHarness {
isFocused(): Promise<boolean>;
isRequired(): Promise<boolean>;
// (undocumented)
protected _textLabel: _angular_cdk_testing.AsyncFactoryFn<_angular_cdk_testing.TestElement>;
protected _textLabel: () => Promise<_angular_cdk_testing.TestElement>;
static with<T extends MatRadioButtonHarness>(this: ComponentHarnessConstructor<T>, options?: RadioButtonHarnessFilters): HarnessPredicate<T>;
}

Expand Down
2 changes: 1 addition & 1 deletion goldens/material/slide-toggle/testing/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class MatSlideToggleHarness extends ComponentHarness {
isRequired(): Promise<boolean>;
isValid(): Promise<boolean>;
// (undocumented)
_nativeElement: _angular_cdk_testing.AsyncFactoryFn<_angular_cdk_testing.TestElement>;
_nativeElement: () => Promise<_angular_cdk_testing.TestElement>;
toggle(): Promise<void>;
uncheck(): Promise<void>;
static with<T extends MatSlideToggleHarness>(this: ComponentHarnessConstructor<T>, options?: SlideToggleHarnessFilters): HarnessPredicate<T>;
Expand Down
2 changes: 1 addition & 1 deletion goldens/material/tree/testing/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class MatTreeNodeHarness extends ContentContainerComponentHarness<string>
isExpanded(): Promise<boolean>;
toggle(): Promise<void>;
// (undocumented)
_toggle: _angular_cdk_testing.AsyncFactoryFn<_angular_cdk_testing.TestElement | null>;
_toggle: () => Promise<_angular_cdk_testing.TestElement | null>;
static with(options?: TreeNodeHarnessFilters): HarnessPredicate<MatTreeNodeHarness>;
}

Expand Down
1 change: 1 addition & 0 deletions src/cdk/testing/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,5 @@ extract_api_to_json(
module_name = "@angular/cdk/testing",
output_name = "cdk_testing.json",
private_modules = [""],
repo = "angular/components",
)
6 changes: 5 additions & 1 deletion src/cdk/testing/change-detection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@

import {BehaviorSubject, Subscription} from 'rxjs';

/** Represents the status of auto change detection. */
/**
* The status of the test harness auto change detection. If not diabled test harnesses will
* automatically trigger change detection after every action (such as a click) and before every read
* (such as getting the text of an element).
*/
export interface AutoChangeDetectionStatus {
/** Whether auto change detection is disabled. */
isDisabled: boolean;
Expand Down
Loading
Loading