@internetarchive/collection-browser 3.5.2-alpha-webdev8164.0 → 3.5.2-alpha-webdev8093.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/collection-facets/facets-template.js +0 -5
- 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 +65 -264
- package/dist/src/collection-facets/more-facets-content.js.map +1 -1
- package/dist/src/tiles/hover/hover-pane-controller.d.ts +8 -0
- package/dist/src/tiles/hover/hover-pane-controller.js +13 -1
- package/dist/src/tiles/hover/hover-pane-controller.js.map +1 -1
- package/dist/test/collection-facets/more-facets-content.test.js +3 -109
- package/dist/test/collection-facets/more-facets-content.test.js.map +1 -1
- package/package.json +1 -1
- package/src/collection-facets/facets-template.ts +0 -5
- package/src/collection-facets/more-facets-content.ts +70 -284
- package/src/tiles/hover/hover-pane-controller.ts +15 -1
- package/test/collection-facets/more-facets-content.test.ts +3 -150
|
@@ -6,7 +6,6 @@ import { MockSearchService } from '../mocks/mock-search-service';
|
|
|
6
6
|
import { MockAnalyticsHandler } from '../mocks/mock-analytics-handler';
|
|
7
7
|
import type { FacetsTemplate } from '../../src/collection-facets/facets-template';
|
|
8
8
|
import type { SelectedFacets } from '../../src/models';
|
|
9
|
-
import { Aggregation, type Bucket } from '@internetarchive/search-service';
|
|
10
9
|
|
|
11
10
|
const selectedFacetsGroup = {
|
|
12
11
|
title: 'Media Type',
|
|
@@ -55,7 +54,7 @@ describe('More facets content', () => {
|
|
|
55
54
|
expect(el.shadowRoot?.querySelector('.facets-loader')).to.exist;
|
|
56
55
|
});
|
|
57
56
|
|
|
58
|
-
it('should
|
|
57
|
+
it('should render pagination for more facets', async () => {
|
|
59
58
|
const searchService = new MockSearchService();
|
|
60
59
|
|
|
61
60
|
const el = await fixture<MoreFacetsContent>(
|
|
@@ -65,22 +64,11 @@ describe('More facets content', () => {
|
|
|
65
64
|
);
|
|
66
65
|
|
|
67
66
|
el.facetKey = 'year';
|
|
68
|
-
el.query = 'more-facets'; // Produces a response with
|
|
67
|
+
el.query = 'more-facets'; // Produces a response with 40+ aggregations for multiple pages
|
|
69
68
|
await el.updateComplete;
|
|
70
69
|
await aTimeout(50); // Give it a moment to perform the (mock) search query after the initial update
|
|
71
70
|
|
|
72
|
-
|
|
73
|
-
expect(el.shadowRoot?.querySelector('more-facets-pagination')).to.not.exist;
|
|
74
|
-
|
|
75
|
-
// Verify horizontal scroll mode CSS class is applied
|
|
76
|
-
expect(
|
|
77
|
-
el.shadowRoot?.querySelector('.facets-content.horizontal-scroll-mode'),
|
|
78
|
-
).to.exist;
|
|
79
|
-
|
|
80
|
-
// Verify footer still exists with buttons
|
|
81
|
-
expect(el.shadowRoot?.querySelector('.footer')).to.exist;
|
|
82
|
-
expect(el.shadowRoot?.querySelector('.btn-cancel')).to.exist;
|
|
83
|
-
expect(el.shadowRoot?.querySelector('.btn-submit')).to.exist;
|
|
71
|
+
expect(el.shadowRoot?.querySelectorAll('more-facets-pagination')).to.exist;
|
|
84
72
|
});
|
|
85
73
|
|
|
86
74
|
it('query for more facets content using search service', async () => {
|
|
@@ -240,139 +228,4 @@ describe('More facets content', () => {
|
|
|
240
228
|
expect(mockAnalyticsHandler.callAction).to.equal('applyMoreFacetsModal');
|
|
241
229
|
expect(mockAnalyticsHandler.callLabel).to.equal('collection');
|
|
242
230
|
});
|
|
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
231
|
});
|