@internetarchive/collection-browser 0.3.5-alpha.1 → 0.3.5

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 (236) hide show
  1. package/.editorconfig +29 -29
  2. package/.github/workflows/ci.yml +26 -26
  3. package/.github/workflows/gh-pages-main.yml +39 -39
  4. package/.github/workflows/npm-publish.yml +39 -39
  5. package/.github/workflows/pr-preview.yml +38 -38
  6. package/.husky/pre-commit +4 -4
  7. package/LICENSE +661 -661
  8. package/README.md +83 -83
  9. package/dist/index.d.ts +9 -9
  10. package/dist/index.js +9 -9
  11. package/dist/src/app-root.d.ts +47 -43
  12. package/dist/src/app-root.js +331 -285
  13. package/dist/src/app-root.js.map +1 -1
  14. package/dist/src/assets/img/icons/arrow-left.d.ts +2 -2
  15. package/dist/src/assets/img/icons/arrow-left.js +2 -2
  16. package/dist/src/assets/img/icons/arrow-right.d.ts +2 -2
  17. package/dist/src/assets/img/icons/arrow-right.js +2 -2
  18. package/dist/src/assets/img/icons/chevron.d.ts +2 -2
  19. package/dist/src/assets/img/icons/chevron.js +2 -2
  20. package/dist/src/assets/img/icons/empty-query.d.ts +2 -2
  21. package/dist/src/assets/img/icons/empty-query.js +2 -2
  22. package/dist/src/assets/img/icons/eye-closed.d.ts +2 -2
  23. package/dist/src/assets/img/icons/eye-closed.js +2 -2
  24. package/dist/src/assets/img/icons/eye.d.ts +2 -2
  25. package/dist/src/assets/img/icons/eye.js +2 -2
  26. package/dist/src/assets/img/icons/favorite-filled.d.ts +1 -1
  27. package/dist/src/assets/img/icons/favorite-filled.js +2 -2
  28. package/dist/src/assets/img/icons/login-required.d.ts +1 -1
  29. package/dist/src/assets/img/icons/login-required.js +2 -2
  30. package/dist/src/assets/img/icons/mediatype/account.d.ts +1 -1
  31. package/dist/src/assets/img/icons/mediatype/account.js +2 -2
  32. package/dist/src/assets/img/icons/mediatype/audio.d.ts +1 -1
  33. package/dist/src/assets/img/icons/mediatype/audio.js +2 -2
  34. package/dist/src/assets/img/icons/mediatype/collection.d.ts +1 -1
  35. package/dist/src/assets/img/icons/mediatype/collection.js +2 -2
  36. package/dist/src/assets/img/icons/mediatype/data.d.ts +1 -1
  37. package/dist/src/assets/img/icons/mediatype/data.js +2 -2
  38. package/dist/src/assets/img/icons/mediatype/etree.d.ts +1 -1
  39. package/dist/src/assets/img/icons/mediatype/etree.js +2 -2
  40. package/dist/src/assets/img/icons/mediatype/film.d.ts +1 -1
  41. package/dist/src/assets/img/icons/mediatype/film.js +2 -2
  42. package/dist/src/assets/img/icons/mediatype/images.d.ts +1 -1
  43. package/dist/src/assets/img/icons/mediatype/images.js +2 -2
  44. package/dist/src/assets/img/icons/mediatype/radio.d.ts +1 -1
  45. package/dist/src/assets/img/icons/mediatype/radio.js +2 -2
  46. package/dist/src/assets/img/icons/mediatype/software.d.ts +1 -1
  47. package/dist/src/assets/img/icons/mediatype/software.js +2 -2
  48. package/dist/src/assets/img/icons/mediatype/texts.d.ts +1 -1
  49. package/dist/src/assets/img/icons/mediatype/texts.js +2 -2
  50. package/dist/src/assets/img/icons/mediatype/tv.d.ts +1 -1
  51. package/dist/src/assets/img/icons/mediatype/tv.js +2 -2
  52. package/dist/src/assets/img/icons/mediatype/video.d.ts +1 -1
  53. package/dist/src/assets/img/icons/mediatype/video.js +2 -2
  54. package/dist/src/assets/img/icons/mediatype/web.d.ts +1 -1
  55. package/dist/src/assets/img/icons/mediatype/web.js +2 -2
  56. package/dist/src/assets/img/icons/null-result.d.ts +2 -2
  57. package/dist/src/assets/img/icons/null-result.js +2 -2
  58. package/dist/src/assets/img/icons/restricted.d.ts +1 -1
  59. package/dist/src/assets/img/icons/restricted.js +2 -2
  60. package/dist/src/assets/img/icons/reviews.d.ts +1 -1
  61. package/dist/src/assets/img/icons/reviews.js +2 -2
  62. package/dist/src/assets/img/icons/upload.d.ts +1 -1
  63. package/dist/src/assets/img/icons/upload.js +2 -2
  64. package/dist/src/assets/img/icons/views.d.ts +1 -1
  65. package/dist/src/assets/img/icons/views.js +2 -2
  66. package/dist/src/circular-activity-indicator.d.ts +5 -5
  67. package/dist/src/circular-activity-indicator.js +17 -17
  68. package/dist/src/collection-browser.d.ts +246 -245
  69. package/dist/src/collection-browser.js +1370 -1359
  70. package/dist/src/collection-browser.js.map +1 -1
  71. package/dist/src/collection-facets/facet-tombstone-row.d.ts +5 -5
  72. package/dist/src/collection-facets/facet-tombstone-row.js +42 -42
  73. package/dist/src/collection-facets/facet-tombstone-row.js.map +1 -1
  74. package/dist/src/collection-facets/facets-template.d.ts +16 -16
  75. package/dist/src/collection-facets/facets-template.js +130 -128
  76. package/dist/src/collection-facets/facets-template.js.map +1 -1
  77. package/dist/src/collection-facets/more-facets-content.d.ts +76 -76
  78. package/dist/src/collection-facets/more-facets-content.js +353 -353
  79. package/dist/src/collection-facets/more-facets-pagination.d.ts +36 -36
  80. package/dist/src/collection-facets/more-facets-pagination.js +192 -192
  81. package/dist/src/collection-facets.d.ts +77 -77
  82. package/dist/src/collection-facets.js +551 -551
  83. package/dist/src/collection-facets.js.map +1 -1
  84. package/dist/src/empty-placeholder.d.ts +11 -11
  85. package/dist/src/empty-placeholder.js +42 -42
  86. package/dist/src/language-code-handler/language-code-handler.d.ts +37 -37
  87. package/dist/src/language-code-handler/language-code-handler.js +26 -26
  88. package/dist/src/language-code-handler/language-code-mapping.d.ts +1 -1
  89. package/dist/src/language-code-handler/language-code-mapping.js +562 -562
  90. package/dist/src/mediatype/mediatype-config.d.ts +3 -3
  91. package/dist/src/mediatype/mediatype-config.js +85 -85
  92. package/dist/src/models.d.ts +103 -102
  93. package/dist/src/models.js +117 -117
  94. package/dist/src/models.js.map +1 -1
  95. package/dist/src/restoration-state-handler.d.ts +46 -45
  96. package/dist/src/restoration-state-handler.js +230 -220
  97. package/dist/src/restoration-state-handler.js.map +1 -1
  98. package/dist/src/sort-filter-bar/alpha-bar.d.ts +9 -9
  99. package/dist/src/sort-filter-bar/alpha-bar.js +41 -41
  100. package/dist/src/sort-filter-bar/img/compact.d.ts +1 -1
  101. package/dist/src/sort-filter-bar/img/compact.js +2 -2
  102. package/dist/src/sort-filter-bar/img/list.d.ts +1 -1
  103. package/dist/src/sort-filter-bar/img/list.js +2 -2
  104. package/dist/src/sort-filter-bar/img/sort-triangle.d.ts +1 -1
  105. package/dist/src/sort-filter-bar/img/sort-triangle.js +2 -2
  106. package/dist/src/sort-filter-bar/img/tile.d.ts +1 -1
  107. package/dist/src/sort-filter-bar/img/tile.js +2 -2
  108. package/dist/src/sort-filter-bar/sort-filter-bar.d.ts +107 -107
  109. package/dist/src/sort-filter-bar/sort-filter-bar.js +423 -423
  110. package/dist/src/styles/item-image-styles.d.ts +8 -8
  111. package/dist/src/styles/item-image-styles.js +9 -9
  112. package/dist/src/tiles/collection-browser-loading-tile.d.ts +5 -5
  113. package/dist/src/tiles/collection-browser-loading-tile.js +15 -15
  114. package/dist/src/tiles/grid/account-tile.d.ts +8 -8
  115. package/dist/src/tiles/grid/account-tile.js +20 -20
  116. package/dist/src/tiles/grid/collection-tile.d.ts +7 -7
  117. package/dist/src/tiles/grid/collection-tile.js +23 -23
  118. package/dist/src/tiles/grid/item-tile.d.ts +24 -24
  119. package/dist/src/tiles/grid/item-tile.js +87 -87
  120. package/dist/src/tiles/grid/tile-stats.d.ts +10 -10
  121. package/dist/src/tiles/grid/tile-stats.js +46 -40
  122. package/dist/src/tiles/grid/tile-stats.js.map +1 -1
  123. package/dist/src/tiles/image-block.d.ts +17 -17
  124. package/dist/src/tiles/image-block.js +69 -69
  125. package/dist/src/tiles/item-image.d.ts +31 -31
  126. package/dist/src/tiles/item-image.js +103 -103
  127. package/dist/src/tiles/list/account-label.d.ts +1 -1
  128. package/dist/src/tiles/list/account-label.js +6 -6
  129. package/dist/src/tiles/list/date-label.d.ts +1 -1
  130. package/dist/src/tiles/list/date-label.js +12 -12
  131. package/dist/src/tiles/list/tile-list-compact-header.d.ts +12 -12
  132. package/dist/src/tiles/list/tile-list-compact-header.js +41 -41
  133. package/dist/src/tiles/list/tile-list-compact.d.ts +21 -20
  134. package/dist/src/tiles/list/tile-list-compact.js +94 -90
  135. package/dist/src/tiles/list/tile-list-compact.js.map +1 -1
  136. package/dist/src/tiles/list/tile-list.d.ts +50 -50
  137. package/dist/src/tiles/list/tile-list.js +271 -268
  138. package/dist/src/tiles/list/tile-list.js.map +1 -1
  139. package/dist/src/tiles/mediatype-icon.d.ts +9 -9
  140. package/dist/src/tiles/mediatype-icon.js +49 -47
  141. package/dist/src/tiles/mediatype-icon.js.map +1 -1
  142. package/dist/src/tiles/overlay/icon-overlay.d.ts +7 -7
  143. package/dist/src/tiles/overlay/icon-overlay.js +30 -30
  144. package/dist/src/tiles/overlay/text-overlay.d.ts +8 -8
  145. package/dist/src/tiles/overlay/text-overlay.js +31 -31
  146. package/dist/src/tiles/text-snippet-block.d.ts +29 -29
  147. package/dist/src/tiles/text-snippet-block.js +81 -81
  148. package/dist/src/tiles/tile-dispatcher.d.ts +36 -36
  149. package/dist/src/tiles/tile-dispatcher.js +128 -128
  150. package/dist/src/utils/analytics-events.d.ts +22 -22
  151. package/dist/src/utils/analytics-events.js +24 -24
  152. package/dist/src/utils/format-count.d.ts +7 -7
  153. package/dist/src/utils/format-count.js +76 -76
  154. package/dist/src/utils/format-date.d.ts +2 -2
  155. package/dist/src/utils/format-date.js +23 -23
  156. package/dist/test/collection-browser.test.d.ts +1 -1
  157. package/dist/test/collection-browser.test.js +481 -415
  158. package/dist/test/collection-browser.test.js.map +1 -1
  159. package/dist/test/collection-facets/facets-template.test.d.ts +1 -1
  160. package/dist/test/collection-facets/facets-template.test.js +62 -62
  161. package/dist/test/collection-facets/facets-template.test.js.map +1 -1
  162. package/dist/test/collection-facets/more-facets-content.test.d.ts +1 -1
  163. package/dist/test/collection-facets/more-facets-content.test.js +114 -114
  164. package/dist/test/collection-facets/more-facets-pagination.test.d.ts +1 -1
  165. package/dist/test/collection-facets/more-facets-pagination.test.js +117 -117
  166. package/dist/test/collection-facets.test.d.ts +2 -2
  167. package/dist/test/collection-facets.test.js +498 -498
  168. package/dist/test/empty-placeholder.test.d.ts +1 -1
  169. package/dist/test/empty-placeholder.test.js +33 -33
  170. package/dist/test/icon-overlay.test.d.ts +1 -1
  171. package/dist/test/icon-overlay.test.js +24 -24
  172. package/dist/test/image-block.test.d.ts +1 -1
  173. package/dist/test/image-block.test.js +48 -48
  174. package/dist/test/item-image.test.d.ts +1 -1
  175. package/dist/test/item-image.test.js +56 -56
  176. package/dist/test/mediatype-config.test.d.ts +1 -1
  177. package/dist/test/mediatype-config.test.js +16 -16
  178. package/dist/test/mocks/mock-analytics-handler.d.ts +10 -10
  179. package/dist/test/mocks/mock-analytics-handler.js +15 -15
  180. package/dist/test/mocks/mock-collection-name-cache.d.ts +7 -7
  181. package/dist/test/mocks/mock-collection-name-cache.js +13 -13
  182. package/dist/test/mocks/mock-search-responses.d.ts +8 -8
  183. package/dist/test/mocks/mock-search-responses.js +198 -198
  184. package/dist/test/mocks/mock-search-responses.js.map +1 -1
  185. package/dist/test/mocks/mock-search-service.d.ts +13 -13
  186. package/dist/test/mocks/mock-search-service.js +32 -32
  187. package/dist/test/mocks/mock-search-service.js.map +1 -1
  188. package/dist/test/restoration-state-handler.test.d.ts +1 -1
  189. package/dist/test/restoration-state-handler.test.js +126 -117
  190. package/dist/test/restoration-state-handler.test.js.map +1 -1
  191. package/dist/test/sort-filter-bar/sort-filter-bar.test.d.ts +1 -1
  192. package/dist/test/sort-filter-bar/sort-filter-bar.test.js +113 -113
  193. package/dist/test/text-overlay.test.d.ts +1 -1
  194. package/dist/test/text-overlay.test.js +41 -41
  195. package/dist/test/text-snippet-block.test.d.ts +1 -1
  196. package/dist/test/text-snippet-block.test.js +57 -57
  197. package/dist/test/tile-stats.test.d.ts +1 -1
  198. package/dist/test/tile-stats.test.js +33 -33
  199. package/dist/test/tiles/grid/item-tile.test.d.ts +1 -1
  200. package/dist/test/tiles/grid/item-tile.test.js +107 -107
  201. package/dist/test/tiles/list/tile-list-compact.test.d.ts +1 -1
  202. package/dist/test/tiles/list/tile-list-compact.test.js +125 -26
  203. package/dist/test/tiles/list/tile-list-compact.test.js.map +1 -1
  204. package/dist/test/tiles/list/tile-list.test.d.ts +1 -1
  205. package/dist/test/tiles/list/tile-list.test.js +79 -47
  206. package/dist/test/tiles/list/tile-list.test.js.map +1 -1
  207. package/dist/test/utils/format-count.test.d.ts +1 -1
  208. package/dist/test/utils/format-count.test.js +23 -23
  209. package/dist/test/utils/format-date.test.d.ts +1 -1
  210. package/dist/test/utils/format-date.test.js +17 -17
  211. package/index.html +24 -24
  212. package/local.archive.org.cert +86 -86
  213. package/local.archive.org.key +27 -27
  214. package/package.json +115 -115
  215. package/renovate.json +6 -6
  216. package/src/app-root.ts +104 -55
  217. package/src/collection-browser.ts +1503 -1488
  218. package/src/collection-facets/facet-tombstone-row.ts +40 -40
  219. package/src/collection-facets/facets-template.ts +5 -3
  220. package/src/collection-facets.ts +635 -635
  221. package/src/models.ts +1 -0
  222. package/src/restoration-state-handler.ts +19 -1
  223. package/src/tiles/grid/tile-stats.ts +18 -5
  224. package/src/tiles/list/tile-list-compact.ts +7 -3
  225. package/src/tiles/list/tile-list.ts +6 -1
  226. package/src/tiles/mediatype-icon.ts +2 -0
  227. package/test/collection-browser.test.ts +679 -599
  228. package/test/collection-facets/facets-template.test.ts +5 -3
  229. package/test/mocks/mock-search-responses.ts +226 -226
  230. package/test/mocks/mock-search-service.ts +61 -61
  231. package/test/restoration-state-handler.test.ts +12 -0
  232. package/test/tiles/list/tile-list-compact.test.ts +110 -0
  233. package/test/tiles/list/tile-list.test.ts +36 -0
  234. package/tsconfig.json +21 -21
  235. package/web-dev-server.config.mjs +30 -30
  236. package/web-test-runner.config.mjs +41 -41
@@ -1,503 +1,503 @@
1
- /* eslint-disable import/no-duplicates */
2
- import { expect, fixture } from '@open-wc/testing';
3
- import sinon from 'sinon';
4
- import { html } from 'lit';
5
- import { Aggregation } from '@internetarchive/search-service';
6
- import { ModalManager, } from '@internetarchive/modal-manager';
7
- import '@internetarchive/modal-manager';
8
- import '../src/collection-facets';
9
- import { LanguageCodeHandler, } from '../src/language-code-handler/language-code-handler';
10
- import { MockAnalyticsHandler } from './mocks/mock-analytics-handler';
11
- describe('Collection Facets', () => {
12
- it('has loader', async () => {
13
- var _a, _b, _c, _d;
14
- const el = await fixture(html `<collection-facets ?facetsLoading=${true}></collection-facets>`);
15
- expect((_b = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('#container')) === null || _b === void 0 ? void 0 : _b.classList.contains('loading')).to.be.true;
16
- el.facetsLoading = false;
17
- await el.updateComplete;
18
- expect((_d = (_c = el.shadowRoot) === null || _c === void 0 ? void 0 : _c.querySelector('#container')) === null || _d === void 0 ? void 0 : _d.classList.contains('loading')).to.be.false;
19
- });
20
- it('renders aggregations as facets', async () => {
21
- var _a, _b, _c, _d, _e;
22
- const el = await fixture(html `<collection-facets></collection-facets>`);
23
- const aggs = {
24
- subject: new Aggregation({
25
- buckets: [
26
- {
27
- key: 'foo',
28
- doc_count: 5,
29
- },
30
- ],
31
- }),
32
- };
33
- el.aggregations = aggs;
34
- await el.updateComplete;
35
- const facetGroups = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll('.facet-group');
36
- expect(facetGroups === null || facetGroups === void 0 ? void 0 : facetGroups.length).to.equal(1);
37
- const titleFacetGroup = facetGroups === null || facetGroups === void 0 ? void 0 : facetGroups[0];
38
- const facetGroupHeader = titleFacetGroup === null || titleFacetGroup === void 0 ? void 0 : titleFacetGroup.querySelector('h1');
39
- expect((_b = facetGroupHeader === null || facetGroupHeader === void 0 ? void 0 : facetGroupHeader.textContent) === null || _b === void 0 ? void 0 : _b.trim()).to.equal('Subject');
40
- const titleFacetRow = (_d = (_c = titleFacetGroup === null || titleFacetGroup === void 0 ? void 0 : titleFacetGroup.querySelector('facets-template')) === null || _c === void 0 ? void 0 : _c.shadowRoot) === null || _d === void 0 ? void 0 : _d.querySelector('.facet-row');
41
- expect((_e = titleFacetRow === null || titleFacetRow === void 0 ? void 0 : titleFacetRow.textContent) === null || _e === void 0 ? void 0 : _e.trim()).to.satisfy((text) => /^foo\s*5$/.test(text));
42
- });
43
- it('renders multiple aggregation types', async () => {
44
- var _a;
45
- const el = await fixture(html `<collection-facets></collection-facets>`);
46
- const aggs = {
47
- subject: new Aggregation({
48
- buckets: [
49
- {
50
- key: 'foo',
51
- doc_count: 5,
52
- },
53
- ],
54
- }),
55
- mediatype: new Aggregation({
56
- buckets: [
57
- {
58
- key: 'bar',
59
- doc_count: 10,
60
- },
61
- ],
62
- }),
63
- };
64
- el.aggregations = aggs;
65
- await el.updateComplete;
66
- const facetGroups = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll('.facet-group');
67
- expect(facetGroups === null || facetGroups === void 0 ? void 0 : facetGroups.length).to.equal(2);
68
- });
69
- it('renders collection facets as links', async () => {
70
- var _a, _b, _c, _d;
71
- const el = await fixture(html `<collection-facets></collection-facets>`);
72
- const aggs = {
73
- collection: new Aggregation({
74
- buckets: [
75
- {
76
- key: 'foo',
77
- doc_count: 5,
78
- },
79
- ],
80
- }),
81
- };
82
- el.aggregations = aggs;
83
- await el.updateComplete;
84
- const collectionName = (_c = (_b = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('facets-template')) === null || _b === void 0 ? void 0 : _b.shadowRoot) === null || _c === void 0 ? void 0 : _c.querySelector('async-collection-name');
85
- expect(collectionName === null || collectionName === void 0 ? void 0 : collectionName.parentElement).to.be.instanceOf(HTMLAnchorElement);
86
- expect((_d = collectionName === null || collectionName === void 0 ? void 0 : collectionName.parentElement) === null || _d === void 0 ? void 0 : _d.getAttribute('href')).to.equal('/details/foo');
87
- });
88
- it('renders non-collection facets without links', async () => {
89
- var _a, _b, _c;
90
- const el = await fixture(html `<collection-facets></collection-facets>`);
91
- const aggs = {
92
- subject: new Aggregation({
93
- buckets: [
94
- {
95
- key: 'foo',
96
- doc_count: 5,
97
- },
98
- ],
99
- }),
100
- };
101
- el.aggregations = aggs;
102
- await el.updateComplete;
103
- const collectionName = (_c = (_b = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('facets-template')) === null || _b === void 0 ? void 0 : _b.shadowRoot) === null || _c === void 0 ? void 0 : _c.querySelector('async-collection-name');
104
- expect(collectionName === null || collectionName === void 0 ? void 0 : collectionName.parentElement).to.not.be.instanceOf(HTMLAnchorElement);
105
- });
106
- it('does not render suppressed collection facets', async () => {
107
- var _a, _b, _c;
108
- const el = await fixture(html `<collection-facets></collection-facets>`);
109
- const aggs = {
110
- collection: new Aggregation({
111
- buckets: [
112
- {
113
- key: 'deemphasize',
114
- doc_count: 5,
115
- },
116
- {
117
- key: 'community',
118
- doc_count: 5,
119
- },
120
- {
121
- key: 'foo',
122
- doc_count: 5,
123
- },
124
- ],
125
- }),
126
- };
127
- el.aggregations = aggs;
128
- await el.updateComplete;
129
- const collectionFacets = (_c = (_b = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('facets-template')) === null || _b === void 0 ? void 0 : _b.shadowRoot) === null || _c === void 0 ? void 0 : _c.querySelectorAll('.facet-row');
130
- expect(collectionFacets === null || collectionFacets === void 0 ? void 0 : collectionFacets.length).to.equal(1);
131
- // The first (and only) collection link should be for 'foo'
132
- const collectionLink = collectionFacets === null || collectionFacets === void 0 ? void 0 : collectionFacets.item(0).querySelector(`a[href='/details/foo']`);
133
- expect(collectionLink).to.exist;
134
- });
135
- it('renders language facets with their human-readable names', async () => {
136
- var _a, _b, _c;
137
- const el = await fixture(html `<collection-facets></collection-facets>`);
138
- const languageCodeHandler = new LanguageCodeHandler();
139
- const aggs = {
140
- language: new Aggregation({
141
- buckets: [
142
- {
143
- key: 'English',
144
- doc_count: 3,
145
- },
146
- ],
147
- }),
148
- };
149
- el.languageCodeHandler = languageCodeHandler;
150
- el.aggregations = aggs;
151
- await el.updateComplete;
152
- const facetsTemplate = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('facets-template');
153
- const languageTitle = (_b = facetsTemplate === null || facetsTemplate === void 0 ? void 0 : facetsTemplate.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('.facet-title');
154
- expect((_c = languageTitle === null || languageTitle === void 0 ? void 0 : languageTitle.textContent) === null || _c === void 0 ? void 0 : _c.trim()).to.equal('English');
155
- });
156
- it('renders selected/negative language facets with human-readable names', async () => {
157
- var _a, _b, _c;
158
- const el = await fixture(html `<collection-facets></collection-facets>`);
159
- const languageCodeHandler = new LanguageCodeHandler();
160
- const selectedFacets = {
161
- subject: {},
162
- lending: {},
163
- mediatype: {},
164
- language: {
165
- en: {
166
- key: 'en',
167
- count: 5,
168
- state: 'selected',
169
- },
170
- },
171
- creator: {},
172
- collection: {},
173
- year: {},
174
- };
175
- el.languageCodeHandler = languageCodeHandler;
176
- el.selectedFacets = selectedFacets;
177
- await el.updateComplete;
178
- const facetsTemplate = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('facets-template');
179
- const languageTitle = (_b = facetsTemplate === null || facetsTemplate === void 0 ? void 0 : facetsTemplate.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('.facet-title');
180
- expect((_c = languageTitle === null || languageTitle === void 0 ? void 0 : languageTitle.textContent) === null || _c === void 0 ? void 0 : _c.trim()).to.equal('English');
181
- });
182
- it('renders lending facets with human-readable names', async () => {
183
- var _a, _b, _c, _d, _e;
184
- const el = await fixture(html `<collection-facets></collection-facets>`);
185
- const aggs = {
186
- lending: new Aggregation({
187
- buckets: [
188
- {
189
- key: 'is_lendable',
190
- doc_count: 3,
191
- },
192
- {
193
- key: 'available_to_borrow',
194
- doc_count: 2,
195
- },
196
- {
197
- key: 'is_readable',
198
- doc_count: 1,
199
- },
200
- ],
201
- }),
202
- };
203
- el.aggregations = aggs;
204
- await el.updateComplete;
205
- const facetsTemplate = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('facets-template');
206
- const lendingTitles = (_b = facetsTemplate === null || facetsTemplate === void 0 ? void 0 : facetsTemplate.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelectorAll('.facet-title');
207
- expect(lendingTitles === null || lendingTitles === void 0 ? void 0 : lendingTitles.length).to.equal(3);
208
- expect((_c = lendingTitles === null || lendingTitles === void 0 ? void 0 : lendingTitles.item(0).textContent) === null || _c === void 0 ? void 0 : _c.trim()).to.equal('Lending Library');
209
- expect((_d = lendingTitles === null || lendingTitles === void 0 ? void 0 : lendingTitles.item(1).textContent) === null || _d === void 0 ? void 0 : _d.trim()).to.equal('Borrow 14 Days');
210
- expect((_e = lendingTitles === null || lendingTitles === void 0 ? void 0 : lendingTitles.item(2).textContent) === null || _e === void 0 ? void 0 : _e.trim()).to.equal('Always Available');
211
- });
212
- it('renders selected/negative lending facets with human-readable names', async () => {
213
- var _a, _b, _c, _d, _e;
214
- const el = await fixture(html `<collection-facets></collection-facets>`);
215
- const selectedFacets = {
216
- subject: {},
217
- lending: {
218
- is_lendable: {
219
- key: 'is_lendable',
220
- count: 5,
221
- state: 'selected',
222
- },
223
- available_to_borrow: {
224
- key: 'available_to_borrow',
225
- count: 4,
226
- state: 'selected',
227
- },
228
- is_readable: {
229
- key: 'is_readable',
230
- count: 3,
231
- state: 'hidden',
232
- },
233
- },
234
- mediatype: {},
235
- language: {},
236
- creator: {},
237
- collection: {},
238
- year: {},
239
- };
240
- el.selectedFacets = selectedFacets;
241
- await el.updateComplete;
242
- const facetsTemplate = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('facets-template');
243
- const lendingTitles = (_b = facetsTemplate === null || facetsTemplate === void 0 ? void 0 : facetsTemplate.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelectorAll('.facet-title');
244
- expect(lendingTitles === null || lendingTitles === void 0 ? void 0 : lendingTitles.length).to.equal(3);
245
- expect((_c = lendingTitles === null || lendingTitles === void 0 ? void 0 : lendingTitles.item(0).textContent) === null || _c === void 0 ? void 0 : _c.trim()).to.equal('Lending Library');
246
- expect((_d = lendingTitles === null || lendingTitles === void 0 ? void 0 : lendingTitles.item(1).textContent) === null || _d === void 0 ? void 0 : _d.trim()).to.equal('Borrow 14 Days');
247
- expect((_e = lendingTitles === null || lendingTitles === void 0 ? void 0 : lendingTitles.item(2).textContent) === null || _e === void 0 ? void 0 : _e.trim()).to.equal('Always Available');
248
- });
249
- it('only renders lending facets for is_lendable, available_to_borrow, and is_readable', async () => {
250
- var _a, _b, _c, _d, _e;
251
- const el = await fixture(html `<collection-facets></collection-facets>`);
252
- const aggs = {
253
- lending: new Aggregation({
254
- buckets: [
255
- {
256
- key: 'is_lendable',
257
- doc_count: 5,
258
- },
259
- {
260
- key: 'is_borrowable',
261
- doc_count: 4,
262
- },
263
- {
264
- key: 'available_to_borrow',
265
- doc_count: 5,
266
- },
267
- {
268
- key: 'is_browsable',
269
- doc_count: 4,
270
- },
271
- {
272
- key: 'available_to_browse',
273
- doc_count: 5,
274
- },
275
- {
276
- key: 'is_readable',
277
- doc_count: 4,
278
- },
279
- {
280
- key: 'available_to_waitlist',
281
- doc_count: 5,
282
- },
283
- ],
284
- }),
285
- };
286
- el.aggregations = aggs;
287
- await el.updateComplete;
288
- const facetsTemplate = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('facets-template');
289
- const lendingTitles = (_b = facetsTemplate === null || facetsTemplate === void 0 ? void 0 : facetsTemplate.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelectorAll('.facet-title');
290
- expect(lendingTitles === null || lendingTitles === void 0 ? void 0 : lendingTitles.length).to.equal(3);
291
- expect((_c = lendingTitles === null || lendingTitles === void 0 ? void 0 : lendingTitles.item(0).textContent) === null || _c === void 0 ? void 0 : _c.trim()).to.equal('Lending Library');
292
- expect((_d = lendingTitles === null || lendingTitles === void 0 ? void 0 : lendingTitles.item(1).textContent) === null || _d === void 0 ? void 0 : _d.trim()).to.equal('Borrow 14 Days');
293
- expect((_e = lendingTitles === null || lendingTitles === void 0 ? void 0 : lendingTitles.item(2).textContent) === null || _e === void 0 ? void 0 : _e.trim()).to.equal('Always Available');
294
- });
295
- it('does not render a More... link for lending facets', async () => {
296
- var _a;
297
- const el = await fixture(html `<collection-facets></collection-facets>`);
298
- const aggs = {
299
- lending: new Aggregation({
300
- buckets: [
301
- {
302
- key: 'is_lendable',
303
- doc_count: 5,
304
- },
305
- {
306
- key: 'is_borrowable',
307
- doc_count: 4,
308
- },
309
- {
310
- key: 'available_to_borrow',
311
- doc_count: 5,
312
- },
313
- {
314
- key: 'is_browsable',
315
- doc_count: 4,
316
- },
317
- {
318
- key: 'available_to_browse',
319
- doc_count: 5,
320
- },
321
- {
322
- key: 'is_readable',
323
- doc_count: 4,
324
- },
325
- {
326
- key: 'available_to_waitlist',
327
- doc_count: 5,
328
- },
329
- ],
330
- }),
331
- };
332
- el.aggregations = aggs;
333
- await el.updateComplete;
334
- const moreLink = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('.more-link');
335
- expect(moreLink).not.to.exist;
336
- });
337
- describe('More Facets', () => {
338
- it('Does not render < allowedFacetCount', async () => {
339
- var _a;
340
- const el = await fixture(html `<collection-facets></collection-facets>`);
341
- const aggs = {
342
- subject: new Aggregation({
343
- buckets: [
344
- {
345
- key: 'foo',
346
- doc_count: 5,
347
- },
348
- ],
349
- }),
350
- };
351
- el.aggregations = aggs;
352
- await el.updateComplete;
353
- const moreLink = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('.more-link');
354
- expect(moreLink).to.be.null;
355
- });
356
- it('renders sorting icons', async () => {
357
- var _a;
358
- const el = await fixture(html `<collection-facets></collection-facets>`);
359
- const aggs = {
360
- subject: new Aggregation({
361
- buckets: [
362
- {
363
- key: 'foo',
364
- doc_count: 5,
365
- },
366
- ],
367
- }),
368
- };
369
- el.aggregations = aggs;
370
- await el.updateComplete;
371
- const sortingIcon = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('.sorting-icon');
372
- expect(sortingIcon).to.exist;
373
- });
374
- it('does not render sorting icon for lending facets', async () => {
375
- var _a;
376
- const el = await fixture(html `<collection-facets></collection-facets>`);
377
- const aggs = {
378
- lending: new Aggregation({
379
- buckets: [
380
- {
381
- key: 'is_readable',
382
- doc_count: 5,
383
- },
384
- ],
385
- }),
386
- };
387
- el.aggregations = aggs;
388
- await el.updateComplete;
389
- const sortingIcon = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('.sorting-icon');
390
- expect(sortingIcon).not.to.exist;
391
- });
392
- it('Render More Facets', async () => {
393
- var _a, _b;
1
+ /* eslint-disable import/no-duplicates */
2
+ import { expect, fixture } from '@open-wc/testing';
3
+ import sinon from 'sinon';
4
+ import { html } from 'lit';
5
+ import { Aggregation } from '@internetarchive/search-service';
6
+ import { ModalManager, } from '@internetarchive/modal-manager';
7
+ import '@internetarchive/modal-manager';
8
+ import '../src/collection-facets';
9
+ import { LanguageCodeHandler, } from '../src/language-code-handler/language-code-handler';
10
+ import { MockAnalyticsHandler } from './mocks/mock-analytics-handler';
11
+ describe('Collection Facets', () => {
12
+ it('has loader', async () => {
13
+ var _a, _b, _c, _d;
14
+ const el = await fixture(html `<collection-facets ?facetsLoading=${true}></collection-facets>`);
15
+ expect((_b = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('#container')) === null || _b === void 0 ? void 0 : _b.classList.contains('loading')).to.be.true;
16
+ el.facetsLoading = false;
17
+ await el.updateComplete;
18
+ expect((_d = (_c = el.shadowRoot) === null || _c === void 0 ? void 0 : _c.querySelector('#container')) === null || _d === void 0 ? void 0 : _d.classList.contains('loading')).to.be.false;
19
+ });
20
+ it('renders aggregations as facets', async () => {
21
+ var _a, _b, _c, _d, _e;
22
+ const el = await fixture(html `<collection-facets></collection-facets>`);
23
+ const aggs = {
24
+ subject: new Aggregation({
25
+ buckets: [
26
+ {
27
+ key: 'foo',
28
+ doc_count: 5,
29
+ },
30
+ ],
31
+ }),
32
+ };
33
+ el.aggregations = aggs;
34
+ await el.updateComplete;
35
+ const facetGroups = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll('.facet-group');
36
+ expect(facetGroups === null || facetGroups === void 0 ? void 0 : facetGroups.length).to.equal(1);
37
+ const titleFacetGroup = facetGroups === null || facetGroups === void 0 ? void 0 : facetGroups[0];
38
+ const facetGroupHeader = titleFacetGroup === null || titleFacetGroup === void 0 ? void 0 : titleFacetGroup.querySelector('h1');
39
+ expect((_b = facetGroupHeader === null || facetGroupHeader === void 0 ? void 0 : facetGroupHeader.textContent) === null || _b === void 0 ? void 0 : _b.trim()).to.equal('Subject');
40
+ const titleFacetRow = (_d = (_c = titleFacetGroup === null || titleFacetGroup === void 0 ? void 0 : titleFacetGroup.querySelector('facets-template')) === null || _c === void 0 ? void 0 : _c.shadowRoot) === null || _d === void 0 ? void 0 : _d.querySelector('.facet-row');
41
+ expect((_e = titleFacetRow === null || titleFacetRow === void 0 ? void 0 : titleFacetRow.textContent) === null || _e === void 0 ? void 0 : _e.trim()).to.satisfy((text) => /^foo\s*5$/.test(text));
42
+ });
43
+ it('renders multiple aggregation types', async () => {
44
+ var _a;
45
+ const el = await fixture(html `<collection-facets></collection-facets>`);
46
+ const aggs = {
47
+ subject: new Aggregation({
48
+ buckets: [
49
+ {
50
+ key: 'foo',
51
+ doc_count: 5,
52
+ },
53
+ ],
54
+ }),
55
+ mediatype: new Aggregation({
56
+ buckets: [
57
+ {
58
+ key: 'bar',
59
+ doc_count: 10,
60
+ },
61
+ ],
62
+ }),
63
+ };
64
+ el.aggregations = aggs;
65
+ await el.updateComplete;
66
+ const facetGroups = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll('.facet-group');
67
+ expect(facetGroups === null || facetGroups === void 0 ? void 0 : facetGroups.length).to.equal(2);
68
+ });
69
+ it('renders collection facets as links', async () => {
70
+ var _a, _b, _c, _d;
71
+ const el = await fixture(html `<collection-facets></collection-facets>`);
72
+ const aggs = {
73
+ collection: new Aggregation({
74
+ buckets: [
75
+ {
76
+ key: 'foo',
77
+ doc_count: 5,
78
+ },
79
+ ],
80
+ }),
81
+ };
82
+ el.aggregations = aggs;
83
+ await el.updateComplete;
84
+ const collectionName = (_c = (_b = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('facets-template')) === null || _b === void 0 ? void 0 : _b.shadowRoot) === null || _c === void 0 ? void 0 : _c.querySelector('async-collection-name');
85
+ expect(collectionName === null || collectionName === void 0 ? void 0 : collectionName.parentElement).to.be.instanceOf(HTMLAnchorElement);
86
+ expect((_d = collectionName === null || collectionName === void 0 ? void 0 : collectionName.parentElement) === null || _d === void 0 ? void 0 : _d.getAttribute('href')).to.equal('/details/foo');
87
+ });
88
+ it('renders non-collection facets without links', async () => {
89
+ var _a, _b, _c;
90
+ const el = await fixture(html `<collection-facets></collection-facets>`);
91
+ const aggs = {
92
+ subject: new Aggregation({
93
+ buckets: [
94
+ {
95
+ key: 'foo',
96
+ doc_count: 5,
97
+ },
98
+ ],
99
+ }),
100
+ };
101
+ el.aggregations = aggs;
102
+ await el.updateComplete;
103
+ const collectionName = (_c = (_b = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('facets-template')) === null || _b === void 0 ? void 0 : _b.shadowRoot) === null || _c === void 0 ? void 0 : _c.querySelector('async-collection-name');
104
+ expect(collectionName === null || collectionName === void 0 ? void 0 : collectionName.parentElement).to.not.be.instanceOf(HTMLAnchorElement);
105
+ });
106
+ it('does not render suppressed collection facets', async () => {
107
+ var _a, _b, _c;
108
+ const el = await fixture(html `<collection-facets></collection-facets>`);
109
+ const aggs = {
110
+ collection: new Aggregation({
111
+ buckets: [
112
+ {
113
+ key: 'deemphasize',
114
+ doc_count: 5,
115
+ },
116
+ {
117
+ key: 'community',
118
+ doc_count: 5,
119
+ },
120
+ {
121
+ key: 'foo',
122
+ doc_count: 5,
123
+ },
124
+ ],
125
+ }),
126
+ };
127
+ el.aggregations = aggs;
128
+ await el.updateComplete;
129
+ const collectionFacets = (_c = (_b = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('facets-template')) === null || _b === void 0 ? void 0 : _b.shadowRoot) === null || _c === void 0 ? void 0 : _c.querySelectorAll('.facet-row');
130
+ expect(collectionFacets === null || collectionFacets === void 0 ? void 0 : collectionFacets.length).to.equal(1);
131
+ // The first (and only) collection link should be for 'foo'
132
+ const collectionLink = collectionFacets === null || collectionFacets === void 0 ? void 0 : collectionFacets.item(0).querySelector(`a[href='/details/foo']`);
133
+ expect(collectionLink).to.exist;
134
+ });
135
+ it('renders language facets with their human-readable names', async () => {
136
+ var _a, _b, _c;
137
+ const el = await fixture(html `<collection-facets></collection-facets>`);
138
+ const languageCodeHandler = new LanguageCodeHandler();
139
+ const aggs = {
140
+ language: new Aggregation({
141
+ buckets: [
142
+ {
143
+ key: 'English',
144
+ doc_count: 3,
145
+ },
146
+ ],
147
+ }),
148
+ };
149
+ el.languageCodeHandler = languageCodeHandler;
150
+ el.aggregations = aggs;
151
+ await el.updateComplete;
152
+ const facetsTemplate = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('facets-template');
153
+ const languageTitle = (_b = facetsTemplate === null || facetsTemplate === void 0 ? void 0 : facetsTemplate.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('.facet-title');
154
+ expect((_c = languageTitle === null || languageTitle === void 0 ? void 0 : languageTitle.textContent) === null || _c === void 0 ? void 0 : _c.trim()).to.equal('English');
155
+ });
156
+ it('renders selected/negative language facets with human-readable names', async () => {
157
+ var _a, _b, _c;
158
+ const el = await fixture(html `<collection-facets></collection-facets>`);
159
+ const languageCodeHandler = new LanguageCodeHandler();
160
+ const selectedFacets = {
161
+ subject: {},
162
+ lending: {},
163
+ mediatype: {},
164
+ language: {
165
+ en: {
166
+ key: 'en',
167
+ count: 5,
168
+ state: 'selected',
169
+ },
170
+ },
171
+ creator: {},
172
+ collection: {},
173
+ year: {},
174
+ };
175
+ el.languageCodeHandler = languageCodeHandler;
176
+ el.selectedFacets = selectedFacets;
177
+ await el.updateComplete;
178
+ const facetsTemplate = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('facets-template');
179
+ const languageTitle = (_b = facetsTemplate === null || facetsTemplate === void 0 ? void 0 : facetsTemplate.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('.facet-title');
180
+ expect((_c = languageTitle === null || languageTitle === void 0 ? void 0 : languageTitle.textContent) === null || _c === void 0 ? void 0 : _c.trim()).to.equal('English');
181
+ });
182
+ it('renders lending facets with human-readable names', async () => {
183
+ var _a, _b, _c, _d, _e;
184
+ const el = await fixture(html `<collection-facets></collection-facets>`);
185
+ const aggs = {
186
+ lending: new Aggregation({
187
+ buckets: [
188
+ {
189
+ key: 'is_lendable',
190
+ doc_count: 3,
191
+ },
192
+ {
193
+ key: 'available_to_borrow',
194
+ doc_count: 2,
195
+ },
196
+ {
197
+ key: 'is_readable',
198
+ doc_count: 1,
199
+ },
200
+ ],
201
+ }),
202
+ };
203
+ el.aggregations = aggs;
204
+ await el.updateComplete;
205
+ const facetsTemplate = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('facets-template');
206
+ const lendingTitles = (_b = facetsTemplate === null || facetsTemplate === void 0 ? void 0 : facetsTemplate.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelectorAll('.facet-title');
207
+ expect(lendingTitles === null || lendingTitles === void 0 ? void 0 : lendingTitles.length).to.equal(3);
208
+ expect((_c = lendingTitles === null || lendingTitles === void 0 ? void 0 : lendingTitles.item(0).textContent) === null || _c === void 0 ? void 0 : _c.trim()).to.equal('Lending Library');
209
+ expect((_d = lendingTitles === null || lendingTitles === void 0 ? void 0 : lendingTitles.item(1).textContent) === null || _d === void 0 ? void 0 : _d.trim()).to.equal('Borrow 14 Days');
210
+ expect((_e = lendingTitles === null || lendingTitles === void 0 ? void 0 : lendingTitles.item(2).textContent) === null || _e === void 0 ? void 0 : _e.trim()).to.equal('Always Available');
211
+ });
212
+ it('renders selected/negative lending facets with human-readable names', async () => {
213
+ var _a, _b, _c, _d, _e;
214
+ const el = await fixture(html `<collection-facets></collection-facets>`);
215
+ const selectedFacets = {
216
+ subject: {},
217
+ lending: {
218
+ is_lendable: {
219
+ key: 'is_lendable',
220
+ count: 5,
221
+ state: 'selected',
222
+ },
223
+ available_to_borrow: {
224
+ key: 'available_to_borrow',
225
+ count: 4,
226
+ state: 'selected',
227
+ },
228
+ is_readable: {
229
+ key: 'is_readable',
230
+ count: 3,
231
+ state: 'hidden',
232
+ },
233
+ },
234
+ mediatype: {},
235
+ language: {},
236
+ creator: {},
237
+ collection: {},
238
+ year: {},
239
+ };
240
+ el.selectedFacets = selectedFacets;
241
+ await el.updateComplete;
242
+ const facetsTemplate = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('facets-template');
243
+ const lendingTitles = (_b = facetsTemplate === null || facetsTemplate === void 0 ? void 0 : facetsTemplate.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelectorAll('.facet-title');
244
+ expect(lendingTitles === null || lendingTitles === void 0 ? void 0 : lendingTitles.length).to.equal(3);
245
+ expect((_c = lendingTitles === null || lendingTitles === void 0 ? void 0 : lendingTitles.item(0).textContent) === null || _c === void 0 ? void 0 : _c.trim()).to.equal('Lending Library');
246
+ expect((_d = lendingTitles === null || lendingTitles === void 0 ? void 0 : lendingTitles.item(1).textContent) === null || _d === void 0 ? void 0 : _d.trim()).to.equal('Borrow 14 Days');
247
+ expect((_e = lendingTitles === null || lendingTitles === void 0 ? void 0 : lendingTitles.item(2).textContent) === null || _e === void 0 ? void 0 : _e.trim()).to.equal('Always Available');
248
+ });
249
+ it('only renders lending facets for is_lendable, available_to_borrow, and is_readable', async () => {
250
+ var _a, _b, _c, _d, _e;
251
+ const el = await fixture(html `<collection-facets></collection-facets>`);
252
+ const aggs = {
253
+ lending: new Aggregation({
254
+ buckets: [
255
+ {
256
+ key: 'is_lendable',
257
+ doc_count: 5,
258
+ },
259
+ {
260
+ key: 'is_borrowable',
261
+ doc_count: 4,
262
+ },
263
+ {
264
+ key: 'available_to_borrow',
265
+ doc_count: 5,
266
+ },
267
+ {
268
+ key: 'is_browsable',
269
+ doc_count: 4,
270
+ },
271
+ {
272
+ key: 'available_to_browse',
273
+ doc_count: 5,
274
+ },
275
+ {
276
+ key: 'is_readable',
277
+ doc_count: 4,
278
+ },
279
+ {
280
+ key: 'available_to_waitlist',
281
+ doc_count: 5,
282
+ },
283
+ ],
284
+ }),
285
+ };
286
+ el.aggregations = aggs;
287
+ await el.updateComplete;
288
+ const facetsTemplate = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('facets-template');
289
+ const lendingTitles = (_b = facetsTemplate === null || facetsTemplate === void 0 ? void 0 : facetsTemplate.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelectorAll('.facet-title');
290
+ expect(lendingTitles === null || lendingTitles === void 0 ? void 0 : lendingTitles.length).to.equal(3);
291
+ expect((_c = lendingTitles === null || lendingTitles === void 0 ? void 0 : lendingTitles.item(0).textContent) === null || _c === void 0 ? void 0 : _c.trim()).to.equal('Lending Library');
292
+ expect((_d = lendingTitles === null || lendingTitles === void 0 ? void 0 : lendingTitles.item(1).textContent) === null || _d === void 0 ? void 0 : _d.trim()).to.equal('Borrow 14 Days');
293
+ expect((_e = lendingTitles === null || lendingTitles === void 0 ? void 0 : lendingTitles.item(2).textContent) === null || _e === void 0 ? void 0 : _e.trim()).to.equal('Always Available');
294
+ });
295
+ it('does not render a More... link for lending facets', async () => {
296
+ var _a;
297
+ const el = await fixture(html `<collection-facets></collection-facets>`);
298
+ const aggs = {
299
+ lending: new Aggregation({
300
+ buckets: [
301
+ {
302
+ key: 'is_lendable',
303
+ doc_count: 5,
304
+ },
305
+ {
306
+ key: 'is_borrowable',
307
+ doc_count: 4,
308
+ },
309
+ {
310
+ key: 'available_to_borrow',
311
+ doc_count: 5,
312
+ },
313
+ {
314
+ key: 'is_browsable',
315
+ doc_count: 4,
316
+ },
317
+ {
318
+ key: 'available_to_browse',
319
+ doc_count: 5,
320
+ },
321
+ {
322
+ key: 'is_readable',
323
+ doc_count: 4,
324
+ },
325
+ {
326
+ key: 'available_to_waitlist',
327
+ doc_count: 5,
328
+ },
329
+ ],
330
+ }),
331
+ };
332
+ el.aggregations = aggs;
333
+ await el.updateComplete;
334
+ const moreLink = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('.more-link');
335
+ expect(moreLink).not.to.exist;
336
+ });
337
+ describe('More Facets', () => {
338
+ it('Does not render < allowedFacetCount', async () => {
339
+ var _a;
340
+ const el = await fixture(html `<collection-facets></collection-facets>`);
341
+ const aggs = {
342
+ subject: new Aggregation({
343
+ buckets: [
344
+ {
345
+ key: 'foo',
346
+ doc_count: 5,
347
+ },
348
+ ],
349
+ }),
350
+ };
351
+ el.aggregations = aggs;
352
+ await el.updateComplete;
353
+ const moreLink = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('.more-link');
354
+ expect(moreLink).to.be.null;
355
+ });
356
+ it('renders sorting icons', async () => {
357
+ var _a;
358
+ const el = await fixture(html `<collection-facets></collection-facets>`);
359
+ const aggs = {
360
+ subject: new Aggregation({
361
+ buckets: [
362
+ {
363
+ key: 'foo',
364
+ doc_count: 5,
365
+ },
366
+ ],
367
+ }),
368
+ };
369
+ el.aggregations = aggs;
370
+ await el.updateComplete;
371
+ const sortingIcon = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('.sorting-icon');
372
+ expect(sortingIcon).to.exist;
373
+ });
374
+ it('does not render sorting icon for lending facets', async () => {
375
+ var _a;
376
+ const el = await fixture(html `<collection-facets></collection-facets>`);
377
+ const aggs = {
378
+ lending: new Aggregation({
379
+ buckets: [
380
+ {
381
+ key: 'is_readable',
382
+ doc_count: 5,
383
+ },
384
+ ],
385
+ }),
386
+ };
387
+ el.aggregations = aggs;
388
+ await el.updateComplete;
389
+ const sortingIcon = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('.sorting-icon');
390
+ expect(sortingIcon).not.to.exist;
391
+ });
392
+ it('Render More Facets', async () => {
393
+ var _a, _b;
394
394
  const el = await fixture(html `<collection-facets
395
395
  .modalManager=${new ModalManager()}
396
- ></collection-facets>`);
397
- const aggs = {
398
- subject: new Aggregation({
399
- buckets: [
400
- {
401
- key: 'foo',
402
- doc_count: 5,
403
- },
404
- {
405
- key: 'fi',
406
- doc_count: 5,
407
- },
408
- {
409
- key: 'fum',
410
- doc_count: 5,
411
- },
412
- {
413
- key: 'flee',
414
- doc_count: 5,
415
- },
416
- {
417
- key: 'wheee',
418
- doc_count: 5,
419
- },
420
- {
421
- key: 'whooo',
422
- doc_count: 5,
423
- },
424
- {
425
- key: 'boop',
426
- doc_count: 5,
427
- },
428
- ],
429
- }),
430
- };
431
- el.aggregations = aggs;
432
- await el.updateComplete;
433
- let eventCaught = false;
434
- let eventFacet = '';
435
- el.addEventListener('showMoreFacets', e => {
436
- eventFacet = e.detail;
437
- eventCaught = true;
438
- });
439
- const moreLink = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('.more-link');
440
- expect(moreLink).to.exist; // has link
441
- const showModalSpy = sinon.spy(el.modalManager, 'showModal');
442
- // let's pop up modal
443
- moreLink === null || moreLink === void 0 ? void 0 : moreLink.click();
444
- await el.updateComplete;
445
- expect(showModalSpy.callCount).to.equal(1);
446
- expect((_b = el.modalManager) === null || _b === void 0 ? void 0 : _b.classList.contains('more-search-facets')).to.be
447
- .true;
448
- expect(eventCaught).to.be.true;
449
- expect(eventFacet).to.equal('subject');
450
- });
451
- });
452
- it('fire analytics on more link', async () => {
453
- var _a;
454
- const mockAnalyticsHandler = new MockAnalyticsHandler();
396
+ ></collection-facets>`);
397
+ const aggs = {
398
+ subject: new Aggregation({
399
+ buckets: [
400
+ {
401
+ key: 'foo',
402
+ doc_count: 5,
403
+ },
404
+ {
405
+ key: 'fi',
406
+ doc_count: 5,
407
+ },
408
+ {
409
+ key: 'fum',
410
+ doc_count: 5,
411
+ },
412
+ {
413
+ key: 'flee',
414
+ doc_count: 5,
415
+ },
416
+ {
417
+ key: 'wheee',
418
+ doc_count: 5,
419
+ },
420
+ {
421
+ key: 'whooo',
422
+ doc_count: 5,
423
+ },
424
+ {
425
+ key: 'boop',
426
+ doc_count: 5,
427
+ },
428
+ ],
429
+ }),
430
+ };
431
+ el.aggregations = aggs;
432
+ await el.updateComplete;
433
+ let eventCaught = false;
434
+ let eventFacet = '';
435
+ el.addEventListener('showMoreFacets', e => {
436
+ eventFacet = e.detail;
437
+ eventCaught = true;
438
+ });
439
+ const moreLink = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('.more-link');
440
+ expect(moreLink).to.exist; // has link
441
+ const showModalSpy = sinon.spy(el.modalManager, 'showModal');
442
+ // let's pop up modal
443
+ moreLink === null || moreLink === void 0 ? void 0 : moreLink.click();
444
+ await el.updateComplete;
445
+ expect(showModalSpy.callCount).to.equal(1);
446
+ expect((_b = el.modalManager) === null || _b === void 0 ? void 0 : _b.classList.contains('more-search-facets')).to.be
447
+ .true;
448
+ expect(eventCaught).to.be.true;
449
+ expect(eventFacet).to.equal('subject');
450
+ });
451
+ });
452
+ it('fire analytics on more link', async () => {
453
+ var _a;
454
+ const mockAnalyticsHandler = new MockAnalyticsHandler();
455
455
  const el = await fixture(html `<collection-facets
456
456
  .analyticsHandler=${mockAnalyticsHandler}
457
- ></collection-facets>`);
458
- const aggs = {
459
- subject: new Aggregation({
460
- buckets: [
461
- {
462
- key: 'foo',
463
- doc_count: 5,
464
- },
465
- {
466
- key: 'fi',
467
- doc_count: 5,
468
- },
469
- {
470
- key: 'fum',
471
- doc_count: 5,
472
- },
473
- {
474
- key: 'flee',
475
- doc_count: 5,
476
- },
477
- {
478
- key: 'wheee',
479
- doc_count: 5,
480
- },
481
- {
482
- key: 'whooo',
483
- doc_count: 5,
484
- },
485
- {
486
- key: 'boop',
487
- doc_count: 5,
488
- },
489
- ],
490
- }),
491
- };
492
- el.aggregations = aggs;
493
- await el.updateComplete;
494
- const moreLink = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('.more-link');
495
- expect(moreLink).to.exist; // has link
496
- moreLink === null || moreLink === void 0 ? void 0 : moreLink.click();
497
- await el.updateComplete;
498
- expect(mockAnalyticsHandler.callCategory).to.equal('collection-browser');
499
- expect(mockAnalyticsHandler.callAction).to.equal('showMoreFacetsModal');
500
- expect(mockAnalyticsHandler.callLabel).to.equal('subject');
501
- });
502
- });
457
+ ></collection-facets>`);
458
+ const aggs = {
459
+ subject: new Aggregation({
460
+ buckets: [
461
+ {
462
+ key: 'foo',
463
+ doc_count: 5,
464
+ },
465
+ {
466
+ key: 'fi',
467
+ doc_count: 5,
468
+ },
469
+ {
470
+ key: 'fum',
471
+ doc_count: 5,
472
+ },
473
+ {
474
+ key: 'flee',
475
+ doc_count: 5,
476
+ },
477
+ {
478
+ key: 'wheee',
479
+ doc_count: 5,
480
+ },
481
+ {
482
+ key: 'whooo',
483
+ doc_count: 5,
484
+ },
485
+ {
486
+ key: 'boop',
487
+ doc_count: 5,
488
+ },
489
+ ],
490
+ }),
491
+ };
492
+ el.aggregations = aggs;
493
+ await el.updateComplete;
494
+ const moreLink = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('.more-link');
495
+ expect(moreLink).to.exist; // has link
496
+ moreLink === null || moreLink === void 0 ? void 0 : moreLink.click();
497
+ await el.updateComplete;
498
+ expect(mockAnalyticsHandler.callCategory).to.equal('collection-browser');
499
+ expect(mockAnalyticsHandler.callAction).to.equal('showMoreFacetsModal');
500
+ expect(mockAnalyticsHandler.callLabel).to.equal('subject');
501
+ });
502
+ });
503
503
  //# sourceMappingURL=collection-facets.test.js.map