@internetarchive/collection-browser 1.14.17-alpha.3 → 1.14.17-alpha.31

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.
Files changed (72) hide show
  1. package/dist/index.js +1 -1
  2. package/dist/index.js.map +1 -1
  3. package/dist/src/collection-browser.d.ts +6 -13
  4. package/dist/src/collection-browser.js +54 -25
  5. package/dist/src/collection-browser.js.map +1 -1
  6. package/dist/src/data-source/collection-browser-data-source.d.ts +48 -30
  7. package/dist/src/data-source/collection-browser-data-source.js +106 -116
  8. package/dist/src/data-source/collection-browser-data-source.js.map +1 -1
  9. package/dist/src/data-source/models.d.ts +7 -3
  10. package/dist/src/data-source/models.js.map +1 -1
  11. package/dist/src/manage/manage-bar.d.ts +1 -1
  12. package/dist/src/manage/manage-bar.js.map +1 -1
  13. package/dist/src/models.d.ts +20 -4
  14. package/dist/src/models.js +105 -0
  15. package/dist/src/models.js.map +1 -1
  16. package/dist/src/sort-filter-bar/sort-filter-bar.js +1 -0
  17. package/dist/src/sort-filter-bar/sort-filter-bar.js.map +1 -1
  18. package/dist/src/tiles/grid/item-tile.d.ts +1 -0
  19. package/dist/src/tiles/grid/item-tile.js +28 -1
  20. package/dist/src/tiles/grid/item-tile.js.map +1 -1
  21. package/dist/src/tiles/grid/tile-stats.js +13 -8
  22. package/dist/src/tiles/grid/tile-stats.js.map +1 -1
  23. package/dist/src/tiles/item-image.js +15 -2
  24. package/dist/src/tiles/item-image.js.map +1 -1
  25. package/dist/src/tiles/list/tile-list.d.ts +1 -0
  26. package/dist/src/tiles/list/tile-list.js +32 -1
  27. package/dist/src/tiles/list/tile-list.js.map +1 -1
  28. package/dist/src/tiles/tile-dispatcher.js +3 -2
  29. package/dist/src/tiles/tile-dispatcher.js.map +1 -1
  30. package/dist/src/tiles/tile-display-value-provider.d.ts +6 -2
  31. package/dist/src/tiles/tile-display-value-provider.js +15 -1
  32. package/dist/src/tiles/tile-display-value-provider.js.map +1 -1
  33. package/dist/src/utils/collapse-repeated-quotes.d.ts +11 -0
  34. package/dist/src/utils/collapse-repeated-quotes.js +14 -0
  35. package/dist/src/utils/collapse-repeated-quotes.js.map +1 -0
  36. package/dist/src/utils/resolve-mediatype.d.ts +8 -0
  37. package/dist/src/utils/resolve-mediatype.js +24 -0
  38. package/dist/src/utils/resolve-mediatype.js.map +1 -0
  39. package/dist/test/collection-browser.test.js +37 -25
  40. package/dist/test/collection-browser.test.js.map +1 -1
  41. package/dist/test/collection-facets/more-facets-content.test.js +2 -2
  42. package/dist/test/collection-facets/more-facets-content.test.js.map +1 -1
  43. package/dist/test/item-image.test.js +33 -34
  44. package/dist/test/item-image.test.js.map +1 -1
  45. package/dist/test/mocks/mock-search-responses.d.ts +1 -0
  46. package/dist/test/mocks/mock-search-responses.js +62 -0
  47. package/dist/test/mocks/mock-search-responses.js.map +1 -1
  48. package/dist/test/sort-filter-bar/sort-filter-bar.test.js +41 -4
  49. package/dist/test/sort-filter-bar/sort-filter-bar.test.js.map +1 -1
  50. package/dist/test/tiles/hover/hover-pane-controller.test.js +18 -17
  51. package/dist/test/tiles/hover/hover-pane-controller.test.js.map +1 -1
  52. package/package.json +2 -2
  53. package/src/collection-browser.ts +62 -42
  54. package/src/data-source/collection-browser-data-source.ts +170 -140
  55. package/src/data-source/models.ts +7 -2
  56. package/src/manage/manage-bar.ts +1 -1
  57. package/src/models.ts +154 -3
  58. package/src/sort-filter-bar/sort-filter-bar.ts +1 -0
  59. package/src/tiles/grid/item-tile.ts +36 -1
  60. package/src/tiles/grid/tile-stats.ts +12 -7
  61. package/src/tiles/item-image.ts +13 -0
  62. package/src/tiles/list/tile-list.ts +43 -5
  63. package/src/tiles/tile-dispatcher.ts +2 -1
  64. package/src/tiles/tile-display-value-provider.ts +20 -2
  65. package/src/utils/collapse-repeated-quotes.ts +13 -0
  66. package/src/utils/resolve-mediatype.ts +26 -0
  67. package/test/collection-browser.test.ts +72 -27
  68. package/test/collection-facets/more-facets-content.test.ts +4 -2
  69. package/test/item-image.test.ts +34 -36
  70. package/test/mocks/mock-search-responses.ts +66 -0
  71. package/test/sort-filter-bar/sort-filter-bar.test.ts +50 -4
  72. package/test/tiles/hover/hover-pane-controller.test.ts +19 -17
@@ -213,9 +213,9 @@ describe('Collection Browser', () => {
213
213
  const facets = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('collection-facets');
214
214
  const sortBar = (_b = el.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('sort-filter-bar');
215
215
  const infiniteScroller = (_c = el.shadowRoot) === null || _c === void 0 ? void 0 : _c.querySelector('infinite-scroller');
216
- expect(facets).to.exist;
217
- expect(sortBar).to.exist;
218
- expect(infiniteScroller).to.exist;
216
+ expect(facets, 'facets').to.exist;
217
+ expect(sortBar, 'sort bar').to.exist;
218
+ expect(infiniteScroller, 'infinite scroller').to.exist;
219
219
  });
220
220
  it('queries the search service when given a base query', async () => {
221
221
  var _a, _b, _c;
@@ -333,6 +333,18 @@ describe('Collection Browser', () => {
333
333
  </collection-browser>`);
334
334
  expect(el.searchType).to.equal(SearchType.FULLTEXT);
335
335
  });
336
+ it('can construct tile models with many fields present', async () => {
337
+ const searchService = new MockSearchService();
338
+ const el = await fixture(html `<collection-browser .searchService=${searchService}>
339
+ </collection-browser>`);
340
+ el.baseQuery = 'many-fields';
341
+ await el.updateComplete;
342
+ await el.initialSearchComplete;
343
+ const cellTemplate = el.cellForIndex(0);
344
+ expect(cellTemplate).to.exist;
345
+ const cell = await fixture(cellTemplate);
346
+ expect(cell).to.exist;
347
+ });
336
348
  it('applies loggedin flag to tile models if needed', async () => {
337
349
  var _a;
338
350
  const searchService = new MockSearchService();
@@ -560,9 +572,9 @@ describe('Collection Browser', () => {
560
572
  el.baseQuery = 'foo';
561
573
  await el.updateComplete;
562
574
  await nextTick();
563
- const sortBar = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('sort-filter-bar');
575
+ const sortBar = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('#content-container sort-filter-bar');
564
576
  const sortSelector = (_b = sortBar === null || sortBar === void 0 ? void 0 : sortBar.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('#desktop-sort-selector');
565
- expect(sortSelector).to.exist;
577
+ expect(sortSelector, 'sort bar').to.exist;
566
578
  // Click the title sorter
567
579
  (_d = (_c = [...sortSelector === null || sortSelector === void 0 ? void 0 : sortSelector.children] // tsc doesn't know children is iterable
568
580
  .find(child => { var _a; return ((_a = child.textContent) === null || _a === void 0 ? void 0 : _a.trim()) === 'Title'; })) === null || _c === void 0 ? void 0 : _c.querySelector('button')) === null || _d === void 0 ? void 0 : _d.click();
@@ -644,19 +656,22 @@ describe('Collection Browser', () => {
644
656
  el.sortDirection = 'asc';
645
657
  el.selectedCreatorFilter = 'X';
646
658
  await el.updateComplete;
647
- await el.initialSearchComplete;
659
+ await nextTick();
648
660
  expect((_a = searchService.searchParams) === null || _a === void 0 ? void 0 : _a.query).to.equal('first-creator');
649
661
  expect((_d = (_c = (_b = searchService.searchParams) === null || _b === void 0 ? void 0 : _b.filters) === null || _c === void 0 ? void 0 : _c.firstCreator) === null || _d === void 0 ? void 0 : _d.X).to.equal(FilterConstraint.INCLUDE);
650
662
  el.baseQuery = 'collection:foo';
651
663
  await el.updateComplete;
652
- await el.initialSearchComplete;
664
+ await nextTick();
653
665
  expect((_e = searchService.searchParams) === null || _e === void 0 ? void 0 : _e.query).to.equal('collection:foo');
654
666
  expect((_g = (_f = searchService.searchParams) === null || _f === void 0 ? void 0 : _f.filters) === null || _g === void 0 ? void 0 : _g.firstCreator).not.to.exist;
655
667
  });
656
668
  it('sets date range query when date picker selection changed', async () => {
657
669
  var _a, _b, _c;
658
670
  const searchService = new MockSearchService();
659
- const el = await fixture(html `<collection-browser .searchService=${searchService}>
671
+ const el = await fixture(html `<collection-browser
672
+ .searchService=${searchService}
673
+ .suppressPlaceholders=${true}
674
+ >
660
675
  </collection-browser>`);
661
676
  el.baseQuery = 'years'; // Includes year_histogram aggregation in response
662
677
  el.showHistogramDatePicker = true;
@@ -666,7 +681,7 @@ describe('Collection Browser', () => {
666
681
  // Wait for the date picker to be rendered (which may take until the next tick)
667
682
  await nextTick();
668
683
  const histogram = (_b = facets === null || facets === void 0 ? void 0 : facets.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('histogram-date-range');
669
- expect(histogram).to.exist;
684
+ expect(histogram, 'histogram exists').to.exist;
670
685
  // Enter a new min date into the date picker
671
686
  const minDateInput = (_c = histogram.shadowRoot) === null || _c === void 0 ? void 0 : _c.querySelector('#date-min');
672
687
  const pressEnterEvent = new KeyboardEvent('keyup', {
@@ -813,7 +828,7 @@ describe('Collection Browser', () => {
813
828
  const spy = sinon.spy();
814
829
  infiniteScroller.scrollToCell = spy;
815
830
  await el.goToPage(1);
816
- expect(spy.callCount).to.equal(1);
831
+ expect(spy.callCount, 'scroll to page fires once').to.equal(1);
817
832
  infiniteScroller.scrollToCell = oldScrollToCell;
818
833
  });
819
834
  it('shows mobile facets in mobile view', async () => {
@@ -869,33 +884,34 @@ describe('Collection Browser', () => {
869
884
  // testing: `loggedIn`
870
885
  el.loggedIn = true;
871
886
  await el.updateComplete;
872
- expect(infiniteScrollerRefreshSpy.called).to.be.true;
873
- expect(infiniteScrollerRefreshSpy.callCount).to.equal(1);
887
+ expect(infiniteScrollerRefreshSpy.called, 'Infinite Scroller Refresh').to.be
888
+ .true;
889
+ expect(infiniteScrollerRefreshSpy.callCount, 'Infinite Scroller Refresh call count').to.equal(1);
874
890
  el.loggedIn = false;
875
891
  await el.updateComplete;
876
- expect(infiniteScrollerRefreshSpy.callCount).to.equal(2);
892
+ expect(infiniteScrollerRefreshSpy.callCount, '2nd Infinite Scroller Refresh').to.equal(2);
877
893
  // testing: `displayMode`
878
894
  el.displayMode = 'list-compact';
879
895
  el.searchContext = 'beta-search';
880
896
  await el.updateComplete;
881
- expect(infiniteScrollerRefreshSpy.callCount).to.equal(3);
897
+ expect(infiniteScrollerRefreshSpy.callCount, '3rd Infinite Scroller Refresh').to.equal(3);
882
898
  expect(mockAnalyticsHandler.callCategory).to.equal('beta-search');
883
899
  expect(mockAnalyticsHandler.callAction).to.equal('displayMode');
884
900
  expect(mockAnalyticsHandler.callLabel).to.equal('list-compact');
885
901
  el.displayMode = 'list-detail';
886
902
  await el.updateComplete;
887
- expect(infiniteScrollerRefreshSpy.callCount).to.equal(4);
903
+ expect(infiniteScrollerRefreshSpy.callCount, '4th Infinite Scroller Refresh').to.equal(4);
888
904
  expect(mockAnalyticsHandler.callCategory).to.equal('beta-search');
889
905
  expect(mockAnalyticsHandler.callAction).to.equal('displayMode');
890
906
  expect(mockAnalyticsHandler.callLabel).to.equal('list-detail');
891
907
  // testing: `baseNavigationUrl`
892
908
  el.baseNavigationUrl = 'https://funtestsite.com';
893
909
  await el.updateComplete;
894
- expect(infiniteScrollerRefreshSpy.callCount).to.equal(5);
910
+ expect(infiniteScrollerRefreshSpy.callCount, '5th Infinite Scroller Refresh').to.equal(5);
895
911
  // testing: `baseImageUrl`
896
912
  el.baseImageUrl = 'https://funtestsiteforimages.com';
897
913
  await el.updateComplete;
898
- expect(infiniteScrollerRefreshSpy.callCount).to.equal(6);
914
+ expect(infiniteScrollerRefreshSpy.callCount, '6th Infinite Scroller Refresh').to.equal(6);
899
915
  });
900
916
  it('query the search service for single result', async () => {
901
917
  var _a, _b;
@@ -1018,8 +1034,6 @@ describe('Collection Browser', () => {
1018
1034
  .withinCollection=${'foobar'}
1019
1035
  >
1020
1036
  </collection-browser>`);
1021
- await el.initialSearchComplete;
1022
- await el.updateComplete;
1023
1037
  el.baseQuery = 'bar';
1024
1038
  await el.updateComplete;
1025
1039
  expect(el.withinCollection).to.equal('foobar');
@@ -1050,8 +1064,6 @@ describe('Collection Browser', () => {
1050
1064
  .withinCollection=${'foobar'}
1051
1065
  >
1052
1066
  </collection-browser>`);
1053
- await el.initialSearchComplete;
1054
- await el.updateComplete;
1055
1067
  el.withinCollection = 'bar';
1056
1068
  await el.updateComplete;
1057
1069
  expect(el.withinCollection).to.equal('bar');
@@ -1106,7 +1118,7 @@ describe('Collection Browser', () => {
1106
1118
  expect(el.displayMode).to.equal('grid');
1107
1119
  });
1108
1120
  it('can remove all checked tiles', async () => {
1109
- var _a, _b, _c, _d, _e, _f, _g, _h;
1121
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
1110
1122
  const searchService = new MockSearchService();
1111
1123
  const el = await fixture(html `<collection-browser
1112
1124
  .searchService=${searchService}
@@ -1140,10 +1152,10 @@ describe('Collection Browser', () => {
1140
1152
  // Remove checked tiles and verify that we only kept the second tile
1141
1153
  el.removeCheckedTiles();
1142
1154
  await el.updateComplete;
1143
- tiles = (_g = infiniteScroller.shadowRoot) === null || _g === void 0 ? void 0 : _g.querySelectorAll('tile-dispatcher');
1155
+ expect((_g = el === null || el === void 0 ? void 0 : el.dataSource) === null || _g === void 0 ? void 0 : _g.size, 'data source count').to.equal(1);
1156
+ tiles = (_j = (_h = el.shadowRoot) === null || _h === void 0 ? void 0 : _h.querySelector('infinite-scroller').shadowRoot) === null || _j === void 0 ? void 0 : _j.querySelectorAll('tile-dispatcher');
1144
1157
  expect(tiles).to.exist;
1145
- expect(tiles === null || tiles === void 0 ? void 0 : tiles.length).to.equal(1);
1146
- expect((_h = tiles[0].model) === null || _h === void 0 ? void 0 : _h.identifier).to.equal('bar');
1158
+ expect(tiles.length, 'tile count after `el.removeCheckedTiles()`').to.equal(1);
1147
1159
  });
1148
1160
  it('can check/uncheck all tiles', async () => {
1149
1161
  const searchService = new MockSearchService();