@skyux/lookup 13.0.0-alpha.0 → 13.0.0-alpha.10
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/fesm2022/skyux-lookup-testing.mjs +65 -164
- package/fesm2022/skyux-lookup-testing.mjs.map +1 -1
- package/fesm2022/skyux-lookup.mjs +36 -61
- package/fesm2022/skyux-lookup.mjs.map +1 -1
- package/index.d.ts +10 -9
- package/package.json +17 -12
- package/testing/index.d.ts +38 -57
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { SkyInputHarness, SkyQueryableComponentHarness, SkyComponentHarness, SkyOverlayHarness } from '@skyux/core/testing';
|
|
2
2
|
import { HarnessPredicate, ComponentHarness } from '@angular/cdk/testing';
|
|
3
|
+
import { SkyTokensHarness, SkyTokenHarness } from '@skyux/indicators/testing';
|
|
4
|
+
import { SkyCheckboxHarness } from '@skyux/forms/testing';
|
|
5
|
+
import { SkyInfiniteScrollHarness, SkyRepeaterItemHarness } from '@skyux/lists/testing';
|
|
3
6
|
import { By } from '@angular/platform-browser';
|
|
4
7
|
import { SkyAppTestUtility } from '@skyux-sdk/testing';
|
|
5
8
|
import * as i0 from '@angular/core';
|
|
6
9
|
import { NgModule } from '@angular/core';
|
|
7
|
-
import { SkyCountryFieldModule, SkySearchModule } from '@skyux/lookup';
|
|
8
|
-
import { SkyTokensHarness, SkyTokenHarness } from '@skyux/indicators/testing';
|
|
9
|
-
import { SkyCheckboxHarness } from '@skyux/forms/testing';
|
|
10
|
-
import { SkyInfiniteScrollHarness, SkyRepeaterItemHarness } from '@skyux/lists/testing';
|
|
11
10
|
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
|
11
|
+
import { SkySearchModule } from '@skyux/lookup';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Harness to interact with the autocomplete input harness.
|
|
@@ -121,22 +121,27 @@ class SkyAutocompleteHarness extends SkyComponentHarness {
|
|
|
121
121
|
return await this.#getInput();
|
|
122
122
|
}
|
|
123
123
|
/**
|
|
124
|
-
*
|
|
124
|
+
* Gets a specific autocomplete search result based on the filter criteria.
|
|
125
|
+
* @param filter The filter criteria.
|
|
126
|
+
*/
|
|
127
|
+
async getSearchResult(filter) {
|
|
128
|
+
const overlay = await this.#getOverlay();
|
|
129
|
+
if (!overlay) {
|
|
130
|
+
throw new Error('Unable to retrieve search result. The autocomplete is closed.');
|
|
131
|
+
}
|
|
132
|
+
return await overlay.queryHarness(SkyAutocompleteSearchResultHarness.with(filter));
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Gets an array of autocomplete search results based on the filter criteria.
|
|
136
|
+
* If no filter is provided, returns all autocomplete search results.
|
|
137
|
+
* @param filters The optional filter criteria.
|
|
125
138
|
*/
|
|
126
139
|
async getSearchResults(filters) {
|
|
127
140
|
const overlay = await this.#getOverlay();
|
|
128
141
|
if (!overlay) {
|
|
129
142
|
throw new Error('Unable to retrieve search results. The autocomplete is closed.');
|
|
130
143
|
}
|
|
131
|
-
|
|
132
|
-
if (filters && harnesses.length === 0) {
|
|
133
|
-
// Stringify the regular expression so that it's readable in the console log.
|
|
134
|
-
if (filters.text instanceof RegExp) {
|
|
135
|
-
filters.text = filters.text.toString();
|
|
136
|
-
}
|
|
137
|
-
throw new Error(`Could not find search results matching filter(s): ${JSON.stringify(filters)}`);
|
|
138
|
-
}
|
|
139
|
-
return harnesses;
|
|
144
|
+
return await overlay.queryHarnesses(SkyAutocompleteSearchResultHarness.with(filters || {}));
|
|
140
145
|
}
|
|
141
146
|
/**
|
|
142
147
|
* Returns the text content for each autocomplete search result.
|
|
@@ -251,128 +256,6 @@ class SkyAutocompleteHarness extends SkyComponentHarness {
|
|
|
251
256
|
}
|
|
252
257
|
}
|
|
253
258
|
|
|
254
|
-
/**
|
|
255
|
-
* Allows interaction with a SKY UX country field component.
|
|
256
|
-
* @internal
|
|
257
|
-
*/
|
|
258
|
-
class SkyCountryFieldFixture {
|
|
259
|
-
#debugEl;
|
|
260
|
-
/**
|
|
261
|
-
* The value of the input field's autocomplete attribute.
|
|
262
|
-
* @deprecated The country field component's `autocompleteAttribute` is deprecated.
|
|
263
|
-
*/
|
|
264
|
-
get autocompleteAttribute() {
|
|
265
|
-
return this.#getInputElement().getAttribute('autocomplete');
|
|
266
|
-
}
|
|
267
|
-
/**
|
|
268
|
-
* A flag indicating whether or not the input has been disabled.
|
|
269
|
-
*/
|
|
270
|
-
get disabled() {
|
|
271
|
-
return this.#getInputElement().disabled;
|
|
272
|
-
}
|
|
273
|
-
/**
|
|
274
|
-
* The value of the input field.
|
|
275
|
-
*/
|
|
276
|
-
get searchText() {
|
|
277
|
-
return this.#getInputElement().value;
|
|
278
|
-
}
|
|
279
|
-
#fixture;
|
|
280
|
-
constructor(fixture, skyTestId) {
|
|
281
|
-
this.#fixture = fixture;
|
|
282
|
-
this.#debugEl = SkyAppTestUtility.getDebugElementByTestId(fixture, skyTestId, 'sky-country-field');
|
|
283
|
-
}
|
|
284
|
-
/**
|
|
285
|
-
* Enters the search text into the input field displaying search results, but making no selection.
|
|
286
|
-
* @param searchText The name of the country to select.
|
|
287
|
-
* @returns The list of country names matching the search text.
|
|
288
|
-
*/
|
|
289
|
-
async search(searchText) {
|
|
290
|
-
const resultNodes = await this.#searchAndGetResults(searchText, this.#fixture);
|
|
291
|
-
const resultArray = Array.prototype.slice.call(resultNodes);
|
|
292
|
-
const results = resultArray
|
|
293
|
-
.map((result) => {
|
|
294
|
-
const countryNameEl = result.querySelector('.sky-highlight-mark');
|
|
295
|
-
const countryName = SkyAppTestUtility.getText(countryNameEl);
|
|
296
|
-
return countryName;
|
|
297
|
-
})
|
|
298
|
-
.filter((result) => result !== undefined);
|
|
299
|
-
this.#fixture.detectChanges();
|
|
300
|
-
await this.#fixture.whenStable();
|
|
301
|
-
return results;
|
|
302
|
-
}
|
|
303
|
-
/**
|
|
304
|
-
* Enters the search text into the input field and selects the first result (if any).
|
|
305
|
-
* @param searchText The name of the country to select.
|
|
306
|
-
*/
|
|
307
|
-
async searchAndSelectFirstResult(searchText) {
|
|
308
|
-
await this.#searchAndSelect(searchText, 0, this.#fixture);
|
|
309
|
-
this.#fixture.detectChanges();
|
|
310
|
-
await this.#fixture.whenStable();
|
|
311
|
-
}
|
|
312
|
-
/**
|
|
313
|
-
* Clears the country selection and input field.
|
|
314
|
-
*/
|
|
315
|
-
async clear() {
|
|
316
|
-
await this.#enterSearch('', this.#fixture);
|
|
317
|
-
this.#fixture.detectChanges();
|
|
318
|
-
await this.#fixture.whenStable();
|
|
319
|
-
}
|
|
320
|
-
//#region helpers
|
|
321
|
-
#getAutocompleteElement() {
|
|
322
|
-
return document.querySelector('.sky-autocomplete-results');
|
|
323
|
-
}
|
|
324
|
-
#getInputElement() {
|
|
325
|
-
const debugEl = this.#debugEl.query(By.css('textarea'));
|
|
326
|
-
return debugEl.nativeElement;
|
|
327
|
-
}
|
|
328
|
-
async #blurInput(fixture) {
|
|
329
|
-
SkyAppTestUtility.fireDomEvent(this.#getInputElement(), 'blur');
|
|
330
|
-
fixture.detectChanges();
|
|
331
|
-
await fixture.whenStable();
|
|
332
|
-
}
|
|
333
|
-
async #enterSearch(newValue, fixture) {
|
|
334
|
-
const inputElement = this.#getInputElement();
|
|
335
|
-
inputElement.value = newValue;
|
|
336
|
-
SkyAppTestUtility.fireDomEvent(inputElement, 'focus');
|
|
337
|
-
SkyAppTestUtility.fireDomEvent(inputElement, 'keyup');
|
|
338
|
-
SkyAppTestUtility.fireDomEvent(inputElement, 'input');
|
|
339
|
-
fixture.detectChanges();
|
|
340
|
-
await fixture.whenStable();
|
|
341
|
-
}
|
|
342
|
-
async #searchAndGetResults(newValue, fixture) {
|
|
343
|
-
await this.#enterSearch(newValue, fixture);
|
|
344
|
-
fixture.detectChanges();
|
|
345
|
-
await fixture.whenStable();
|
|
346
|
-
return this.#getAutocompleteElement().querySelectorAll('.sky-autocomplete-result');
|
|
347
|
-
}
|
|
348
|
-
async #searchAndSelect(newValue, index, fixture) {
|
|
349
|
-
const inputElement = this.#getInputElement();
|
|
350
|
-
const searchResults = await this.#searchAndGetResults(newValue, fixture);
|
|
351
|
-
if (searchResults.length < index + 1) {
|
|
352
|
-
throw new Error('Index out of range for results');
|
|
353
|
-
}
|
|
354
|
-
// Note: the ordering of these events is important!
|
|
355
|
-
SkyAppTestUtility.fireDomEvent(inputElement, 'change');
|
|
356
|
-
SkyAppTestUtility.fireDomEvent(searchResults[index], 'click');
|
|
357
|
-
await this.#blurInput(fixture);
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
/**
|
|
362
|
-
* @internal
|
|
363
|
-
*/
|
|
364
|
-
class SkyCountryFieldTestingModule {
|
|
365
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.5", ngImport: i0, type: SkyCountryFieldTestingModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
366
|
-
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.0.5", ngImport: i0, type: SkyCountryFieldTestingModule, exports: [SkyCountryFieldModule] }); }
|
|
367
|
-
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.0.5", ngImport: i0, type: SkyCountryFieldTestingModule, imports: [SkyCountryFieldModule] }); }
|
|
368
|
-
}
|
|
369
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.5", ngImport: i0, type: SkyCountryFieldTestingModule, decorators: [{
|
|
370
|
-
type: NgModule,
|
|
371
|
-
args: [{
|
|
372
|
-
exports: [SkyCountryFieldModule],
|
|
373
|
-
}]
|
|
374
|
-
}] });
|
|
375
|
-
|
|
376
259
|
/**
|
|
377
260
|
* Harness for interacting with an autocomplete search result in tests.
|
|
378
261
|
*/
|
|
@@ -461,22 +344,27 @@ class SkyCountryFieldHarness extends SkyAutocompleteHarness {
|
|
|
461
344
|
return await super.getAriaLabelledby();
|
|
462
345
|
}
|
|
463
346
|
/**
|
|
464
|
-
*
|
|
347
|
+
* Gets a specific country field search result based on the filter criteria.
|
|
348
|
+
* @param filter The filter criteria.
|
|
349
|
+
*/
|
|
350
|
+
async getSearchResult(filter) {
|
|
351
|
+
const overlay = await this.#getOverlay();
|
|
352
|
+
if (!overlay) {
|
|
353
|
+
throw new Error('Unable to retrieve search result. The country field is closed.');
|
|
354
|
+
}
|
|
355
|
+
return await overlay.queryHarness(SkyCountryFieldSearchResultHarness.with(filter));
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Gets an array of country field search results based on the filter criteria.
|
|
359
|
+
* If no filter is provided, returns all country field search results.
|
|
360
|
+
* @param filters The optional filter criteria.
|
|
465
361
|
*/
|
|
466
362
|
async getSearchResults(filters) {
|
|
467
363
|
const overlay = await this.#getOverlay();
|
|
468
364
|
if (!overlay) {
|
|
469
365
|
throw new Error('Unable to retrieve search results. The country field is closed.');
|
|
470
366
|
}
|
|
471
|
-
|
|
472
|
-
if (filters && harnesses.length === 0) {
|
|
473
|
-
// Stringify the regular expression so that it's readable in the console log.
|
|
474
|
-
if (filters.text instanceof RegExp) {
|
|
475
|
-
filters.text = filters.text.toString();
|
|
476
|
-
}
|
|
477
|
-
throw new Error(`Could not find search results matching filter(s): ${JSON.stringify(filters)}`);
|
|
478
|
-
}
|
|
479
|
-
return harnesses;
|
|
367
|
+
return await overlay.queryHarnesses(SkyCountryFieldSearchResultHarness.with(filters || {}));
|
|
480
368
|
}
|
|
481
369
|
/**
|
|
482
370
|
* Returns the text content for each country field search result.
|
|
@@ -758,7 +646,6 @@ class SkySelectionModalHarness extends ComponentHarness {
|
|
|
758
646
|
await (await this.#getSearchHarness()).enterText(value);
|
|
759
647
|
}
|
|
760
648
|
/**
|
|
761
|
-
*
|
|
762
649
|
* Gets the search input's aria-label.
|
|
763
650
|
*/
|
|
764
651
|
async getSearchAriaLabel() {
|
|
@@ -799,18 +686,27 @@ class SkySelectionModalHarness extends ComponentHarness {
|
|
|
799
686
|
await (await this.#getCancelButton()).click();
|
|
800
687
|
}
|
|
801
688
|
/**
|
|
802
|
-
* Gets a
|
|
689
|
+
* Gets a specific search result based on the filter criteria.
|
|
690
|
+
* @param filter The filter criteria.
|
|
691
|
+
*/
|
|
692
|
+
async getSearchResult(filter) {
|
|
693
|
+
const pickerId = (await (await this.host()).getAttribute('id'));
|
|
694
|
+
return await this.locatorFor(SkyRepeaterItemHarness.with({
|
|
695
|
+
...filter,
|
|
696
|
+
ancestor: `#${pickerId}`,
|
|
697
|
+
}))();
|
|
698
|
+
}
|
|
699
|
+
/**
|
|
700
|
+
* Gets an array of search results based on the filter criteria.
|
|
701
|
+
* If no filter is provided, returns all search results.
|
|
702
|
+
* @param filters The optional filter criteria.
|
|
803
703
|
*/
|
|
804
704
|
async getSearchResults(filters) {
|
|
805
705
|
const pickerId = (await (await this.host()).getAttribute('id'));
|
|
806
|
-
|
|
706
|
+
return await this.locatorForAll(SkyRepeaterItemHarness.with({
|
|
807
707
|
...(filters || {}),
|
|
808
708
|
ancestor: `#${pickerId}`,
|
|
809
709
|
}))();
|
|
810
|
-
if (filters && harnesses.length === 0) {
|
|
811
|
-
throw new Error(`Could not find search results in the picker matching filter(s): ${JSON.stringify(filters)}`);
|
|
812
|
-
}
|
|
813
|
-
return harnesses;
|
|
814
710
|
}
|
|
815
711
|
/**
|
|
816
712
|
* Clears all selections made.
|
|
@@ -1006,22 +902,27 @@ class SkyLookupHarness extends SkyAutocompleteHarness {
|
|
|
1006
902
|
return await super.getAriaLabelledby();
|
|
1007
903
|
}
|
|
1008
904
|
/**
|
|
1009
|
-
*
|
|
905
|
+
* Gets a specific lookup search result based on the filter criteria.
|
|
906
|
+
* @param filters The filter criteria.
|
|
907
|
+
*/
|
|
908
|
+
async getSearchResult(filters) {
|
|
909
|
+
const overlay = await this.#getOverlay();
|
|
910
|
+
if (!overlay) {
|
|
911
|
+
throw new Error('Unable to retrieve search result. The lookup is closed.');
|
|
912
|
+
}
|
|
913
|
+
return await overlay.queryHarness(SkyLookupSearchResultHarness.with(filters));
|
|
914
|
+
}
|
|
915
|
+
/**
|
|
916
|
+
* Gets an array of lookup search results based on the filter criteria.
|
|
917
|
+
* If no filter is provided, returns all lookup search results.
|
|
918
|
+
* @param filters The optional filter criteria.
|
|
1010
919
|
*/
|
|
1011
920
|
async getSearchResults(filters) {
|
|
1012
921
|
const overlay = await this.#getOverlay();
|
|
1013
922
|
if (!overlay) {
|
|
1014
923
|
throw new Error('Unable to retrieve search results. The lookup is closed.');
|
|
1015
924
|
}
|
|
1016
|
-
|
|
1017
|
-
if (filters && harnesses.length === 0) {
|
|
1018
|
-
// Stringify the regular expression so that it's readable in the console log.
|
|
1019
|
-
if (filters.text instanceof RegExp) {
|
|
1020
|
-
filters.text = filters.text.toString();
|
|
1021
|
-
}
|
|
1022
|
-
throw new Error(`Could not find search results matching filter(s): ${JSON.stringify(filters)}`);
|
|
1023
|
-
}
|
|
1024
|
-
return harnesses;
|
|
925
|
+
return await overlay.queryHarnesses(SkyLookupSearchResultHarness.with(filters || {}));
|
|
1025
926
|
}
|
|
1026
927
|
/**
|
|
1027
928
|
* Returns the text content for each lookup search result.
|
|
@@ -1200,5 +1101,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.5", ngImpor
|
|
|
1200
1101
|
* Generated bundle index. Do not edit.
|
|
1201
1102
|
*/
|
|
1202
1103
|
|
|
1203
|
-
export { SkyAutocompleteHarness, SkyAutocompleteInputHarness, SkyAutocompleteSearchResultHarness,
|
|
1104
|
+
export { SkyAutocompleteHarness, SkyAutocompleteInputHarness, SkyAutocompleteSearchResultHarness, SkyCountryFieldHarness, SkyCountryFieldSearchResultHarness, SkyLookupHarness, SkyLookupSearchResultHarness, SkyLookupSelectionHarness, SkyLookupSelectionsListHarness, SkyLookupShowMorePickerHarness, SkyLookupShowMorePickerSearchResultHarness, SkySearchFixture, SkySearchHarness, SkySearchTestingModule, SkySelectionModalHarness, SkySelectionModalSearchResultHarness };
|
|
1204
1105
|
//# sourceMappingURL=skyux-lookup-testing.mjs.map
|