@angular/cdk 20.0.0-next.9 → 20.0.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_adev_assets/cdk_testing.json +7032 -1
- package/_adev_assets/cdk_testing_protractor.json +1747 -1
- package/_adev_assets/cdk_testing_selenium_webdriver.json +1801 -1
- package/_adev_assets/cdk_testing_testbed.json +1903 -1
- package/dialog/index.d.ts +1 -1
- package/fesm2022/cdk.mjs +1 -1
- package/fesm2022/cdk.mjs.map +1 -1
- package/fesm2022/dialog.mjs +1 -1
- package/fesm2022/dialog.mjs.map +1 -1
- package/fesm2022/testing.mjs +255 -52
- package/fesm2022/testing.mjs.map +1 -1
- package/{harness-environment.d-BatBdODN.d.ts → harness-environment.d-BbFzIFDE.d.ts} +362 -89
- package/package.json +1 -1
- package/schematics/ng-add/index.js +1 -1
- package/testing/index.d.ts +6 -2
- package/testing/selenium-webdriver/index.d.ts +1 -1
- package/testing/testbed/index.d.ts +1 -1
|
@@ -2,9 +2,13 @@
|
|
|
2
2
|
* Dimensions for element size and its position relative to the viewport.
|
|
3
3
|
*/
|
|
4
4
|
interface ElementDimensions {
|
|
5
|
+
/** The distance from the top of the viewport in pixels */
|
|
5
6
|
top: number;
|
|
7
|
+
/** The distance from the left of the viewport in pixels */
|
|
6
8
|
left: number;
|
|
9
|
+
/** The width of the element in pixels */
|
|
7
10
|
width: number;
|
|
11
|
+
/** The height of the element in pixels */
|
|
8
12
|
height: number;
|
|
9
13
|
}
|
|
10
14
|
|
|
@@ -138,12 +142,20 @@ interface TestElement {
|
|
|
138
142
|
*/
|
|
139
143
|
dispatchEvent(name: string, data?: Record<string, EventData>): Promise<void>;
|
|
140
144
|
}
|
|
145
|
+
/**
|
|
146
|
+
* Options that affect the text returned by `TestElement.text`.
|
|
147
|
+
*/
|
|
141
148
|
interface TextOptions {
|
|
142
|
-
/** Optional selector for elements
|
|
149
|
+
/** Optional selector for elements whose content should be excluded from the text string. */
|
|
143
150
|
exclude?: string;
|
|
144
151
|
}
|
|
145
152
|
|
|
146
|
-
/**
|
|
153
|
+
/**
|
|
154
|
+
* An async function that returns a promise when called.
|
|
155
|
+
* @deprecated This was just an alias for `() => Promise<T>`. Use that instead.
|
|
156
|
+
* @breaking-change 21.0.0 Remove this alias.
|
|
157
|
+
* @docs-private
|
|
158
|
+
*/
|
|
147
159
|
type AsyncFactoryFn<T> = () => Promise<T>;
|
|
148
160
|
/** An async function that takes an item and returns a boolean promise */
|
|
149
161
|
type AsyncPredicate<T> = (item: T) => Promise<boolean>;
|
|
@@ -166,15 +178,23 @@ type HarnessQuery<T extends ComponentHarness> = ComponentHarnessConstructor<T> |
|
|
|
166
178
|
* Since we don't know for sure which query will match, the result type if the union of the types
|
|
167
179
|
* for all possible results.
|
|
168
180
|
*
|
|
169
|
-
*
|
|
181
|
+
* @usageNotes
|
|
182
|
+
* ### Example
|
|
183
|
+
*
|
|
170
184
|
* The type:
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
*
|
|
185
|
+
* ```ts
|
|
186
|
+
* LocatorFnResult<[
|
|
187
|
+
* ComponentHarnessConstructor<MyHarness>,
|
|
188
|
+
* HarnessPredicate<MyOtherHarness>,
|
|
174
189
|
* string
|
|
175
|
-
* ]
|
|
190
|
+
* ]>
|
|
191
|
+
* ```
|
|
192
|
+
*
|
|
176
193
|
* is equivalent to:
|
|
177
|
-
*
|
|
194
|
+
*
|
|
195
|
+
* ```ts
|
|
196
|
+
* MyHarness | MyOtherHarness | TestElement
|
|
197
|
+
* ```
|
|
178
198
|
*/
|
|
179
199
|
type LocatorFnResult<T extends (HarnessQuery<any> | string)[]> = {
|
|
180
200
|
[I in keyof T]: T[I] extends new (...args: any[]) => infer C ? C : T[I] extends {
|
|
@@ -250,6 +270,21 @@ interface LocatorFactory {
|
|
|
250
270
|
/**
|
|
251
271
|
* Creates an asynchronous locator function that can be used to find a `ComponentHarness` instance
|
|
252
272
|
* or element under the root element of this `LocatorFactory`.
|
|
273
|
+
*
|
|
274
|
+
* For example, given the following DOM and assuming `DivHarness.hostSelector` is `'div'`
|
|
275
|
+
*
|
|
276
|
+
* ```html
|
|
277
|
+
* <div id="d1"></div><div id="d2"></div>
|
|
278
|
+
* ```
|
|
279
|
+
*
|
|
280
|
+
* then we expect:
|
|
281
|
+
*
|
|
282
|
+
* ```ts
|
|
283
|
+
* await lf.locatorFor(DivHarness, 'div')() // Gets a `DivHarness` instance for #d1
|
|
284
|
+
* await lf.locatorFor('div', DivHarness)() // Gets a `TestElement` instance for #d1
|
|
285
|
+
* await lf.locatorFor('span')() // Throws because the `Promise` rejects
|
|
286
|
+
* ```
|
|
287
|
+
*
|
|
253
288
|
* @param queries A list of queries specifying which harnesses and elements to search for:
|
|
254
289
|
* - A `string` searches for elements matching the CSS selector specified by the string.
|
|
255
290
|
* - A `ComponentHarness` constructor searches for `ComponentHarness` instances matching the
|
|
@@ -261,17 +296,26 @@ interface LocatorFactory {
|
|
|
261
296
|
* order in the DOM, and second by order in the queries list. If no matches are found, the
|
|
262
297
|
* `Promise` rejects. The type that the `Promise` resolves to is a union of all result types for
|
|
263
298
|
* each query.
|
|
264
|
-
*
|
|
265
|
-
* e.g. Given the following DOM: `<div id="d1" /><div id="d2" />`, and assuming
|
|
266
|
-
* `DivHarness.hostSelector === 'div'`:
|
|
267
|
-
* - `await lf.locatorFor(DivHarness, 'div')()` gets a `DivHarness` instance for `#d1`
|
|
268
|
-
* - `await lf.locatorFor('div', DivHarness)()` gets a `TestElement` instance for `#d1`
|
|
269
|
-
* - `await lf.locatorFor('span')()` throws because the `Promise` rejects.
|
|
270
299
|
*/
|
|
271
|
-
locatorFor<T extends (HarnessQuery<any> | string)[]>(...queries: T):
|
|
300
|
+
locatorFor<T extends (HarnessQuery<any> | string)[]>(...queries: T): () => Promise<LocatorFnResult<T>>;
|
|
272
301
|
/**
|
|
273
302
|
* Creates an asynchronous locator function that can be used to find a `ComponentHarness` instance
|
|
274
303
|
* or element under the root element of this `LocatorFactory`.
|
|
304
|
+
*
|
|
305
|
+
* For example, given the following DOM and assuming `DivHarness.hostSelector` is `'div'`
|
|
306
|
+
*
|
|
307
|
+
* ```html
|
|
308
|
+
* <div id="d1"></div><div id="d2"></div>
|
|
309
|
+
* ```
|
|
310
|
+
*
|
|
311
|
+
* then we expect:
|
|
312
|
+
*
|
|
313
|
+
* ```ts
|
|
314
|
+
* await lf.locatorForOptional(DivHarness, 'div')() // Gets a `DivHarness` instance for #d1
|
|
315
|
+
* await lf.locatorForOptional('div', DivHarness)() // Gets a `TestElement` instance for #d1
|
|
316
|
+
* await lf.locatorForOptional('span')() // Gets `null`
|
|
317
|
+
* ```
|
|
318
|
+
*
|
|
275
319
|
* @param queries A list of queries specifying which harnesses and elements to search for:
|
|
276
320
|
* - A `string` searches for elements matching the CSS selector specified by the string.
|
|
277
321
|
* - A `ComponentHarness` constructor searches for `ComponentHarness` instances matching the
|
|
@@ -283,17 +327,32 @@ interface LocatorFactory {
|
|
|
283
327
|
* order in the DOM, and second by order in the queries list. If no matches are found, the
|
|
284
328
|
* `Promise` is resolved with `null`. The type that the `Promise` resolves to is a union of all
|
|
285
329
|
* result types for each query or null.
|
|
286
|
-
*
|
|
287
|
-
* e.g. Given the following DOM: `<div id="d1" /><div id="d2" />`, and assuming
|
|
288
|
-
* `DivHarness.hostSelector === 'div'`:
|
|
289
|
-
* - `await lf.locatorForOptional(DivHarness, 'div')()` gets a `DivHarness` instance for `#d1`
|
|
290
|
-
* - `await lf.locatorForOptional('div', DivHarness)()` gets a `TestElement` instance for `#d1`
|
|
291
|
-
* - `await lf.locatorForOptional('span')()` gets `null`.
|
|
292
330
|
*/
|
|
293
|
-
locatorForOptional<T extends (HarnessQuery<any> | string)[]>(...queries: T):
|
|
331
|
+
locatorForOptional<T extends (HarnessQuery<any> | string)[]>(...queries: T): () => Promise<LocatorFnResult<T> | null>;
|
|
294
332
|
/**
|
|
295
333
|
* Creates an asynchronous locator function that can be used to find `ComponentHarness` instances
|
|
296
334
|
* or elements under the root element of this `LocatorFactory`.
|
|
335
|
+
*
|
|
336
|
+
* For example, given the following DOM and assuming `DivHarness.hostSelector` is `'div'` and
|
|
337
|
+
* `IdIsD1Harness.hostSelector` is `'#d1'`
|
|
338
|
+
*
|
|
339
|
+
* ```html
|
|
340
|
+
* <div id="d1"></div><div id="d2"></div>
|
|
341
|
+
* ```
|
|
342
|
+
*
|
|
343
|
+
* then we expect:
|
|
344
|
+
*
|
|
345
|
+
* ```ts
|
|
346
|
+
* // Gets [DivHarness for #d1, TestElement for #d1, DivHarness for #d2, TestElement for #d2]
|
|
347
|
+
* await lf.locatorForAll(DivHarness, 'div')()
|
|
348
|
+
* // Gets [TestElement for #d1, TestElement for #d2]
|
|
349
|
+
* await lf.locatorForAll('div', '#d1')()
|
|
350
|
+
* // Gets [DivHarness for #d1, IdIsD1Harness for #d1, DivHarness for #d2]
|
|
351
|
+
* await lf.locatorForAll(DivHarness, IdIsD1Harness)()
|
|
352
|
+
* // Gets []
|
|
353
|
+
* await lf.locatorForAll('span')()
|
|
354
|
+
* ```
|
|
355
|
+
*
|
|
297
356
|
* @param queries A list of queries specifying which harnesses and elements to search for:
|
|
298
357
|
* - A `string` searches for elements matching the CSS selector specified by the string.
|
|
299
358
|
* - A `ComponentHarness` constructor searches for `ComponentHarness` instances matching the
|
|
@@ -307,27 +366,8 @@ interface LocatorFactory {
|
|
|
307
366
|
* an element matches multiple `string` selectors, only one `TestElement` instance is returned
|
|
308
367
|
* for that element. The type that the `Promise` resolves to is an array where each element is
|
|
309
368
|
* the union of all result types for each query.
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
* `DivHarness.hostSelector === 'div'` and `IdIsD1Harness.hostSelector === '#d1'`:
|
|
313
|
-
* - `await lf.locatorForAll(DivHarness, 'div')()` gets `[
|
|
314
|
-
* DivHarness, // for #d1
|
|
315
|
-
* TestElement, // for #d1
|
|
316
|
-
* DivHarness, // for #d2
|
|
317
|
-
* TestElement // for #d2
|
|
318
|
-
* ]`
|
|
319
|
-
* - `await lf.locatorForAll('div', '#d1')()` gets `[
|
|
320
|
-
* TestElement, // for #d1
|
|
321
|
-
* TestElement // for #d2
|
|
322
|
-
* ]`
|
|
323
|
-
* - `await lf.locatorForAll(DivHarness, IdIsD1Harness)()` gets `[
|
|
324
|
-
* DivHarness, // for #d1
|
|
325
|
-
* IdIsD1Harness, // for #d1
|
|
326
|
-
* DivHarness // for #d2
|
|
327
|
-
* ]`
|
|
328
|
-
* - `await lf.locatorForAll('span')()` gets `[]`.
|
|
329
|
-
*/
|
|
330
|
-
locatorForAll<T extends (HarnessQuery<any> | string)[]>(...queries: T): AsyncFactoryFn<LocatorFnResult<T>[]>;
|
|
369
|
+
*/
|
|
370
|
+
locatorForAll<T extends (HarnessQuery<any> | string)[]>(...queries: T): () => Promise<LocatorFnResult<T>[]>;
|
|
331
371
|
/** @return A `HarnessLoader` rooted at the root element of this `LocatorFactory`. */
|
|
332
372
|
rootHarnessLoader(): Promise<HarnessLoader>;
|
|
333
373
|
/**
|
|
@@ -363,9 +403,8 @@ interface LocatorFactory {
|
|
|
363
403
|
waitForTasksOutsideAngular(): Promise<void>;
|
|
364
404
|
}
|
|
365
405
|
/**
|
|
366
|
-
* Base class for component harnesses that all component harness authors should extend. This
|
|
367
|
-
* component harness provides the basic ability to locate element and sub-component
|
|
368
|
-
* should be inherited when defining user's own harness.
|
|
406
|
+
* Base class for component test harnesses that all component harness authors should extend. This
|
|
407
|
+
* base component harness provides the basic ability to locate element and sub-component harnesses.
|
|
369
408
|
*/
|
|
370
409
|
declare abstract class ComponentHarness {
|
|
371
410
|
protected readonly locatorFactory: LocatorFactory;
|
|
@@ -381,6 +420,21 @@ declare abstract class ComponentHarness {
|
|
|
381
420
|
/**
|
|
382
421
|
* Creates an asynchronous locator function that can be used to find a `ComponentHarness` instance
|
|
383
422
|
* or element under the host element of this `ComponentHarness`.
|
|
423
|
+
*
|
|
424
|
+
* For example, given the following DOM and assuming `DivHarness.hostSelector` is `'div'`
|
|
425
|
+
*
|
|
426
|
+
* ```html
|
|
427
|
+
* <div id="d1"></div><div id="d2"></div>
|
|
428
|
+
* ```
|
|
429
|
+
*
|
|
430
|
+
* then we expect:
|
|
431
|
+
*
|
|
432
|
+
* ```ts
|
|
433
|
+
* await ch.locatorFor(DivHarness, 'div')() // Gets a `DivHarness` instance for #d1
|
|
434
|
+
* await ch.locatorFor('div', DivHarness)() // Gets a `TestElement` instance for #d1
|
|
435
|
+
* await ch.locatorFor('span')() // Throws because the `Promise` rejects
|
|
436
|
+
* ```
|
|
437
|
+
*
|
|
384
438
|
* @param queries A list of queries specifying which harnesses and elements to search for:
|
|
385
439
|
* - A `string` searches for elements matching the CSS selector specified by the string.
|
|
386
440
|
* - A `ComponentHarness` constructor searches for `ComponentHarness` instances matching the
|
|
@@ -392,17 +446,26 @@ declare abstract class ComponentHarness {
|
|
|
392
446
|
* order in the DOM, and second by order in the queries list. If no matches are found, the
|
|
393
447
|
* `Promise` rejects. The type that the `Promise` resolves to is a union of all result types for
|
|
394
448
|
* each query.
|
|
395
|
-
*
|
|
396
|
-
* e.g. Given the following DOM: `<div id="d1" /><div id="d2" />`, and assuming
|
|
397
|
-
* `DivHarness.hostSelector === 'div'`:
|
|
398
|
-
* - `await ch.locatorFor(DivHarness, 'div')()` gets a `DivHarness` instance for `#d1`
|
|
399
|
-
* - `await ch.locatorFor('div', DivHarness)()` gets a `TestElement` instance for `#d1`
|
|
400
|
-
* - `await ch.locatorFor('span')()` throws because the `Promise` rejects.
|
|
401
449
|
*/
|
|
402
|
-
protected locatorFor<T extends (HarnessQuery<any> | string)[]>(...queries: T):
|
|
450
|
+
protected locatorFor<T extends (HarnessQuery<any> | string)[]>(...queries: T): () => Promise<LocatorFnResult<T>>;
|
|
403
451
|
/**
|
|
404
452
|
* Creates an asynchronous locator function that can be used to find a `ComponentHarness` instance
|
|
405
453
|
* or element under the host element of this `ComponentHarness`.
|
|
454
|
+
*
|
|
455
|
+
* For example, given the following DOM and assuming `DivHarness.hostSelector` is `'div'`
|
|
456
|
+
*
|
|
457
|
+
* ```html
|
|
458
|
+
* <div id="d1"></div><div id="d2"></div>
|
|
459
|
+
* ```
|
|
460
|
+
*
|
|
461
|
+
* then we expect:
|
|
462
|
+
*
|
|
463
|
+
* ```ts
|
|
464
|
+
* await ch.locatorForOptional(DivHarness, 'div')() // Gets a `DivHarness` instance for #d1
|
|
465
|
+
* await ch.locatorForOptional('div', DivHarness)() // Gets a `TestElement` instance for #d1
|
|
466
|
+
* await ch.locatorForOptional('span')() // Gets `null`
|
|
467
|
+
* ```
|
|
468
|
+
*
|
|
406
469
|
* @param queries A list of queries specifying which harnesses and elements to search for:
|
|
407
470
|
* - A `string` searches for elements matching the CSS selector specified by the string.
|
|
408
471
|
* - A `ComponentHarness` constructor searches for `ComponentHarness` instances matching the
|
|
@@ -414,17 +477,32 @@ declare abstract class ComponentHarness {
|
|
|
414
477
|
* order in the DOM, and second by order in the queries list. If no matches are found, the
|
|
415
478
|
* `Promise` is resolved with `null`. The type that the `Promise` resolves to is a union of all
|
|
416
479
|
* result types for each query or null.
|
|
417
|
-
*
|
|
418
|
-
* e.g. Given the following DOM: `<div id="d1" /><div id="d2" />`, and assuming
|
|
419
|
-
* `DivHarness.hostSelector === 'div'`:
|
|
420
|
-
* - `await ch.locatorForOptional(DivHarness, 'div')()` gets a `DivHarness` instance for `#d1`
|
|
421
|
-
* - `await ch.locatorForOptional('div', DivHarness)()` gets a `TestElement` instance for `#d1`
|
|
422
|
-
* - `await ch.locatorForOptional('span')()` gets `null`.
|
|
423
480
|
*/
|
|
424
|
-
protected locatorForOptional<T extends (HarnessQuery<any> | string)[]>(...queries: T):
|
|
481
|
+
protected locatorForOptional<T extends (HarnessQuery<any> | string)[]>(...queries: T): () => Promise<LocatorFnResult<T> | null>;
|
|
425
482
|
/**
|
|
426
483
|
* Creates an asynchronous locator function that can be used to find `ComponentHarness` instances
|
|
427
484
|
* or elements under the host element of this `ComponentHarness`.
|
|
485
|
+
*
|
|
486
|
+
* For example, given the following DOM and assuming `DivHarness.hostSelector` is `'div'` and
|
|
487
|
+
* `IdIsD1Harness.hostSelector` is `'#d1'`
|
|
488
|
+
*
|
|
489
|
+
* ```html
|
|
490
|
+
* <div id="d1"></div><div id="d2"></div>
|
|
491
|
+
* ```
|
|
492
|
+
*
|
|
493
|
+
* then we expect:
|
|
494
|
+
*
|
|
495
|
+
* ```ts
|
|
496
|
+
* // Gets [DivHarness for #d1, TestElement for #d1, DivHarness for #d2, TestElement for #d2]
|
|
497
|
+
* await ch.locatorForAll(DivHarness, 'div')()
|
|
498
|
+
* // Gets [TestElement for #d1, TestElement for #d2]
|
|
499
|
+
* await ch.locatorForAll('div', '#d1')()
|
|
500
|
+
* // Gets [DivHarness for #d1, IdIsD1Harness for #d1, DivHarness for #d2]
|
|
501
|
+
* await ch.locatorForAll(DivHarness, IdIsD1Harness)()
|
|
502
|
+
* // Gets []
|
|
503
|
+
* await ch.locatorForAll('span')()
|
|
504
|
+
* ```
|
|
505
|
+
*
|
|
428
506
|
* @param queries A list of queries specifying which harnesses and elements to search for:
|
|
429
507
|
* - A `string` searches for elements matching the CSS selector specified by the string.
|
|
430
508
|
* - A `ComponentHarness` constructor searches for `ComponentHarness` instances matching the
|
|
@@ -438,27 +516,8 @@ declare abstract class ComponentHarness {
|
|
|
438
516
|
* an element matches multiple `string` selectors, only one `TestElement` instance is returned
|
|
439
517
|
* for that element. The type that the `Promise` resolves to is an array where each element is
|
|
440
518
|
* the union of all result types for each query.
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
* `DivHarness.hostSelector === 'div'` and `IdIsD1Harness.hostSelector === '#d1'`:
|
|
444
|
-
* - `await ch.locatorForAll(DivHarness, 'div')()` gets `[
|
|
445
|
-
* DivHarness, // for #d1
|
|
446
|
-
* TestElement, // for #d1
|
|
447
|
-
* DivHarness, // for #d2
|
|
448
|
-
* TestElement // for #d2
|
|
449
|
-
* ]`
|
|
450
|
-
* - `await ch.locatorForAll('div', '#d1')()` gets `[
|
|
451
|
-
* TestElement, // for #d1
|
|
452
|
-
* TestElement // for #d2
|
|
453
|
-
* ]`
|
|
454
|
-
* - `await ch.locatorForAll(DivHarness, IdIsD1Harness)()` gets `[
|
|
455
|
-
* DivHarness, // for #d1
|
|
456
|
-
* IdIsD1Harness, // for #d1
|
|
457
|
-
* DivHarness // for #d2
|
|
458
|
-
* ]`
|
|
459
|
-
* - `await ch.locatorForAll('span')()` gets `[]`.
|
|
460
|
-
*/
|
|
461
|
-
protected locatorForAll<T extends (HarnessQuery<any> | string)[]>(...queries: T): AsyncFactoryFn<LocatorFnResult<T>[]>;
|
|
519
|
+
*/
|
|
520
|
+
protected locatorForAll<T extends (HarnessQuery<any> | string)[]>(...queries: T): () => Promise<LocatorFnResult<T>[]>;
|
|
462
521
|
/**
|
|
463
522
|
* Flushes change detection and async tasks in the Angular zone.
|
|
464
523
|
* In most cases it should not be necessary to call this manually. However, there may be some edge
|
|
@@ -476,11 +535,46 @@ declare abstract class ComponentHarness {
|
|
|
476
535
|
* of the harness may want to access other harnesses within the `<ng-content>` of the component.
|
|
477
536
|
*/
|
|
478
537
|
declare abstract class ContentContainerComponentHarness<S extends string = string> extends ComponentHarness implements HarnessLoader {
|
|
538
|
+
/**
|
|
539
|
+
* Gets a `HarnessLoader` that searches for harnesses under the first element matching the given
|
|
540
|
+
* selector within the current harness's content.
|
|
541
|
+
* @param selector The selector for an element in the component's content.
|
|
542
|
+
* @returns A `HarnessLoader` that searches for harnesses under the given selector.
|
|
543
|
+
*/
|
|
479
544
|
getChildLoader(selector: S): Promise<HarnessLoader>;
|
|
545
|
+
/**
|
|
546
|
+
* Gets a list of `HarnessLoader` for each element matching the given selector under the current
|
|
547
|
+
* harness's cotnent that searches for harnesses under that element.
|
|
548
|
+
* @param selector The selector for elements in the component's content.
|
|
549
|
+
* @returns A list of `HarnessLoader` for each element matching the given selector.
|
|
550
|
+
*/
|
|
480
551
|
getAllChildLoaders(selector: S): Promise<HarnessLoader[]>;
|
|
552
|
+
/**
|
|
553
|
+
* Gets the first matching harness for the given query within the current harness's content.
|
|
554
|
+
* @param query The harness query to search for.
|
|
555
|
+
* @returns The first harness matching the given query.
|
|
556
|
+
* @throws If no matching harness is found.
|
|
557
|
+
*/
|
|
481
558
|
getHarness<T extends ComponentHarness>(query: HarnessQuery<T>): Promise<T>;
|
|
559
|
+
/**
|
|
560
|
+
* Gets the first matching harness for the given query within the current harness's content.
|
|
561
|
+
* @param query The harness query to search for.
|
|
562
|
+
* @returns The first harness matching the given query, or null if none is found.
|
|
563
|
+
*/
|
|
482
564
|
getHarnessOrNull<T extends ComponentHarness>(query: HarnessQuery<T>): Promise<T | null>;
|
|
565
|
+
/**
|
|
566
|
+
* Gets all matching harnesses for the given query within the current harness's content.
|
|
567
|
+
* @param query The harness query to search for.
|
|
568
|
+
* @returns The list of harness matching the given query.
|
|
569
|
+
*/
|
|
483
570
|
getAllHarnesses<T extends ComponentHarness>(query: HarnessQuery<T>): Promise<T[]>;
|
|
571
|
+
/**
|
|
572
|
+
* Checks whether there is a matching harnesses for the given query within the current harness's
|
|
573
|
+
* content.
|
|
574
|
+
*
|
|
575
|
+
* @param query The harness query to search for.
|
|
576
|
+
* @returns Whetehr there is matching harnesses for the given query.
|
|
577
|
+
*/
|
|
484
578
|
hasHarness<T extends ComponentHarness>(query: HarnessQuery<T>): Promise<boolean>;
|
|
485
579
|
/**
|
|
486
580
|
* Gets the root harness loader from which to start
|
|
@@ -488,7 +582,10 @@ declare abstract class ContentContainerComponentHarness<S extends string = strin
|
|
|
488
582
|
*/
|
|
489
583
|
protected getRootHarnessLoader(): Promise<HarnessLoader>;
|
|
490
584
|
}
|
|
491
|
-
/**
|
|
585
|
+
/**
|
|
586
|
+
* Constructor for a ComponentHarness subclass. To be a valid ComponentHarnessConstructor, the
|
|
587
|
+
* class must also have a static `hostSelector` property.
|
|
588
|
+
*/
|
|
492
589
|
interface ComponentHarnessConstructor<T extends ComponentHarness> {
|
|
493
590
|
new (locatorFactory: LocatorFactory): T;
|
|
494
591
|
/**
|
|
@@ -506,8 +603,8 @@ interface BaseHarnessFilters {
|
|
|
506
603
|
ancestor?: string;
|
|
507
604
|
}
|
|
508
605
|
/**
|
|
509
|
-
* A class used to associate a ComponentHarness class with
|
|
510
|
-
* filter instances of the class.
|
|
606
|
+
* A class used to associate a ComponentHarness class with predicate functions that can be used to
|
|
607
|
+
* filter instances of the class to be matched.
|
|
511
608
|
*/
|
|
512
609
|
declare class HarnessPredicate<T extends ComponentHarness> {
|
|
513
610
|
harnessType: ComponentHarnessConstructor<T>;
|
|
@@ -569,34 +666,210 @@ declare class HarnessPredicate<T extends ComponentHarness> {
|
|
|
569
666
|
* element type, `E`, used by the particular test environment.
|
|
570
667
|
*/
|
|
571
668
|
declare abstract class HarnessEnvironment<E> implements HarnessLoader, LocatorFactory {
|
|
669
|
+
/** The native root element of this `HarnessEnvironment`. */
|
|
572
670
|
protected rawRootElement: E;
|
|
671
|
+
/** The root element of this `HarnessEnvironment` as a `TestElement`. */
|
|
573
672
|
get rootElement(): TestElement;
|
|
574
673
|
set rootElement(element: TestElement);
|
|
575
674
|
private _rootElement;
|
|
576
|
-
protected constructor(
|
|
675
|
+
protected constructor(
|
|
676
|
+
/** The native root element of this `HarnessEnvironment`. */
|
|
677
|
+
rawRootElement: E);
|
|
678
|
+
/** Gets a locator factory rooted at the document root. */
|
|
577
679
|
documentRootLocatorFactory(): LocatorFactory;
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
680
|
+
/**
|
|
681
|
+
* Creates an asynchronous locator function that can be used to find a `ComponentHarness` instance
|
|
682
|
+
* or element under the root element of this `HarnessEnvironment`.
|
|
683
|
+
*
|
|
684
|
+
* For example, given the following DOM and assuming `DivHarness.hostSelector` is `'div'`
|
|
685
|
+
*
|
|
686
|
+
* ```html
|
|
687
|
+
* <div id="d1"></div><div id="d2"></div>
|
|
688
|
+
* ```
|
|
689
|
+
*
|
|
690
|
+
* then we expect:
|
|
691
|
+
*
|
|
692
|
+
* ```ts
|
|
693
|
+
* await lf.locatorFor(DivHarness, 'div')() // Gets a `DivHarness` instance for #d1
|
|
694
|
+
* await lf.locatorFor('div', DivHarness)() // Gets a `TestElement` instance for #d1
|
|
695
|
+
* await lf.locatorFor('span')() // Throws because the `Promise` rejects
|
|
696
|
+
* ```
|
|
697
|
+
*
|
|
698
|
+
* @param queries A list of queries specifying which harnesses and elements to search for:
|
|
699
|
+
* - A `string` searches for elements matching the CSS selector specified by the string.
|
|
700
|
+
* - A `ComponentHarness` constructor searches for `ComponentHarness` instances matching the
|
|
701
|
+
* given class.
|
|
702
|
+
* - A `HarnessPredicate` searches for `ComponentHarness` instances matching the given
|
|
703
|
+
* predicate.
|
|
704
|
+
* @return An asynchronous locator function that searches for and returns a `Promise` for the
|
|
705
|
+
* first element or harness matching the given search criteria. Matches are ordered first by
|
|
706
|
+
* order in the DOM, and second by order in the queries list. If no matches are found, the
|
|
707
|
+
* `Promise` rejects. The type that the `Promise` resolves to is a union of all result types for
|
|
708
|
+
* each query.
|
|
709
|
+
*/
|
|
710
|
+
locatorFor<T extends (HarnessQuery<any> | string)[]>(...queries: T): () => Promise<LocatorFnResult<T>>;
|
|
711
|
+
/**
|
|
712
|
+
* Creates an asynchronous locator function that can be used to find a `ComponentHarness` instance
|
|
713
|
+
* or element under the root element of this `HarnessEnvironmnet`.
|
|
714
|
+
*
|
|
715
|
+
* For example, given the following DOM and assuming `DivHarness.hostSelector` is `'div'`
|
|
716
|
+
*
|
|
717
|
+
* ```html
|
|
718
|
+
* <div id="d1"></div><div id="d2"></div>
|
|
719
|
+
* ```
|
|
720
|
+
*
|
|
721
|
+
* then we expect:
|
|
722
|
+
*
|
|
723
|
+
* ```ts
|
|
724
|
+
* await lf.locatorForOptional(DivHarness, 'div')() // Gets a `DivHarness` instance for #d1
|
|
725
|
+
* await lf.locatorForOptional('div', DivHarness)() // Gets a `TestElement` instance for #d1
|
|
726
|
+
* await lf.locatorForOptional('span')() // Gets `null`
|
|
727
|
+
* ```
|
|
728
|
+
*
|
|
729
|
+
* @param queries A list of queries specifying which harnesses and elements to search for:
|
|
730
|
+
* - A `string` searches for elements matching the CSS selector specified by the string.
|
|
731
|
+
* - A `ComponentHarness` constructor searches for `ComponentHarness` instances matching the
|
|
732
|
+
* given class.
|
|
733
|
+
* - A `HarnessPredicate` searches for `ComponentHarness` instances matching the given
|
|
734
|
+
* predicate.
|
|
735
|
+
* @return An asynchronous locator function that searches for and returns a `Promise` for the
|
|
736
|
+
* first element or harness matching the given search criteria. Matches are ordered first by
|
|
737
|
+
* order in the DOM, and second by order in the queries list. If no matches are found, the
|
|
738
|
+
* `Promise` is resolved with `null`. The type that the `Promise` resolves to is a union of all
|
|
739
|
+
* result types for each query or null.
|
|
740
|
+
*/
|
|
741
|
+
locatorForOptional<T extends (HarnessQuery<any> | string)[]>(...queries: T): () => Promise<LocatorFnResult<T> | null>;
|
|
742
|
+
/**
|
|
743
|
+
* Creates an asynchronous locator function that can be used to find `ComponentHarness` instances
|
|
744
|
+
* or elements under the root element of this `HarnessEnvironment`.
|
|
745
|
+
*
|
|
746
|
+
* For example, given the following DOM and assuming `DivHarness.hostSelector` is `'div'` and
|
|
747
|
+
* `IdIsD1Harness.hostSelector` is `'#d1'`
|
|
748
|
+
*
|
|
749
|
+
* ```html
|
|
750
|
+
* <div id="d1"></div><div id="d2"></div>
|
|
751
|
+
* ```
|
|
752
|
+
*
|
|
753
|
+
* then we expect:
|
|
754
|
+
*
|
|
755
|
+
* ```ts
|
|
756
|
+
* // Gets [DivHarness for #d1, TestElement for #d1, DivHarness for #d2, TestElement for #d2]
|
|
757
|
+
* await lf.locatorForAll(DivHarness, 'div')()
|
|
758
|
+
* // Gets [TestElement for #d1, TestElement for #d2]
|
|
759
|
+
* await lf.locatorForAll('div', '#d1')()
|
|
760
|
+
* // Gets [DivHarness for #d1, IdIsD1Harness for #d1, DivHarness for #d2]
|
|
761
|
+
* await lf.locatorForAll(DivHarness, IdIsD1Harness)()
|
|
762
|
+
* // Gets []
|
|
763
|
+
* await lf.locatorForAll('span')()
|
|
764
|
+
* ```
|
|
765
|
+
*
|
|
766
|
+
* @param queries A list of queries specifying which harnesses and elements to search for:
|
|
767
|
+
* - A `string` searches for elements matching the CSS selector specified by the string.
|
|
768
|
+
* - A `ComponentHarness` constructor searches for `ComponentHarness` instances matching the
|
|
769
|
+
* given class.
|
|
770
|
+
* - A `HarnessPredicate` searches for `ComponentHarness` instances matching the given
|
|
771
|
+
* predicate.
|
|
772
|
+
* @return An asynchronous locator function that searches for and returns a `Promise` for all
|
|
773
|
+
* elements and harnesses matching the given search criteria. Matches are ordered first by
|
|
774
|
+
* order in the DOM, and second by order in the queries list. If an element matches more than
|
|
775
|
+
* one `ComponentHarness` class, the locator gets an instance of each for the same element. If
|
|
776
|
+
* an element matches multiple `string` selectors, only one `TestElement` instance is returned
|
|
777
|
+
* for that element. The type that the `Promise` resolves to is an array where each element is
|
|
778
|
+
* the union of all result types for each query.
|
|
779
|
+
*/
|
|
780
|
+
locatorForAll<T extends (HarnessQuery<any> | string)[]>(...queries: T): () => Promise<LocatorFnResult<T>[]>;
|
|
781
|
+
/** @return A `HarnessLoader` rooted at the root element of this `HarnessEnvironment`. */
|
|
581
782
|
rootHarnessLoader(): Promise<HarnessLoader>;
|
|
783
|
+
/**
|
|
784
|
+
* Gets a `HarnessLoader` instance for an element under the root of this `HarnessEnvironment`.
|
|
785
|
+
* @param selector The selector for the root element.
|
|
786
|
+
* @return A `HarnessLoader` rooted at the first element matching the given selector.
|
|
787
|
+
* @throws If no matching element is found for the given selector.
|
|
788
|
+
*/
|
|
582
789
|
harnessLoaderFor(selector: string): Promise<HarnessLoader>;
|
|
790
|
+
/**
|
|
791
|
+
* Gets a `HarnessLoader` instance for an element under the root of this `HarnessEnvironment`.
|
|
792
|
+
* @param selector The selector for the root element.
|
|
793
|
+
* @return A `HarnessLoader` rooted at the first element matching the given selector, or null if
|
|
794
|
+
* no matching element is found.
|
|
795
|
+
*/
|
|
583
796
|
harnessLoaderForOptional(selector: string): Promise<HarnessLoader | null>;
|
|
797
|
+
/**
|
|
798
|
+
* Gets a list of `HarnessLoader` instances, one for each matching element.
|
|
799
|
+
* @param selector The selector for the root element.
|
|
800
|
+
* @return A list of `HarnessLoader`, one rooted at each element matching the given selector.
|
|
801
|
+
*/
|
|
584
802
|
harnessLoaderForAll(selector: string): Promise<HarnessLoader[]>;
|
|
803
|
+
/**
|
|
804
|
+
* Searches for an instance of the component corresponding to the given harness type under the
|
|
805
|
+
* `HarnessEnvironment`'s root element, and returns a `ComponentHarness` for that instance. If
|
|
806
|
+
* multiple matching components are found, a harness for the first one is returned. If no matching
|
|
807
|
+
* component is found, an error is thrown.
|
|
808
|
+
* @param query A query for a harness to create
|
|
809
|
+
* @return An instance of the given harness type
|
|
810
|
+
* @throws If a matching component instance can't be found.
|
|
811
|
+
*/
|
|
585
812
|
getHarness<T extends ComponentHarness>(query: HarnessQuery<T>): Promise<T>;
|
|
813
|
+
/**
|
|
814
|
+
* Searches for an instance of the component corresponding to the given harness type under the
|
|
815
|
+
* `HarnessEnvironment`'s root element, and returns a `ComponentHarness` for that instance. If
|
|
816
|
+
* multiple matching components are found, a harness for the first one is returned. If no matching
|
|
817
|
+
* component is found, null is returned.
|
|
818
|
+
* @param query A query for a harness to create
|
|
819
|
+
* @return An instance of the given harness type (or null if not found).
|
|
820
|
+
*/
|
|
586
821
|
getHarnessOrNull<T extends ComponentHarness>(query: HarnessQuery<T>): Promise<T | null>;
|
|
822
|
+
/**
|
|
823
|
+
* Searches for all instances of the component corresponding to the given harness type under the
|
|
824
|
+
* `HarnessEnvironment`'s root element, and returns a list `ComponentHarness` for each instance.
|
|
825
|
+
* @param query A query for a harness to create
|
|
826
|
+
* @return A list instances of the given harness type.
|
|
827
|
+
*/
|
|
587
828
|
getAllHarnesses<T extends ComponentHarness>(query: HarnessQuery<T>): Promise<T[]>;
|
|
829
|
+
/**
|
|
830
|
+
* Searches for an instance of the component corresponding to the given harness type under the
|
|
831
|
+
* `HarnessEnvironment`'s root element, and returns a boolean indicating if any were found.
|
|
832
|
+
* @param query A query for a harness to create
|
|
833
|
+
* @return A boolean indicating if an instance was found.
|
|
834
|
+
*/
|
|
588
835
|
hasHarness<T extends ComponentHarness>(query: HarnessQuery<T>): Promise<boolean>;
|
|
836
|
+
/**
|
|
837
|
+
* Searches for an element with the given selector under the evironment's root element,
|
|
838
|
+
* and returns a `HarnessLoader` rooted at the matching element. If multiple elements match the
|
|
839
|
+
* selector, the first is used. If no elements match, an error is thrown.
|
|
840
|
+
* @param selector The selector for the root element of the new `HarnessLoader`
|
|
841
|
+
* @return A `HarnessLoader` rooted at the element matching the given selector.
|
|
842
|
+
* @throws If a matching element can't be found.
|
|
843
|
+
*/
|
|
589
844
|
getChildLoader(selector: string): Promise<HarnessLoader>;
|
|
845
|
+
/**
|
|
846
|
+
* Searches for all elements with the given selector under the environment's root element,
|
|
847
|
+
* and returns an array of `HarnessLoader`s, one for each matching element, rooted at that
|
|
848
|
+
* element.
|
|
849
|
+
* @param selector The selector for the root element of the new `HarnessLoader`
|
|
850
|
+
* @return A list of `HarnessLoader`s, one for each matching element, rooted at that element.
|
|
851
|
+
*/
|
|
590
852
|
getAllChildLoaders(selector: string): Promise<HarnessLoader[]>;
|
|
591
853
|
/** Creates a `ComponentHarness` for the given harness type with the given raw host element. */
|
|
592
854
|
protected createComponentHarness<T extends ComponentHarness>(harnessType: ComponentHarnessConstructor<T>, element: E): T;
|
|
855
|
+
/**
|
|
856
|
+
* Flushes change detection and async tasks captured in the Angular zone.
|
|
857
|
+
* In most cases it should not be necessary to call this manually. However, there may be some edge
|
|
858
|
+
* cases where it is needed to fully flush animation events.
|
|
859
|
+
* This is an abstrct method that must be implemented by subclasses.
|
|
860
|
+
*/
|
|
593
861
|
abstract forceStabilize(): Promise<void>;
|
|
862
|
+
/**
|
|
863
|
+
* Waits for all scheduled or running async tasks to complete. This allows harness
|
|
864
|
+
* authors to wait for async tasks outside of the Angular zone.
|
|
865
|
+
* This is an abstrct method that must be implemented by subclasses.
|
|
866
|
+
*/
|
|
594
867
|
abstract waitForTasksOutsideAngular(): Promise<void>;
|
|
595
868
|
/** Gets the root element for the document. */
|
|
596
869
|
protected abstract getDocumentRoot(): E;
|
|
597
870
|
/** Creates a `TestElement` from a raw element. */
|
|
598
871
|
protected abstract createTestElement(element: E): TestElement;
|
|
599
|
-
/** Creates a `
|
|
872
|
+
/** Creates a `HarnessEnvironment` rooted at the given raw element. */
|
|
600
873
|
protected abstract createEnvironment(element: E): HarnessEnvironment<E>;
|
|
601
874
|
/**
|
|
602
875
|
* Gets a list of all elements matching the given selector under this environment's root element.
|
package/package.json
CHANGED
|
@@ -26,6 +26,6 @@ function default_1() {
|
|
|
26
26
|
// In order to align the CDK version with other Angular dependencies that are setup by
|
|
27
27
|
// `@schematics/angular`, we use tilde instead of caret. This is default for Angular
|
|
28
28
|
// dependencies in new CLI projects.
|
|
29
|
-
return (0, utility_1.addDependency)('@angular/cdk', `~20.0.0-
|
|
29
|
+
return (0, utility_1.addDependency)('@angular/cdk', `~20.0.0-rc.0`, { existing: utility_1.ExistingBehavior.Skip });
|
|
30
30
|
}
|
|
31
31
|
//# sourceMappingURL=index.js.map
|
package/testing/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as AsyncFactoryFn, g as AsyncOptionPredicate, f as AsyncPredicate, B as BaseHarnessFilters, C as ComponentHarness, e as ComponentHarnessConstructor, j as ContentContainerComponentHarness, E as ElementDimensions, c as EventData, H as HarnessEnvironment, d as HarnessLoader, k as HarnessPredicate, h as HarnessQuery, i as LocatorFactory, L as LocatorFnResult, M as ModifierKeys, T as TestElement, a as TestKey, b as TextOptions } from '../harness-environment.d-
|
|
1
|
+
export { A as AsyncFactoryFn, g as AsyncOptionPredicate, f as AsyncPredicate, B as BaseHarnessFilters, C as ComponentHarness, e as ComponentHarnessConstructor, j as ContentContainerComponentHarness, E as ElementDimensions, c as EventData, H as HarnessEnvironment, d as HarnessLoader, k as HarnessPredicate, h as HarnessQuery, i as LocatorFactory, L as LocatorFnResult, M as ModifierKeys, T as TestElement, a as TestKey, b as TextOptions } from '../harness-environment.d-BbFzIFDE.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Returns an error which reports that no keys have been specified.
|
|
@@ -13,7 +13,11 @@ declare function getNoKeysSpecifiedError(): Error;
|
|
|
13
13
|
*/
|
|
14
14
|
declare function _getTextWithExcludedElements(element: Element, excludeSelector: string): string;
|
|
15
15
|
|
|
16
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* The status of the test harness auto change detection. If not diabled test harnesses will
|
|
18
|
+
* automatically trigger change detection after every action (such as a click) and before every read
|
|
19
|
+
* (such as getting the text of an element).
|
|
20
|
+
*/
|
|
17
21
|
interface AutoChangeDetectionStatus {
|
|
18
22
|
/** Whether auto change detection is disabled. */
|
|
19
23
|
isDisabled: boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as webdriver from 'selenium-webdriver';
|
|
2
|
-
import { T as TestElement, M as ModifierKeys, a as TestKey, b as TextOptions, E as ElementDimensions, c as EventData, H as HarnessEnvironment, d as HarnessLoader } from '../../harness-environment.d-
|
|
2
|
+
import { T as TestElement, M as ModifierKeys, a as TestKey, b as TextOptions, E as ElementDimensions, c as EventData, H as HarnessEnvironment, d as HarnessLoader } from '../../harness-environment.d-BbFzIFDE.js';
|
|
3
3
|
|
|
4
4
|
/** A `TestElement` implementation for WebDriver. */
|
|
5
5
|
declare class SeleniumWebDriverElement implements TestElement {
|