@internetarchive/collection-browser 3.5.2-alpha-webdev8164.0 → 3.5.2-webdev-8162.1
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/.editorconfig +29 -29
- package/.github/workflows/ci.yml +27 -27
- package/.github/workflows/gh-pages-main.yml +39 -39
- package/.github/workflows/npm-publish.yml +39 -39
- package/.github/workflows/pr-preview.yml +38 -38
- package/.prettierignore +1 -1
- package/LICENSE +661 -661
- package/README.md +83 -83
- package/dist/src/app-root.js +606 -606
- package/dist/src/app-root.js.map +1 -1
- package/dist/src/collection-facets/facets-template.js +23 -28
- package/dist/src/collection-facets/facets-template.js.map +1 -1
- package/dist/src/collection-facets/more-facets-content.d.ts +8 -34
- package/dist/src/collection-facets/more-facets-content.js +159 -358
- package/dist/src/collection-facets/more-facets-content.js.map +1 -1
- package/dist/src/tiles/grid/collection-tile.js +77 -77
- package/dist/src/tiles/grid/collection-tile.js.map +1 -1
- package/dist/src/tiles/grid/item-tile.js +137 -137
- package/dist/src/tiles/grid/item-tile.js.map +1 -1
- package/dist/src/tiles/models.js.map +1 -1
- package/dist/src/tiles/tile-dispatcher.js +215 -215
- package/dist/src/tiles/tile-dispatcher.js.map +1 -1
- package/dist/test/collection-browser.test.js +1 -1
- package/dist/test/collection-browser.test.js.map +1 -1
- package/dist/test/collection-facets/more-facets-content.test.js +31 -137
- package/dist/test/collection-facets/more-facets-content.test.js.map +1 -1
- package/eslint.config.mjs +53 -53
- package/index.html +24 -24
- package/local.archive.org.cert +86 -86
- package/local.archive.org.key +27 -27
- package/package.json +121 -119
- package/renovate.json +6 -6
- package/src/app-root.ts +1140 -1140
- package/src/collection-facets/facets-template.ts +83 -88
- package/src/collection-facets/more-facets-content.ts +642 -856
- package/src/tiles/grid/collection-tile.ts +163 -163
- package/src/tiles/grid/item-tile.ts +340 -340
- package/src/tiles/models.ts +1 -1
- package/src/tiles/tile-dispatcher.ts +517 -517
- package/test/collection-browser.test.ts +1 -1
- package/test/collection-facets/more-facets-content.test.ts +231 -378
- package/tsconfig.json +25 -25
- package/web-dev-server.config.mjs +30 -30
- package/web-test-runner.config.mjs +52 -41
- package/.husky/pre-commit +0 -4
|
@@ -970,7 +970,7 @@ describe('Collection Browser', () => {
|
|
|
970
970
|
</collection-browser>`,
|
|
971
971
|
);
|
|
972
972
|
|
|
973
|
-
expect(el.selectedSort).to.equal(SortField.
|
|
973
|
+
expect(el.selectedSort).to.equal(SortField.relevance);
|
|
974
974
|
|
|
975
975
|
el.baseQuery = 'foo';
|
|
976
976
|
await el.updateComplete;
|
|
@@ -1,378 +1,231 @@
|
|
|
1
|
-
import { aTimeout, expect, fixture } from '@open-wc/testing';
|
|
2
|
-
import { html } from 'lit';
|
|
3
|
-
import type { MoreFacetsContent } from '../../src/collection-facets/more-facets-content';
|
|
4
|
-
import '../../src/collection-facets/more-facets-content';
|
|
5
|
-
import { MockSearchService } from '../mocks/mock-search-service';
|
|
6
|
-
import { MockAnalyticsHandler } from '../mocks/mock-analytics-handler';
|
|
7
|
-
import type { FacetsTemplate } from '../../src/collection-facets/facets-template';
|
|
8
|
-
import type { SelectedFacets } from '../../src/models';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
{ displayText: '
|
|
16
|
-
{ displayText: '
|
|
17
|
-
{ displayText: '
|
|
18
|
-
{ displayText: '
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
},
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
el.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
el.
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
el.
|
|
68
|
-
el.
|
|
69
|
-
await
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
);
|
|
94
|
-
|
|
95
|
-
el
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
const
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
const
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
const
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
const
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
// select submit button
|
|
233
|
-
const submitButton = el.shadowRoot?.querySelector(
|
|
234
|
-
'.footer > .btn-submit',
|
|
235
|
-
) as HTMLButtonElement;
|
|
236
|
-
expect(submitButton).to.exist;
|
|
237
|
-
submitButton?.click();
|
|
238
|
-
|
|
239
|
-
expect(mockAnalyticsHandler.callCategory).to.equal('collection-browser');
|
|
240
|
-
expect(mockAnalyticsHandler.callAction).to.equal('applyMoreFacetsModal');
|
|
241
|
-
expect(mockAnalyticsHandler.callLabel).to.equal('collection');
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
it('should have horizontal scrolling enabled', async () => {
|
|
245
|
-
const searchService = new MockSearchService();
|
|
246
|
-
|
|
247
|
-
const el = await fixture<MoreFacetsContent>(
|
|
248
|
-
html`<more-facets-content
|
|
249
|
-
.searchService=${searchService}
|
|
250
|
-
></more-facets-content>`,
|
|
251
|
-
);
|
|
252
|
-
|
|
253
|
-
el.facetKey = 'year';
|
|
254
|
-
el.query = 'more-facets';
|
|
255
|
-
await el.updateComplete;
|
|
256
|
-
await aTimeout(50);
|
|
257
|
-
|
|
258
|
-
const facetsContent = el.shadowRoot?.querySelector(
|
|
259
|
-
'.facets-content',
|
|
260
|
-
) as HTMLElement;
|
|
261
|
-
const styles = window.getComputedStyle(facetsContent);
|
|
262
|
-
|
|
263
|
-
expect(styles.overflowX).to.equal('auto');
|
|
264
|
-
expect(styles.overflowY).to.equal('hidden');
|
|
265
|
-
});
|
|
266
|
-
|
|
267
|
-
it('should have horizontal container wrapper', async () => {
|
|
268
|
-
const searchService = new MockSearchService();
|
|
269
|
-
|
|
270
|
-
const el = await fixture<MoreFacetsContent>(
|
|
271
|
-
html`<more-facets-content
|
|
272
|
-
.searchService=${searchService}
|
|
273
|
-
></more-facets-content>`,
|
|
274
|
-
);
|
|
275
|
-
|
|
276
|
-
el.facetKey = 'year';
|
|
277
|
-
el.query = 'more-facets';
|
|
278
|
-
await el.updateComplete;
|
|
279
|
-
await aTimeout(50);
|
|
280
|
-
|
|
281
|
-
const container = el.shadowRoot?.querySelector(
|
|
282
|
-
'.facets-horizontal-container',
|
|
283
|
-
);
|
|
284
|
-
expect(container).to.exist;
|
|
285
|
-
|
|
286
|
-
const facetsTemplate = container?.querySelector('facets-template');
|
|
287
|
-
expect(facetsTemplate).to.exist;
|
|
288
|
-
});
|
|
289
|
-
|
|
290
|
-
it('should render pagination when facet count >= 1000', async () => {
|
|
291
|
-
// Manually create aggregations with 1000+ facets
|
|
292
|
-
const buckets: Bucket[] = [];
|
|
293
|
-
for (let i = 0; i < 1000; i++) {
|
|
294
|
-
buckets.push({ key: `value-${i}`, doc_count: i + 1 });
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
const el = await fixture<MoreFacetsContent>(
|
|
298
|
-
html`<more-facets-content
|
|
299
|
-
.facetKey=${'subject'}
|
|
300
|
-
.selectedFacets=${{
|
|
301
|
-
mediatype: {},
|
|
302
|
-
lending: {},
|
|
303
|
-
year: {},
|
|
304
|
-
subject: {},
|
|
305
|
-
collection: {},
|
|
306
|
-
creator: {},
|
|
307
|
-
language: {},
|
|
308
|
-
}}
|
|
309
|
-
></more-facets-content>`,
|
|
310
|
-
);
|
|
311
|
-
|
|
312
|
-
// @ts-expect-error - accessing private property for testing
|
|
313
|
-
el.aggregations = {
|
|
314
|
-
subject: new Aggregation({ buckets }),
|
|
315
|
-
};
|
|
316
|
-
el.facetsLoading = false;
|
|
317
|
-
await el.updateComplete;
|
|
318
|
-
|
|
319
|
-
// Verify pagination component IS present
|
|
320
|
-
expect(el.shadowRoot?.querySelector('more-facets-pagination')).to.exist;
|
|
321
|
-
|
|
322
|
-
// Verify pagination mode CSS class is applied
|
|
323
|
-
expect(el.shadowRoot?.querySelector('.facets-content.pagination-mode')).to
|
|
324
|
-
.exist;
|
|
325
|
-
|
|
326
|
-
// Verify horizontal container wrapper does NOT exist in pagination mode
|
|
327
|
-
expect(el.shadowRoot?.querySelector('.facets-horizontal-container')).to.not
|
|
328
|
-
.exist;
|
|
329
|
-
});
|
|
330
|
-
|
|
331
|
-
it('pagination page change should send analytics event', async () => {
|
|
332
|
-
const mockAnalyticsHandler = new MockAnalyticsHandler();
|
|
333
|
-
|
|
334
|
-
// Manually create aggregations with 1000+ facets
|
|
335
|
-
const buckets: Bucket[] = [];
|
|
336
|
-
for (let i = 0; i < 1000; i++) {
|
|
337
|
-
buckets.push({ key: `value-${i}`, doc_count: i + 1 });
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
const el = await fixture<MoreFacetsContent>(
|
|
341
|
-
html`<more-facets-content
|
|
342
|
-
.facetKey=${'subject'}
|
|
343
|
-
.selectedFacets=${{
|
|
344
|
-
mediatype: {},
|
|
345
|
-
lending: {},
|
|
346
|
-
year: {},
|
|
347
|
-
subject: {},
|
|
348
|
-
collection: {},
|
|
349
|
-
creator: {},
|
|
350
|
-
language: {},
|
|
351
|
-
}}
|
|
352
|
-
.analyticsHandler=${mockAnalyticsHandler}
|
|
353
|
-
></more-facets-content>`,
|
|
354
|
-
);
|
|
355
|
-
|
|
356
|
-
// @ts-expect-error - accessing private property for testing
|
|
357
|
-
el.aggregations = {
|
|
358
|
-
subject: new Aggregation({ buckets }),
|
|
359
|
-
};
|
|
360
|
-
el.facetsLoading = false;
|
|
361
|
-
await el.updateComplete;
|
|
362
|
-
|
|
363
|
-
// Get the pagination component
|
|
364
|
-
const pagination = el.shadowRoot?.querySelector(
|
|
365
|
-
'more-facets-pagination',
|
|
366
|
-
) as any;
|
|
367
|
-
expect(pagination).to.exist;
|
|
368
|
-
|
|
369
|
-
// Simulate clicking page 2
|
|
370
|
-
pagination.currentPage = 2;
|
|
371
|
-
await pagination.updateComplete;
|
|
372
|
-
|
|
373
|
-
// Verify analytics event was sent
|
|
374
|
-
expect(mockAnalyticsHandler.callCategory).to.equal('collection-browser');
|
|
375
|
-
expect(mockAnalyticsHandler.callAction).to.equal('moreFacetsPageChange');
|
|
376
|
-
expect(mockAnalyticsHandler.callLabel).to.equal('2');
|
|
377
|
-
});
|
|
378
|
-
});
|
|
1
|
+
import { aTimeout, expect, fixture } from '@open-wc/testing';
|
|
2
|
+
import { html } from 'lit';
|
|
3
|
+
import type { MoreFacetsContent } from '../../src/collection-facets/more-facets-content';
|
|
4
|
+
import '../../src/collection-facets/more-facets-content';
|
|
5
|
+
import { MockSearchService } from '../mocks/mock-search-service';
|
|
6
|
+
import { MockAnalyticsHandler } from '../mocks/mock-analytics-handler';
|
|
7
|
+
import type { FacetsTemplate } from '../../src/collection-facets/facets-template';
|
|
8
|
+
import type { SelectedFacets } from '../../src/models';
|
|
9
|
+
|
|
10
|
+
const selectedFacetsGroup = {
|
|
11
|
+
title: 'Media Type',
|
|
12
|
+
key: 'mediatype',
|
|
13
|
+
buckets: [
|
|
14
|
+
{ displayText: 'audio', key: 'audio', count: 1001, state: 'none' },
|
|
15
|
+
{ displayText: 'movies', key: 'movies', count: 901, state: 'none' },
|
|
16
|
+
{ displayText: 'texts', key: 'texts', count: 2101, state: 'none' },
|
|
17
|
+
{ displayText: 'data', key: 'data', count: 230, state: 'none' },
|
|
18
|
+
{ displayText: 'web', key: 'web', count: 453, state: 'none' },
|
|
19
|
+
],
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const yearSelectedFacets: SelectedFacets = {
|
|
23
|
+
mediatype: {},
|
|
24
|
+
lending: {},
|
|
25
|
+
year: {
|
|
26
|
+
'2000': { key: '2000', count: 5, state: 'selected' },
|
|
27
|
+
},
|
|
28
|
+
subject: {},
|
|
29
|
+
collection: {},
|
|
30
|
+
creator: {},
|
|
31
|
+
language: {},
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
describe('More facets content', () => {
|
|
35
|
+
it('should render more facets template', async () => {
|
|
36
|
+
const el = await fixture<MoreFacetsContent>(
|
|
37
|
+
html`<more-facets-content></more-facets-content>`,
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
el.facetsLoading = false;
|
|
41
|
+
await el.updateComplete;
|
|
42
|
+
|
|
43
|
+
expect(el.shadowRoot?.querySelector('.facets-content')).to.exist;
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('should render more facets loader template', async () => {
|
|
47
|
+
const el = await fixture<MoreFacetsContent>(
|
|
48
|
+
html`<more-facets-content></more-facets-content>`,
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
el.facetsLoading = true;
|
|
52
|
+
await el.updateComplete;
|
|
53
|
+
|
|
54
|
+
expect(el.shadowRoot?.querySelector('.facets-loader')).to.exist;
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('should render pagination for more facets', async () => {
|
|
58
|
+
const searchService = new MockSearchService();
|
|
59
|
+
|
|
60
|
+
const el = await fixture<MoreFacetsContent>(
|
|
61
|
+
html`<more-facets-content
|
|
62
|
+
.searchService=${searchService}
|
|
63
|
+
></more-facets-content>`,
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
el.facetKey = 'year';
|
|
67
|
+
el.query = 'more-facets'; // Produces a response with 40+ aggregations for multiple pages
|
|
68
|
+
await el.updateComplete;
|
|
69
|
+
await aTimeout(50); // Give it a moment to perform the (mock) search query after the initial update
|
|
70
|
+
|
|
71
|
+
expect(el.shadowRoot?.querySelectorAll('more-facets-pagination')).to.exist;
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it('query for more facets content using search service', async () => {
|
|
75
|
+
const searchService = new MockSearchService();
|
|
76
|
+
|
|
77
|
+
const el = await fixture<MoreFacetsContent>(
|
|
78
|
+
html`<more-facets-content
|
|
79
|
+
.searchService=${searchService}
|
|
80
|
+
></more-facets-content>`,
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
el.facetKey = 'collection';
|
|
84
|
+
el.query = 'collection-aggregations';
|
|
85
|
+
await el.updateComplete;
|
|
86
|
+
|
|
87
|
+
expect(searchService.searchParams?.query).to.equal(
|
|
88
|
+
'collection-aggregations',
|
|
89
|
+
);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it('queries for more facets using search service within a collection (no query)', async () => {
|
|
93
|
+
const searchService = new MockSearchService();
|
|
94
|
+
|
|
95
|
+
const el = await fixture<MoreFacetsContent>(
|
|
96
|
+
html`<more-facets-content
|
|
97
|
+
.searchService=${searchService}
|
|
98
|
+
.pageSpecifierParams=${{
|
|
99
|
+
pageType: 'collection_details',
|
|
100
|
+
pageTarget: 'foobar',
|
|
101
|
+
}}
|
|
102
|
+
></more-facets-content>`,
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
el.facetKey = 'subject';
|
|
106
|
+
await el.updateComplete;
|
|
107
|
+
|
|
108
|
+
expect(searchService.searchParams?.query).to.be.empty;
|
|
109
|
+
expect(searchService.searchParams?.pageTarget).to.equal('foobar');
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it('queries for more facets using search service within a collection (with query)', async () => {
|
|
113
|
+
const searchService = new MockSearchService();
|
|
114
|
+
|
|
115
|
+
const el = await fixture<MoreFacetsContent>(
|
|
116
|
+
html`<more-facets-content
|
|
117
|
+
.searchService=${searchService}
|
|
118
|
+
.pageSpecifierParams=${{
|
|
119
|
+
pageType: 'collection_details',
|
|
120
|
+
pageTarget: 'foobar',
|
|
121
|
+
}}
|
|
122
|
+
></more-facets-content>`,
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
el.facetKey = 'subject';
|
|
126
|
+
el.query = 'title:hello';
|
|
127
|
+
await el.updateComplete;
|
|
128
|
+
|
|
129
|
+
expect(searchService.searchParams?.query).to.equal('title:hello');
|
|
130
|
+
expect(searchService.searchParams?.pageTarget).to.equal('foobar');
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it('filter raw selectedFacets object', async () => {
|
|
134
|
+
const searchService = new MockSearchService();
|
|
135
|
+
|
|
136
|
+
const el = await fixture<MoreFacetsContent>(
|
|
137
|
+
html`<more-facets-content
|
|
138
|
+
.searchService=${searchService}
|
|
139
|
+
.selectedFacets=${selectedFacetsGroup}
|
|
140
|
+
></more-facets-content>`,
|
|
141
|
+
);
|
|
142
|
+
|
|
143
|
+
el.facetKey = 'collection';
|
|
144
|
+
el.query = 'title:hello';
|
|
145
|
+
await el.updateComplete;
|
|
146
|
+
|
|
147
|
+
expect(searchService.searchParams?.query).to.equal('title:hello');
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
it('combines selectedFacets and aggregationFacets and renders on modal', async () => {
|
|
151
|
+
const searchService = new MockSearchService();
|
|
152
|
+
|
|
153
|
+
const el = await fixture<MoreFacetsContent>(
|
|
154
|
+
html`<more-facets-content
|
|
155
|
+
.facetKey=${'year'}
|
|
156
|
+
.query=${'more-facets'}
|
|
157
|
+
.searchService=${searchService}
|
|
158
|
+
.selectedFacets=${yearSelectedFacets}
|
|
159
|
+
></more-facets-content>`,
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
const facetsTemplate = el.shadowRoot?.querySelector(
|
|
163
|
+
'facets-template',
|
|
164
|
+
) as FacetsTemplate;
|
|
165
|
+
expect(facetsTemplate).to.exist;
|
|
166
|
+
|
|
167
|
+
const { facetGroup } = facetsTemplate;
|
|
168
|
+
expect(facetGroup?.key).to.equal('year');
|
|
169
|
+
expect(facetGroup?.title).to.equal('Year');
|
|
170
|
+
|
|
171
|
+
// First bucket is the one that was included in the selected facets
|
|
172
|
+
const firstBucket = facetGroup?.buckets[0];
|
|
173
|
+
expect(firstBucket?.key).to.equal('2000');
|
|
174
|
+
expect(firstBucket?.count).to.equal(5);
|
|
175
|
+
|
|
176
|
+
// Second bucket is the most recent year, since year facets default to descending order of year
|
|
177
|
+
const secondBucket = facetGroup?.buckets[1];
|
|
178
|
+
expect(secondBucket?.key).to.equal('2024');
|
|
179
|
+
expect(secondBucket?.count).to.equal(5);
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
it('cancel button clicked event', async () => {
|
|
183
|
+
const searchService = new MockSearchService();
|
|
184
|
+
const mockAnalyticsHandler = new MockAnalyticsHandler();
|
|
185
|
+
|
|
186
|
+
const el = await fixture<MoreFacetsContent>(
|
|
187
|
+
html`<more-facets-content
|
|
188
|
+
.facetKey=${'collection'}
|
|
189
|
+
.query=${'collection-aggregations'}
|
|
190
|
+
.searchService=${searchService}
|
|
191
|
+
.analyticsHandler=${mockAnalyticsHandler}
|
|
192
|
+
></more-facets-content>`,
|
|
193
|
+
);
|
|
194
|
+
|
|
195
|
+
// select cancel button
|
|
196
|
+
const cancelButton = el.shadowRoot?.querySelector(
|
|
197
|
+
'.footer > .btn-cancel',
|
|
198
|
+
) as HTMLButtonElement;
|
|
199
|
+
expect(cancelButton).to.exist;
|
|
200
|
+
cancelButton?.click();
|
|
201
|
+
|
|
202
|
+
expect(mockAnalyticsHandler.callCategory).to.equal('collection-browser');
|
|
203
|
+
expect(mockAnalyticsHandler.callAction).to.equal('closeMoreFacetsModal');
|
|
204
|
+
expect(mockAnalyticsHandler.callLabel).to.equal('collection');
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
it('facet apply button clicked event', async () => {
|
|
208
|
+
const searchService = new MockSearchService();
|
|
209
|
+
const mockAnalyticsHandler = new MockAnalyticsHandler();
|
|
210
|
+
|
|
211
|
+
const el = await fixture<MoreFacetsContent>(
|
|
212
|
+
html`<more-facets-content
|
|
213
|
+
.facetKey=${'collection'}
|
|
214
|
+
.query=${'collection-aggregations'}
|
|
215
|
+
.searchService=${searchService}
|
|
216
|
+
.analyticsHandler=${mockAnalyticsHandler}
|
|
217
|
+
></more-facets-content>`,
|
|
218
|
+
);
|
|
219
|
+
|
|
220
|
+
// select submit button
|
|
221
|
+
const submitButton = el.shadowRoot?.querySelector(
|
|
222
|
+
'.footer > .btn-submit',
|
|
223
|
+
) as HTMLButtonElement;
|
|
224
|
+
expect(submitButton).to.exist;
|
|
225
|
+
submitButton?.click();
|
|
226
|
+
|
|
227
|
+
expect(mockAnalyticsHandler.callCategory).to.equal('collection-browser');
|
|
228
|
+
expect(mockAnalyticsHandler.callAction).to.equal('applyMoreFacetsModal');
|
|
229
|
+
expect(mockAnalyticsHandler.callLabel).to.equal('collection');
|
|
230
|
+
});
|
|
231
|
+
});
|