@internetarchive/collection-browser 1.14.9-alpha1 → 1.14.9-alpha10
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.d.ts +1 -0
- package/dist/src/app-root.js +154 -82
- package/dist/src/app-root.js.map +1 -1
- package/dist/src/collection-browser.d.ts +2 -2
- package/dist/src/collection-browser.js +23 -18
- package/dist/src/collection-browser.js.map +1 -1
- package/dist/src/collection-facets/facet-row.d.ts +30 -0
- package/dist/src/collection-facets/facet-row.js +245 -0
- package/dist/src/collection-facets/facet-row.js.map +1 -0
- package/dist/src/collection-facets/facets-template.d.ts +1 -4
- package/dist/src/collection-facets/facets-template.js +40 -182
- package/dist/src/collection-facets/facets-template.js.map +1 -1
- package/dist/src/models.d.ts +18 -2
- package/dist/src/models.js.map +1 -1
- package/dist/test/collection-browser.test.js +36 -4
- package/dist/test/collection-browser.test.js.map +1 -1
- package/dist/test/collection-facets/facet-row.test.d.ts +1 -0
- package/dist/test/collection-facets/facet-row.test.js +235 -0
- package/dist/test/collection-facets/facet-row.test.js.map +1 -0
- package/dist/test/collection-facets/facets-template.test.js +65 -96
- package/dist/test/collection-facets/facets-template.test.js.map +1 -1
- package/dist/test/collection-facets.test.js +39 -70
- package/dist/test/collection-facets.test.js.map +1 -1
- package/package.json +2 -2
- package/src/app-root.ts +159 -82
- package/src/collection-browser.ts +23 -20
- package/src/collection-facets/facet-row.ts +274 -0
- package/src/collection-facets/facets-template.ts +49 -196
- package/src/models.ts +18 -2
- package/test/collection-browser.test.ts +36 -4
- package/test/collection-facets/facet-row.test.ts +328 -0
- package/test/collection-facets/facets-template.test.ts +72 -110
- package/test/collection-facets.test.ts +69 -101
|
@@ -17,6 +17,8 @@ import {
|
|
|
17
17
|
} from '../src/models';
|
|
18
18
|
import { MockAnalyticsHandler } from './mocks/mock-analytics-handler';
|
|
19
19
|
import { MockCollectionNameCache } from './mocks/mock-collection-name-cache';
|
|
20
|
+
import type { FacetRow } from '../src/collection-facets/facet-row';
|
|
21
|
+
import type { FacetsTemplate } from '../src/collection-facets/facets-template';
|
|
20
22
|
|
|
21
23
|
describe('Collection Facets', () => {
|
|
22
24
|
it('has loader', async () => {
|
|
@@ -210,10 +212,11 @@ describe('Collection Facets', () => {
|
|
|
210
212
|
|
|
211
213
|
const titleFacetRow = titleFacetGroup
|
|
212
214
|
?.querySelector('facets-template')
|
|
213
|
-
?.shadowRoot?.querySelector('
|
|
215
|
+
?.shadowRoot?.querySelector('facet-row') as FacetRow;
|
|
216
|
+
await titleFacetRow.updateComplete;
|
|
214
217
|
|
|
215
|
-
expect(titleFacetRow?.textContent?.trim()).to.satisfy(
|
|
216
|
-
/^foo\s*5$/.test(text)
|
|
218
|
+
expect(titleFacetRow?.shadowRoot?.textContent?.trim()).to.satisfy(
|
|
219
|
+
(text: string) => /^foo\s*5$/.test(text)
|
|
217
220
|
);
|
|
218
221
|
});
|
|
219
222
|
|
|
@@ -248,61 +251,6 @@ describe('Collection Facets', () => {
|
|
|
248
251
|
expect(facetGroups?.length).to.equal(2);
|
|
249
252
|
});
|
|
250
253
|
|
|
251
|
-
it('renders collection facets as links', async () => {
|
|
252
|
-
const el = await fixture<CollectionFacets>(
|
|
253
|
-
html`<collection-facets></collection-facets>`
|
|
254
|
-
);
|
|
255
|
-
|
|
256
|
-
const aggs: Record<string, Aggregation> = {
|
|
257
|
-
collection: new Aggregation({
|
|
258
|
-
buckets: [
|
|
259
|
-
{
|
|
260
|
-
key: 'foo',
|
|
261
|
-
doc_count: 5,
|
|
262
|
-
},
|
|
263
|
-
],
|
|
264
|
-
}),
|
|
265
|
-
};
|
|
266
|
-
|
|
267
|
-
el.aggregations = aggs;
|
|
268
|
-
await el.updateComplete;
|
|
269
|
-
|
|
270
|
-
const collectionName = el.shadowRoot
|
|
271
|
-
?.querySelector('facets-template')
|
|
272
|
-
?.shadowRoot?.querySelector('async-collection-name');
|
|
273
|
-
expect(collectionName?.parentElement).to.be.instanceOf(HTMLAnchorElement);
|
|
274
|
-
expect(collectionName?.parentElement?.getAttribute('href')).to.equal(
|
|
275
|
-
'/details/foo'
|
|
276
|
-
);
|
|
277
|
-
});
|
|
278
|
-
|
|
279
|
-
it('renders non-collection facets without links', async () => {
|
|
280
|
-
const el = await fixture<CollectionFacets>(
|
|
281
|
-
html`<collection-facets></collection-facets>`
|
|
282
|
-
);
|
|
283
|
-
|
|
284
|
-
const aggs: Record<string, Aggregation> = {
|
|
285
|
-
subject: new Aggregation({
|
|
286
|
-
buckets: [
|
|
287
|
-
{
|
|
288
|
-
key: 'foo',
|
|
289
|
-
doc_count: 5,
|
|
290
|
-
},
|
|
291
|
-
],
|
|
292
|
-
}),
|
|
293
|
-
};
|
|
294
|
-
|
|
295
|
-
el.aggregations = aggs;
|
|
296
|
-
await el.updateComplete;
|
|
297
|
-
|
|
298
|
-
const collectionName = el.shadowRoot
|
|
299
|
-
?.querySelector('facets-template')
|
|
300
|
-
?.shadowRoot?.querySelector('async-collection-name');
|
|
301
|
-
expect(collectionName?.parentElement).to.not.be.instanceOf(
|
|
302
|
-
HTMLAnchorElement
|
|
303
|
-
);
|
|
304
|
-
});
|
|
305
|
-
|
|
306
254
|
it('does not render suppressed collection facets', async () => {
|
|
307
255
|
const el = await fixture<CollectionFacets>(
|
|
308
256
|
html`<collection-facets></collection-facets>`
|
|
@@ -332,14 +280,11 @@ describe('Collection Facets', () => {
|
|
|
332
280
|
|
|
333
281
|
const collectionFacets = el.shadowRoot
|
|
334
282
|
?.querySelector('facets-template')
|
|
335
|
-
?.shadowRoot?.querySelectorAll('
|
|
283
|
+
?.shadowRoot?.querySelectorAll('facet-row') as ArrayLike<FacetRow>;
|
|
336
284
|
expect(collectionFacets?.length).to.equal(1);
|
|
337
285
|
|
|
338
286
|
// The first (and only) collection link should be for 'foo'
|
|
339
|
-
|
|
340
|
-
?.item(0)
|
|
341
|
-
.querySelector(`a[href='/details/foo']`);
|
|
342
|
-
expect(collectionLink).to.exist;
|
|
287
|
+
expect(collectionFacets[0].bucket?.key).to.equal('foo');
|
|
343
288
|
});
|
|
344
289
|
|
|
345
290
|
it('renders lending facets with human-readable names', async () => {
|
|
@@ -369,18 +314,24 @@ describe('Collection Facets', () => {
|
|
|
369
314
|
el.aggregations = aggs;
|
|
370
315
|
await el.updateComplete;
|
|
371
316
|
|
|
372
|
-
const facetsTemplate = el.shadowRoot?.querySelector(
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
317
|
+
const facetsTemplate = el.shadowRoot?.querySelector(
|
|
318
|
+
'facets-template'
|
|
319
|
+
) as FacetsTemplate;
|
|
320
|
+
await facetsTemplate?.updateComplete;
|
|
321
|
+
|
|
322
|
+
const lendingFacets = facetsTemplate?.shadowRoot?.querySelectorAll(
|
|
323
|
+
'facet-row'
|
|
324
|
+
) as ArrayLike<FacetRow>;
|
|
325
|
+
expect(lendingFacets?.length).to.equal(3);
|
|
326
|
+
|
|
327
|
+
expect(lendingFacets[0].shadowRoot?.textContent?.trim()).to.match(
|
|
328
|
+
/^Lending Library\s*3$/
|
|
378
329
|
);
|
|
379
|
-
expect(
|
|
380
|
-
|
|
330
|
+
expect(lendingFacets[1].shadowRoot?.textContent?.trim()).to.match(
|
|
331
|
+
/^Borrow 14 Days\s*2$/
|
|
381
332
|
);
|
|
382
|
-
expect(
|
|
383
|
-
|
|
333
|
+
expect(lendingFacets[2].shadowRoot?.textContent?.trim()).to.match(
|
|
334
|
+
/^Always Available\s*1$/
|
|
384
335
|
);
|
|
385
336
|
});
|
|
386
337
|
|
|
@@ -418,18 +369,24 @@ describe('Collection Facets', () => {
|
|
|
418
369
|
el.selectedFacets = selectedFacets;
|
|
419
370
|
await el.updateComplete;
|
|
420
371
|
|
|
421
|
-
const facetsTemplate = el.shadowRoot?.querySelector(
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
372
|
+
const facetsTemplate = el.shadowRoot?.querySelector(
|
|
373
|
+
'facets-template'
|
|
374
|
+
) as FacetsTemplate;
|
|
375
|
+
await facetsTemplate?.updateComplete;
|
|
376
|
+
|
|
377
|
+
const lendingFacets = facetsTemplate?.shadowRoot?.querySelectorAll(
|
|
378
|
+
'facet-row'
|
|
379
|
+
) as ArrayLike<FacetRow>;
|
|
380
|
+
expect(lendingFacets?.length).to.equal(3);
|
|
381
|
+
|
|
382
|
+
expect(lendingFacets[0].shadowRoot?.textContent?.trim()).to.match(
|
|
383
|
+
/^Lending Library\s*5$/
|
|
427
384
|
);
|
|
428
|
-
expect(
|
|
429
|
-
|
|
385
|
+
expect(lendingFacets[1].shadowRoot?.textContent?.trim()).to.match(
|
|
386
|
+
/^Borrow 14 Days\s*4$/
|
|
430
387
|
);
|
|
431
|
-
expect(
|
|
432
|
-
|
|
388
|
+
expect(lendingFacets[2].shadowRoot?.textContent?.trim()).to.match(
|
|
389
|
+
/^Always Available\s*3$/
|
|
433
390
|
);
|
|
434
391
|
});
|
|
435
392
|
|
|
@@ -476,18 +433,27 @@ describe('Collection Facets', () => {
|
|
|
476
433
|
el.aggregations = aggs;
|
|
477
434
|
await el.updateComplete;
|
|
478
435
|
|
|
479
|
-
const facetsTemplate = el.shadowRoot?.querySelector(
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
436
|
+
const facetsTemplate = el.shadowRoot?.querySelector(
|
|
437
|
+
'facets-template'
|
|
438
|
+
) as FacetsTemplate;
|
|
439
|
+
await facetsTemplate?.updateComplete;
|
|
440
|
+
await new Promise(res => {
|
|
441
|
+
setTimeout(res, 100);
|
|
442
|
+
});
|
|
443
|
+
|
|
444
|
+
const lendingFacets = facetsTemplate?.shadowRoot?.querySelectorAll(
|
|
445
|
+
'facet-row'
|
|
446
|
+
) as ArrayLike<FacetRow>;
|
|
447
|
+
expect(lendingFacets?.length).to.equal(3);
|
|
448
|
+
|
|
449
|
+
expect(lendingFacets[0].shadowRoot?.textContent?.trim()).to.match(
|
|
450
|
+
/^Lending Library\s*5$/
|
|
485
451
|
);
|
|
486
|
-
expect(
|
|
487
|
-
|
|
452
|
+
expect(lendingFacets[1].shadowRoot?.textContent?.trim()).to.match(
|
|
453
|
+
/^Borrow 14 Days\s*5$/
|
|
488
454
|
);
|
|
489
|
-
expect(
|
|
490
|
-
|
|
455
|
+
expect(lendingFacets[2].shadowRoot?.textContent?.trim()).to.match(
|
|
456
|
+
/^Always Available\s*4$/
|
|
491
457
|
);
|
|
492
458
|
});
|
|
493
459
|
|
|
@@ -586,10 +552,11 @@ describe('Collection Facets', () => {
|
|
|
586
552
|
await el.updateComplete;
|
|
587
553
|
|
|
588
554
|
const facetsTemplate = el.shadowRoot?.querySelector('facets-template');
|
|
589
|
-
const
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
expect(
|
|
555
|
+
const facetRows = facetsTemplate?.shadowRoot?.querySelectorAll(
|
|
556
|
+
'facet-row'
|
|
557
|
+
) as ArrayLike<FacetRow>;
|
|
558
|
+
expect(facetRows?.length).to.equal(6);
|
|
559
|
+
expect(facetRows?.[5]?.bucket?.key).to.equal('collection');
|
|
593
560
|
});
|
|
594
561
|
|
|
595
562
|
it('renders the mediatype:collection facet even when >=6 other mediatypes are selected', async () => {
|
|
@@ -652,10 +619,11 @@ describe('Collection Facets', () => {
|
|
|
652
619
|
await el.updateComplete;
|
|
653
620
|
|
|
654
621
|
const facetsTemplate = el.shadowRoot?.querySelector('facets-template');
|
|
655
|
-
const
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
expect(
|
|
622
|
+
const facetRows = facetsTemplate?.shadowRoot?.querySelectorAll(
|
|
623
|
+
'facet-row'
|
|
624
|
+
) as ArrayLike<FacetRow>;
|
|
625
|
+
expect(facetRows?.length).to.equal(8);
|
|
626
|
+
expect(facetRows?.[7]?.bucket?.key).to.equal('collection');
|
|
659
627
|
});
|
|
660
628
|
|
|
661
629
|
describe('More Facets', () => {
|