Skip to content

Commit e969063

Browse files
authored
docs(cdk/testing): cleanup apis for landing on adev (angular#31013)
* docs(cdk/testing): cleanup apis for landing on adev * fixup! docs(cdk/testing): cleanup apis for landing on adev * fixup! docs(cdk/testing): cleanup apis for landing on adev * fixup! docs(cdk/testing): cleanup apis for landing on adev * fixup! docs(cdk/testing): cleanup apis for landing on adev * docs(cdk/testing): specify repo in api docs
1 parent 9288222 commit e969063

File tree

19 files changed

+403
-158
lines changed

19 files changed

+403
-158
lines changed

goldens/cdk/testing/index.api.md

+13-40
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
```ts
66

7-
// @public
7+
// @public @deprecated
88
export type AsyncFactoryFn<T> = () => Promise<T>;
99

1010
// @public
@@ -33,9 +33,9 @@ export abstract class ComponentHarness {
3333
host(): Promise<TestElement>;
3434
// (undocumented)
3535
protected readonly locatorFactory: LocatorFactory;
36-
protected locatorFor<T extends (HarnessQuery<any> | string)[]>(...queries: T): AsyncFactoryFn<LocatorFnResult<T>>;
37-
protected locatorForAll<T extends (HarnessQuery<any> | string)[]>(...queries: T): AsyncFactoryFn<LocatorFnResult<T>[]>;
38-
protected locatorForOptional<T extends (HarnessQuery<any> | string)[]>(...queries: T): AsyncFactoryFn<LocatorFnResult<T> | null>;
36+
protected locatorFor<T extends (HarnessQuery<any> | string)[]>(...queries: T): () => Promise<LocatorFnResult<T>>;
37+
protected locatorForAll<T extends (HarnessQuery<any> | string)[]>(...queries: T): () => Promise<LocatorFnResult<T>[]>;
38+
protected locatorForOptional<T extends (HarnessQuery<any> | string)[]>(...queries: T): () => Promise<LocatorFnResult<T> | null>;
3939
protected waitForTasksOutsideAngular(): Promise<void>;
4040
}
4141

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

4949
// @public
5050
export abstract class ContentContainerComponentHarness<S extends string = string> extends ComponentHarness implements HarnessLoader {
51-
// (undocumented)
5251
getAllChildLoaders(selector: S): Promise<HarnessLoader[]>;
53-
// (undocumented)
5452
getAllHarnesses<T extends ComponentHarness>(query: HarnessQuery<T>): Promise<T[]>;
55-
// (undocumented)
5653
getChildLoader(selector: S): Promise<HarnessLoader>;
57-
// (undocumented)
5854
getHarness<T extends ComponentHarness>(query: HarnessQuery<T>): Promise<T>;
59-
// (undocumented)
6055
getHarnessOrNull<T extends ComponentHarness>(query: HarnessQuery<T>): Promise<T | null>;
6156
protected getRootHarnessLoader(): Promise<HarnessLoader>;
62-
// (undocumented)
6357
hasHarness<T extends ComponentHarness>(query: HarnessQuery<T>): Promise<boolean>;
6458
}
6559

6660
// @public
6761
export interface ElementDimensions {
68-
// (undocumented)
6962
height: number;
70-
// (undocumented)
7163
left: number;
72-
// (undocumented)
7364
top: number;
74-
// (undocumented)
7565
width: number;
7666
}
7767

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

9282
// @public
9383
export abstract class HarnessEnvironment<E> implements HarnessLoader, LocatorFactory {
94-
protected constructor(rawRootElement: E);
84+
protected constructor(
85+
rawRootElement: E);
9586
protected createComponentHarness<T extends ComponentHarness>(harnessType: ComponentHarnessConstructor<T>, element: E): T;
9687
protected abstract createEnvironment(element: E): HarnessEnvironment<E>;
9788
protected abstract createTestElement(element: E): TestElement;
98-
// (undocumented)
9989
documentRootLocatorFactory(): LocatorFactory;
100-
// (undocumented)
10190
abstract forceStabilize(): Promise<void>;
102-
// (undocumented)
10391
getAllChildLoaders(selector: string): Promise<HarnessLoader[]>;
104-
// (undocumented)
10592
getAllHarnesses<T extends ComponentHarness>(query: HarnessQuery<T>): Promise<T[]>;
10693
protected abstract getAllRawElements(selector: string): Promise<E[]>;
107-
// (undocumented)
10894
getChildLoader(selector: string): Promise<HarnessLoader>;
10995
protected abstract getDocumentRoot(): E;
110-
// (undocumented)
11196
getHarness<T extends ComponentHarness>(query: HarnessQuery<T>): Promise<T>;
112-
// (undocumented)
11397
getHarnessOrNull<T extends ComponentHarness>(query: HarnessQuery<T>): Promise<T | null>;
114-
// (undocumented)
11598
harnessLoaderFor(selector: string): Promise<HarnessLoader>;
116-
// (undocumented)
11799
harnessLoaderForAll(selector: string): Promise<HarnessLoader[]>;
118-
// (undocumented)
119100
harnessLoaderForOptional(selector: string): Promise<HarnessLoader | null>;
120-
// (undocumented)
121101
hasHarness<T extends ComponentHarness>(query: HarnessQuery<T>): Promise<boolean>;
122-
// (undocumented)
123-
locatorFor<T extends (HarnessQuery<any> | string)[]>(...queries: T): AsyncFactoryFn<LocatorFnResult<T>>;
124-
// (undocumented)
125-
locatorForAll<T extends (HarnessQuery<any> | string)[]>(...queries: T): AsyncFactoryFn<LocatorFnResult<T>[]>;
126-
// (undocumented)
127-
locatorForOptional<T extends (HarnessQuery<any> | string)[]>(...queries: T): AsyncFactoryFn<LocatorFnResult<T> | null>;
128-
// (undocumented)
102+
locatorFor<T extends (HarnessQuery<any> | string)[]>(...queries: T): () => Promise<LocatorFnResult<T>>;
103+
locatorForAll<T extends (HarnessQuery<any> | string)[]>(...queries: T): () => Promise<LocatorFnResult<T>[]>;
104+
locatorForOptional<T extends (HarnessQuery<any> | string)[]>(...queries: T): () => Promise<LocatorFnResult<T> | null>;
129105
protected rawRootElement: E;
130-
// (undocumented)
131106
get rootElement(): TestElement;
132107
set rootElement(element: TestElement);
133-
// (undocumented)
134108
rootHarnessLoader(): Promise<HarnessLoader>;
135-
// (undocumented)
136109
abstract waitForTasksOutsideAngular(): Promise<void>;
137110
}
138111

@@ -170,9 +143,9 @@ export interface LocatorFactory {
170143
harnessLoaderFor(selector: string): Promise<HarnessLoader>;
171144
harnessLoaderForAll(selector: string): Promise<HarnessLoader[]>;
172145
harnessLoaderForOptional(selector: string): Promise<HarnessLoader | null>;
173-
locatorFor<T extends (HarnessQuery<any> | string)[]>(...queries: T): AsyncFactoryFn<LocatorFnResult<T>>;
174-
locatorForAll<T extends (HarnessQuery<any> | string)[]>(...queries: T): AsyncFactoryFn<LocatorFnResult<T>[]>;
175-
locatorForOptional<T extends (HarnessQuery<any> | string)[]>(...queries: T): AsyncFactoryFn<LocatorFnResult<T> | null>;
146+
locatorFor<T extends (HarnessQuery<any> | string)[]>(...queries: T): () => Promise<LocatorFnResult<T>>;
147+
locatorForAll<T extends (HarnessQuery<any> | string)[]>(...queries: T): () => Promise<LocatorFnResult<T>[]>;
148+
locatorForOptional<T extends (HarnessQuery<any> | string)[]>(...queries: T): () => Promise<LocatorFnResult<T> | null>;
176149
rootElement: TestElement;
177150
rootHarnessLoader(): Promise<HarnessLoader>;
178151
waitForTasksOutsideAngular(): Promise<void>;
@@ -322,7 +295,7 @@ export enum TestKey {
322295
UP_ARROW = 12
323296
}
324297

325-
// @public (undocumented)
298+
// @public
326299
export interface TextOptions {
327300
exclude?: string;
328301
}

goldens/material/checkbox/testing/index.api.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export class MatCheckboxHarness extends ComponentHarness {
3131
// (undocumented)
3232
static hostSelector: string;
3333
// (undocumented)
34-
_input: _angular_cdk_testing.AsyncFactoryFn<_angular_cdk_testing.TestElement>;
34+
_input: () => Promise<_angular_cdk_testing.TestElement>;
3535
isChecked(): Promise<boolean>;
3636
isDisabled(): Promise<boolean>;
3737
isFocused(): Promise<boolean>;

goldens/material/chips/testing/index.api.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export class MatChipHarness extends ContentContainerComponentHarness {
9696
static hostSelector: string;
9797
isDisabled(): Promise<boolean>;
9898
// (undocumented)
99-
protected _primaryAction: _angular_cdk_testing.AsyncFactoryFn<_angular_cdk_testing.TestElement>;
99+
protected _primaryAction: () => Promise<_angular_cdk_testing.TestElement>;
100100
remove(): Promise<void>;
101101
static with<T extends MatChipHarness>(this: ComponentHarnessConstructor<T>, options?: ChipHarnessFilters): HarnessPredicate<T>;
102102
}

goldens/material/dialog/testing/index.api.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ export interface DialogHarnessFilters extends BaseHarnessFilters {
3434
// @public
3535
export class MatDialogHarness extends ContentContainerComponentHarness<MatDialogSection | string> {
3636
// (undocumented)
37-
protected _actions: _angular_cdk_testing.AsyncFactoryFn<_angular_cdk_testing.TestElement | null>;
37+
protected _actions: () => Promise<_angular_cdk_testing.TestElement | null>;
3838
close(): Promise<void>;
3939
// (undocumented)
40-
protected _content: _angular_cdk_testing.AsyncFactoryFn<_angular_cdk_testing.TestElement | null>;
40+
protected _content: () => Promise<_angular_cdk_testing.TestElement | null>;
4141
getActionsText(): Promise<string>;
4242
getAriaDescribedby(): Promise<string | null>;
4343
getAriaLabel(): Promise<string | null>;
@@ -49,7 +49,7 @@ export class MatDialogHarness extends ContentContainerComponentHarness<MatDialog
4949
getTitleText(): Promise<string>;
5050
static hostSelector: string;
5151
// (undocumented)
52-
protected _title: _angular_cdk_testing.AsyncFactoryFn<_angular_cdk_testing.TestElement | null>;
52+
protected _title: () => Promise<_angular_cdk_testing.TestElement | null>;
5353
static with<T extends MatDialogHarness>(this: ComponentHarnessConstructor<T>, options?: DialogHarnessFilters): HarnessPredicate<T>;
5454
}
5555

goldens/material/paginator/testing/index.api.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ export class MatPaginatorHarness extends ComponentHarness {
2424
// (undocumented)
2525
isPreviousPageDisabled(): Promise<boolean>;
2626
// (undocumented)
27-
_rangeLabel: _angular_cdk_testing.AsyncFactoryFn<_angular_cdk_testing.TestElement>;
27+
_rangeLabel: () => Promise<_angular_cdk_testing.TestElement>;
2828
// (undocumented)
29-
_select: _angular_cdk_testing.AsyncFactoryFn<MatSelectHarness | null>;
29+
_select: () => Promise<MatSelectHarness | null>;
3030
setPageSize(size: number): Promise<void>;
3131
static with<T extends MatPaginatorHarness>(this: ComponentHarnessConstructor<T>, options?: PaginatorHarnessFilters): HarnessPredicate<T>;
3232
}

goldens/material/radio/testing/index.api.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export class MatRadioButtonHarness extends ComponentHarness {
1515
blur(): Promise<void>;
1616
check(): Promise<void>;
1717
// (undocumented)
18-
protected _clickLabel: _angular_cdk_testing.AsyncFactoryFn<_angular_cdk_testing.TestElement>;
18+
protected _clickLabel: () => Promise<_angular_cdk_testing.TestElement>;
1919
focus(): Promise<void>;
2020
getId(): Promise<string | null>;
2121
getLabelText(): Promise<string>;
@@ -27,7 +27,7 @@ export class MatRadioButtonHarness extends ComponentHarness {
2727
isFocused(): Promise<boolean>;
2828
isRequired(): Promise<boolean>;
2929
// (undocumented)
30-
protected _textLabel: _angular_cdk_testing.AsyncFactoryFn<_angular_cdk_testing.TestElement>;
30+
protected _textLabel: () => Promise<_angular_cdk_testing.TestElement>;
3131
static with<T extends MatRadioButtonHarness>(this: ComponentHarnessConstructor<T>, options?: RadioButtonHarnessFilters): HarnessPredicate<T>;
3232
}
3333

goldens/material/slide-toggle/testing/index.api.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export class MatSlideToggleHarness extends ComponentHarness {
2727
isRequired(): Promise<boolean>;
2828
isValid(): Promise<boolean>;
2929
// (undocumented)
30-
_nativeElement: _angular_cdk_testing.AsyncFactoryFn<_angular_cdk_testing.TestElement>;
30+
_nativeElement: () => Promise<_angular_cdk_testing.TestElement>;
3131
toggle(): Promise<void>;
3232
uncheck(): Promise<void>;
3333
static with<T extends MatSlideToggleHarness>(this: ComponentHarnessConstructor<T>, options?: SlideToggleHarnessFilters): HarnessPredicate<T>;

goldens/material/tree/testing/index.api.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export class MatTreeNodeHarness extends ContentContainerComponentHarness<string>
3030
isExpanded(): Promise<boolean>;
3131
toggle(): Promise<void>;
3232
// (undocumented)
33-
_toggle: _angular_cdk_testing.AsyncFactoryFn<_angular_cdk_testing.TestElement | null>;
33+
_toggle: () => Promise<_angular_cdk_testing.TestElement | null>;
3434
static with(options?: TreeNodeHarnessFilters): HarnessPredicate<MatTreeNodeHarness>;
3535
}
3636

src/cdk/testing/BUILD.bazel

+1
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,5 @@ extract_api_to_json(
5858
module_name = "@angular/cdk/testing",
5959
output_name = "cdk_testing.json",
6060
private_modules = [""],
61+
repo = "angular/components",
6162
)

src/cdk/testing/change-detection.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88

99
import {BehaviorSubject, Subscription} from 'rxjs';
1010

11-
/** Represents the status of auto change detection. */
11+
/**
12+
* The status of the test harness auto change detection. If not diabled test harnesses will
13+
* automatically trigger change detection after every action (such as a click) and before every read
14+
* (such as getting the text of an element).
15+
*/
1216
export interface AutoChangeDetectionStatus {
1317
/** Whether auto change detection is disabled. */
1418
isDisabled: boolean;

0 commit comments

Comments
 (0)