@internetarchive/collection-browser 4.2.1-alpha-webdev8165.0 → 4.3.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/.claude/settings.local.json +11 -0
- package/dist/src/data-source/collection-browser-data-source.d.ts +7 -0
- package/dist/src/data-source/collection-browser-data-source.js +24 -8
- package/dist/src/data-source/collection-browser-data-source.js.map +1 -1
- package/dist/src/models.d.ts +6 -0
- package/dist/src/models.js +16 -7
- package/dist/src/models.js.map +1 -1
- package/dist/src/restoration-state-handler.js +3 -1
- package/dist/src/restoration-state-handler.js.map +1 -1
- package/dist/src/tiles/list/tile-list-compact-header.js +45 -45
- package/dist/src/tiles/list/tile-list-compact-header.js.map +1 -1
- package/dist/src/tiles/list/tile-list-compact.js +99 -99
- package/dist/src/tiles/list/tile-list-compact.js.map +1 -1
- package/dist/src/tiles/list/tile-list.js +300 -299
- package/dist/src/tiles/list/tile-list.js.map +1 -1
- package/dist/src/tiles/tile-display-value-provider.d.ts +5 -0
- package/dist/src/tiles/tile-display-value-provider.js +9 -0
- package/dist/src/tiles/tile-display-value-provider.js.map +1 -1
- package/dist/test/data-source/collection-browser-data-source.test.js +54 -2
- package/dist/test/data-source/collection-browser-data-source.test.js.map +1 -1
- package/dist/test/restoration-state-handler.test.js +0 -70
- package/dist/test/restoration-state-handler.test.js.map +1 -1
- package/dist/test/tiles/list/tile-list-compact-header.test.d.ts +1 -0
- package/dist/test/tiles/list/tile-list-compact-header.test.js +36 -0
- package/dist/test/tiles/list/tile-list-compact-header.test.js.map +1 -0
- package/dist/test/tiles/list/tile-list.test.js +147 -127
- package/dist/test/tiles/list/tile-list.test.js.map +1 -1
- package/package.json +1 -1
- package/src/data-source/collection-browser-data-source.ts +1465 -1445
- package/src/models.ts +23 -7
- package/src/restoration-state-handler.ts +5 -1
- package/src/tiles/list/tile-list-compact-header.ts +86 -86
- package/src/tiles/list/tile-list-compact.ts +239 -239
- package/src/tiles/list/tile-list.ts +700 -700
- package/src/tiles/tile-display-value-provider.ts +134 -124
- package/test/data-source/collection-browser-data-source.test.ts +193 -131
- package/test/restoration-state-handler.test.ts +0 -89
- package/test/tiles/list/tile-list-compact-header.test.ts +43 -0
- package/test/tiles/list/tile-list.test.ts +576 -552
|
@@ -460,95 +460,6 @@ describe('Restoration state handler', () => {
|
|
|
460
460
|
expect(window.location.search).to.equal('?sin=MD');
|
|
461
461
|
});
|
|
462
462
|
|
|
463
|
-
it('should write relevance sort to URL when explicitly selected', async () => {
|
|
464
|
-
const url = new URL(window.location.href);
|
|
465
|
-
url.search = '';
|
|
466
|
-
window.history.replaceState({ path: url.href }, '', url.href);
|
|
467
|
-
|
|
468
|
-
const handler = new RestorationStateHandler({ context: 'search' });
|
|
469
|
-
handler.persistState({
|
|
470
|
-
selectedSort: SortField.relevance,
|
|
471
|
-
selectedFacets: getDefaultSelectedFacets(),
|
|
472
|
-
});
|
|
473
|
-
|
|
474
|
-
expect(window.location.search).to.equal('?sort=relevance');
|
|
475
|
-
});
|
|
476
|
-
|
|
477
|
-
it('should write relevance sort to URL for TV search', async () => {
|
|
478
|
-
const url = new URL(window.location.href);
|
|
479
|
-
url.search = '';
|
|
480
|
-
window.history.replaceState({ path: url.href }, '', url.href);
|
|
481
|
-
|
|
482
|
-
const handler = new RestorationStateHandler({ context: 'search' });
|
|
483
|
-
handler.persistState({
|
|
484
|
-
searchType: SearchType.TV,
|
|
485
|
-
selectedSort: SortField.relevance,
|
|
486
|
-
selectedFacets: getDefaultSelectedFacets(),
|
|
487
|
-
});
|
|
488
|
-
|
|
489
|
-
expect(window.location.search).to.include('sort=relevance');
|
|
490
|
-
});
|
|
491
|
-
|
|
492
|
-
it('should not write sort param for SortField.default', async () => {
|
|
493
|
-
const url = new URL(window.location.href);
|
|
494
|
-
url.search = '';
|
|
495
|
-
window.history.replaceState({ path: url.href }, '', url.href);
|
|
496
|
-
|
|
497
|
-
const handler = new RestorationStateHandler({ context: 'search' });
|
|
498
|
-
handler.persistState({
|
|
499
|
-
selectedSort: SortField.default,
|
|
500
|
-
selectedFacets: getDefaultSelectedFacets(),
|
|
501
|
-
});
|
|
502
|
-
|
|
503
|
-
expect(window.location.search).to.not.include('sort');
|
|
504
|
-
});
|
|
505
|
-
|
|
506
|
-
it('should write datefavorited sort to URL when explicitly selected', async () => {
|
|
507
|
-
const url = new URL(window.location.href);
|
|
508
|
-
url.search = '';
|
|
509
|
-
window.history.replaceState({ path: url.href }, '', url.href);
|
|
510
|
-
|
|
511
|
-
const handler = new RestorationStateHandler({ context: 'search' });
|
|
512
|
-
handler.persistState({
|
|
513
|
-
selectedSort: SortField.datefavorited,
|
|
514
|
-
sortDirection: 'desc',
|
|
515
|
-
selectedFacets: getDefaultSelectedFacets(),
|
|
516
|
-
});
|
|
517
|
-
|
|
518
|
-
expect(window.location.search).to.equal('?sort=-favoritedate');
|
|
519
|
-
});
|
|
520
|
-
|
|
521
|
-
it('should round-trip relevance sort via URL', async () => {
|
|
522
|
-
// 1. Set the URL to include the new canonical relevance sort param
|
|
523
|
-
const url = new URL(window.location.href);
|
|
524
|
-
url.search = '?sort=relevance';
|
|
525
|
-
window.history.replaceState({ path: url.href }, '', url.href);
|
|
526
|
-
|
|
527
|
-
const handler = new RestorationStateHandler({ context: 'search' });
|
|
528
|
-
|
|
529
|
-
// 2. Load state from the URL and verify it resolves to relevance sort
|
|
530
|
-
const restorationState = handler.getRestorationState();
|
|
531
|
-
expect(restorationState.selectedSort).to.equal(SortField.relevance);
|
|
532
|
-
|
|
533
|
-
// 3. Persist the state back and verify the sort param is preserved
|
|
534
|
-
handler.persistState(restorationState);
|
|
535
|
-
expect(window.location.search).to.include('sort=relevance');
|
|
536
|
-
});
|
|
537
|
-
|
|
538
|
-
it('should still resolve legacy _score URL param to relevance sort', async () => {
|
|
539
|
-
const url = new URL(window.location.href);
|
|
540
|
-
url.search = '?sort=_score';
|
|
541
|
-
window.history.replaceState({ path: url.href }, '', url.href);
|
|
542
|
-
|
|
543
|
-
const handler = new RestorationStateHandler({ context: 'search' });
|
|
544
|
-
const restorationState = handler.getRestorationState();
|
|
545
|
-
expect(restorationState.selectedSort).to.equal(SortField.relevance);
|
|
546
|
-
|
|
547
|
-
// Re-persisting upgrades the URL to the canonical form
|
|
548
|
-
handler.persistState(restorationState);
|
|
549
|
-
expect(window.location.search).to.include('sort=relevance');
|
|
550
|
-
});
|
|
551
|
-
|
|
552
463
|
it('round trip load/persist should erase numbers in square brackets', async () => {
|
|
553
464
|
const handler = new RestorationStateHandler({ context: 'search' });
|
|
554
465
|
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { expect, fixture } from '@open-wc/testing';
|
|
2
|
+
import { html } from 'lit';
|
|
3
|
+
import type { TileListCompactHeader } from '../../../src/tiles/list/tile-list-compact-header';
|
|
4
|
+
|
|
5
|
+
import '../../../src/tiles/list/tile-list-compact-header';
|
|
6
|
+
|
|
7
|
+
describe('List Tile Compact Header', () => {
|
|
8
|
+
it('should render Weekly views header when sorting by week', async () => {
|
|
9
|
+
const el = await fixture<TileListCompactHeader>(html`
|
|
10
|
+
<tile-list-compact-header
|
|
11
|
+
.sortParam=${{ field: 'week', direction: 'desc' }}
|
|
12
|
+
>
|
|
13
|
+
</tile-list-compact-header>
|
|
14
|
+
`);
|
|
15
|
+
|
|
16
|
+
const viewsColumn = el.shadowRoot?.getElementById('views');
|
|
17
|
+
expect(viewsColumn).to.exist;
|
|
18
|
+
expect(viewsColumn?.textContent?.trim()).to.equal('Weekly views');
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('should render All-time views header when sorting by non-week field', async () => {
|
|
22
|
+
const el = await fixture<TileListCompactHeader>(html`
|
|
23
|
+
<tile-list-compact-header
|
|
24
|
+
.sortParam=${{ field: 'downloads', direction: 'desc' }}
|
|
25
|
+
>
|
|
26
|
+
</tile-list-compact-header>
|
|
27
|
+
`);
|
|
28
|
+
|
|
29
|
+
const viewsColumn = el.shadowRoot?.getElementById('views');
|
|
30
|
+
expect(viewsColumn).to.exist;
|
|
31
|
+
expect(viewsColumn?.textContent?.trim()).to.equal('All-time views');
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('should render All-time views header with no sort param', async () => {
|
|
35
|
+
const el = await fixture<TileListCompactHeader>(html`
|
|
36
|
+
<tile-list-compact-header> </tile-list-compact-header>
|
|
37
|
+
`);
|
|
38
|
+
|
|
39
|
+
const viewsColumn = el.shadowRoot?.getElementById('views');
|
|
40
|
+
expect(viewsColumn).to.exist;
|
|
41
|
+
expect(viewsColumn?.textContent?.trim()).to.equal('All-time views');
|
|
42
|
+
});
|
|
43
|
+
});
|