@internetarchive/collection-browser 3.4.1-alpha-webdev7761.2 → 3.4.1-alpha-webdev7761.4
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/dist/src/app-root.js +19 -28
- package/dist/src/app-root.js.map +1 -1
- package/dist/src/collection-browser.d.ts +14 -10
- package/dist/src/collection-browser.js +870 -886
- package/dist/src/collection-browser.js.map +1 -1
- package/dist/src/collection-facets/facet-row.js +3 -4
- package/dist/src/collection-facets/facet-row.js.map +1 -1
- package/dist/src/collection-facets/models.js.map +1 -1
- package/dist/src/collection-facets/more-facets-content.js +145 -156
- package/dist/src/collection-facets/more-facets-content.js.map +1 -1
- package/dist/src/collection-facets/more-facets-pagination.js +6 -10
- package/dist/src/collection-facets/more-facets-pagination.js.map +1 -1
- package/dist/src/collection-facets/smart-facets/heuristics/wikidata/wikidata-heuristic.js +16 -21
- package/dist/src/collection-facets/smart-facets/heuristics/wikidata/wikidata-heuristic.js.map +1 -1
- package/dist/src/collection-facets/smart-facets/smart-facet-bar.js +7 -10
- package/dist/src/collection-facets/smart-facets/smart-facet-bar.js.map +1 -1
- package/dist/src/collection-facets/smart-facets/smart-facet-button.js +3 -2
- package/dist/src/collection-facets/smart-facets/smart-facet-button.js.map +1 -1
- package/dist/src/collection-facets/smart-facets/smart-facet-dropdown.js +9 -11
- package/dist/src/collection-facets/smart-facets/smart-facet-dropdown.js.map +1 -1
- package/dist/src/collection-facets/smart-facets/smart-facet-heuristics.js +7 -7
- package/dist/src/collection-facets/smart-facets/smart-facet-heuristics.js.map +1 -1
- package/dist/src/collection-facets/toggle-switch.js +4 -6
- package/dist/src/collection-facets/toggle-switch.js.map +1 -1
- package/dist/src/collection-facets.js +34 -50
- package/dist/src/collection-facets.js.map +1 -1
- package/dist/src/combo-box/caret-closed.js +5 -11
- package/dist/src/combo-box/caret-closed.js.map +1 -1
- package/dist/src/combo-box/caret-open.js +5 -11
- package/dist/src/combo-box/caret-open.js.map +1 -1
- package/dist/src/combo-box/clear.d.ts +2 -0
- package/dist/src/combo-box/clear.js +11 -0
- package/dist/src/combo-box/clear.js.map +1 -0
- package/dist/src/combo-box/ia-combo-box.d.ts +40 -9
- package/dist/src/combo-box/ia-combo-box.js +363 -272
- package/dist/src/combo-box/ia-combo-box.js.map +1 -1
- package/dist/src/combo-box/models.d.ts +14 -0
- package/dist/src/combo-box/models.js +32 -1
- package/dist/src/combo-box/models.js.map +1 -1
- package/dist/src/data-source/collection-browser-data-source.js +35 -47
- package/dist/src/data-source/collection-browser-data-source.js.map +1 -1
- package/dist/src/empty-placeholder.js +19 -18
- package/dist/src/empty-placeholder.js.map +1 -1
- package/dist/src/expanded-date-picker.js +6 -10
- package/dist/src/expanded-date-picker.js.map +1 -1
- package/dist/src/language-code-handler/language-code-handler.js +2 -2
- package/dist/src/language-code-handler/language-code-handler.js.map +1 -1
- package/dist/src/manage/manage-bar.js +86 -92
- package/dist/src/manage/manage-bar.js.map +1 -1
- package/dist/src/manage/remove-items-modal-content.js +2 -2
- package/dist/src/manage/remove-items-modal-content.js.map +1 -1
- package/dist/src/models.js +36 -40
- package/dist/src/models.js.map +1 -1
- package/dist/src/restoration-state-handler.js +9 -10
- package/dist/src/restoration-state-handler.js.map +1 -1
- package/dist/src/sort-filter-bar/alpha-bar.js +9 -14
- package/dist/src/sort-filter-bar/alpha-bar.js.map +1 -1
- package/dist/src/sort-filter-bar/sort-filter-bar.js +14 -24
- package/dist/src/sort-filter-bar/sort-filter-bar.js.map +1 -1
- package/dist/src/tiles/base-tile-component.js +1 -2
- package/dist/src/tiles/base-tile-component.js.map +1 -1
- package/dist/src/tiles/grid/account-tile.js +36 -38
- package/dist/src/tiles/grid/account-tile.js.map +1 -1
- package/dist/src/tiles/grid/collection-tile.js +79 -82
- package/dist/src/tiles/grid/collection-tile.js.map +1 -1
- package/dist/src/tiles/grid/item-tile.js +154 -164
- package/dist/src/tiles/grid/item-tile.js.map +1 -1
- package/dist/src/tiles/grid/search-tile.js +42 -43
- package/dist/src/tiles/grid/search-tile.js.map +1 -1
- package/dist/src/tiles/grid/styles/tile-grid-shared-styles.js +119 -119
- package/dist/src/tiles/grid/styles/tile-grid-shared-styles.js.map +1 -1
- package/dist/src/tiles/grid/tile-stats.js +2 -3
- package/dist/src/tiles/grid/tile-stats.js.map +1 -1
- package/dist/src/tiles/hover/hover-pane-controller.js +42 -49
- package/dist/src/tiles/hover/hover-pane-controller.js.map +1 -1
- package/dist/src/tiles/hover/tile-hover-pane.js +113 -114
- package/dist/src/tiles/hover/tile-hover-pane.js.map +1 -1
- package/dist/src/tiles/image-block.js +5 -8
- package/dist/src/tiles/image-block.js.map +1 -1
- package/dist/src/tiles/item-image.js +12 -19
- package/dist/src/tiles/item-image.js.map +1 -1
- package/dist/src/tiles/list/tile-list-compact.js +114 -122
- package/dist/src/tiles/list/tile-list-compact.js.map +1 -1
- package/dist/src/tiles/list/tile-list.js +326 -347
- package/dist/src/tiles/list/tile-list.js.map +1 -1
- package/dist/src/tiles/overlay/icon-overlay.js +1 -2
- package/dist/src/tiles/overlay/icon-overlay.js.map +1 -1
- package/dist/src/tiles/overlay/text-overlay.js +2 -4
- package/dist/src/tiles/overlay/text-overlay.js.map +1 -1
- package/dist/src/tiles/text-snippet-block.js +2 -4
- package/dist/src/tiles/text-snippet-block.js.map +1 -1
- package/dist/src/tiles/tile-dispatcher.js +233 -241
- package/dist/src/tiles/tile-dispatcher.js.map +1 -1
- package/dist/src/tiles/tile-display-value-provider.js +5 -9
- package/dist/src/tiles/tile-display-value-provider.js.map +1 -1
- package/dist/src/tiles/tile-mediatype-icon.js +12 -19
- package/dist/src/tiles/tile-mediatype-icon.js.map +1 -1
- package/dist/src/utils/collapse-repeated-quotes.js +1 -1
- package/dist/src/utils/collapse-repeated-quotes.js.map +1 -1
- package/dist/src/utils/facet-utils.js +3 -5
- package/dist/src/utils/facet-utils.js.map +1 -1
- package/dist/src/utils/format-count.js +10 -10
- package/dist/src/utils/format-count.js.map +1 -1
- package/dist/src/utils/format-date.js.map +1 -1
- package/dist/src/utils/resolve-mediatype.js +2 -3
- package/dist/src/utils/resolve-mediatype.js.map +1 -1
- package/dist/test/collection-browser.test.js +131 -185
- package/dist/test/collection-browser.test.js.map +1 -1
- package/dist/test/collection-facets/facet-row.test.js +60 -75
- package/dist/test/collection-facets/facet-row.test.js.map +1 -1
- package/dist/test/collection-facets/facets-template.test.js +17 -23
- package/dist/test/collection-facets/facets-template.test.js.map +1 -1
- package/dist/test/collection-facets/more-facets-content.test.js +22 -32
- package/dist/test/collection-facets/more-facets-content.test.js.map +1 -1
- package/dist/test/collection-facets/more-facets-pagination.test.js +16 -22
- package/dist/test/collection-facets/more-facets-pagination.test.js.map +1 -1
- package/dist/test/collection-facets/toggle-switch.test.js +22 -19
- package/dist/test/collection-facets/toggle-switch.test.js.map +1 -1
- package/dist/test/collection-facets.test.js +80 -97
- package/dist/test/collection-facets.test.js.map +1 -1
- package/dist/test/empty-placeholder.test.js +11 -17
- package/dist/test/empty-placeholder.test.js.map +1 -1
- package/dist/test/expanded-date-picker.test.js +8 -14
- package/dist/test/expanded-date-picker.test.js.map +1 -1
- package/dist/test/icon-overlay.test.js +7 -6
- package/dist/test/icon-overlay.test.js.map +1 -1
- package/dist/test/image-block.test.js +16 -26
- package/dist/test/image-block.test.js.map +1 -1
- package/dist/test/item-image.test.js +23 -32
- package/dist/test/item-image.test.js.map +1 -1
- package/dist/test/manage/manage-bar.test.js +21 -33
- package/dist/test/manage/manage-bar.test.js.map +1 -1
- package/dist/test/manage/remove-items-modal-content.test.js +10 -15
- package/dist/test/manage/remove-items-modal-content.test.js.map +1 -1
- package/dist/test/mocks/mock-search-service.js +2 -3
- package/dist/test/mocks/mock-search-service.js.map +1 -1
- package/dist/test/restoration-state-handler.test.js +13 -21
- package/dist/test/restoration-state-handler.test.js.map +1 -1
- package/dist/test/review-block.test.js +16 -18
- package/dist/test/review-block.test.js.map +1 -1
- package/dist/test/sort-filter-bar/alpha-bar-tooltip.test.js +2 -3
- package/dist/test/sort-filter-bar/alpha-bar-tooltip.test.js.map +1 -1
- package/dist/test/sort-filter-bar/alpha-bar.test.js +18 -24
- package/dist/test/sort-filter-bar/alpha-bar.test.js.map +1 -1
- package/dist/test/sort-filter-bar/sort-filter-bar.test.js +178 -180
- package/dist/test/sort-filter-bar/sort-filter-bar.test.js.map +1 -1
- package/dist/test/text-overlay.test.js +16 -15
- package/dist/test/text-overlay.test.js.map +1 -1
- package/dist/test/text-snippet-block.test.js +14 -19
- package/dist/test/text-snippet-block.test.js.map +1 -1
- package/dist/test/tile-stats.test.js +73 -34
- package/dist/test/tile-stats.test.js.map +1 -1
- package/dist/test/tiles/grid/account-tile.test.js +25 -25
- package/dist/test/tiles/grid/account-tile.test.js.map +1 -1
- package/dist/test/tiles/grid/collection-tile.test.js +13 -19
- package/dist/test/tiles/grid/collection-tile.test.js.map +1 -1
- package/dist/test/tiles/grid/item-tile.test.js +141 -168
- package/dist/test/tiles/grid/item-tile.test.js.map +1 -1
- package/dist/test/tiles/grid/search-tile.test.js +9 -13
- package/dist/test/tiles/grid/search-tile.test.js.map +1 -1
- package/dist/test/tiles/hover/hover-pane-controller.test.js +50 -62
- package/dist/test/tiles/hover/hover-pane-controller.test.js.map +1 -1
- package/dist/test/tiles/hover/tile-hover-pane.test.js +12 -16
- package/dist/test/tiles/hover/tile-hover-pane.test.js.map +1 -1
- package/dist/test/tiles/list/tile-list-compact.test.js +104 -118
- package/dist/test/tiles/list/tile-list-compact.test.js.map +1 -1
- package/dist/test/tiles/list/tile-list.test.js +202 -231
- package/dist/test/tiles/list/tile-list.test.js.map +1 -1
- package/dist/test/tiles/tile-dispatcher.test.js +97 -110
- package/dist/test/tiles/tile-dispatcher.test.js.map +1 -1
- package/dist/test/tiles/tile-mediatype-icon.test.js +12 -24
- package/dist/test/tiles/tile-mediatype-icon.test.js.map +1 -1
- package/dist/test/utils/format-date.test.js.map +1 -1
- package/index.html +1 -1
- package/package.json +5 -3
- package/src/collection-browser.ts +3060 -3030
- package/src/collection-facets/models.ts +10 -10
- package/src/collection-facets/more-facets-content.ts +639 -639
- package/src/collection-facets.ts +1 -1
- package/src/combo-box/caret-closed.ts +5 -11
- package/src/combo-box/caret-open.ts +5 -11
- package/src/combo-box/clear.ts +11 -0
- package/src/combo-box/ia-combo-box.ts +1288 -1180
- package/src/combo-box/models.ts +31 -1
- package/src/manage/manage-bar.ts +247 -247
- package/src/restoration-state-handler.ts +5 -1
- package/src/tiles/base-tile-component.ts +65 -65
- package/src/tiles/grid/account-tile.ts +113 -113
- package/src/tiles/grid/collection-tile.ts +163 -163
- package/src/tiles/grid/item-tile.ts +340 -340
- package/src/tiles/grid/search-tile.ts +90 -90
- package/src/tiles/grid/styles/tile-grid-shared-styles.ts +130 -130
- package/src/tiles/hover/hover-pane-controller.ts +613 -613
- package/src/tiles/hover/tile-hover-pane.ts +184 -184
- package/src/tiles/list/tile-list-compact.ts +239 -239
- package/src/tiles/list/tile-list.ts +700 -700
- package/src/tiles/tile-dispatcher.ts +517 -517
- package/src/utils/format-date.ts +62 -62
- package/test/collection-facets/facet-row.test.ts +375 -375
- package/test/collection-facets.test.ts +928 -928
- package/test/tiles/grid/item-tile.test.ts +520 -520
- package/test/tiles/hover/hover-pane-controller.test.ts +418 -418
- package/test/tiles/list/tile-list-compact.test.ts +282 -282
- package/test/tiles/list/tile-list.test.ts +552 -552
- package/test/tiles/tile-dispatcher.test.ts +283 -283
- package/test/utils/format-date.test.ts +89 -89
- package/tsconfig.json +8 -3
- package/vite.config.ts +29 -22
|
@@ -11,15 +11,13 @@ import { MockAnalyticsHandler } from './mocks/mock-analytics-handler';
|
|
|
11
11
|
// import type { FacetsTemplate } from '../src/collection-facets/facets-template'; Used in lending tests (disabled)
|
|
12
12
|
describe('Collection Facets', () => {
|
|
13
13
|
it('has loader', async () => {
|
|
14
|
-
var _a, _b, _c, _d;
|
|
15
14
|
const el = await fixture(html `<collection-facets ?facetsLoading=${true}></collection-facets>`);
|
|
16
|
-
expect(
|
|
15
|
+
expect(el.shadowRoot?.querySelector('#container')?.classList.contains('loading')).to.be.true;
|
|
17
16
|
el.facetsLoading = false;
|
|
18
17
|
await el.updateComplete;
|
|
19
|
-
expect(
|
|
18
|
+
expect(el.shadowRoot?.querySelector('#container')?.classList.contains('loading')).to.be.false;
|
|
20
19
|
});
|
|
21
20
|
it('renders a date picker loading placeholder when date picker enabled', async () => {
|
|
22
|
-
var _a;
|
|
23
21
|
const el = await fixture(html `<collection-facets></collection-facets>`);
|
|
24
22
|
el.histogramAggregationLoading = true;
|
|
25
23
|
el.showHistogramDatePicker = true;
|
|
@@ -29,11 +27,10 @@ describe('Collection Facets', () => {
|
|
|
29
27
|
last_bucket_key: 2,
|
|
30
28
|
});
|
|
31
29
|
await el.updateComplete;
|
|
32
|
-
const histogramLoader =
|
|
30
|
+
const histogramLoader = el.shadowRoot?.querySelector('.histogram-loading-indicator');
|
|
33
31
|
expect(histogramLoader).to.exist;
|
|
34
32
|
});
|
|
35
33
|
it('does not render a date picker loading placeholder when date picker disabled', async () => {
|
|
36
|
-
var _a;
|
|
37
34
|
const el = await fixture(html `<collection-facets></collection-facets>`);
|
|
38
35
|
el.histogramAggregationLoading = true;
|
|
39
36
|
el.showHistogramDatePicker = false;
|
|
@@ -43,11 +40,10 @@ describe('Collection Facets', () => {
|
|
|
43
40
|
last_bucket_key: 2,
|
|
44
41
|
});
|
|
45
42
|
await el.updateComplete;
|
|
46
|
-
const histogramLoader =
|
|
43
|
+
const histogramLoader = el.shadowRoot?.querySelector('.histogram-loading-indicator');
|
|
47
44
|
expect(histogramLoader).to.be.null;
|
|
48
45
|
});
|
|
49
46
|
it('renders the date picker when enabled with data present', async () => {
|
|
50
|
-
var _a;
|
|
51
47
|
const el = await fixture(html `<collection-facets></collection-facets>`);
|
|
52
48
|
el.histogramAggregationLoading = false;
|
|
53
49
|
el.showHistogramDatePicker = true;
|
|
@@ -57,11 +53,10 @@ describe('Collection Facets', () => {
|
|
|
57
53
|
last_bucket_key: 2,
|
|
58
54
|
});
|
|
59
55
|
await el.updateComplete;
|
|
60
|
-
const histogram =
|
|
56
|
+
const histogram = el.shadowRoot?.querySelector('histogram-date-range');
|
|
61
57
|
expect(histogram).to.exist;
|
|
62
58
|
});
|
|
63
59
|
it('does not render the date picker when disabled', async () => {
|
|
64
|
-
var _a;
|
|
65
60
|
const el = await fixture(html `<collection-facets></collection-facets>`);
|
|
66
61
|
el.histogramAggregationLoading = false;
|
|
67
62
|
el.showHistogramDatePicker = false;
|
|
@@ -71,11 +66,10 @@ describe('Collection Facets', () => {
|
|
|
71
66
|
last_bucket_key: 2,
|
|
72
67
|
});
|
|
73
68
|
await el.updateComplete;
|
|
74
|
-
const histogram =
|
|
69
|
+
const histogram = el.shadowRoot?.querySelector('histogram-date-range');
|
|
75
70
|
expect(histogram).to.be.null;
|
|
76
71
|
});
|
|
77
72
|
it('renders button to expand the date picker when allowed', async () => {
|
|
78
|
-
var _a;
|
|
79
73
|
const el = await fixture(html `<collection-facets></collection-facets>`);
|
|
80
74
|
el.histogramAggregationLoading = false;
|
|
81
75
|
el.showHistogramDatePicker = true;
|
|
@@ -86,11 +80,10 @@ describe('Collection Facets', () => {
|
|
|
86
80
|
last_bucket_key: 2,
|
|
87
81
|
});
|
|
88
82
|
await el.updateComplete;
|
|
89
|
-
const expandBtn =
|
|
83
|
+
const expandBtn = el.shadowRoot?.querySelector('.expand-date-picker-btn');
|
|
90
84
|
expect(expandBtn).to.exist;
|
|
91
85
|
});
|
|
92
86
|
it('does not render button to expand the date picker when disallowed', async () => {
|
|
93
|
-
var _a;
|
|
94
87
|
const el = await fixture(html `<collection-facets></collection-facets>`);
|
|
95
88
|
el.histogramAggregationLoading = false;
|
|
96
89
|
el.showHistogramDatePicker = true;
|
|
@@ -101,14 +94,13 @@ describe('Collection Facets', () => {
|
|
|
101
94
|
last_bucket_key: 2,
|
|
102
95
|
});
|
|
103
96
|
await el.updateComplete;
|
|
104
|
-
const expandBtn =
|
|
97
|
+
const expandBtn = el.shadowRoot?.querySelector('.expand-date-picker-btn');
|
|
105
98
|
expect(expandBtn).to.be.null;
|
|
106
99
|
});
|
|
107
100
|
it('opens modal when date picker expand button clicked', async () => {
|
|
108
|
-
var _a, _b;
|
|
109
101
|
const modalManager = await fixture(html `<modal-manager></modal-manager>`);
|
|
110
|
-
const el = await fixture(html `<collection-facets
|
|
111
|
-
.modalManager=${modalManager}
|
|
102
|
+
const el = await fixture(html `<collection-facets
|
|
103
|
+
.modalManager=${modalManager}
|
|
112
104
|
></collection-facets>`);
|
|
113
105
|
el.histogramAggregationLoading = false;
|
|
114
106
|
el.showHistogramDatePicker = true;
|
|
@@ -119,18 +111,17 @@ describe('Collection Facets', () => {
|
|
|
119
111
|
last_bucket_key: 2,
|
|
120
112
|
});
|
|
121
113
|
await el.updateComplete;
|
|
122
|
-
const expandBtn =
|
|
114
|
+
const expandBtn = el.shadowRoot?.querySelector('.expand-date-picker-btn');
|
|
123
115
|
expect(expandBtn).to.exist;
|
|
124
116
|
const showModalSpy = sinon.spy(el.modalManager, 'showModal');
|
|
125
117
|
// Click the expand button to open the modal
|
|
126
|
-
expandBtn
|
|
118
|
+
expandBtn?.click();
|
|
127
119
|
await el.updateComplete;
|
|
128
120
|
expect(showModalSpy.callCount).to.equal(1);
|
|
129
|
-
expect(
|
|
121
|
+
expect(el.modalManager?.classList.contains('expanded-date-picker')).to.be
|
|
130
122
|
.true;
|
|
131
123
|
});
|
|
132
124
|
it('renders aggregations as facets', async () => {
|
|
133
|
-
var _a, _b, _c, _d, _e, _f;
|
|
134
125
|
const el = await fixture(html `<collection-facets></collection-facets>`);
|
|
135
126
|
const aggs = {
|
|
136
127
|
subject: new Aggregation({
|
|
@@ -144,19 +135,20 @@ describe('Collection Facets', () => {
|
|
|
144
135
|
};
|
|
145
136
|
el.aggregations = aggs;
|
|
146
137
|
await el.updateComplete;
|
|
147
|
-
const facetGroups =
|
|
148
|
-
expect(facetGroups
|
|
149
|
-
const titleFacetGroup = facetGroups
|
|
150
|
-
const facetGroupHeader = titleFacetGroup
|
|
138
|
+
const facetGroups = el.shadowRoot?.querySelectorAll('.facet-group');
|
|
139
|
+
expect(facetGroups?.length).to.equal(1);
|
|
140
|
+
const titleFacetGroup = facetGroups?.[0];
|
|
141
|
+
const facetGroupHeader = titleFacetGroup?.querySelector('h3');
|
|
151
142
|
// Every facet group header has an invisible " filters" suffix for screen-readers
|
|
152
|
-
expect(
|
|
143
|
+
expect(facetGroupHeader?.querySelector('span.sr-only')?.textContent?.trim()).to.equal('filters');
|
|
153
144
|
// Ignoring the screen-reader suffix, we should be left with only the readable, capitalized title
|
|
154
|
-
expect(
|
|
155
|
-
const titleFacetRow =
|
|
145
|
+
expect(facetGroupHeader?.textContent?.trim().replace(/\s*filters$/, '')).to.equal('Subject');
|
|
146
|
+
const titleFacetRow = titleFacetGroup
|
|
147
|
+
?.querySelector('facets-template')
|
|
148
|
+
?.shadowRoot?.querySelector('facet-row');
|
|
156
149
|
await titleFacetRow.updateComplete;
|
|
157
150
|
});
|
|
158
151
|
it('renders multiple aggregation types', async () => {
|
|
159
|
-
var _a;
|
|
160
152
|
const el = await fixture(html `<collection-facets></collection-facets>`);
|
|
161
153
|
const aggs = {
|
|
162
154
|
subject: new Aggregation({
|
|
@@ -178,11 +170,10 @@ describe('Collection Facets', () => {
|
|
|
178
170
|
};
|
|
179
171
|
el.aggregations = aggs;
|
|
180
172
|
await el.updateComplete;
|
|
181
|
-
const facetGroups =
|
|
182
|
-
expect(facetGroups
|
|
173
|
+
const facetGroups = el.shadowRoot?.querySelectorAll('.facet-group');
|
|
174
|
+
expect(facetGroups?.length).to.equal(2);
|
|
183
175
|
});
|
|
184
176
|
it('does not render suppressed collection facets', async () => {
|
|
185
|
-
var _a, _b, _c, _d;
|
|
186
177
|
const el = await fixture(html `<collection-facets></collection-facets>`);
|
|
187
178
|
const aggs = {
|
|
188
179
|
collection: new Aggregation({
|
|
@@ -204,10 +195,12 @@ describe('Collection Facets', () => {
|
|
|
204
195
|
};
|
|
205
196
|
el.aggregations = aggs;
|
|
206
197
|
await el.updateComplete;
|
|
207
|
-
const collectionFacets =
|
|
208
|
-
|
|
198
|
+
const collectionFacets = el.shadowRoot
|
|
199
|
+
?.querySelector('facets-template')
|
|
200
|
+
?.shadowRoot?.querySelectorAll('facet-row');
|
|
201
|
+
expect(collectionFacets?.length).to.equal(1);
|
|
209
202
|
// The first (and only) collection link should be for 'foo'
|
|
210
|
-
expect(
|
|
203
|
+
expect(collectionFacets[0].bucket?.key).to.equal('foo');
|
|
211
204
|
});
|
|
212
205
|
// Lending tests disabled because lending facet disabled
|
|
213
206
|
// it('renders lending facets with human-readable names', async () => {
|
|
@@ -406,7 +399,6 @@ describe('Collection Facets', () => {
|
|
|
406
399
|
// expect(moreLink).not.to.exist;
|
|
407
400
|
// });
|
|
408
401
|
it('always renders the mediatype:collection facet when present', async () => {
|
|
409
|
-
var _a, _b, _c, _d;
|
|
410
402
|
const el = await fixture(html `<collection-facets></collection-facets>`);
|
|
411
403
|
const aggs = {
|
|
412
404
|
mediatype: new Aggregation({
|
|
@@ -448,13 +440,12 @@ describe('Collection Facets', () => {
|
|
|
448
440
|
};
|
|
449
441
|
el.aggregations = aggs;
|
|
450
442
|
await el.updateComplete;
|
|
451
|
-
const facetsTemplate =
|
|
452
|
-
const facetRows =
|
|
453
|
-
expect(facetRows
|
|
454
|
-
expect(
|
|
443
|
+
const facetsTemplate = el.shadowRoot?.querySelector('facets-template');
|
|
444
|
+
const facetRows = facetsTemplate?.shadowRoot?.querySelectorAll('facet-row');
|
|
445
|
+
expect(facetRows?.length).to.equal(6);
|
|
446
|
+
expect(facetRows?.[5]?.bucket?.key).to.equal('collection');
|
|
455
447
|
});
|
|
456
448
|
it('renders the mediatype:collection facet even when >=6 other mediatypes are selected', async () => {
|
|
457
|
-
var _a, _b, _c, _d;
|
|
458
449
|
const el = await fixture(html `<collection-facets></collection-facets>`);
|
|
459
450
|
const aggs = {
|
|
460
451
|
mediatype: new Aggregation({
|
|
@@ -507,15 +498,14 @@ describe('Collection Facets', () => {
|
|
|
507
498
|
el.aggregations = aggs;
|
|
508
499
|
el.selectedFacets = selectedFacets;
|
|
509
500
|
await el.updateComplete;
|
|
510
|
-
const facetsTemplate =
|
|
511
|
-
const facetRows =
|
|
512
|
-
expect(facetRows
|
|
513
|
-
expect(
|
|
501
|
+
const facetsTemplate = el.shadowRoot?.querySelector('facets-template');
|
|
502
|
+
const facetRows = facetsTemplate?.shadowRoot?.querySelectorAll('facet-row');
|
|
503
|
+
expect(facetRows?.length).to.equal(8);
|
|
504
|
+
expect(facetRows?.[7]?.bucket?.key).to.equal('collection');
|
|
514
505
|
});
|
|
515
506
|
it('uses specified facet display order', async () => {
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
.facetDisplayOrder=${['language', 'creator']}
|
|
507
|
+
const el = await fixture(html `<collection-facets
|
|
508
|
+
.facetDisplayOrder=${['language', 'creator']}
|
|
519
509
|
></collection-facets>`);
|
|
520
510
|
const aggs = {
|
|
521
511
|
mediatype: new Aggregation({
|
|
@@ -533,15 +523,14 @@ describe('Collection Facets', () => {
|
|
|
533
523
|
};
|
|
534
524
|
el.aggregations = aggs;
|
|
535
525
|
await el.updateComplete;
|
|
536
|
-
const facetHeaders =
|
|
526
|
+
const facetHeaders = el.shadowRoot?.querySelectorAll('.facet-group-header');
|
|
537
527
|
// The only two facet groups should be Language and Creator (in that order)
|
|
538
|
-
expect(facetHeaders
|
|
539
|
-
expect(facetHeaders
|
|
540
|
-
expect(facetHeaders
|
|
528
|
+
expect(facetHeaders?.length).to.equal(2);
|
|
529
|
+
expect(facetHeaders?.[0].textContent).to.contain('Language');
|
|
530
|
+
expect(facetHeaders?.[1].textContent).to.contain('Creator');
|
|
541
531
|
});
|
|
542
532
|
describe('More Facets', () => {
|
|
543
533
|
it('Does not render < allowedFacetCount', async () => {
|
|
544
|
-
var _a;
|
|
545
534
|
const el = await fixture(html `<collection-facets></collection-facets>`);
|
|
546
535
|
const aggs = {
|
|
547
536
|
subject: new Aggregation({
|
|
@@ -555,14 +544,13 @@ describe('Collection Facets', () => {
|
|
|
555
544
|
};
|
|
556
545
|
el.aggregations = aggs;
|
|
557
546
|
await el.updateComplete;
|
|
558
|
-
const moreLink =
|
|
547
|
+
const moreLink = el.shadowRoot?.querySelector('.more-link');
|
|
559
548
|
expect(moreLink).to.be.null;
|
|
560
549
|
});
|
|
561
550
|
it('Render More Facets', async () => {
|
|
562
|
-
var _a, _b;
|
|
563
551
|
const modalManager = await fixture(html `<modal-manager></modal-manager>`);
|
|
564
|
-
const el = await fixture(html `<collection-facets
|
|
565
|
-
.modalManager=${modalManager}
|
|
552
|
+
const el = await fixture(html `<collection-facets
|
|
553
|
+
.modalManager=${modalManager}
|
|
566
554
|
></collection-facets>`);
|
|
567
555
|
const aggs = {
|
|
568
556
|
subject: new Aggregation({
|
|
@@ -606,24 +594,23 @@ describe('Collection Facets', () => {
|
|
|
606
594
|
eventFacet = e.detail;
|
|
607
595
|
eventCaught = true;
|
|
608
596
|
});
|
|
609
|
-
const moreLink =
|
|
597
|
+
const moreLink = el.shadowRoot?.querySelector('.more-link');
|
|
610
598
|
expect(moreLink).to.exist; // has link
|
|
611
599
|
const showModalSpy = sinon.spy(el.modalManager, 'showModal');
|
|
612
600
|
// let's pop up modal
|
|
613
|
-
moreLink
|
|
601
|
+
moreLink?.click();
|
|
614
602
|
await el.updateComplete;
|
|
615
603
|
expect(showModalSpy.callCount).to.equal(1);
|
|
616
|
-
expect(
|
|
604
|
+
expect(el.modalManager?.classList.contains('more-search-facets')).to.be
|
|
617
605
|
.true;
|
|
618
606
|
expect(eventCaught).to.be.true;
|
|
619
607
|
expect(eventFacet).to.equal('subject');
|
|
620
608
|
});
|
|
621
609
|
});
|
|
622
610
|
it('fire analytics on more link', async () => {
|
|
623
|
-
var _a;
|
|
624
611
|
const mockAnalyticsHandler = new MockAnalyticsHandler();
|
|
625
|
-
const el = await fixture(html `<collection-facets
|
|
626
|
-
.analyticsHandler=${mockAnalyticsHandler}
|
|
612
|
+
const el = await fixture(html `<collection-facets
|
|
613
|
+
.analyticsHandler=${mockAnalyticsHandler}
|
|
627
614
|
></collection-facets>`);
|
|
628
615
|
const aggs = {
|
|
629
616
|
subject: new Aggregation({
|
|
@@ -661,47 +648,44 @@ describe('Collection Facets', () => {
|
|
|
661
648
|
};
|
|
662
649
|
el.aggregations = aggs;
|
|
663
650
|
await el.updateComplete;
|
|
664
|
-
const moreLink =
|
|
651
|
+
const moreLink = el.shadowRoot?.querySelector('.more-link');
|
|
665
652
|
expect(moreLink).to.exist; // has link
|
|
666
|
-
moreLink
|
|
653
|
+
moreLink?.click();
|
|
667
654
|
await el.updateComplete;
|
|
668
655
|
expect(mockAnalyticsHandler.callCategory).to.equal('collection-browser');
|
|
669
656
|
expect(mockAnalyticsHandler.callAction).to.equal('showMoreFacetsModal');
|
|
670
657
|
expect(mockAnalyticsHandler.callLabel).to.equal('subject');
|
|
671
658
|
});
|
|
672
659
|
it('includes Part Of section for collections', async () => {
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
.
|
|
676
|
-
.
|
|
677
|
-
.parentCollections=${['bar', 'baz']}
|
|
660
|
+
const el = await fixture(html `<collection-facets
|
|
661
|
+
.baseNavigationUrl=${''}
|
|
662
|
+
.withinCollection=${'foo'}
|
|
663
|
+
.parentCollections=${['bar', 'baz']}
|
|
678
664
|
.collectionTitles=${new Map([
|
|
679
665
|
['foo', 'foo-name'],
|
|
680
666
|
['bar', 'bar-name'],
|
|
681
667
|
['baz', 'baz-name'],
|
|
682
|
-
])}
|
|
668
|
+
])}
|
|
683
669
|
></collection-facets>`);
|
|
684
|
-
const partOfSection =
|
|
670
|
+
const partOfSection = el.shadowRoot?.querySelector('.partof-collections');
|
|
685
671
|
expect(partOfSection).to.exist;
|
|
686
|
-
const partOfLinks = partOfSection
|
|
687
|
-
expect(partOfLinks
|
|
688
|
-
expect(
|
|
689
|
-
expect(
|
|
690
|
-
expect(
|
|
691
|
-
expect(
|
|
672
|
+
const partOfLinks = partOfSection?.querySelectorAll('a[href]');
|
|
673
|
+
expect(partOfLinks?.length).to.equal(2);
|
|
674
|
+
expect(partOfLinks?.[0]?.textContent?.trim()).to.equal('bar-name');
|
|
675
|
+
expect(partOfLinks?.[0]?.getAttribute('href')).to.equal('/details/bar');
|
|
676
|
+
expect(partOfLinks?.[1]?.textContent?.trim()).to.equal('baz-name');
|
|
677
|
+
expect(partOfLinks?.[1]?.getAttribute('href')).to.equal('/details/baz');
|
|
692
678
|
});
|
|
693
679
|
it('does not include Part Of section without parent collections', async () => {
|
|
694
|
-
var _a;
|
|
695
680
|
// No parentCollections prop
|
|
696
681
|
const el = await fixture(html `<collection-facets .withinCollection=${'foo'}></collection-facets>`);
|
|
697
|
-
const partOfSection =
|
|
682
|
+
const partOfSection = el.shadowRoot?.querySelector('.partof-collections');
|
|
698
683
|
expect(partOfSection).not.to.exist;
|
|
699
684
|
});
|
|
700
685
|
it('fires analytics on expanding date picker', async () => {
|
|
701
|
-
var _a;
|
|
702
686
|
const mockAnalyticsHandler = new MockAnalyticsHandler();
|
|
703
|
-
const el = await fixture(html `<collection-facets
|
|
704
|
-
.analyticsHandler=${mockAnalyticsHandler}
|
|
687
|
+
const el = await fixture(html `<collection-facets
|
|
688
|
+
.analyticsHandler=${mockAnalyticsHandler}
|
|
705
689
|
></collection-facets>`);
|
|
706
690
|
el.histogramAggregationLoading = false;
|
|
707
691
|
el.showHistogramDatePicker = true;
|
|
@@ -712,30 +696,29 @@ describe('Collection Facets', () => {
|
|
|
712
696
|
last_bucket_key: 2,
|
|
713
697
|
});
|
|
714
698
|
await el.updateComplete;
|
|
715
|
-
const expandBtn =
|
|
699
|
+
const expandBtn = el.shadowRoot?.querySelector('.expand-date-picker-btn');
|
|
716
700
|
expect(expandBtn).to.exist;
|
|
717
701
|
// Click the expand button to open the modal
|
|
718
|
-
expandBtn
|
|
702
|
+
expandBtn?.click();
|
|
719
703
|
await el.updateComplete;
|
|
720
704
|
expect(mockAnalyticsHandler.callCategory).to.equal('collection-browser');
|
|
721
705
|
expect(mockAnalyticsHandler.callAction).to.equal('histogramExpanded');
|
|
722
706
|
expect(mockAnalyticsHandler.callLabel).to.equal(window.location.href);
|
|
723
707
|
});
|
|
724
708
|
it('fires analytics on clicking Part Of collection link', async () => {
|
|
725
|
-
var _a;
|
|
726
709
|
const mockAnalyticsHandler = new MockAnalyticsHandler();
|
|
727
|
-
const el = await fixture(html `<collection-facets
|
|
728
|
-
.baseNavigationUrl=${''}
|
|
729
|
-
.withinCollection=${'foo'}
|
|
730
|
-
.parentCollections=${['bar']}
|
|
731
|
-
.analyticsHandler=${mockAnalyticsHandler}
|
|
710
|
+
const el = await fixture(html `<collection-facets
|
|
711
|
+
.baseNavigationUrl=${''}
|
|
712
|
+
.withinCollection=${'foo'}
|
|
713
|
+
.parentCollections=${['bar']}
|
|
714
|
+
.analyticsHandler=${mockAnalyticsHandler}
|
|
732
715
|
></collection-facets>`);
|
|
733
|
-
const partOfLinks =
|
|
734
|
-
expect(partOfLinks
|
|
716
|
+
const partOfLinks = el.shadowRoot?.querySelectorAll('.partof-collections a[href]');
|
|
717
|
+
expect(partOfLinks?.length).to.equal(1);
|
|
735
718
|
// Click the expand button to open the modal
|
|
736
|
-
const link = partOfLinks
|
|
737
|
-
link
|
|
738
|
-
link
|
|
719
|
+
const link = partOfLinks?.[0];
|
|
720
|
+
link?.addEventListener('click', e => e.preventDefault());
|
|
721
|
+
link?.click();
|
|
739
722
|
await el.updateComplete;
|
|
740
723
|
expect(mockAnalyticsHandler.callCategory).to.equal('collection-browser');
|
|
741
724
|
expect(mockAnalyticsHandler.callAction).to.equal('partOfCollectionClicked');
|