@skyux/lists 13.3.1 → 13.4.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.
@@ -1,11 +1,11 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { NgModule } from '@angular/core';
3
3
  import { SkyFilterModule, SkyInfiniteScrollModule } from '@skyux/lists';
4
- import { SkyComponentHarness, SkyQueryableComponentHarness } from '@skyux/core/testing';
5
- import { SkyTokenHarness, SkyChevronHarness } from '@skyux/indicators/testing';
6
- import { By } from '@angular/platform-browser';
7
4
  import { SkyAppTestUtility } from '@skyux-sdk/testing';
8
- import { ComponentHarness, HarnessPredicate } from '@angular/cdk/testing';
5
+ import { By } from '@angular/platform-browser';
6
+ import { SkyComponentHarness, SkyQueryableComponentHarness } from '@skyux/core/testing';
7
+ import { SkyTokenHarness, SkyKeyInfoHarness, SkyChevronHarness } from '@skyux/indicators/testing';
8
+ import { HarnessPredicate, ComponentHarness } from '@angular/cdk/testing';
9
9
  import { SkyCheckboxHarness } from '@skyux/forms/testing';
10
10
  import { SkyInlineFormHarness } from '@skyux/inline-form/testing';
11
11
  import { SkyDropdownHarness, SkyDropdownItemHarness } from '@skyux/popovers/testing';
@@ -25,6 +25,293 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImpor
25
25
  }]
26
26
  }] });
27
27
 
28
+ /**
29
+ * Provides information for and interaction with a SKY UX infinite scroll component.
30
+ * By using the fixture API, a test insulates itself against updates to the internals
31
+ * of a component, such as changing its DOM structure.
32
+ * @deprecated Use `SkyInfiniteScrollHarness` instead.
33
+ * @internal
34
+ */
35
+ class SkyInfiniteScrollFixture {
36
+ #debugElement;
37
+ #fixture;
38
+ constructor(fixture, skyTestId) {
39
+ this.#fixture = fixture;
40
+ this.#debugElement = SkyAppTestUtility.getDebugElementByTestId(fixture, skyTestId, 'sky-infinite-scroll');
41
+ }
42
+ get loadMoreButtonIsVisible() {
43
+ return this.#getButton() !== null;
44
+ }
45
+ async clickLoadMoreButton() {
46
+ const button = this.#getButton();
47
+ if (button !== null) {
48
+ button.click();
49
+ }
50
+ this.#fixture.detectChanges();
51
+ await this.#fixture.whenStable();
52
+ }
53
+ #getButton() {
54
+ return this.#debugElement.nativeElement.querySelector('.sky-infinite-scroll .sky-btn');
55
+ }
56
+ }
57
+
58
+ /**
59
+ * @internal
60
+ */
61
+ class SkyInfiniteScrollTestingModule {
62
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: SkyInfiniteScrollTestingModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
63
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.0", ngImport: i0, type: SkyInfiniteScrollTestingModule, exports: [SkyInfiniteScrollModule] }); }
64
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: SkyInfiniteScrollTestingModule, imports: [SkyInfiniteScrollModule] }); }
65
+ }
66
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: SkyInfiniteScrollTestingModule, decorators: [{
67
+ type: NgModule,
68
+ args: [{
69
+ exports: [SkyInfiniteScrollModule],
70
+ }]
71
+ }] });
72
+
73
+ /**
74
+ * Provides information for and interaction with a SKY UX paging component.
75
+ * By using the fixture API, a test insulates itself against updates to the internals
76
+ * of a component, such as changing its DOM structure.
77
+ * @deprecated Use `SkyPagingHarness` instead.
78
+ * @internal
79
+ */
80
+ class SkyPagingFixture {
81
+ #_debugEl;
82
+ /**
83
+ * The id of the active page, if available.
84
+ */
85
+ get activePageId() {
86
+ return this.#getPageId(this.#activePageButton);
87
+ }
88
+ /**
89
+ * Properties of the page links displayed in the paging component.
90
+ */
91
+ get pageLinks() {
92
+ return this.#pagingLinks.map((page) => {
93
+ return {
94
+ id: this.#getPageId(page.nativeElement),
95
+ isActive: page.nativeElement.classList.contains('sky-paging-current'),
96
+ isEnabled: !page.nativeElement.disabled,
97
+ };
98
+ });
99
+ }
100
+ #fixture;
101
+ constructor(fixture, skyTestId) {
102
+ this.#fixture = fixture;
103
+ this.#_debugEl = SkyAppTestUtility.getDebugElementByTestId(fixture, skyTestId, 'sky-paging');
104
+ void this.#waitForComponentInitialization();
105
+ }
106
+ /**
107
+ * Selects the specified page by id, if it is enabled.
108
+ */
109
+ async selectPage(id) {
110
+ const pageButton = this.#getPageLink(id.toString());
111
+ if (pageButton !== undefined && !pageButton.disabled) {
112
+ pageButton.click();
113
+ this.#fixture.detectChanges();
114
+ await this.#fixture.whenStable();
115
+ }
116
+ }
117
+ /**
118
+ * Clicks the next page button, if it is enabled.
119
+ */
120
+ async selectNextPage() {
121
+ const nextButton = this.#nextPageButton;
122
+ if (nextButton !== undefined && !nextButton.disabled) {
123
+ nextButton.click();
124
+ this.#fixture.detectChanges();
125
+ await this.#fixture.whenStable();
126
+ }
127
+ }
128
+ /**
129
+ * Clicks the previous page button, if it is enabled.
130
+ */
131
+ async selectPreviousPage() {
132
+ const previousButton = this.#previousPageButton;
133
+ if (previousButton !== undefined && !previousButton.disabled) {
134
+ previousButton.click();
135
+ this.#fixture.detectChanges();
136
+ await this.#fixture.whenStable();
137
+ }
138
+ }
139
+ //#region helpers
140
+ get #activePageButton() {
141
+ return this.#_debugEl.query(By.css('.sky-list-paging-link .sky-paging-current'))?.nativeElement;
142
+ }
143
+ get #nextPageButton() {
144
+ return this.#_debugEl.query(By.css('.sky-paging-btn[sky-cmp-id="next"]'))
145
+ ?.nativeElement;
146
+ }
147
+ get #previousPageButton() {
148
+ return this.#_debugEl.query(By.css('.sky-paging-btn[sky-cmp-id="previous"]'))?.nativeElement;
149
+ }
150
+ get #pagingLinks() {
151
+ return this.#_debugEl.queryAll(By.css('.sky-list-paging-link button'));
152
+ }
153
+ #getPageLink(id) {
154
+ return this.#_debugEl.query(By.css(`.sky-list-paging-link button[sky-cmp-id="${id}"]`))?.nativeElement;
155
+ }
156
+ #getPageId(page) {
157
+ return page?.getAttribute('sky-cmp-id') ?? '';
158
+ }
159
+ async #waitForComponentInitialization() {
160
+ this.#fixture.detectChanges();
161
+ await this.#fixture.whenStable();
162
+ this.#fixture.detectChanges();
163
+ await this.#fixture.whenStable();
164
+ }
165
+ }
166
+
167
+ /**
168
+ * Provides information for and interaction with a SKY UX sort component.
169
+ * By using the fixture API, a test insulates itself against updates to the internals
170
+ * of a component, such as changing its DOM structure.
171
+ * @deprecated Use `SkySortHarness` instead.
172
+ * @internal
173
+ */
174
+ class SkySortFixture {
175
+ /**
176
+ * The active sort menu item, if one exists. Menu items are only available when the menu dropdown
177
+ * is open. If the menu dropdown is closed, this property will be undefined.
178
+ */
179
+ get activeMenuItem() {
180
+ return this.menuItems?.find((x) => x.isActive);
181
+ }
182
+ /**
183
+ * The sort menu's properties.
184
+ */
185
+ get menu() {
186
+ /* istanbul ignore next */
187
+ const buttonText = SkyAppTestUtility.getText(this.#getSortButtonTextEl()) || '';
188
+ return {
189
+ buttonText,
190
+ isOpen: this.#getDropdownMenuEl() !== null,
191
+ };
192
+ }
193
+ /**
194
+ * The properties of each sort menu item. Menu items are only available when the menu dropdown
195
+ * is open. If the menu dropdown is closed, this property will be undefined.
196
+ */
197
+ get menuItems() {
198
+ // Return undefined when we can't determine what the options are.
199
+ // We do this to avoid any confusion with an empty set of options.
200
+ if (!this.menu.isOpen) {
201
+ return;
202
+ }
203
+ return this.#getSortItems().map((item, i) => {
204
+ const itemButton = item.querySelector('button');
205
+ return {
206
+ index: i,
207
+ isActive: item.classList.contains('sky-sort-item-selected'),
208
+ text: SkyAppTestUtility.getText(itemButton),
209
+ };
210
+ });
211
+ }
212
+ #debugEl;
213
+ #fixture;
214
+ constructor(fixture, skyTestId) {
215
+ this.#fixture = fixture;
216
+ this.#debugEl = SkyAppTestUtility.getDebugElementByTestId(fixture, skyTestId, 'sky-sort');
217
+ }
218
+ /**
219
+ * Closes the sort dropdown menu if it isn't closed already.
220
+ */
221
+ async closeMenu() {
222
+ // if the menu is already closed, do nothing
223
+ if (!this.menu.isOpen) {
224
+ return;
225
+ }
226
+ const menu = this.#getDropdownButtonEl();
227
+ if (menu !== undefined && !menu.disabled) {
228
+ menu.click();
229
+ this.#fixture.detectChanges();
230
+ await this.#fixture.whenStable();
231
+ this.#fixture.detectChanges();
232
+ await this.#fixture.whenStable();
233
+ }
234
+ }
235
+ /**
236
+ * Opens the sort dropdown menu if it isn't open already.
237
+ */
238
+ async openMenu() {
239
+ // if the menu is already open, do nothing
240
+ if (this.menu.isOpen) {
241
+ return;
242
+ }
243
+ const menu = this.#getDropdownButtonEl();
244
+ if (menu !== undefined && !menu.disabled) {
245
+ menu.click();
246
+ this.#fixture.detectChanges();
247
+ await this.#fixture.whenStable();
248
+ this.#fixture.detectChanges();
249
+ await this.#fixture.whenStable();
250
+ }
251
+ }
252
+ /**
253
+ * Ensures the sort menu is open and selects the menu item with the specified index, if it exists.
254
+ * @param menuItemIndex The index of the menu item to select.
255
+ */
256
+ async selectMenuItemByIndex(menuItemIndex) {
257
+ return await this.#selectMenuItem((_item, index) => {
258
+ return index === menuItemIndex;
259
+ });
260
+ }
261
+ /**
262
+ * Ensures the sort menu is open and selects the menu item with the specified text,
263
+ * if a matching item is available.
264
+ * @param menuItemText The text of the menu item to select.
265
+ */
266
+ async selectMenuItemByText(menuItemText) {
267
+ /* istanbul ignore else */
268
+ if (menuItemText) {
269
+ return await this.#selectMenuItem((item) => {
270
+ return SkyAppTestUtility.getText(item) === menuItemText;
271
+ });
272
+ }
273
+ else {
274
+ return;
275
+ }
276
+ }
277
+ //#region helpers
278
+ #getDropdownButtonEl() {
279
+ return this.#debugEl.query(By.css('.sky-dropdown-button')).nativeElement;
280
+ }
281
+ #getDropdownMenuEl() {
282
+ return document.querySelector('sky-overlay .sky-dropdown-menu');
283
+ }
284
+ #getSortButtonTextEl() {
285
+ return this.#debugEl.query(By.css('.sky-sort-btn-text')).nativeElement;
286
+ }
287
+ #getSortItems() {
288
+ const resultNodes = document.querySelectorAll('sky-overlay .sky-sort-item');
289
+ return Array.prototype.slice.call(resultNodes);
290
+ }
291
+ /**
292
+ * Ensures the sort menu is open and selects the menu item via a selection predicate,
293
+ * if a matching item is available.
294
+ * @param selectionPredicate The menu item selector method to use.
295
+ */
296
+ async #selectMenuItem(selectionPredicate) {
297
+ // make sure the sort menu is open
298
+ if (!this.menu.isOpen) {
299
+ await this.openMenu();
300
+ }
301
+ // find the requested menu item using the selectionPredicate parameter
302
+ const items = this.#getSortItems();
303
+ const targetItem = items.find((item, index) => selectionPredicate(item, index));
304
+ // if we found the item, select it
305
+ if (targetItem) {
306
+ // we've got the '.sky-sort-item' div, but we want to click it's child button element
307
+ const targetButton = targetItem.querySelector('button');
308
+ targetButton?.click();
309
+ this.#fixture.detectChanges();
310
+ await this.#fixture.whenStable();
311
+ }
312
+ }
313
+ }
314
+
28
315
  /**
29
316
  * Harness for interacting with a filter button component in tests.
30
317
  */
@@ -213,96 +500,148 @@ class SkyFilterSummaryHarness extends SkyComponentHarness {
213
500
  }
214
501
 
215
502
  /**
216
- * Provides information for and interaction with a SKY UX paging component.
217
- * By using the fixture API, a test insulates itself against updates to the internals
218
- * of a component, such as changing its DOM structure.
219
- * @deprecated Use `SkyPagingHarness` instead.
220
- * @internal
503
+ * Harness for interacting with an infinite scroll component in tests.
221
504
  */
222
- class SkyPagingFixture {
223
- #_debugEl;
505
+ class SkyInfiniteScrollHarness extends SkyComponentHarness {
224
506
  /**
225
- * The id of the active page, if available.
507
+ * @internal
226
508
  */
227
- get activePageId() {
228
- return this.#getPageId(this.#activePageButton);
509
+ static { this.hostSelector = 'sky-infinite-scroll'; }
510
+ #showMoreButton = this.locatorForOptional('button.sky-infinite-scroll-load-more-button');
511
+ /**
512
+ * Gets a `HarnessPredicate` that can be used to search for a
513
+ * `SkyInfiniteScrollHarness` that meets certain criteria.
514
+ */
515
+ static with(filters) {
516
+ return this.getDataSkyIdPredicate(filters);
229
517
  }
230
518
  /**
231
- * Properties of the page links displayed in the paging component.
519
+ * Whether the infinite scroll is enabled.
232
520
  */
233
- get pageLinks() {
234
- return this.#pagingLinks.map((page) => {
235
- return {
236
- id: this.#getPageId(page.nativeElement),
237
- isActive: page.nativeElement.classList.contains('sky-paging-current'),
238
- isEnabled: !page.nativeElement.disabled,
239
- };
240
- });
521
+ async isEnabled() {
522
+ return (await this.locatorForOptional('.sky-infinite-scroll')()) !== null;
241
523
  }
242
- #fixture;
243
- constructor(fixture, skyTestId) {
244
- this.#fixture = fixture;
245
- this.#_debugEl = SkyAppTestUtility.getDebugElementByTestId(fixture, skyTestId, 'sky-paging');
246
- void this.#waitForComponentInitialization();
524
+ /**
525
+ * Whether the infinite scroll is loading.
526
+ */
527
+ async isLoading() {
528
+ return (await this.isEnabled()) && (await this.#showMoreButton()) === null;
247
529
  }
248
530
  /**
249
- * Selects the specified page by id, if it is enabled.
531
+ * Clicks the "Load more" button.
250
532
  */
251
- async selectPage(id) {
252
- const pageButton = this.#getPageLink(id.toString());
253
- if (pageButton !== undefined && !pageButton.disabled) {
254
- pageButton.click();
255
- this.#fixture.detectChanges();
256
- await this.#fixture.whenStable();
533
+ async loadMore() {
534
+ const button = await this.#showMoreButton();
535
+ if (button) {
536
+ await button.click();
537
+ }
538
+ else {
539
+ if (!(await this.isEnabled())) {
540
+ throw new Error('Unable to click the "Load more" button because the infinite scroll is not enabled.');
541
+ }
542
+ else {
543
+ throw new Error('Unable to click the "Load more" button because the infinite scroll is loading.');
544
+ }
257
545
  }
258
546
  }
547
+ }
548
+
549
+ /**
550
+ * Harness for interacting with a list summary item component in tests.
551
+ */
552
+ class SkyListSummaryItemHarness extends SkyComponentHarness {
259
553
  /**
260
- * Clicks the next page button, if it is enabled.
554
+ * @internal
261
555
  */
262
- async selectNextPage() {
263
- const nextButton = this.#nextPageButton;
264
- if (nextButton !== undefined && !nextButton.disabled) {
265
- nextButton.click();
266
- this.#fixture.detectChanges();
267
- await this.#fixture.whenStable();
268
- }
556
+ static { this.hostSelector = 'sky-list-summary-item'; }
557
+ #getKeyInfo = this.locatorFor(SkyKeyInfoHarness);
558
+ /**
559
+ * Gets a `HarnessPredicate` that can be used to search for a
560
+ * `SkyListSummaryItemHarness` that meets certain criteria.
561
+ */
562
+ static with(filters) {
563
+ return SkyListSummaryItemHarness.getDataSkyIdPredicate(filters)
564
+ .addOption('labelText', filters.labelText, async (harness, labelText) => {
565
+ const actualLabelText = await harness.getLabelText();
566
+ return await HarnessPredicate.stringMatches(actualLabelText, labelText);
567
+ })
568
+ .addOption('valueText', filters.valueText, async (harness, valueText) => {
569
+ const actualValueText = await harness.getValueText();
570
+ return await HarnessPredicate.stringMatches(actualValueText, valueText);
571
+ });
269
572
  }
270
573
  /**
271
- * Clicks the previous page button, if it is enabled.
574
+ * Gets the current value text.
272
575
  */
273
- async selectPreviousPage() {
274
- const previousButton = this.#previousPageButton;
275
- if (previousButton !== undefined && !previousButton.disabled) {
276
- previousButton.click();
277
- this.#fixture.detectChanges();
278
- await this.#fixture.whenStable();
279
- }
576
+ async getValueText() {
577
+ const keyInfo = await this.#getKeyInfo();
578
+ return await keyInfo.getValueText();
280
579
  }
281
- //#region helpers
282
- get #activePageButton() {
283
- return this.#_debugEl.query(By.css('.sky-list-paging-link .sky-paging-current'))?.nativeElement;
580
+ /**
581
+ * Gets the current label text.
582
+ */
583
+ async getLabelText() {
584
+ const keyInfo = await this.#getKeyInfo();
585
+ return await keyInfo.getLabelText();
284
586
  }
285
- get #nextPageButton() {
286
- return this.#_debugEl.query(By.css('.sky-paging-btn[sky-cmp-id="next"]'))
287
- ?.nativeElement;
587
+ /**
588
+ * Gets the key info harness for advanced interactions.
589
+ */
590
+ async getKeyInfo() {
591
+ return await this.#getKeyInfo();
288
592
  }
289
- get #previousPageButton() {
290
- return this.#_debugEl.query(By.css('.sky-paging-btn[sky-cmp-id="previous"]'))?.nativeElement;
593
+ /**
594
+ * Clicks the help inline button to show the help popover.
595
+ */
596
+ async clickHelpInline() {
597
+ const keyInfo = await this.#getKeyInfo();
598
+ return await keyInfo.clickHelpInline();
291
599
  }
292
- get #pagingLinks() {
293
- return this.#_debugEl.queryAll(By.css('.sky-list-paging-link button'));
600
+ /**
601
+ * Gets the help popover content text.
602
+ */
603
+ async getHelpPopoverContent() {
604
+ const keyInfo = await this.#getKeyInfo();
605
+ return await keyInfo.getHelpPopoverContent();
294
606
  }
295
- #getPageLink(id) {
296
- return this.#_debugEl.query(By.css(`.sky-list-paging-link button[sky-cmp-id="${id}"]`))?.nativeElement;
607
+ /**
608
+ * Gets the help popover title text.
609
+ */
610
+ async getHelpPopoverTitle() {
611
+ const keyInfo = await this.#getKeyInfo();
612
+ return await keyInfo.getHelpPopoverTitle();
613
+ }
614
+ }
615
+
616
+ /**
617
+ * Harness for interacting with a list summary component in tests.
618
+ */
619
+ class SkyListSummaryHarness extends SkyQueryableComponentHarness {
620
+ /**
621
+ * @internal
622
+ */
623
+ static { this.hostSelector = 'sky-list-summary'; }
624
+ /**
625
+ * Gets a `HarnessPredicate` that can be used to search for a
626
+ * `SkyListSummaryHarness` that meets certain criteria.
627
+ */
628
+ static with(filters) {
629
+ return SkyListSummaryHarness.getDataSkyIdPredicate(filters);
297
630
  }
298
- #getPageId(page) {
299
- return page?.getAttribute('sky-cmp-id') ?? '';
631
+ /**
632
+ * Gets a specific list summary item based on the filter criteria.
633
+ * @param filter The filter criteria.
634
+ */
635
+ async getSummaryItem(filter) {
636
+ return await this.locatorFor(SkyListSummaryItemHarness.with(filter))();
300
637
  }
301
- async #waitForComponentInitialization() {
302
- this.#fixture.detectChanges();
303
- await this.#fixture.whenStable();
304
- this.#fixture.detectChanges();
305
- await this.#fixture.whenStable();
638
+ /**
639
+ * Gets an array of list summary items based on the filter criteria.
640
+ * If no filter is provided, returns all summary items.
641
+ * @param filters The optional filter criteria.
642
+ */
643
+ async getSummaryItems(filters) {
644
+ return await this.locatorForAll(SkyListSummaryItemHarness.with(filters || {}))();
306
645
  }
307
646
  }
308
647
 
@@ -648,154 +987,6 @@ class SkyRepeaterHarness extends SkyComponentHarness {
648
987
  }
649
988
  }
650
989
 
651
- /**
652
- * Provides information for and interaction with a SKY UX sort component.
653
- * By using the fixture API, a test insulates itself against updates to the internals
654
- * of a component, such as changing its DOM structure.
655
- * @deprecated Use `SkySortHarness` instead.
656
- * @internal
657
- */
658
- class SkySortFixture {
659
- /**
660
- * The active sort menu item, if one exists. Menu items are only available when the menu dropdown
661
- * is open. If the menu dropdown is closed, this property will be undefined.
662
- */
663
- get activeMenuItem() {
664
- return this.menuItems?.find((x) => x.isActive);
665
- }
666
- /**
667
- * The sort menu's properties.
668
- */
669
- get menu() {
670
- /* istanbul ignore next */
671
- const buttonText = SkyAppTestUtility.getText(this.#getSortButtonTextEl()) || '';
672
- return {
673
- buttonText,
674
- isOpen: this.#getDropdownMenuEl() !== null,
675
- };
676
- }
677
- /**
678
- * The properties of each sort menu item. Menu items are only available when the menu dropdown
679
- * is open. If the menu dropdown is closed, this property will be undefined.
680
- */
681
- get menuItems() {
682
- // Return undefined when we can't determine what the options are.
683
- // We do this to avoid any confusion with an empty set of options.
684
- if (!this.menu.isOpen) {
685
- return;
686
- }
687
- return this.#getSortItems().map((item, i) => {
688
- const itemButton = item.querySelector('button');
689
- return {
690
- index: i,
691
- isActive: item.classList.contains('sky-sort-item-selected'),
692
- text: SkyAppTestUtility.getText(itemButton),
693
- };
694
- });
695
- }
696
- #debugEl;
697
- #fixture;
698
- constructor(fixture, skyTestId) {
699
- this.#fixture = fixture;
700
- this.#debugEl = SkyAppTestUtility.getDebugElementByTestId(fixture, skyTestId, 'sky-sort');
701
- }
702
- /**
703
- * Closes the sort dropdown menu if it isn't closed already.
704
- */
705
- async closeMenu() {
706
- // if the menu is already closed, do nothing
707
- if (!this.menu.isOpen) {
708
- return;
709
- }
710
- const menu = this.#getDropdownButtonEl();
711
- if (menu !== undefined && !menu.disabled) {
712
- menu.click();
713
- this.#fixture.detectChanges();
714
- await this.#fixture.whenStable();
715
- this.#fixture.detectChanges();
716
- await this.#fixture.whenStable();
717
- }
718
- }
719
- /**
720
- * Opens the sort dropdown menu if it isn't open already.
721
- */
722
- async openMenu() {
723
- // if the menu is already open, do nothing
724
- if (this.menu.isOpen) {
725
- return;
726
- }
727
- const menu = this.#getDropdownButtonEl();
728
- if (menu !== undefined && !menu.disabled) {
729
- menu.click();
730
- this.#fixture.detectChanges();
731
- await this.#fixture.whenStable();
732
- this.#fixture.detectChanges();
733
- await this.#fixture.whenStable();
734
- }
735
- }
736
- /**
737
- * Ensures the sort menu is open and selects the menu item with the specified index, if it exists.
738
- * @param menuItemIndex The index of the menu item to select.
739
- */
740
- async selectMenuItemByIndex(menuItemIndex) {
741
- return await this.#selectMenuItem((_item, index) => {
742
- return index === menuItemIndex;
743
- });
744
- }
745
- /**
746
- * Ensures the sort menu is open and selects the menu item with the specified text,
747
- * if a matching item is available.
748
- * @param menuItemText The text of the menu item to select.
749
- */
750
- async selectMenuItemByText(menuItemText) {
751
- /* istanbul ignore else */
752
- if (menuItemText) {
753
- return await this.#selectMenuItem((item) => {
754
- return SkyAppTestUtility.getText(item) === menuItemText;
755
- });
756
- }
757
- else {
758
- return;
759
- }
760
- }
761
- //#region helpers
762
- #getDropdownButtonEl() {
763
- return this.#debugEl.query(By.css('.sky-dropdown-button')).nativeElement;
764
- }
765
- #getDropdownMenuEl() {
766
- return document.querySelector('sky-overlay .sky-dropdown-menu');
767
- }
768
- #getSortButtonTextEl() {
769
- return this.#debugEl.query(By.css('.sky-sort-btn-text')).nativeElement;
770
- }
771
- #getSortItems() {
772
- const resultNodes = document.querySelectorAll('sky-overlay .sky-sort-item');
773
- return Array.prototype.slice.call(resultNodes);
774
- }
775
- /**
776
- * Ensures the sort menu is open and selects the menu item via a selection predicate,
777
- * if a matching item is available.
778
- * @param selectionPredicate The menu item selector method to use.
779
- */
780
- async #selectMenuItem(selectionPredicate) {
781
- // make sure the sort menu is open
782
- if (!this.menu.isOpen) {
783
- await this.openMenu();
784
- }
785
- // find the requested menu item using the selectionPredicate parameter
786
- const items = this.#getSortItems();
787
- const targetItem = items.find((item, index) => selectionPredicate(item, index));
788
- // if we found the item, select it
789
- if (targetItem) {
790
- // we've got the '.sky-sort-item' div, but we want to click it's child button element
791
- const targetButton = targetItem.querySelector('button');
792
- targetButton?.click();
793
- this.#fixture.detectChanges();
794
- await this.#fixture.whenStable();
795
- }
796
- }
797
- }
798
-
799
990
  /**
800
991
  * Harness for interacting with a sort item component in tests.
801
992
  */
@@ -902,101 +1093,9 @@ class SkySortHarness extends SkyComponentHarness {
902
1093
  }
903
1094
  }
904
1095
 
905
- /**
906
- * Provides information for and interaction with a SKY UX infinite scroll component.
907
- * By using the fixture API, a test insulates itself against updates to the internals
908
- * of a component, such as changing its DOM structure.
909
- * @deprecated Use `SkyInfiniteScrollHarness` instead.
910
- * @internal
911
- */
912
- class SkyInfiniteScrollFixture {
913
- #debugElement;
914
- #fixture;
915
- constructor(fixture, skyTestId) {
916
- this.#fixture = fixture;
917
- this.#debugElement = SkyAppTestUtility.getDebugElementByTestId(fixture, skyTestId, 'sky-infinite-scroll');
918
- }
919
- get loadMoreButtonIsVisible() {
920
- return this.#getButton() !== null;
921
- }
922
- async clickLoadMoreButton() {
923
- const button = this.#getButton();
924
- if (button !== null) {
925
- button.click();
926
- }
927
- this.#fixture.detectChanges();
928
- await this.#fixture.whenStable();
929
- }
930
- #getButton() {
931
- return this.#debugElement.nativeElement.querySelector('.sky-infinite-scroll .sky-btn');
932
- }
933
- }
934
-
935
- /**
936
- * @internal
937
- */
938
- class SkyInfiniteScrollTestingModule {
939
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: SkyInfiniteScrollTestingModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
940
- static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.0", ngImport: i0, type: SkyInfiniteScrollTestingModule, exports: [SkyInfiniteScrollModule] }); }
941
- static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: SkyInfiniteScrollTestingModule, imports: [SkyInfiniteScrollModule] }); }
942
- }
943
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: SkyInfiniteScrollTestingModule, decorators: [{
944
- type: NgModule,
945
- args: [{
946
- exports: [SkyInfiniteScrollModule],
947
- }]
948
- }] });
949
-
950
- /**
951
- * Harness for interacting with an infinite scroll component in tests.
952
- */
953
- class SkyInfiniteScrollHarness extends SkyComponentHarness {
954
- /**
955
- * @internal
956
- */
957
- static { this.hostSelector = 'sky-infinite-scroll'; }
958
- #showMoreButton = this.locatorForOptional('button.sky-infinite-scroll-load-more-button');
959
- /**
960
- * Gets a `HarnessPredicate` that can be used to search for a
961
- * `SkyInfiniteScrollHarness` that meets certain criteria.
962
- */
963
- static with(filters) {
964
- return this.getDataSkyIdPredicate(filters);
965
- }
966
- /**
967
- * Whether the infinite scroll is enabled.
968
- */
969
- async isEnabled() {
970
- return (await this.locatorForOptional('.sky-infinite-scroll')()) !== null;
971
- }
972
- /**
973
- * Whether the infinite scroll is loading.
974
- */
975
- async isLoading() {
976
- return (await this.isEnabled()) && (await this.#showMoreButton()) === null;
977
- }
978
- /**
979
- * Clicks the "Load more" button.
980
- */
981
- async loadMore() {
982
- const button = await this.#showMoreButton();
983
- if (button) {
984
- await button.click();
985
- }
986
- else {
987
- if (!(await this.isEnabled())) {
988
- throw new Error('Unable to click the "Load more" button because the infinite scroll is not enabled.');
989
- }
990
- else {
991
- throw new Error('Unable to click the "Load more" button because the infinite scroll is loading.');
992
- }
993
- }
994
- }
995
- }
996
-
997
1096
  /**
998
1097
  * Generated bundle index. Do not edit.
999
1098
  */
1000
1099
 
1001
- export { SkyFilterButtonHarness, SkyFilterInlineHarness, SkyFilterInlineItemHarness, SkyFilterSummaryHarness, SkyFilterSummaryItemHarness, SkyFilterTestingModule, SkyInfiniteScrollFixture, SkyInfiniteScrollHarness, SkyInfiniteScrollTestingModule, SkyPagingContentHarness, SkyPagingFixture, SkyPagingHarness, SkyRepeaterHarness, SkyRepeaterItemContextMenuHarness, SkyRepeaterItemHarness, SkySortFixture, SkySortHarness, SkySortItemHarness };
1100
+ export { SkyFilterButtonHarness, SkyFilterInlineHarness, SkyFilterInlineItemHarness, SkyFilterSummaryHarness, SkyFilterSummaryItemHarness, SkyFilterTestingModule, SkyInfiniteScrollFixture, SkyInfiniteScrollHarness, SkyInfiniteScrollTestingModule, SkyListSummaryHarness, SkyListSummaryItemHarness, SkyPagingContentHarness, SkyPagingFixture, SkyPagingHarness, SkyRepeaterHarness, SkyRepeaterItemContextMenuHarness, SkyRepeaterItemHarness, SkySortFixture, SkySortHarness, SkySortItemHarness };
1002
1101
  //# sourceMappingURL=skyux-lists-testing.mjs.map