@internetarchive/collection-browser 3.3.2 → 3.3.4-alpha-webdev7761.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.
Files changed (543) hide show
  1. package/.editorconfig +29 -29
  2. package/.github/workflows/ci.yml +27 -27
  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/.prettierignore +1 -1
  8. package/LICENSE +661 -661
  9. package/README.md +83 -83
  10. package/dist/index.d.ts +16 -0
  11. package/dist/index.js.map +1 -0
  12. package/dist/src/app-root.d.ts +105 -0
  13. package/dist/src/app-root.js +1076 -0
  14. package/dist/src/app-root.js.map +1 -0
  15. package/dist/src/assets/img/icons/arrow-left.d.ts +2 -0
  16. package/dist/src/assets/img/icons/arrow-left.js +10 -0
  17. package/dist/src/assets/img/icons/arrow-left.js.map +1 -0
  18. package/dist/src/assets/img/icons/arrow-right.d.ts +2 -0
  19. package/dist/src/assets/img/icons/arrow-right.js +10 -0
  20. package/dist/src/assets/img/icons/arrow-right.js.map +1 -0
  21. package/dist/src/assets/img/icons/chevron.d.ts +2 -0
  22. package/dist/src/assets/img/icons/chevron.js +4 -0
  23. package/dist/src/assets/img/icons/chevron.js.map +1 -0
  24. package/dist/src/assets/img/icons/close-circle-dark.d.ts +2 -0
  25. package/dist/src/assets/img/icons/close-circle-dark.js +5 -0
  26. package/dist/src/assets/img/icons/close-circle-dark.js.map +1 -0
  27. package/dist/src/assets/img/icons/contract.d.ts +2 -0
  28. package/dist/src/assets/img/icons/contract.js +9 -0
  29. package/dist/src/assets/img/icons/contract.js.map +1 -0
  30. package/dist/src/assets/img/icons/empty-query.d.ts +2 -0
  31. package/dist/src/assets/img/icons/empty-query.js +5 -0
  32. package/dist/src/assets/img/icons/empty-query.js.map +1 -0
  33. package/dist/src/assets/img/icons/expand.d.ts +2 -0
  34. package/dist/src/assets/img/icons/expand.js +9 -0
  35. package/dist/src/assets/img/icons/expand.js.map +1 -0
  36. package/dist/src/assets/img/icons/eye-closed.d.ts +2 -0
  37. package/dist/src/assets/img/icons/eye-closed.js +5 -0
  38. package/dist/src/assets/img/icons/eye-closed.js.map +1 -0
  39. package/dist/src/assets/img/icons/eye.d.ts +2 -0
  40. package/dist/src/assets/img/icons/eye.js +5 -0
  41. package/dist/src/assets/img/icons/eye.js.map +1 -0
  42. package/dist/src/assets/img/icons/favorite-filled.d.ts +1 -0
  43. package/dist/src/assets/img/icons/favorite-filled.js +10 -0
  44. package/dist/src/assets/img/icons/favorite-filled.js.map +1 -0
  45. package/dist/src/assets/img/icons/favorite-unfilled.d.ts +1 -0
  46. package/dist/src/assets/img/icons/favorite-unfilled.js +9 -0
  47. package/dist/src/assets/img/icons/favorite-unfilled.js.map +1 -0
  48. package/dist/src/assets/img/icons/filter.d.ts +2 -0
  49. package/dist/src/assets/img/icons/filter.js +10 -0
  50. package/dist/src/assets/img/icons/filter.js.map +1 -0
  51. package/dist/src/assets/img/icons/login-required.d.ts +1 -0
  52. package/dist/src/assets/img/icons/login-required.js +18 -0
  53. package/dist/src/assets/img/icons/login-required.js.map +1 -0
  54. package/dist/src/assets/img/icons/mediatype/account.d.ts +1 -0
  55. package/dist/src/assets/img/icons/mediatype/account.js +14 -0
  56. package/dist/src/assets/img/icons/mediatype/account.js.map +1 -0
  57. package/dist/src/assets/img/icons/mediatype/audio.d.ts +1 -0
  58. package/dist/src/assets/img/icons/mediatype/audio.js +14 -0
  59. package/dist/src/assets/img/icons/mediatype/audio.js.map +1 -0
  60. package/dist/src/assets/img/icons/mediatype/collection.d.ts +1 -0
  61. package/dist/src/assets/img/icons/mediatype/collection.js +12 -0
  62. package/dist/src/assets/img/icons/mediatype/collection.js.map +1 -0
  63. package/dist/src/assets/img/icons/mediatype/data.d.ts +1 -0
  64. package/dist/src/assets/img/icons/mediatype/data.js +15 -0
  65. package/dist/src/assets/img/icons/mediatype/data.js.map +1 -0
  66. package/dist/src/assets/img/icons/mediatype/etree.d.ts +1 -0
  67. package/dist/src/assets/img/icons/mediatype/etree.js +14 -0
  68. package/dist/src/assets/img/icons/mediatype/etree.js.map +1 -0
  69. package/dist/src/assets/img/icons/mediatype/film.d.ts +1 -0
  70. package/dist/src/assets/img/icons/mediatype/film.js +14 -0
  71. package/dist/src/assets/img/icons/mediatype/film.js.map +1 -0
  72. package/dist/src/assets/img/icons/mediatype/images.d.ts +1 -0
  73. package/dist/src/assets/img/icons/mediatype/images.js +13 -0
  74. package/dist/src/assets/img/icons/mediatype/images.js.map +1 -0
  75. package/dist/src/assets/img/icons/mediatype/radio.d.ts +1 -0
  76. package/dist/src/assets/img/icons/mediatype/radio.js +15 -0
  77. package/dist/src/assets/img/icons/mediatype/radio.js.map +1 -0
  78. package/dist/src/assets/img/icons/mediatype/search.d.ts +1 -0
  79. package/dist/src/assets/img/icons/mediatype/search.js +14 -0
  80. package/dist/src/assets/img/icons/mediatype/search.js.map +1 -0
  81. package/dist/src/assets/img/icons/mediatype/software.d.ts +1 -0
  82. package/dist/src/assets/img/icons/mediatype/software.js +13 -0
  83. package/dist/src/assets/img/icons/mediatype/software.js.map +1 -0
  84. package/dist/src/assets/img/icons/mediatype/texts.d.ts +1 -0
  85. package/dist/src/assets/img/icons/mediatype/texts.js +13 -0
  86. package/dist/src/assets/img/icons/mediatype/texts.js.map +1 -0
  87. package/dist/src/assets/img/icons/mediatype/tv-commercial.d.ts +1 -0
  88. package/dist/src/assets/img/icons/mediatype/tv-commercial.js +12 -0
  89. package/dist/src/assets/img/icons/mediatype/tv-commercial.js.map +1 -0
  90. package/dist/src/assets/img/icons/mediatype/tv-fact-check.d.ts +1 -0
  91. package/dist/src/assets/img/icons/mediatype/tv-fact-check.js +12 -0
  92. package/dist/src/assets/img/icons/mediatype/tv-fact-check.js.map +1 -0
  93. package/dist/src/assets/img/icons/mediatype/tv-quote.d.ts +1 -0
  94. package/dist/src/assets/img/icons/mediatype/tv-quote.js +12 -0
  95. package/dist/src/assets/img/icons/mediatype/tv-quote.js.map +1 -0
  96. package/dist/src/assets/img/icons/mediatype/tv.d.ts +1 -0
  97. package/dist/src/assets/img/icons/mediatype/tv.js +14 -0
  98. package/dist/src/assets/img/icons/mediatype/tv.js.map +1 -0
  99. package/dist/src/assets/img/icons/mediatype/video.d.ts +1 -0
  100. package/dist/src/assets/img/icons/mediatype/video.js +14 -0
  101. package/dist/src/assets/img/icons/mediatype/video.js.map +1 -0
  102. package/dist/src/assets/img/icons/mediatype/web.d.ts +1 -0
  103. package/dist/src/assets/img/icons/mediatype/web.js +13 -0
  104. package/dist/src/assets/img/icons/mediatype/web.js.map +1 -0
  105. package/dist/src/assets/img/icons/null-result.d.ts +2 -0
  106. package/dist/src/assets/img/icons/null-result.js +5 -0
  107. package/dist/src/assets/img/icons/null-result.js.map +1 -0
  108. package/dist/src/assets/img/icons/quote.d.ts +1 -0
  109. package/dist/src/assets/img/icons/quote.js +7 -0
  110. package/dist/src/assets/img/icons/quote.js.map +1 -0
  111. package/dist/src/assets/img/icons/restricted.d.ts +1 -0
  112. package/dist/src/assets/img/icons/restricted.js +13 -0
  113. package/dist/src/assets/img/icons/restricted.js.map +1 -0
  114. package/dist/src/assets/img/icons/reviews.d.ts +1 -0
  115. package/dist/src/assets/img/icons/reviews.js +11 -0
  116. package/dist/src/assets/img/icons/reviews.js.map +1 -0
  117. package/dist/src/assets/img/icons/upload.d.ts +1 -0
  118. package/dist/src/assets/img/icons/upload.js +12 -0
  119. package/dist/src/assets/img/icons/upload.js.map +1 -0
  120. package/dist/src/assets/img/icons/views.d.ts +1 -0
  121. package/dist/src/assets/img/icons/views.js +11 -0
  122. package/dist/src/assets/img/icons/views.js.map +1 -0
  123. package/dist/src/circular-activity-indicator.d.ts +5 -0
  124. package/dist/src/circular-activity-indicator.js +66 -0
  125. package/dist/src/circular-activity-indicator.js.map +1 -0
  126. package/dist/src/collection-browser.d.ts +692 -0
  127. package/dist/src/collection-browser.js +2669 -0
  128. package/dist/src/collection-browser.js.map +1 -0
  129. package/dist/src/collection-facets/facet-row.d.ts +30 -0
  130. package/dist/src/collection-facets/facet-row.js +266 -0
  131. package/dist/src/collection-facets/facet-row.js.map +1 -0
  132. package/dist/src/collection-facets/facet-tombstone-row.d.ts +5 -0
  133. package/dist/src/collection-facets/facet-tombstone-row.js +43 -0
  134. package/dist/src/collection-facets/facet-tombstone-row.js.map +1 -0
  135. package/dist/src/collection-facets/facets-template.d.ts +13 -0
  136. package/dist/src/collection-facets/facets-template.js +68 -0
  137. package/dist/src/collection-facets/facets-template.js.map +1 -0
  138. package/dist/src/collection-facets/models.d.ts +9 -0
  139. package/dist/src/collection-facets/models.js +10 -0
  140. package/dist/src/collection-facets/models.js.map +1 -0
  141. package/dist/src/collection-facets/more-facets-content.d.ts +109 -0
  142. package/dist/src/collection-facets/more-facets-content.js +547 -0
  143. package/dist/src/collection-facets/more-facets-content.js.map +1 -0
  144. package/dist/src/collection-facets/more-facets-pagination.d.ts +36 -0
  145. package/dist/src/collection-facets/more-facets-pagination.js +264 -0
  146. package/dist/src/collection-facets/more-facets-pagination.js.map +1 -0
  147. package/dist/src/collection-facets/smart-facets/dedupe.d.ts +10 -0
  148. package/dist/src/collection-facets/smart-facets/dedupe.js +35 -0
  149. package/dist/src/collection-facets/smart-facets/dedupe.js.map +1 -0
  150. package/dist/src/collection-facets/smart-facets/heuristics/browser-language/browser-language-heuristic.d.ts +5 -0
  151. package/dist/src/collection-facets/smart-facets/heuristics/browser-language/browser-language-heuristic.js +24 -0
  152. package/dist/src/collection-facets/smart-facets/heuristics/browser-language/browser-language-heuristic.js.map +1 -0
  153. package/dist/src/collection-facets/smart-facets/heuristics/index.d.ts +3 -0
  154. package/dist/src/collection-facets/smart-facets/heuristics/index.js +4 -0
  155. package/dist/src/collection-facets/smart-facets/heuristics/index.js.map +1 -0
  156. package/dist/src/collection-facets/smart-facets/heuristics/query-keywords/query-keywords-heuristic.d.ts +4 -0
  157. package/dist/src/collection-facets/smart-facets/heuristics/query-keywords/query-keywords-heuristic.js +14 -0
  158. package/dist/src/collection-facets/smart-facets/heuristics/query-keywords/query-keywords-heuristic.js.map +1 -0
  159. package/dist/src/collection-facets/smart-facets/heuristics/query-keywords/query-keywords-map.d.ts +6 -0
  160. package/dist/src/collection-facets/smart-facets/heuristics/query-keywords/query-keywords-map.js +68 -0
  161. package/dist/src/collection-facets/smart-facets/heuristics/query-keywords/query-keywords-map.js.map +1 -0
  162. package/dist/src/collection-facets/smart-facets/heuristics/wikidata/wikidata-entity-map.d.ts +9 -0
  163. package/dist/src/collection-facets/smart-facets/heuristics/wikidata/wikidata-entity-map.js +69 -0
  164. package/dist/src/collection-facets/smart-facets/heuristics/wikidata/wikidata-entity-map.js.map +1 -0
  165. package/dist/src/collection-facets/smart-facets/heuristics/wikidata/wikidata-heuristic.d.ts +21 -0
  166. package/dist/src/collection-facets/smart-facets/heuristics/wikidata/wikidata-heuristic.js +76 -0
  167. package/dist/src/collection-facets/smart-facets/heuristics/wikidata/wikidata-heuristic.js.map +1 -0
  168. package/dist/src/collection-facets/smart-facets/models.d.ts +30 -0
  169. package/dist/src/collection-facets/smart-facets/models.js +2 -0
  170. package/dist/src/collection-facets/smart-facets/models.js.map +1 -0
  171. package/dist/src/collection-facets/smart-facets/smart-facet-bar.d.ts +54 -0
  172. package/dist/src/collection-facets/smart-facets/smart-facet-bar.js +383 -0
  173. package/dist/src/collection-facets/smart-facets/smart-facet-bar.js.map +1 -0
  174. package/dist/src/collection-facets/smart-facets/smart-facet-button.d.ts +11 -0
  175. package/dist/src/collection-facets/smart-facets/smart-facet-button.js +133 -0
  176. package/dist/src/collection-facets/smart-facets/smart-facet-button.js.map +1 -0
  177. package/dist/src/collection-facets/smart-facets/smart-facet-dropdown.d.ts +28 -0
  178. package/dist/src/collection-facets/smart-facets/smart-facet-dropdown.js +172 -0
  179. package/dist/src/collection-facets/smart-facets/smart-facet-dropdown.js.map +1 -0
  180. package/dist/src/collection-facets/smart-facets/smart-facet-equals.d.ts +2 -0
  181. package/dist/src/collection-facets/smart-facets/smart-facet-equals.js +13 -0
  182. package/dist/src/collection-facets/smart-facets/smart-facet-equals.js.map +1 -0
  183. package/dist/src/collection-facets/smart-facets/smart-facet-heuristics.d.ts +5 -0
  184. package/dist/src/collection-facets/smart-facets/smart-facet-heuristics.js +18 -0
  185. package/dist/src/collection-facets/smart-facets/smart-facet-heuristics.js.map +1 -0
  186. package/dist/src/collection-facets/toggle-switch.d.ts +41 -0
  187. package/dist/src/collection-facets/toggle-switch.js +174 -0
  188. package/dist/src/collection-facets/toggle-switch.js.map +1 -0
  189. package/dist/src/collection-facets.d.ts +113 -0
  190. package/dist/src/collection-facets.js +884 -0
  191. package/dist/src/collection-facets.js.map +1 -0
  192. package/dist/src/data-source/collection-browser-data-source-interface.d.ts +270 -0
  193. package/dist/src/data-source/collection-browser-data-source-interface.js +2 -0
  194. package/dist/src/data-source/collection-browser-data-source-interface.js.map +1 -0
  195. package/dist/src/data-source/collection-browser-data-source.d.ts +418 -0
  196. package/dist/src/data-source/collection-browser-data-source.js +1121 -0
  197. package/dist/src/data-source/collection-browser-data-source.js.map +1 -0
  198. package/dist/src/data-source/collection-browser-query-state.d.ts +48 -0
  199. package/dist/src/data-source/collection-browser-query-state.js +2 -0
  200. package/dist/src/data-source/collection-browser-query-state.js.map +1 -0
  201. package/dist/src/data-source/models.d.ts +43 -0
  202. package/dist/src/data-source/models.js +9 -0
  203. package/dist/src/data-source/models.js.map +1 -0
  204. package/dist/src/empty-placeholder.d.ts +23 -0
  205. package/dist/src/empty-placeholder.js +165 -0
  206. package/dist/src/empty-placeholder.js.map +1 -0
  207. package/dist/src/expanded-date-picker.d.ts +50 -0
  208. package/dist/src/expanded-date-picker.js +182 -0
  209. package/dist/src/expanded-date-picker.js.map +1 -0
  210. package/dist/src/language-code-handler/language-code-handler.d.ts +37 -0
  211. package/dist/src/language-code-handler/language-code-handler.js +27 -0
  212. package/dist/src/language-code-handler/language-code-handler.js.map +1 -0
  213. package/dist/src/language-code-handler/language-code-mapping.d.ts +1 -0
  214. package/dist/src/language-code-handler/language-code-mapping.js +563 -0
  215. package/dist/src/language-code-handler/language-code-mapping.js.map +1 -0
  216. package/dist/src/manage/manage-bar.d.ts +58 -0
  217. package/dist/src/manage/manage-bar.js +237 -0
  218. package/dist/src/manage/manage-bar.js.map +1 -0
  219. package/dist/src/manage/remove-items-modal-content.d.ts +9 -0
  220. package/dist/src/manage/remove-items-modal-content.js +104 -0
  221. package/dist/src/manage/remove-items-modal-content.js.map +1 -0
  222. package/dist/src/mediatype/mediatype-config.d.ts +11 -0
  223. package/dist/src/mediatype/mediatype-config.js +116 -0
  224. package/dist/src/mediatype/mediatype-config.js.map +1 -0
  225. package/dist/src/models.d.ts +298 -0
  226. package/dist/src/models.js +507 -0
  227. package/dist/src/models.js.map +1 -0
  228. package/dist/src/restoration-state-handler.d.ts +74 -0
  229. package/dist/src/restoration-state-handler.js +397 -0
  230. package/dist/src/restoration-state-handler.js.map +1 -0
  231. package/dist/src/sort-filter-bar/alpha-bar-tooltip.d.ts +6 -0
  232. package/dist/src/sort-filter-bar/alpha-bar-tooltip.js +60 -0
  233. package/dist/src/sort-filter-bar/alpha-bar-tooltip.js.map +1 -0
  234. package/dist/src/sort-filter-bar/alpha-bar.d.ts +21 -0
  235. package/dist/src/sort-filter-bar/alpha-bar.js +241 -0
  236. package/dist/src/sort-filter-bar/alpha-bar.js.map +1 -0
  237. package/dist/src/sort-filter-bar/img/compact.d.ts +1 -0
  238. package/dist/src/sort-filter-bar/img/compact.js +5 -0
  239. package/dist/src/sort-filter-bar/img/compact.js.map +1 -0
  240. package/dist/src/sort-filter-bar/img/list.d.ts +1 -0
  241. package/dist/src/sort-filter-bar/img/list.js +5 -0
  242. package/dist/src/sort-filter-bar/img/list.js.map +1 -0
  243. package/dist/src/sort-filter-bar/img/sort-toggle-disabled.d.ts +1 -0
  244. package/dist/src/sort-filter-bar/img/sort-toggle-disabled.js +15 -0
  245. package/dist/src/sort-filter-bar/img/sort-toggle-disabled.js.map +1 -0
  246. package/dist/src/sort-filter-bar/img/sort-toggle-down.d.ts +1 -0
  247. package/dist/src/sort-filter-bar/img/sort-toggle-down.js +17 -0
  248. package/dist/src/sort-filter-bar/img/sort-toggle-down.js.map +1 -0
  249. package/dist/src/sort-filter-bar/img/sort-toggle-up.d.ts +1 -0
  250. package/dist/src/sort-filter-bar/img/sort-toggle-up.js +17 -0
  251. package/dist/src/sort-filter-bar/img/sort-toggle-up.js.map +1 -0
  252. package/dist/src/sort-filter-bar/img/sort-triangle.d.ts +1 -0
  253. package/dist/src/sort-filter-bar/img/sort-triangle.js +5 -0
  254. package/dist/src/sort-filter-bar/img/sort-triangle.js.map +1 -0
  255. package/dist/src/sort-filter-bar/img/tile.d.ts +1 -0
  256. package/dist/src/sort-filter-bar/img/tile.js +5 -0
  257. package/dist/src/sort-filter-bar/img/tile.js.map +1 -0
  258. package/dist/src/sort-filter-bar/sort-filter-bar.d.ts +278 -0
  259. package/dist/src/sort-filter-bar/sort-filter-bar.js +1161 -0
  260. package/dist/src/sort-filter-bar/sort-filter-bar.js.map +1 -0
  261. package/dist/src/styles/ia-button.d.ts +2 -0
  262. package/dist/src/styles/ia-button.js +134 -0
  263. package/dist/src/styles/ia-button.js.map +1 -0
  264. package/dist/src/styles/item-image-styles.d.ts +8 -0
  265. package/dist/src/styles/item-image-styles.js +123 -0
  266. package/dist/src/styles/item-image-styles.js.map +1 -0
  267. package/dist/src/styles/sr-only.d.ts +1 -0
  268. package/dist/src/styles/sr-only.js +18 -0
  269. package/dist/src/styles/sr-only.js.map +1 -0
  270. package/dist/src/tiles/base-tile-component.d.ts +27 -0
  271. package/dist/src/tiles/base-tile-component.js +82 -0
  272. package/dist/src/tiles/base-tile-component.js.map +1 -0
  273. package/dist/src/tiles/collection-browser-loading-tile.d.ts +5 -0
  274. package/dist/src/tiles/collection-browser-loading-tile.js +29 -0
  275. package/dist/src/tiles/collection-browser-loading-tile.js.map +1 -0
  276. package/dist/src/tiles/grid/account-tile.d.ts +18 -0
  277. package/dist/src/tiles/grid/account-tile.js +111 -0
  278. package/dist/src/tiles/grid/account-tile.js.map +1 -0
  279. package/dist/src/tiles/grid/collection-tile.d.ts +15 -0
  280. package/dist/src/tiles/grid/collection-tile.js +160 -0
  281. package/dist/src/tiles/grid/collection-tile.js.map +1 -0
  282. package/dist/src/tiles/grid/item-tile.d.ts +41 -0
  283. package/dist/src/tiles/grid/item-tile.js +321 -0
  284. package/dist/src/tiles/grid/item-tile.js.map +1 -0
  285. package/dist/src/tiles/grid/search-tile.d.ts +10 -0
  286. package/dist/src/tiles/grid/search-tile.js +95 -0
  287. package/dist/src/tiles/grid/search-tile.js.map +1 -0
  288. package/dist/src/tiles/grid/styles/tile-grid-shared-styles.d.ts +1 -0
  289. package/dist/src/tiles/grid/styles/tile-grid-shared-styles.js +128 -0
  290. package/dist/src/tiles/grid/styles/tile-grid-shared-styles.js.map +1 -0
  291. package/dist/src/tiles/grid/tile-stats.d.ts +58 -0
  292. package/dist/src/tiles/grid/tile-stats.js +204 -0
  293. package/dist/src/tiles/grid/tile-stats.js.map +1 -0
  294. package/dist/src/tiles/hover/hover-pane-controller.d.ts +228 -0
  295. package/dist/src/tiles/hover/hover-pane-controller.js +446 -0
  296. package/dist/src/tiles/hover/hover-pane-controller.js.map +1 -0
  297. package/dist/src/tiles/hover/tile-hover-pane.d.ts +20 -0
  298. package/dist/src/tiles/hover/tile-hover-pane.js +185 -0
  299. package/dist/src/tiles/hover/tile-hover-pane.js.map +1 -0
  300. package/dist/src/tiles/image-block.d.ts +19 -0
  301. package/dist/src/tiles/image-block.js +175 -0
  302. package/dist/src/tiles/image-block.js.map +1 -0
  303. package/dist/src/tiles/item-image.d.ts +40 -0
  304. package/dist/src/tiles/item-image.js +191 -0
  305. package/dist/src/tiles/item-image.js.map +1 -0
  306. package/dist/src/tiles/list/tile-list-compact-header.d.ts +6 -0
  307. package/dist/src/tiles/list/tile-list-compact-header.js +85 -0
  308. package/dist/src/tiles/list/tile-list-compact-header.js.map +1 -0
  309. package/dist/src/tiles/list/tile-list-compact.d.ts +19 -0
  310. package/dist/src/tiles/list/tile-list-compact.js +223 -0
  311. package/dist/src/tiles/list/tile-list-compact.js.map +1 -0
  312. package/dist/src/tiles/list/tile-list.d.ts +54 -0
  313. package/dist/src/tiles/list/tile-list.js +621 -0
  314. package/dist/src/tiles/list/tile-list.js.map +1 -0
  315. package/dist/src/tiles/models.d.ts +1 -0
  316. package/dist/src/tiles/models.js +2 -0
  317. package/dist/src/tiles/models.js.map +1 -0
  318. package/dist/src/tiles/overlay/icon-overlay.d.ts +8 -0
  319. package/dist/src/tiles/overlay/icon-overlay.js +55 -0
  320. package/dist/src/tiles/overlay/icon-overlay.js.map +1 -0
  321. package/dist/src/tiles/overlay/text-overlay.d.ts +9 -0
  322. package/dist/src/tiles/overlay/text-overlay.js +74 -0
  323. package/dist/src/tiles/overlay/text-overlay.js.map +1 -0
  324. package/dist/src/tiles/review-block.d.ts +12 -0
  325. package/dist/src/tiles/review-block.js +134 -0
  326. package/dist/src/tiles/review-block.js.map +1 -0
  327. package/dist/src/tiles/text-snippet-block.d.ts +27 -0
  328. package/dist/src/tiles/text-snippet-block.js +132 -0
  329. package/dist/src/tiles/text-snippet-block.js.map +1 -0
  330. package/dist/src/tiles/tile-dispatcher.d.ts +71 -0
  331. package/dist/src/tiles/tile-dispatcher.js +472 -0
  332. package/dist/src/tiles/tile-dispatcher.js.map +1 -0
  333. package/dist/src/tiles/tile-display-value-provider.d.ts +47 -0
  334. package/dist/src/tiles/tile-display-value-provider.js +95 -0
  335. package/dist/src/tiles/tile-display-value-provider.js.map +1 -0
  336. package/dist/src/tiles/tile-mediatype-icon.d.ts +27 -0
  337. package/dist/src/tiles/tile-mediatype-icon.js +130 -0
  338. package/dist/src/tiles/tile-mediatype-icon.js.map +1 -0
  339. package/dist/src/utils/analytics-events.d.ts +28 -0
  340. package/dist/src/utils/analytics-events.js +31 -0
  341. package/dist/src/utils/analytics-events.js.map +1 -0
  342. package/dist/src/utils/array-equals.d.ts +4 -0
  343. package/dist/src/utils/array-equals.js +11 -0
  344. package/dist/src/utils/array-equals.js.map +1 -0
  345. package/dist/src/utils/collapse-repeated-quotes.d.ts +11 -0
  346. package/dist/src/utils/collapse-repeated-quotes.js +14 -0
  347. package/dist/src/utils/collapse-repeated-quotes.js.map +1 -0
  348. package/dist/src/utils/facet-utils.d.ts +83 -0
  349. package/dist/src/utils/facet-utils.js +152 -0
  350. package/dist/src/utils/facet-utils.js.map +1 -0
  351. package/dist/src/utils/format-count.d.ts +7 -0
  352. package/dist/src/utils/format-count.js +76 -0
  353. package/dist/src/utils/format-count.js.map +1 -0
  354. package/dist/src/utils/format-date.d.ts +16 -0
  355. package/dist/src/utils/format-date.js +33 -0
  356. package/dist/src/utils/format-date.js.map +1 -0
  357. package/dist/src/utils/format-unit-size.d.ts +2 -0
  358. package/dist/src/utils/format-unit-size.js +34 -0
  359. package/dist/src/utils/format-unit-size.js.map +1 -0
  360. package/dist/src/utils/local-date-from-utc.d.ts +9 -0
  361. package/dist/src/utils/local-date-from-utc.js +16 -0
  362. package/dist/src/utils/local-date-from-utc.js.map +1 -0
  363. package/dist/src/utils/log.d.ts +7 -0
  364. package/dist/src/utils/log.js +14 -0
  365. package/dist/src/utils/log.js.map +1 -0
  366. package/dist/src/utils/resolve-mediatype.d.ts +8 -0
  367. package/dist/src/utils/resolve-mediatype.js +24 -0
  368. package/dist/src/utils/resolve-mediatype.js.map +1 -0
  369. package/dist/src/utils/sha1.d.ts +2 -0
  370. package/dist/src/utils/sha1.js +9 -0
  371. package/dist/src/utils/sha1.js.map +1 -0
  372. package/dist/test/collection-browser.test.d.ts +1 -0
  373. package/dist/test/collection-browser.test.js +1721 -0
  374. package/dist/test/collection-browser.test.js.map +1 -0
  375. package/dist/test/collection-facets/facet-row.test.d.ts +1 -0
  376. package/dist/test/collection-facets/facet-row.test.js +274 -0
  377. package/dist/test/collection-facets/facet-row.test.js.map +1 -0
  378. package/dist/test/collection-facets/facets-template.test.d.ts +1 -0
  379. package/dist/test/collection-facets/facets-template.test.js +101 -0
  380. package/dist/test/collection-facets/facets-template.test.js.map +1 -0
  381. package/dist/test/collection-facets/more-facets-content.test.d.ts +1 -0
  382. package/dist/test/collection-facets/more-facets-content.test.js +169 -0
  383. package/dist/test/collection-facets/more-facets-content.test.js.map +1 -0
  384. package/dist/test/collection-facets/more-facets-pagination.test.d.ts +1 -0
  385. package/dist/test/collection-facets/more-facets-pagination.test.js +132 -0
  386. package/dist/test/collection-facets/more-facets-pagination.test.js.map +1 -0
  387. package/dist/test/collection-facets/toggle-switch.test.d.ts +1 -0
  388. package/dist/test/collection-facets/toggle-switch.test.js +96 -0
  389. package/dist/test/collection-facets/toggle-switch.test.js.map +1 -0
  390. package/dist/test/collection-facets.test.d.ts +2 -0
  391. package/dist/test/collection-facets.test.js +745 -0
  392. package/dist/test/collection-facets.test.js.map +1 -0
  393. package/dist/test/data-source/collection-browser-data-source.test.d.ts +1 -0
  394. package/dist/test/data-source/collection-browser-data-source.test.js +102 -0
  395. package/dist/test/data-source/collection-browser-data-source.test.js.map +1 -0
  396. package/dist/test/empty-placeholder.test.d.ts +1 -0
  397. package/dist/test/empty-placeholder.test.js +63 -0
  398. package/dist/test/empty-placeholder.test.js.map +1 -0
  399. package/dist/test/expanded-date-picker.test.d.ts +1 -0
  400. package/dist/test/expanded-date-picker.test.js +130 -0
  401. package/dist/test/expanded-date-picker.test.js.map +1 -0
  402. package/dist/test/icon-overlay.test.d.ts +1 -0
  403. package/dist/test/icon-overlay.test.js +30 -0
  404. package/dist/test/icon-overlay.test.js.map +1 -0
  405. package/dist/test/image-block.test.d.ts +1 -0
  406. package/dist/test/image-block.test.js +218 -0
  407. package/dist/test/image-block.test.js.map +1 -0
  408. package/dist/test/item-image.test.d.ts +1 -0
  409. package/dist/test/item-image.test.js +196 -0
  410. package/dist/test/item-image.test.js.map +1 -0
  411. package/dist/test/manage/manage-bar.test.d.ts +2 -0
  412. package/dist/test/manage/manage-bar.test.js +106 -0
  413. package/dist/test/manage/manage-bar.test.js.map +1 -0
  414. package/dist/test/manage/remove-items-modal-content.test.d.ts +1 -0
  415. package/dist/test/manage/remove-items-modal-content.test.js +65 -0
  416. package/dist/test/manage/remove-items-modal-content.test.js.map +1 -0
  417. package/dist/test/mediatype-config.test.d.ts +1 -0
  418. package/dist/test/mediatype-config.test.js +11 -0
  419. package/dist/test/mediatype-config.test.js.map +1 -0
  420. package/dist/test/mocks/mock-analytics-handler.d.ts +10 -0
  421. package/dist/test/mocks/mock-analytics-handler.js +16 -0
  422. package/dist/test/mocks/mock-analytics-handler.js.map +1 -0
  423. package/dist/test/mocks/mock-search-responses.d.ts +31 -0
  424. package/dist/test/mocks/mock-search-responses.js +1241 -0
  425. package/dist/test/mocks/mock-search-responses.js.map +1 -0
  426. package/dist/test/mocks/mock-search-service.d.ts +16 -0
  427. package/dist/test/mocks/mock-search-service.js +65 -0
  428. package/dist/test/mocks/mock-search-service.js.map +1 -0
  429. package/dist/test/restoration-state-handler.test.d.ts +1 -0
  430. package/dist/test/restoration-state-handler.test.js +343 -0
  431. package/dist/test/restoration-state-handler.test.js.map +1 -0
  432. package/dist/test/review-block.test.d.ts +1 -0
  433. package/dist/test/review-block.test.js +48 -0
  434. package/dist/test/review-block.test.js.map +1 -0
  435. package/dist/test/sort-filter-bar/alpha-bar-tooltip.test.d.ts +1 -0
  436. package/dist/test/sort-filter-bar/alpha-bar-tooltip.test.js +13 -0
  437. package/dist/test/sort-filter-bar/alpha-bar-tooltip.test.js.map +1 -0
  438. package/dist/test/sort-filter-bar/alpha-bar.test.d.ts +1 -0
  439. package/dist/test/sort-filter-bar/alpha-bar.test.js +74 -0
  440. package/dist/test/sort-filter-bar/alpha-bar.test.js.map +1 -0
  441. package/dist/test/sort-filter-bar/sort-filter-bar.test.d.ts +1 -0
  442. package/dist/test/sort-filter-bar/sort-filter-bar.test.js +609 -0
  443. package/dist/test/sort-filter-bar/sort-filter-bar.test.js.map +1 -0
  444. package/dist/test/text-overlay.test.d.ts +1 -0
  445. package/dist/test/text-overlay.test.js +42 -0
  446. package/dist/test/text-overlay.test.js.map +1 -0
  447. package/dist/test/text-snippet-block.test.d.ts +1 -0
  448. package/dist/test/text-snippet-block.test.js +63 -0
  449. package/dist/test/text-snippet-block.test.js.map +1 -0
  450. package/dist/test/tile-stats.test.d.ts +1 -0
  451. package/dist/test/tile-stats.test.js +128 -0
  452. package/dist/test/tile-stats.test.js.map +1 -0
  453. package/dist/test/tiles/grid/account-tile.test.d.ts +1 -0
  454. package/dist/test/tiles/grid/account-tile.test.js +96 -0
  455. package/dist/test/tiles/grid/account-tile.test.js.map +1 -0
  456. package/dist/test/tiles/grid/collection-tile.test.d.ts +1 -0
  457. package/dist/test/tiles/grid/collection-tile.test.js +96 -0
  458. package/dist/test/tiles/grid/collection-tile.test.js.map +1 -0
  459. package/dist/test/tiles/grid/item-tile.test.d.ts +1 -0
  460. package/dist/test/tiles/grid/item-tile.test.js +427 -0
  461. package/dist/test/tiles/grid/item-tile.test.js.map +1 -0
  462. package/dist/test/tiles/grid/search-tile.test.d.ts +1 -0
  463. package/dist/test/tiles/grid/search-tile.test.js +66 -0
  464. package/dist/test/tiles/grid/search-tile.test.js.map +1 -0
  465. package/dist/test/tiles/hover/hover-pane-controller.test.d.ts +1 -0
  466. package/dist/test/tiles/hover/hover-pane-controller.test.js +329 -0
  467. package/dist/test/tiles/hover/hover-pane-controller.test.js.map +1 -0
  468. package/dist/test/tiles/hover/tile-hover-pane.test.d.ts +1 -0
  469. package/dist/test/tiles/hover/tile-hover-pane.test.js +57 -0
  470. package/dist/test/tiles/hover/tile-hover-pane.test.js.map +1 -0
  471. package/dist/test/tiles/list/tile-list-compact.test.d.ts +1 -0
  472. package/dist/test/tiles/list/tile-list-compact.test.js +251 -0
  473. package/dist/test/tiles/list/tile-list-compact.test.js.map +1 -0
  474. package/dist/test/tiles/list/tile-list.test.d.ts +1 -0
  475. package/dist/test/tiles/list/tile-list.test.js +469 -0
  476. package/dist/test/tiles/list/tile-list.test.js.map +1 -0
  477. package/dist/test/tiles/tile-dispatcher.test.d.ts +1 -0
  478. package/dist/test/tiles/tile-dispatcher.test.js +231 -0
  479. package/dist/test/tiles/tile-dispatcher.test.js.map +1 -0
  480. package/dist/test/tiles/tile-display-value-provider.test.d.ts +1 -0
  481. package/dist/test/tiles/tile-display-value-provider.test.js +142 -0
  482. package/dist/test/tiles/tile-display-value-provider.test.js.map +1 -0
  483. package/dist/test/tiles/tile-mediatype-icon.test.d.ts +1 -0
  484. package/dist/test/tiles/tile-mediatype-icon.test.js +145 -0
  485. package/dist/test/tiles/tile-mediatype-icon.test.js.map +1 -0
  486. package/dist/test/utils/array-equals.test.d.ts +1 -0
  487. package/dist/test/utils/array-equals.test.js +27 -0
  488. package/dist/test/utils/array-equals.test.js.map +1 -0
  489. package/dist/test/utils/format-count.test.d.ts +1 -0
  490. package/dist/test/utils/format-count.test.js +24 -0
  491. package/dist/test/utils/format-count.test.js.map +1 -0
  492. package/dist/test/utils/format-date.test.d.ts +1 -0
  493. package/dist/test/utils/format-date.test.js +61 -0
  494. package/dist/test/utils/format-date.test.js.map +1 -0
  495. package/dist/test/utils/format-unit-size.test.d.ts +1 -0
  496. package/dist/test/utils/format-unit-size.test.js +18 -0
  497. package/dist/test/utils/format-unit-size.test.js.map +1 -0
  498. package/dist/test/utils/local-date-from-utc.test.d.ts +1 -0
  499. package/dist/test/utils/local-date-from-utc.test.js +27 -0
  500. package/dist/test/utils/local-date-from-utc.test.js.map +1 -0
  501. package/eslint.config.mjs +53 -53
  502. package/index.html +24 -24
  503. package/local.archive.org.cert +86 -86
  504. package/local.archive.org.key +27 -27
  505. package/package.json +118 -117
  506. package/renovate.json +6 -6
  507. package/src/collection-browser.ts +2954 -2829
  508. package/src/collection-facets/facet-row.ts +299 -296
  509. package/src/collection-facets/models.ts +10 -10
  510. package/src/collection-facets/more-facets-content.ts +639 -639
  511. package/src/collection-facets.ts +1005 -995
  512. package/src/data-source/collection-browser-data-source-interface.ts +345 -333
  513. package/src/data-source/collection-browser-data-source.ts +1441 -1401
  514. package/src/data-source/collection-browser-query-state.ts +59 -65
  515. package/src/data-source/models.ts +56 -43
  516. package/src/manage/manage-bar.ts +247 -247
  517. package/src/models.ts +866 -870
  518. package/src/restoration-state-handler.ts +542 -544
  519. package/src/tiles/base-tile-component.ts +65 -65
  520. package/src/tiles/grid/account-tile.ts +113 -113
  521. package/src/tiles/grid/collection-tile.ts +163 -163
  522. package/src/tiles/grid/item-tile.ts +340 -340
  523. package/src/tiles/grid/search-tile.ts +90 -90
  524. package/src/tiles/grid/styles/tile-grid-shared-styles.ts +130 -130
  525. package/src/tiles/hover/hover-pane-controller.ts +613 -517
  526. package/src/tiles/hover/tile-hover-pane.ts +184 -180
  527. package/src/tiles/list/tile-list-compact.ts +239 -239
  528. package/src/tiles/list/tile-list.ts +700 -700
  529. package/src/tiles/tile-dispatcher.ts +517 -490
  530. package/src/utils/format-date.ts +62 -62
  531. package/test/collection-browser.test.ts +2413 -2403
  532. package/test/collection-facets/facet-row.test.ts +375 -375
  533. package/test/collection-facets.test.ts +928 -928
  534. package/test/restoration-state-handler.test.ts +480 -510
  535. package/test/tiles/grid/item-tile.test.ts +520 -520
  536. package/test/tiles/hover/hover-pane-controller.test.ts +418 -353
  537. package/test/tiles/list/tile-list-compact.test.ts +282 -282
  538. package/test/tiles/list/tile-list.test.ts +552 -552
  539. package/test/tiles/tile-dispatcher.test.ts +283 -187
  540. package/test/utils/format-date.test.ts +89 -89
  541. package/tsconfig.json +20 -20
  542. package/web-dev-server.config.mjs +30 -30
  543. package/web-test-runner.config.mjs +41 -41
@@ -1,928 +1,928 @@
1
- import { expect, fixture } from '@open-wc/testing';
2
- import sinon from 'sinon';
3
- import { html } from 'lit';
4
- import { Aggregation } from '@internetarchive/search-service';
5
- import {
6
- ModalManager,
7
- ModalManagerInterface,
8
- } from '@internetarchive/modal-manager';
9
- import type { CollectionFacets } from '../src/collection-facets';
10
- import '@internetarchive/modal-manager';
11
- import '../src/collection-facets';
12
- import {
13
- FacetOption,
14
- // SelectedFacets, Used in lending tests (disabled)
15
- getDefaultSelectedFacets,
16
- } from '../src/models';
17
- import { MockAnalyticsHandler } from './mocks/mock-analytics-handler';
18
- import type { FacetRow } from '../src/collection-facets/facet-row';
19
- // import type { FacetsTemplate } from '../src/collection-facets/facets-template'; Used in lending tests (disabled)
20
-
21
- describe('Collection Facets', () => {
22
- it('has loader', async () => {
23
- const el = await fixture<CollectionFacets>(
24
- html`<collection-facets ?facetsLoading=${true}></collection-facets>`,
25
- );
26
-
27
- expect(
28
- el.shadowRoot?.querySelector('#container')?.classList.contains('loading'),
29
- ).to.be.true;
30
-
31
- el.facetsLoading = false;
32
- await el.updateComplete;
33
-
34
- expect(
35
- el.shadowRoot?.querySelector('#container')?.classList.contains('loading'),
36
- ).to.be.false;
37
- });
38
-
39
- it('renders a date picker loading placeholder when date picker enabled', async () => {
40
- const el = await fixture<CollectionFacets>(
41
- html`<collection-facets></collection-facets>`,
42
- );
43
-
44
- el.histogramAggregationLoading = true;
45
- el.showHistogramDatePicker = true;
46
- el.histogramAggregation = new Aggregation({
47
- buckets: [1, 2, 3],
48
- first_bucket_key: 0,
49
- last_bucket_key: 2,
50
- });
51
- await el.updateComplete;
52
-
53
- const histogramLoader = el.shadowRoot?.querySelector(
54
- '.histogram-loading-indicator',
55
- );
56
- expect(histogramLoader).to.exist;
57
- });
58
-
59
- it('does not render a date picker loading placeholder when date picker disabled', async () => {
60
- const el = await fixture<CollectionFacets>(
61
- html`<collection-facets></collection-facets>`,
62
- );
63
-
64
- el.histogramAggregationLoading = true;
65
- el.showHistogramDatePicker = false;
66
- el.histogramAggregation = new Aggregation({
67
- buckets: [1, 2, 3],
68
- first_bucket_key: 0,
69
- last_bucket_key: 2,
70
- });
71
- await el.updateComplete;
72
-
73
- const histogramLoader = el.shadowRoot?.querySelector(
74
- '.histogram-loading-indicator',
75
- );
76
- expect(histogramLoader).to.be.null;
77
- });
78
-
79
- it('renders the date picker when enabled with data present', async () => {
80
- const el = await fixture<CollectionFacets>(
81
- html`<collection-facets></collection-facets>`,
82
- );
83
-
84
- el.histogramAggregationLoading = false;
85
- el.showHistogramDatePicker = true;
86
- el.histogramAggregation = new Aggregation({
87
- buckets: [1, 2, 3],
88
- first_bucket_key: 0,
89
- last_bucket_key: 2,
90
- });
91
- await el.updateComplete;
92
-
93
- const histogram = el.shadowRoot?.querySelector('histogram-date-range');
94
- expect(histogram).to.exist;
95
- });
96
-
97
- it('does not render the date picker when disabled', async () => {
98
- const el = await fixture<CollectionFacets>(
99
- html`<collection-facets></collection-facets>`,
100
- );
101
-
102
- el.histogramAggregationLoading = false;
103
- el.showHistogramDatePicker = false;
104
- el.histogramAggregation = new Aggregation({
105
- buckets: [1, 2, 3],
106
- first_bucket_key: 0,
107
- last_bucket_key: 2,
108
- });
109
- await el.updateComplete;
110
-
111
- const histogram = el.shadowRoot?.querySelector('histogram-date-range');
112
- expect(histogram).to.be.null;
113
- });
114
-
115
- it('renders button to expand the date picker when allowed', async () => {
116
- const el = await fixture<CollectionFacets>(
117
- html`<collection-facets></collection-facets>`,
118
- );
119
-
120
- el.histogramAggregationLoading = false;
121
- el.showHistogramDatePicker = true;
122
- el.allowExpandingDatePicker = true;
123
- el.histogramAggregation = new Aggregation({
124
- buckets: [1, 2, 3],
125
- first_bucket_key: 0,
126
- last_bucket_key: 2,
127
- });
128
- await el.updateComplete;
129
-
130
- const expandBtn = el.shadowRoot?.querySelector('.expand-date-picker-btn');
131
- expect(expandBtn).to.exist;
132
- });
133
-
134
- it('does not render button to expand the date picker when disallowed', async () => {
135
- const el = await fixture<CollectionFacets>(
136
- html`<collection-facets></collection-facets>`,
137
- );
138
-
139
- el.histogramAggregationLoading = false;
140
- el.showHistogramDatePicker = true;
141
- el.allowExpandingDatePicker = false;
142
- el.histogramAggregation = new Aggregation({
143
- buckets: [1, 2, 3],
144
- first_bucket_key: 0,
145
- last_bucket_key: 2,
146
- });
147
- await el.updateComplete;
148
-
149
- const expandBtn = el.shadowRoot?.querySelector('.expand-date-picker-btn');
150
- expect(expandBtn).to.be.null;
151
- });
152
-
153
- it('opens modal when date picker expand button clicked', async () => {
154
- const modalManager = await fixture<ModalManager>(
155
- html`<modal-manager></modal-manager>`,
156
- );
157
-
158
- const el = await fixture<CollectionFacets>(
159
- html`<collection-facets
160
- .modalManager=${modalManager}
161
- ></collection-facets>`,
162
- );
163
-
164
- el.histogramAggregationLoading = false;
165
- el.showHistogramDatePicker = true;
166
- el.allowExpandingDatePicker = true;
167
- el.histogramAggregation = new Aggregation({
168
- buckets: [1, 2, 3],
169
- first_bucket_key: 0,
170
- last_bucket_key: 2,
171
- });
172
- await el.updateComplete;
173
-
174
- const expandBtn = el.shadowRoot?.querySelector(
175
- '.expand-date-picker-btn',
176
- ) as HTMLButtonElement;
177
- expect(expandBtn).to.exist;
178
-
179
- const showModalSpy = sinon.spy(
180
- el.modalManager as ModalManagerInterface,
181
- 'showModal',
182
- );
183
-
184
- // Click the expand button to open the modal
185
- expandBtn?.click();
186
- await el.updateComplete;
187
-
188
- expect(showModalSpy.callCount).to.equal(1);
189
- expect(el.modalManager?.classList.contains('expanded-date-picker')).to.be
190
- .true;
191
- });
192
-
193
- it('renders aggregations as facets', async () => {
194
- const el = await fixture<CollectionFacets>(
195
- html`<collection-facets></collection-facets>`,
196
- );
197
-
198
- const aggs: Record<string, Aggregation> = {
199
- subject: new Aggregation({
200
- buckets: [
201
- {
202
- key: 'foo',
203
- doc_count: 5,
204
- },
205
- ],
206
- }),
207
- };
208
-
209
- el.aggregations = aggs;
210
- await el.updateComplete;
211
- const facetGroups = el.shadowRoot?.querySelectorAll('.facet-group');
212
- expect(facetGroups?.length).to.equal(1);
213
-
214
- const titleFacetGroup = facetGroups?.[0];
215
- const facetGroupHeader = titleFacetGroup?.querySelector('h3');
216
- // Every facet group header has an invisible " filters" suffix for screen-readers
217
- expect(
218
- facetGroupHeader?.querySelector('span.sr-only')?.textContent?.trim(),
219
- ).to.equal('filters');
220
- // Ignoring the screen-reader suffix, we should be left with only the readable, capitalized title
221
- expect(
222
- facetGroupHeader?.textContent?.trim().replace(/\s*filters$/, ''),
223
- ).to.equal('Subject');
224
-
225
- const titleFacetRow = titleFacetGroup
226
- ?.querySelector('facets-template')
227
- ?.shadowRoot?.querySelector('facet-row') as FacetRow;
228
- await titleFacetRow.updateComplete;
229
- });
230
-
231
- it('renders multiple aggregation types', async () => {
232
- const el = await fixture<CollectionFacets>(
233
- html`<collection-facets></collection-facets>`,
234
- );
235
-
236
- const aggs: Record<string, Aggregation> = {
237
- subject: new Aggregation({
238
- buckets: [
239
- {
240
- key: 'foo',
241
- doc_count: 5,
242
- },
243
- ],
244
- }),
245
- mediatype: new Aggregation({
246
- buckets: [
247
- {
248
- key: 'bar',
249
- doc_count: 10,
250
- },
251
- ],
252
- }),
253
- };
254
-
255
- el.aggregations = aggs;
256
- await el.updateComplete;
257
-
258
- const facetGroups = el.shadowRoot?.querySelectorAll('.facet-group');
259
- expect(facetGroups?.length).to.equal(2);
260
- });
261
-
262
- it('does not render suppressed collection facets', async () => {
263
- const el = await fixture<CollectionFacets>(
264
- html`<collection-facets></collection-facets>`,
265
- );
266
-
267
- const aggs: Record<string, Aggregation> = {
268
- collection: new Aggregation({
269
- buckets: [
270
- {
271
- key: 'deemphasize',
272
- doc_count: 5,
273
- },
274
- {
275
- key: 'community',
276
- doc_count: 5,
277
- },
278
- {
279
- key: 'foo',
280
- doc_count: 5,
281
- },
282
- ],
283
- }),
284
- };
285
-
286
- el.aggregations = aggs;
287
- await el.updateComplete;
288
-
289
- const collectionFacets = el.shadowRoot
290
- ?.querySelector('facets-template')
291
- ?.shadowRoot?.querySelectorAll('facet-row') as ArrayLike<FacetRow>;
292
- expect(collectionFacets?.length).to.equal(1);
293
-
294
- // The first (and only) collection link should be for 'foo'
295
- expect(collectionFacets[0].bucket?.key).to.equal('foo');
296
- });
297
-
298
- // Lending tests disabled because lending facet disabled
299
- // it('renders lending facets with human-readable names', async () => {
300
- // const el = await fixture<CollectionFacets>(
301
- // html`<collection-facets></collection-facets>`
302
- // );
303
-
304
- // const aggs: Record<string, Aggregation> = {
305
- // lending: new Aggregation({
306
- // buckets: [
307
- // {
308
- // key: 'is_lendable',
309
- // doc_count: 3,
310
- // },
311
- // {
312
- // key: 'available_to_borrow',
313
- // doc_count: 2,
314
- // },
315
- // {
316
- // key: 'is_readable',
317
- // doc_count: 1,
318
- // },
319
- // ],
320
- // }),
321
- // };
322
-
323
- // el.aggregations = aggs;
324
- // await el.updateComplete;
325
-
326
- // const facetsTemplate = el.shadowRoot?.querySelector(
327
- // 'facets-template'
328
- // ) as FacetsTemplate;
329
- // await facetsTemplate?.updateComplete;
330
-
331
- // const lendingFacets = facetsTemplate?.shadowRoot?.querySelectorAll(
332
- // 'facet-row'
333
- // ) as ArrayLike<FacetRow>;
334
- // expect(lendingFacets?.length).to.equal(3);
335
-
336
- // expect(lendingFacets[0].shadowRoot?.textContent?.trim()).to.match(
337
- // /^Lending Library\s*3$/
338
- // );
339
- // expect(lendingFacets[1].shadowRoot?.textContent?.trim()).to.match(
340
- // /^Borrow 14 Days\s*2$/
341
- // );
342
- // expect(lendingFacets[2].shadowRoot?.textContent?.trim()).to.match(
343
- // /^Always Available\s*1$/
344
- // );
345
- // });
346
-
347
- // it('renders selected/negative lending facets with human-readable names', async () => {
348
- // const el = await fixture<CollectionFacets>(
349
- // html`<collection-facets></collection-facets>`
350
- // );
351
-
352
- // const selectedFacets: SelectedFacets = {
353
- // subject: {},
354
- // lending: {
355
- // is_lendable: {
356
- // key: 'is_lendable',
357
- // count: 5,
358
- // state: 'selected',
359
- // },
360
- // available_to_borrow: {
361
- // key: 'available_to_borrow',
362
- // count: 4,
363
- // state: 'selected',
364
- // },
365
- // is_readable: {
366
- // key: 'is_readable',
367
- // count: 3,
368
- // state: 'hidden',
369
- // },
370
- // },
371
- // mediatype: {},
372
- // language: {},
373
- // creator: {},
374
- // collection: {},
375
- // year: {},
376
- // };
377
-
378
- // el.selectedFacets = selectedFacets;
379
- // await el.updateComplete;
380
-
381
- // const facetsTemplate = el.shadowRoot?.querySelector(
382
- // 'facets-template'
383
- // ) as FacetsTemplate;
384
- // await facetsTemplate?.updateComplete;
385
-
386
- // const lendingFacets = facetsTemplate?.shadowRoot?.querySelectorAll(
387
- // 'facet-row'
388
- // ) as ArrayLike<FacetRow>;
389
- // expect(lendingFacets?.length).to.equal(3);
390
-
391
- // expect(lendingFacets[0].shadowRoot?.textContent?.trim()).to.match(
392
- // /^Lending Library\s*5$/
393
- // );
394
- // expect(lendingFacets[1].shadowRoot?.textContent?.trim()).to.match(
395
- // /^Borrow 14 Days\s*4$/
396
- // );
397
- // expect(lendingFacets[2].shadowRoot?.textContent?.trim()).to.match(
398
- // /^Always Available\s*3$/
399
- // );
400
- // });
401
-
402
- // it('only renders lending facets for is_lendable, available_to_borrow, and is_readable', async () => {
403
- // const el = await fixture<CollectionFacets>(
404
- // html`<collection-facets></collection-facets>`
405
- // );
406
-
407
- // const aggs: Record<string, Aggregation> = {
408
- // lending: new Aggregation({
409
- // buckets: [
410
- // {
411
- // key: 'is_lendable',
412
- // doc_count: 5,
413
- // },
414
- // {
415
- // key: 'is_borrowable',
416
- // doc_count: 4,
417
- // },
418
- // {
419
- // key: 'available_to_borrow',
420
- // doc_count: 5,
421
- // },
422
- // {
423
- // key: 'is_browsable',
424
- // doc_count: 4,
425
- // },
426
- // {
427
- // key: 'available_to_browse',
428
- // doc_count: 5,
429
- // },
430
- // {
431
- // key: 'is_readable',
432
- // doc_count: 4,
433
- // },
434
- // {
435
- // key: 'available_to_waitlist',
436
- // doc_count: 5,
437
- // },
438
- // ],
439
- // }),
440
- // };
441
-
442
- // el.aggregations = aggs;
443
- // await el.updateComplete;
444
-
445
- // const facetsTemplate = el.shadowRoot?.querySelector(
446
- // 'facets-template'
447
- // ) as FacetsTemplate;
448
- // await facetsTemplate?.updateComplete;
449
- // await new Promise(res => {
450
- // setTimeout(res, 100);
451
- // });
452
-
453
- // const lendingFacets = facetsTemplate?.shadowRoot?.querySelectorAll(
454
- // 'facet-row'
455
- // ) as ArrayLike<FacetRow>;
456
- // expect(lendingFacets?.length).to.equal(3);
457
-
458
- // expect(lendingFacets[0].shadowRoot?.textContent?.trim()).to.match(
459
- // /^Lending Library\s*5$/
460
- // );
461
- // expect(lendingFacets[1].shadowRoot?.textContent?.trim()).to.match(
462
- // /^Borrow 14 Days\s*5$/
463
- // );
464
- // expect(lendingFacets[2].shadowRoot?.textContent?.trim()).to.match(
465
- // /^Always Available\s*4$/
466
- // );
467
- // });
468
-
469
- // it('does not render a More... link for lending facets', async () => {
470
- // const el = await fixture<CollectionFacets>(
471
- // html`<collection-facets></collection-facets>`
472
- // );
473
-
474
- // const aggs: Record<string, Aggregation> = {
475
- // lending: new Aggregation({
476
- // buckets: [
477
- // {
478
- // key: 'is_lendable',
479
- // doc_count: 5,
480
- // },
481
- // {
482
- // key: 'is_borrowable',
483
- // doc_count: 4,
484
- // },
485
- // {
486
- // key: 'available_to_borrow',
487
- // doc_count: 5,
488
- // },
489
- // {
490
- // key: 'is_browsable',
491
- // doc_count: 4,
492
- // },
493
- // {
494
- // key: 'available_to_browse',
495
- // doc_count: 5,
496
- // },
497
- // {
498
- // key: 'is_readable',
499
- // doc_count: 4,
500
- // },
501
- // {
502
- // key: 'available_to_waitlist',
503
- // doc_count: 5,
504
- // },
505
- // ],
506
- // }),
507
- // };
508
-
509
- // el.aggregations = aggs;
510
- // await el.updateComplete;
511
-
512
- // const moreLink = el.shadowRoot?.querySelector('.more-link');
513
- // expect(moreLink).not.to.exist;
514
- // });
515
-
516
- it('always renders the mediatype:collection facet when present', async () => {
517
- const el = await fixture<CollectionFacets>(
518
- html`<collection-facets></collection-facets>`,
519
- );
520
-
521
- const aggs: Record<string, Aggregation> = {
522
- mediatype: new Aggregation({
523
- buckets: [
524
- {
525
- key: 'texts',
526
- doc_count: 10000,
527
- },
528
- {
529
- key: 'image',
530
- doc_count: 9000,
531
- },
532
- {
533
- key: 'audio',
534
- doc_count: 8000,
535
- },
536
- {
537
- key: 'movies',
538
- doc_count: 7000,
539
- },
540
- {
541
- key: 'software',
542
- doc_count: 6000,
543
- },
544
- {
545
- key: 'data',
546
- doc_count: 5000,
547
- },
548
- {
549
- key: 'etree',
550
- doc_count: 4000,
551
- },
552
- {
553
- key: 'collection',
554
- doc_count: 1,
555
- },
556
- ],
557
- }),
558
- };
559
-
560
- el.aggregations = aggs;
561
- await el.updateComplete;
562
-
563
- const facetsTemplate = el.shadowRoot?.querySelector('facets-template');
564
- const facetRows = facetsTemplate?.shadowRoot?.querySelectorAll(
565
- 'facet-row',
566
- ) as ArrayLike<FacetRow>;
567
- expect(facetRows?.length).to.equal(6);
568
- expect(facetRows?.[5]?.bucket?.key).to.equal('collection');
569
- });
570
-
571
- it('renders the mediatype:collection facet even when >=6 other mediatypes are selected', async () => {
572
- const el = await fixture<CollectionFacets>(
573
- html`<collection-facets></collection-facets>`,
574
- );
575
-
576
- const aggs: Record<string, Aggregation> = {
577
- mediatype: new Aggregation({
578
- buckets: [
579
- {
580
- key: 'texts',
581
- doc_count: 10000,
582
- },
583
- {
584
- key: 'image',
585
- doc_count: 9000,
586
- },
587
- {
588
- key: 'audio',
589
- doc_count: 8000,
590
- },
591
- {
592
- key: 'movies',
593
- doc_count: 7000,
594
- },
595
- {
596
- key: 'software',
597
- doc_count: 6000,
598
- },
599
- {
600
- key: 'data',
601
- doc_count: 5000,
602
- },
603
- {
604
- key: 'etree',
605
- doc_count: 4000,
606
- },
607
- {
608
- key: 'collection',
609
- doc_count: 1,
610
- },
611
- ],
612
- }),
613
- };
614
-
615
- const selectedFacets = getDefaultSelectedFacets();
616
- selectedFacets.mediatype = {
617
- texts: { key: 'texts', count: 10000, state: 'selected' },
618
- image: { key: 'image', count: 9000, state: 'selected' },
619
- audio: { key: 'audio', count: 8000, state: 'selected' },
620
- movies: { key: 'movies', count: 7000, state: 'selected' },
621
- software: { key: 'software', count: 6000, state: 'selected' },
622
- data: { key: 'data', count: 5000, state: 'selected' },
623
- etree: { key: 'etree', count: 4000, state: 'selected' },
624
- };
625
-
626
- el.aggregations = aggs;
627
- el.selectedFacets = selectedFacets;
628
- await el.updateComplete;
629
-
630
- const facetsTemplate = el.shadowRoot?.querySelector('facets-template');
631
- const facetRows = facetsTemplate?.shadowRoot?.querySelectorAll(
632
- 'facet-row',
633
- ) as ArrayLike<FacetRow>;
634
- expect(facetRows?.length).to.equal(8);
635
- expect(facetRows?.[7]?.bucket?.key).to.equal('collection');
636
- });
637
-
638
- it('uses specified facet display order', async () => {
639
- const el = await fixture<CollectionFacets>(
640
- html`<collection-facets
641
- .facetDisplayOrder=${['language', 'creator'] as FacetOption[]}
642
- ></collection-facets>`,
643
- );
644
-
645
- const aggs: Record<string, Aggregation> = {
646
- mediatype: new Aggregation({
647
- buckets: [{ key: 'texts', doc_count: 5 }],
648
- }),
649
- collection: new Aggregation({
650
- buckets: [{ key: 'foo', doc_count: 10 }],
651
- }),
652
- creator: new Aggregation({
653
- buckets: [{ key: 'bar', doc_count: 15 }],
654
- }),
655
- language: new Aggregation({
656
- buckets: [{ key: 'baz', doc_count: 20 }],
657
- }),
658
- };
659
-
660
- el.aggregations = aggs;
661
- await el.updateComplete;
662
-
663
- const facetHeaders = el.shadowRoot?.querySelectorAll('.facet-group-header');
664
-
665
- // The only two facet groups should be Language and Creator (in that order)
666
- expect(facetHeaders?.length).to.equal(2);
667
- expect(facetHeaders?.[0].textContent).to.contain('Language');
668
- expect(facetHeaders?.[1].textContent).to.contain('Creator');
669
- });
670
-
671
- describe('More Facets', () => {
672
- it('Does not render < allowedFacetCount', async () => {
673
- const el = await fixture<CollectionFacets>(
674
- html`<collection-facets></collection-facets>`,
675
- );
676
-
677
- const aggs: Record<string, Aggregation> = {
678
- subject: new Aggregation({
679
- buckets: [
680
- {
681
- key: 'foo',
682
- doc_count: 5,
683
- },
684
- ],
685
- }),
686
- };
687
-
688
- el.aggregations = aggs;
689
- await el.updateComplete;
690
-
691
- const moreLink = el.shadowRoot?.querySelector('.more-link');
692
- expect(moreLink).to.be.null;
693
- });
694
-
695
- it('Render More Facets', async () => {
696
- const modalManager = await fixture<ModalManager>(
697
- html`<modal-manager></modal-manager>`,
698
- );
699
-
700
- const el = await fixture<CollectionFacets>(
701
- html`<collection-facets
702
- .modalManager=${modalManager}
703
- ></collection-facets>`,
704
- );
705
-
706
- const aggs: Record<string, Aggregation> = {
707
- subject: new Aggregation({
708
- buckets: [
709
- {
710
- key: 'foo',
711
- doc_count: 5,
712
- },
713
- {
714
- key: 'fi',
715
- doc_count: 5,
716
- },
717
- {
718
- key: 'fum',
719
- doc_count: 5,
720
- },
721
- {
722
- key: 'flee',
723
- doc_count: 5,
724
- },
725
- {
726
- key: 'wheee',
727
- doc_count: 5,
728
- },
729
- {
730
- key: 'whooo',
731
- doc_count: 5,
732
- },
733
- {
734
- key: 'boop',
735
- doc_count: 5,
736
- },
737
- ],
738
- }),
739
- };
740
-
741
- el.aggregations = aggs;
742
- await el.updateComplete;
743
-
744
- let eventCaught = false;
745
- let eventFacet = '';
746
- el.addEventListener('showMoreFacets', e => {
747
- eventFacet = (e as CustomEvent).detail;
748
- eventCaught = true;
749
- });
750
-
751
- const moreLink = el.shadowRoot?.querySelector(
752
- '.more-link',
753
- ) as HTMLButtonElement;
754
- expect(moreLink).to.exist; // has link
755
-
756
- const showModalSpy = sinon.spy(
757
- el.modalManager as ModalManagerInterface,
758
- 'showModal',
759
- );
760
- // let's pop up modal
761
- moreLink?.click();
762
- await el.updateComplete;
763
-
764
- expect(showModalSpy.callCount).to.equal(1);
765
- expect(el.modalManager?.classList.contains('more-search-facets')).to.be
766
- .true;
767
- expect(eventCaught).to.be.true;
768
- expect(eventFacet).to.equal('subject' as FacetOption);
769
- });
770
- });
771
-
772
- it('fire analytics on more link', async () => {
773
- const mockAnalyticsHandler = new MockAnalyticsHandler();
774
-
775
- const el = await fixture<CollectionFacets>(
776
- html`<collection-facets
777
- .analyticsHandler=${mockAnalyticsHandler}
778
- ></collection-facets>`,
779
- );
780
- const aggs: Record<string, Aggregation> = {
781
- subject: new Aggregation({
782
- buckets: [
783
- {
784
- key: 'foo',
785
- doc_count: 5,
786
- },
787
- {
788
- key: 'fi',
789
- doc_count: 5,
790
- },
791
- {
792
- key: 'fum',
793
- doc_count: 5,
794
- },
795
- {
796
- key: 'flee',
797
- doc_count: 5,
798
- },
799
- {
800
- key: 'wheee',
801
- doc_count: 5,
802
- },
803
- {
804
- key: 'whooo',
805
- doc_count: 5,
806
- },
807
- {
808
- key: 'boop',
809
- doc_count: 5,
810
- },
811
- ],
812
- }),
813
- };
814
-
815
- el.aggregations = aggs;
816
- await el.updateComplete;
817
-
818
- const moreLink = el.shadowRoot?.querySelector(
819
- '.more-link',
820
- ) as HTMLButtonElement;
821
-
822
- expect(moreLink).to.exist; // has link
823
-
824
- moreLink?.click();
825
- await el.updateComplete;
826
-
827
- expect(mockAnalyticsHandler.callCategory).to.equal('collection-browser');
828
- expect(mockAnalyticsHandler.callAction).to.equal('showMoreFacetsModal');
829
- expect(mockAnalyticsHandler.callLabel).to.equal('subject');
830
- });
831
-
832
- it('includes Part Of section for collections', async () => {
833
- const el = await fixture<CollectionFacets>(
834
- html`<collection-facets
835
- .baseNavigationUrl=${''}
836
- .withinCollection=${'foo'}
837
- .parentCollections=${['bar', 'baz']}
838
- .collectionTitles=${new Map([
839
- ['foo', 'foo-name'],
840
- ['bar', 'bar-name'],
841
- ['baz', 'baz-name'],
842
- ])}
843
- ></collection-facets>`,
844
- );
845
-
846
- const partOfSection = el.shadowRoot?.querySelector('.partof-collections');
847
- expect(partOfSection).to.exist;
848
-
849
- const partOfLinks = partOfSection?.querySelectorAll('a[href]');
850
- expect(partOfLinks?.length).to.equal(2);
851
-
852
- expect(partOfLinks?.[0]?.textContent?.trim()).to.equal('bar-name');
853
- expect(partOfLinks?.[0]?.getAttribute('href')).to.equal('/details/bar');
854
- expect(partOfLinks?.[1]?.textContent?.trim()).to.equal('baz-name');
855
- expect(partOfLinks?.[1]?.getAttribute('href')).to.equal('/details/baz');
856
- });
857
-
858
- it('does not include Part Of section without parent collections', async () => {
859
- // No parentCollections prop
860
- const el = await fixture<CollectionFacets>(
861
- html`<collection-facets .withinCollection=${'foo'}></collection-facets>`,
862
- );
863
-
864
- const partOfSection = el.shadowRoot?.querySelector('.partof-collections');
865
- expect(partOfSection).not.to.exist;
866
- });
867
-
868
- it('fires analytics on expanding date picker', async () => {
869
- const mockAnalyticsHandler = new MockAnalyticsHandler();
870
-
871
- const el = await fixture<CollectionFacets>(
872
- html`<collection-facets
873
- .analyticsHandler=${mockAnalyticsHandler}
874
- ></collection-facets>`,
875
- );
876
-
877
- el.histogramAggregationLoading = false;
878
- el.showHistogramDatePicker = true;
879
- el.allowExpandingDatePicker = true;
880
- el.histogramAggregation = new Aggregation({
881
- buckets: [1, 2, 3],
882
- first_bucket_key: 0,
883
- last_bucket_key: 2,
884
- });
885
- await el.updateComplete;
886
-
887
- const expandBtn = el.shadowRoot?.querySelector(
888
- '.expand-date-picker-btn',
889
- ) as HTMLButtonElement;
890
- expect(expandBtn).to.exist;
891
-
892
- // Click the expand button to open the modal
893
- expandBtn?.click();
894
- await el.updateComplete;
895
-
896
- expect(mockAnalyticsHandler.callCategory).to.equal('collection-browser');
897
- expect(mockAnalyticsHandler.callAction).to.equal('histogramExpanded');
898
- expect(mockAnalyticsHandler.callLabel).to.equal(window.location.href);
899
- });
900
-
901
- it('fires analytics on clicking Part Of collection link', async () => {
902
- const mockAnalyticsHandler = new MockAnalyticsHandler();
903
-
904
- const el = await fixture<CollectionFacets>(
905
- html`<collection-facets
906
- .baseNavigationUrl=${''}
907
- .withinCollection=${'foo'}
908
- .parentCollections=${['bar']}
909
- .analyticsHandler=${mockAnalyticsHandler}
910
- ></collection-facets>`,
911
- );
912
-
913
- const partOfLinks = el.shadowRoot?.querySelectorAll(
914
- '.partof-collections a[href]',
915
- );
916
- expect(partOfLinks?.length).to.equal(1);
917
-
918
- // Click the expand button to open the modal
919
- const link = partOfLinks?.[0] as HTMLAnchorElement;
920
- link?.addEventListener('click', e => e.preventDefault());
921
- link?.click();
922
- await el.updateComplete;
923
-
924
- expect(mockAnalyticsHandler.callCategory).to.equal('collection-browser');
925
- expect(mockAnalyticsHandler.callAction).to.equal('partOfCollectionClicked');
926
- expect(mockAnalyticsHandler.callLabel).to.equal('bar');
927
- });
928
- });
1
+ import { expect, fixture } from '@open-wc/testing';
2
+ import sinon from 'sinon';
3
+ import { html } from 'lit';
4
+ import { Aggregation } from '@internetarchive/search-service';
5
+ import {
6
+ ModalManager,
7
+ ModalManagerInterface,
8
+ } from '@internetarchive/modal-manager';
9
+ import type { CollectionFacets } from '../src/collection-facets';
10
+ import '@internetarchive/modal-manager';
11
+ import '../src/collection-facets';
12
+ import {
13
+ FacetOption,
14
+ // SelectedFacets, Used in lending tests (disabled)
15
+ getDefaultSelectedFacets,
16
+ } from '../src/models';
17
+ import { MockAnalyticsHandler } from './mocks/mock-analytics-handler';
18
+ import type { FacetRow } from '../src/collection-facets/facet-row';
19
+ // import type { FacetsTemplate } from '../src/collection-facets/facets-template'; Used in lending tests (disabled)
20
+
21
+ describe('Collection Facets', () => {
22
+ it('has loader', async () => {
23
+ const el = await fixture<CollectionFacets>(
24
+ html`<collection-facets ?facetsLoading=${true}></collection-facets>`,
25
+ );
26
+
27
+ expect(
28
+ el.shadowRoot?.querySelector('#container')?.classList.contains('loading'),
29
+ ).to.be.true;
30
+
31
+ el.facetsLoading = false;
32
+ await el.updateComplete;
33
+
34
+ expect(
35
+ el.shadowRoot?.querySelector('#container')?.classList.contains('loading'),
36
+ ).to.be.false;
37
+ });
38
+
39
+ it('renders a date picker loading placeholder when date picker enabled', async () => {
40
+ const el = await fixture<CollectionFacets>(
41
+ html`<collection-facets></collection-facets>`,
42
+ );
43
+
44
+ el.histogramAggregationLoading = true;
45
+ el.showHistogramDatePicker = true;
46
+ el.histogramAggregation = new Aggregation({
47
+ buckets: [1, 2, 3],
48
+ first_bucket_key: 0,
49
+ last_bucket_key: 2,
50
+ });
51
+ await el.updateComplete;
52
+
53
+ const histogramLoader = el.shadowRoot?.querySelector(
54
+ '.histogram-loading-indicator',
55
+ );
56
+ expect(histogramLoader).to.exist;
57
+ });
58
+
59
+ it('does not render a date picker loading placeholder when date picker disabled', async () => {
60
+ const el = await fixture<CollectionFacets>(
61
+ html`<collection-facets></collection-facets>`,
62
+ );
63
+
64
+ el.histogramAggregationLoading = true;
65
+ el.showHistogramDatePicker = false;
66
+ el.histogramAggregation = new Aggregation({
67
+ buckets: [1, 2, 3],
68
+ first_bucket_key: 0,
69
+ last_bucket_key: 2,
70
+ });
71
+ await el.updateComplete;
72
+
73
+ const histogramLoader = el.shadowRoot?.querySelector(
74
+ '.histogram-loading-indicator',
75
+ );
76
+ expect(histogramLoader).to.be.null;
77
+ });
78
+
79
+ it('renders the date picker when enabled with data present', async () => {
80
+ const el = await fixture<CollectionFacets>(
81
+ html`<collection-facets></collection-facets>`,
82
+ );
83
+
84
+ el.histogramAggregationLoading = false;
85
+ el.showHistogramDatePicker = true;
86
+ el.histogramAggregation = new Aggregation({
87
+ buckets: [1, 2, 3],
88
+ first_bucket_key: 0,
89
+ last_bucket_key: 2,
90
+ });
91
+ await el.updateComplete;
92
+
93
+ const histogram = el.shadowRoot?.querySelector('histogram-date-range');
94
+ expect(histogram).to.exist;
95
+ });
96
+
97
+ it('does not render the date picker when disabled', async () => {
98
+ const el = await fixture<CollectionFacets>(
99
+ html`<collection-facets></collection-facets>`,
100
+ );
101
+
102
+ el.histogramAggregationLoading = false;
103
+ el.showHistogramDatePicker = false;
104
+ el.histogramAggregation = new Aggregation({
105
+ buckets: [1, 2, 3],
106
+ first_bucket_key: 0,
107
+ last_bucket_key: 2,
108
+ });
109
+ await el.updateComplete;
110
+
111
+ const histogram = el.shadowRoot?.querySelector('histogram-date-range');
112
+ expect(histogram).to.be.null;
113
+ });
114
+
115
+ it('renders button to expand the date picker when allowed', async () => {
116
+ const el = await fixture<CollectionFacets>(
117
+ html`<collection-facets></collection-facets>`,
118
+ );
119
+
120
+ el.histogramAggregationLoading = false;
121
+ el.showHistogramDatePicker = true;
122
+ el.allowExpandingDatePicker = true;
123
+ el.histogramAggregation = new Aggregation({
124
+ buckets: [1, 2, 3],
125
+ first_bucket_key: 0,
126
+ last_bucket_key: 2,
127
+ });
128
+ await el.updateComplete;
129
+
130
+ const expandBtn = el.shadowRoot?.querySelector('.expand-date-picker-btn');
131
+ expect(expandBtn).to.exist;
132
+ });
133
+
134
+ it('does not render button to expand the date picker when disallowed', async () => {
135
+ const el = await fixture<CollectionFacets>(
136
+ html`<collection-facets></collection-facets>`,
137
+ );
138
+
139
+ el.histogramAggregationLoading = false;
140
+ el.showHistogramDatePicker = true;
141
+ el.allowExpandingDatePicker = false;
142
+ el.histogramAggregation = new Aggregation({
143
+ buckets: [1, 2, 3],
144
+ first_bucket_key: 0,
145
+ last_bucket_key: 2,
146
+ });
147
+ await el.updateComplete;
148
+
149
+ const expandBtn = el.shadowRoot?.querySelector('.expand-date-picker-btn');
150
+ expect(expandBtn).to.be.null;
151
+ });
152
+
153
+ it('opens modal when date picker expand button clicked', async () => {
154
+ const modalManager = await fixture<ModalManager>(
155
+ html`<modal-manager></modal-manager>`,
156
+ );
157
+
158
+ const el = await fixture<CollectionFacets>(
159
+ html`<collection-facets
160
+ .modalManager=${modalManager}
161
+ ></collection-facets>`,
162
+ );
163
+
164
+ el.histogramAggregationLoading = false;
165
+ el.showHistogramDatePicker = true;
166
+ el.allowExpandingDatePicker = true;
167
+ el.histogramAggregation = new Aggregation({
168
+ buckets: [1, 2, 3],
169
+ first_bucket_key: 0,
170
+ last_bucket_key: 2,
171
+ });
172
+ await el.updateComplete;
173
+
174
+ const expandBtn = el.shadowRoot?.querySelector(
175
+ '.expand-date-picker-btn',
176
+ ) as HTMLButtonElement;
177
+ expect(expandBtn).to.exist;
178
+
179
+ const showModalSpy = sinon.spy(
180
+ el.modalManager as ModalManagerInterface,
181
+ 'showModal',
182
+ );
183
+
184
+ // Click the expand button to open the modal
185
+ expandBtn?.click();
186
+ await el.updateComplete;
187
+
188
+ expect(showModalSpy.callCount).to.equal(1);
189
+ expect(el.modalManager?.classList.contains('expanded-date-picker')).to.be
190
+ .true;
191
+ });
192
+
193
+ it('renders aggregations as facets', async () => {
194
+ const el = await fixture<CollectionFacets>(
195
+ html`<collection-facets></collection-facets>`,
196
+ );
197
+
198
+ const aggs: Record<string, Aggregation> = {
199
+ subject: new Aggregation({
200
+ buckets: [
201
+ {
202
+ key: 'foo',
203
+ doc_count: 5,
204
+ },
205
+ ],
206
+ }),
207
+ };
208
+
209
+ el.aggregations = aggs;
210
+ await el.updateComplete;
211
+ const facetGroups = el.shadowRoot?.querySelectorAll('.facet-group');
212
+ expect(facetGroups?.length).to.equal(1);
213
+
214
+ const titleFacetGroup = facetGroups?.[0];
215
+ const facetGroupHeader = titleFacetGroup?.querySelector('h3');
216
+ // Every facet group header has an invisible " filters" suffix for screen-readers
217
+ expect(
218
+ facetGroupHeader?.querySelector('span.sr-only')?.textContent?.trim(),
219
+ ).to.equal('filters');
220
+ // Ignoring the screen-reader suffix, we should be left with only the readable, capitalized title
221
+ expect(
222
+ facetGroupHeader?.textContent?.trim().replace(/\s*filters$/, ''),
223
+ ).to.equal('Subject');
224
+
225
+ const titleFacetRow = titleFacetGroup
226
+ ?.querySelector('facets-template')
227
+ ?.shadowRoot?.querySelector('facet-row') as FacetRow;
228
+ await titleFacetRow.updateComplete;
229
+ });
230
+
231
+ it('renders multiple aggregation types', async () => {
232
+ const el = await fixture<CollectionFacets>(
233
+ html`<collection-facets></collection-facets>`,
234
+ );
235
+
236
+ const aggs: Record<string, Aggregation> = {
237
+ subject: new Aggregation({
238
+ buckets: [
239
+ {
240
+ key: 'foo',
241
+ doc_count: 5,
242
+ },
243
+ ],
244
+ }),
245
+ mediatype: new Aggregation({
246
+ buckets: [
247
+ {
248
+ key: 'bar',
249
+ doc_count: 10,
250
+ },
251
+ ],
252
+ }),
253
+ };
254
+
255
+ el.aggregations = aggs;
256
+ await el.updateComplete;
257
+
258
+ const facetGroups = el.shadowRoot?.querySelectorAll('.facet-group');
259
+ expect(facetGroups?.length).to.equal(2);
260
+ });
261
+
262
+ it('does not render suppressed collection facets', async () => {
263
+ const el = await fixture<CollectionFacets>(
264
+ html`<collection-facets></collection-facets>`,
265
+ );
266
+
267
+ const aggs: Record<string, Aggregation> = {
268
+ collection: new Aggregation({
269
+ buckets: [
270
+ {
271
+ key: 'deemphasize',
272
+ doc_count: 5,
273
+ },
274
+ {
275
+ key: 'community',
276
+ doc_count: 5,
277
+ },
278
+ {
279
+ key: 'foo',
280
+ doc_count: 5,
281
+ },
282
+ ],
283
+ }),
284
+ };
285
+
286
+ el.aggregations = aggs;
287
+ await el.updateComplete;
288
+
289
+ const collectionFacets = el.shadowRoot
290
+ ?.querySelector('facets-template')
291
+ ?.shadowRoot?.querySelectorAll('facet-row') as ArrayLike<FacetRow>;
292
+ expect(collectionFacets?.length).to.equal(1);
293
+
294
+ // The first (and only) collection link should be for 'foo'
295
+ expect(collectionFacets[0].bucket?.key).to.equal('foo');
296
+ });
297
+
298
+ // Lending tests disabled because lending facet disabled
299
+ // it('renders lending facets with human-readable names', async () => {
300
+ // const el = await fixture<CollectionFacets>(
301
+ // html`<collection-facets></collection-facets>`
302
+ // );
303
+
304
+ // const aggs: Record<string, Aggregation> = {
305
+ // lending: new Aggregation({
306
+ // buckets: [
307
+ // {
308
+ // key: 'is_lendable',
309
+ // doc_count: 3,
310
+ // },
311
+ // {
312
+ // key: 'available_to_borrow',
313
+ // doc_count: 2,
314
+ // },
315
+ // {
316
+ // key: 'is_readable',
317
+ // doc_count: 1,
318
+ // },
319
+ // ],
320
+ // }),
321
+ // };
322
+
323
+ // el.aggregations = aggs;
324
+ // await el.updateComplete;
325
+
326
+ // const facetsTemplate = el.shadowRoot?.querySelector(
327
+ // 'facets-template'
328
+ // ) as FacetsTemplate;
329
+ // await facetsTemplate?.updateComplete;
330
+
331
+ // const lendingFacets = facetsTemplate?.shadowRoot?.querySelectorAll(
332
+ // 'facet-row'
333
+ // ) as ArrayLike<FacetRow>;
334
+ // expect(lendingFacets?.length).to.equal(3);
335
+
336
+ // expect(lendingFacets[0].shadowRoot?.textContent?.trim()).to.match(
337
+ // /^Lending Library\s*3$/
338
+ // );
339
+ // expect(lendingFacets[1].shadowRoot?.textContent?.trim()).to.match(
340
+ // /^Borrow 14 Days\s*2$/
341
+ // );
342
+ // expect(lendingFacets[2].shadowRoot?.textContent?.trim()).to.match(
343
+ // /^Always Available\s*1$/
344
+ // );
345
+ // });
346
+
347
+ // it('renders selected/negative lending facets with human-readable names', async () => {
348
+ // const el = await fixture<CollectionFacets>(
349
+ // html`<collection-facets></collection-facets>`
350
+ // );
351
+
352
+ // const selectedFacets: SelectedFacets = {
353
+ // subject: {},
354
+ // lending: {
355
+ // is_lendable: {
356
+ // key: 'is_lendable',
357
+ // count: 5,
358
+ // state: 'selected',
359
+ // },
360
+ // available_to_borrow: {
361
+ // key: 'available_to_borrow',
362
+ // count: 4,
363
+ // state: 'selected',
364
+ // },
365
+ // is_readable: {
366
+ // key: 'is_readable',
367
+ // count: 3,
368
+ // state: 'hidden',
369
+ // },
370
+ // },
371
+ // mediatype: {},
372
+ // language: {},
373
+ // creator: {},
374
+ // collection: {},
375
+ // year: {},
376
+ // };
377
+
378
+ // el.selectedFacets = selectedFacets;
379
+ // await el.updateComplete;
380
+
381
+ // const facetsTemplate = el.shadowRoot?.querySelector(
382
+ // 'facets-template'
383
+ // ) as FacetsTemplate;
384
+ // await facetsTemplate?.updateComplete;
385
+
386
+ // const lendingFacets = facetsTemplate?.shadowRoot?.querySelectorAll(
387
+ // 'facet-row'
388
+ // ) as ArrayLike<FacetRow>;
389
+ // expect(lendingFacets?.length).to.equal(3);
390
+
391
+ // expect(lendingFacets[0].shadowRoot?.textContent?.trim()).to.match(
392
+ // /^Lending Library\s*5$/
393
+ // );
394
+ // expect(lendingFacets[1].shadowRoot?.textContent?.trim()).to.match(
395
+ // /^Borrow 14 Days\s*4$/
396
+ // );
397
+ // expect(lendingFacets[2].shadowRoot?.textContent?.trim()).to.match(
398
+ // /^Always Available\s*3$/
399
+ // );
400
+ // });
401
+
402
+ // it('only renders lending facets for is_lendable, available_to_borrow, and is_readable', async () => {
403
+ // const el = await fixture<CollectionFacets>(
404
+ // html`<collection-facets></collection-facets>`
405
+ // );
406
+
407
+ // const aggs: Record<string, Aggregation> = {
408
+ // lending: new Aggregation({
409
+ // buckets: [
410
+ // {
411
+ // key: 'is_lendable',
412
+ // doc_count: 5,
413
+ // },
414
+ // {
415
+ // key: 'is_borrowable',
416
+ // doc_count: 4,
417
+ // },
418
+ // {
419
+ // key: 'available_to_borrow',
420
+ // doc_count: 5,
421
+ // },
422
+ // {
423
+ // key: 'is_browsable',
424
+ // doc_count: 4,
425
+ // },
426
+ // {
427
+ // key: 'available_to_browse',
428
+ // doc_count: 5,
429
+ // },
430
+ // {
431
+ // key: 'is_readable',
432
+ // doc_count: 4,
433
+ // },
434
+ // {
435
+ // key: 'available_to_waitlist',
436
+ // doc_count: 5,
437
+ // },
438
+ // ],
439
+ // }),
440
+ // };
441
+
442
+ // el.aggregations = aggs;
443
+ // await el.updateComplete;
444
+
445
+ // const facetsTemplate = el.shadowRoot?.querySelector(
446
+ // 'facets-template'
447
+ // ) as FacetsTemplate;
448
+ // await facetsTemplate?.updateComplete;
449
+ // await new Promise(res => {
450
+ // setTimeout(res, 100);
451
+ // });
452
+
453
+ // const lendingFacets = facetsTemplate?.shadowRoot?.querySelectorAll(
454
+ // 'facet-row'
455
+ // ) as ArrayLike<FacetRow>;
456
+ // expect(lendingFacets?.length).to.equal(3);
457
+
458
+ // expect(lendingFacets[0].shadowRoot?.textContent?.trim()).to.match(
459
+ // /^Lending Library\s*5$/
460
+ // );
461
+ // expect(lendingFacets[1].shadowRoot?.textContent?.trim()).to.match(
462
+ // /^Borrow 14 Days\s*5$/
463
+ // );
464
+ // expect(lendingFacets[2].shadowRoot?.textContent?.trim()).to.match(
465
+ // /^Always Available\s*4$/
466
+ // );
467
+ // });
468
+
469
+ // it('does not render a More... link for lending facets', async () => {
470
+ // const el = await fixture<CollectionFacets>(
471
+ // html`<collection-facets></collection-facets>`
472
+ // );
473
+
474
+ // const aggs: Record<string, Aggregation> = {
475
+ // lending: new Aggregation({
476
+ // buckets: [
477
+ // {
478
+ // key: 'is_lendable',
479
+ // doc_count: 5,
480
+ // },
481
+ // {
482
+ // key: 'is_borrowable',
483
+ // doc_count: 4,
484
+ // },
485
+ // {
486
+ // key: 'available_to_borrow',
487
+ // doc_count: 5,
488
+ // },
489
+ // {
490
+ // key: 'is_browsable',
491
+ // doc_count: 4,
492
+ // },
493
+ // {
494
+ // key: 'available_to_browse',
495
+ // doc_count: 5,
496
+ // },
497
+ // {
498
+ // key: 'is_readable',
499
+ // doc_count: 4,
500
+ // },
501
+ // {
502
+ // key: 'available_to_waitlist',
503
+ // doc_count: 5,
504
+ // },
505
+ // ],
506
+ // }),
507
+ // };
508
+
509
+ // el.aggregations = aggs;
510
+ // await el.updateComplete;
511
+
512
+ // const moreLink = el.shadowRoot?.querySelector('.more-link');
513
+ // expect(moreLink).not.to.exist;
514
+ // });
515
+
516
+ it('always renders the mediatype:collection facet when present', async () => {
517
+ const el = await fixture<CollectionFacets>(
518
+ html`<collection-facets></collection-facets>`,
519
+ );
520
+
521
+ const aggs: Record<string, Aggregation> = {
522
+ mediatype: new Aggregation({
523
+ buckets: [
524
+ {
525
+ key: 'texts',
526
+ doc_count: 10000,
527
+ },
528
+ {
529
+ key: 'image',
530
+ doc_count: 9000,
531
+ },
532
+ {
533
+ key: 'audio',
534
+ doc_count: 8000,
535
+ },
536
+ {
537
+ key: 'movies',
538
+ doc_count: 7000,
539
+ },
540
+ {
541
+ key: 'software',
542
+ doc_count: 6000,
543
+ },
544
+ {
545
+ key: 'data',
546
+ doc_count: 5000,
547
+ },
548
+ {
549
+ key: 'etree',
550
+ doc_count: 4000,
551
+ },
552
+ {
553
+ key: 'collection',
554
+ doc_count: 1,
555
+ },
556
+ ],
557
+ }),
558
+ };
559
+
560
+ el.aggregations = aggs;
561
+ await el.updateComplete;
562
+
563
+ const facetsTemplate = el.shadowRoot?.querySelector('facets-template');
564
+ const facetRows = facetsTemplate?.shadowRoot?.querySelectorAll(
565
+ 'facet-row',
566
+ ) as ArrayLike<FacetRow>;
567
+ expect(facetRows?.length).to.equal(6);
568
+ expect(facetRows?.[5]?.bucket?.key).to.equal('collection');
569
+ });
570
+
571
+ it('renders the mediatype:collection facet even when >=6 other mediatypes are selected', async () => {
572
+ const el = await fixture<CollectionFacets>(
573
+ html`<collection-facets></collection-facets>`,
574
+ );
575
+
576
+ const aggs: Record<string, Aggregation> = {
577
+ mediatype: new Aggregation({
578
+ buckets: [
579
+ {
580
+ key: 'texts',
581
+ doc_count: 10000,
582
+ },
583
+ {
584
+ key: 'image',
585
+ doc_count: 9000,
586
+ },
587
+ {
588
+ key: 'audio',
589
+ doc_count: 8000,
590
+ },
591
+ {
592
+ key: 'movies',
593
+ doc_count: 7000,
594
+ },
595
+ {
596
+ key: 'software',
597
+ doc_count: 6000,
598
+ },
599
+ {
600
+ key: 'data',
601
+ doc_count: 5000,
602
+ },
603
+ {
604
+ key: 'etree',
605
+ doc_count: 4000,
606
+ },
607
+ {
608
+ key: 'collection',
609
+ doc_count: 1,
610
+ },
611
+ ],
612
+ }),
613
+ };
614
+
615
+ const selectedFacets = getDefaultSelectedFacets();
616
+ selectedFacets.mediatype = {
617
+ texts: { key: 'texts', count: 10000, state: 'selected' },
618
+ image: { key: 'image', count: 9000, state: 'selected' },
619
+ audio: { key: 'audio', count: 8000, state: 'selected' },
620
+ movies: { key: 'movies', count: 7000, state: 'selected' },
621
+ software: { key: 'software', count: 6000, state: 'selected' },
622
+ data: { key: 'data', count: 5000, state: 'selected' },
623
+ etree: { key: 'etree', count: 4000, state: 'selected' },
624
+ };
625
+
626
+ el.aggregations = aggs;
627
+ el.selectedFacets = selectedFacets;
628
+ await el.updateComplete;
629
+
630
+ const facetsTemplate = el.shadowRoot?.querySelector('facets-template');
631
+ const facetRows = facetsTemplate?.shadowRoot?.querySelectorAll(
632
+ 'facet-row',
633
+ ) as ArrayLike<FacetRow>;
634
+ expect(facetRows?.length).to.equal(8);
635
+ expect(facetRows?.[7]?.bucket?.key).to.equal('collection');
636
+ });
637
+
638
+ it('uses specified facet display order', async () => {
639
+ const el = await fixture<CollectionFacets>(
640
+ html`<collection-facets
641
+ .facetDisplayOrder=${['language', 'creator'] as FacetOption[]}
642
+ ></collection-facets>`,
643
+ );
644
+
645
+ const aggs: Record<string, Aggregation> = {
646
+ mediatype: new Aggregation({
647
+ buckets: [{ key: 'texts', doc_count: 5 }],
648
+ }),
649
+ collection: new Aggregation({
650
+ buckets: [{ key: 'foo', doc_count: 10 }],
651
+ }),
652
+ creator: new Aggregation({
653
+ buckets: [{ key: 'bar', doc_count: 15 }],
654
+ }),
655
+ language: new Aggregation({
656
+ buckets: [{ key: 'baz', doc_count: 20 }],
657
+ }),
658
+ };
659
+
660
+ el.aggregations = aggs;
661
+ await el.updateComplete;
662
+
663
+ const facetHeaders = el.shadowRoot?.querySelectorAll('.facet-group-header');
664
+
665
+ // The only two facet groups should be Language and Creator (in that order)
666
+ expect(facetHeaders?.length).to.equal(2);
667
+ expect(facetHeaders?.[0].textContent).to.contain('Language');
668
+ expect(facetHeaders?.[1].textContent).to.contain('Creator');
669
+ });
670
+
671
+ describe('More Facets', () => {
672
+ it('Does not render < allowedFacetCount', async () => {
673
+ const el = await fixture<CollectionFacets>(
674
+ html`<collection-facets></collection-facets>`,
675
+ );
676
+
677
+ const aggs: Record<string, Aggregation> = {
678
+ subject: new Aggregation({
679
+ buckets: [
680
+ {
681
+ key: 'foo',
682
+ doc_count: 5,
683
+ },
684
+ ],
685
+ }),
686
+ };
687
+
688
+ el.aggregations = aggs;
689
+ await el.updateComplete;
690
+
691
+ const moreLink = el.shadowRoot?.querySelector('.more-link');
692
+ expect(moreLink).to.be.null;
693
+ });
694
+
695
+ it('Render More Facets', async () => {
696
+ const modalManager = await fixture<ModalManager>(
697
+ html`<modal-manager></modal-manager>`,
698
+ );
699
+
700
+ const el = await fixture<CollectionFacets>(
701
+ html`<collection-facets
702
+ .modalManager=${modalManager}
703
+ ></collection-facets>`,
704
+ );
705
+
706
+ const aggs: Record<string, Aggregation> = {
707
+ subject: new Aggregation({
708
+ buckets: [
709
+ {
710
+ key: 'foo',
711
+ doc_count: 5,
712
+ },
713
+ {
714
+ key: 'fi',
715
+ doc_count: 5,
716
+ },
717
+ {
718
+ key: 'fum',
719
+ doc_count: 5,
720
+ },
721
+ {
722
+ key: 'flee',
723
+ doc_count: 5,
724
+ },
725
+ {
726
+ key: 'wheee',
727
+ doc_count: 5,
728
+ },
729
+ {
730
+ key: 'whooo',
731
+ doc_count: 5,
732
+ },
733
+ {
734
+ key: 'boop',
735
+ doc_count: 5,
736
+ },
737
+ ],
738
+ }),
739
+ };
740
+
741
+ el.aggregations = aggs;
742
+ await el.updateComplete;
743
+
744
+ let eventCaught = false;
745
+ let eventFacet = '';
746
+ el.addEventListener('showMoreFacets', e => {
747
+ eventFacet = (e as CustomEvent).detail;
748
+ eventCaught = true;
749
+ });
750
+
751
+ const moreLink = el.shadowRoot?.querySelector(
752
+ '.more-link',
753
+ ) as HTMLButtonElement;
754
+ expect(moreLink).to.exist; // has link
755
+
756
+ const showModalSpy = sinon.spy(
757
+ el.modalManager as ModalManagerInterface,
758
+ 'showModal',
759
+ );
760
+ // let's pop up modal
761
+ moreLink?.click();
762
+ await el.updateComplete;
763
+
764
+ expect(showModalSpy.callCount).to.equal(1);
765
+ expect(el.modalManager?.classList.contains('more-search-facets')).to.be
766
+ .true;
767
+ expect(eventCaught).to.be.true;
768
+ expect(eventFacet).to.equal('subject' as FacetOption);
769
+ });
770
+ });
771
+
772
+ it('fire analytics on more link', async () => {
773
+ const mockAnalyticsHandler = new MockAnalyticsHandler();
774
+
775
+ const el = await fixture<CollectionFacets>(
776
+ html`<collection-facets
777
+ .analyticsHandler=${mockAnalyticsHandler}
778
+ ></collection-facets>`,
779
+ );
780
+ const aggs: Record<string, Aggregation> = {
781
+ subject: new Aggregation({
782
+ buckets: [
783
+ {
784
+ key: 'foo',
785
+ doc_count: 5,
786
+ },
787
+ {
788
+ key: 'fi',
789
+ doc_count: 5,
790
+ },
791
+ {
792
+ key: 'fum',
793
+ doc_count: 5,
794
+ },
795
+ {
796
+ key: 'flee',
797
+ doc_count: 5,
798
+ },
799
+ {
800
+ key: 'wheee',
801
+ doc_count: 5,
802
+ },
803
+ {
804
+ key: 'whooo',
805
+ doc_count: 5,
806
+ },
807
+ {
808
+ key: 'boop',
809
+ doc_count: 5,
810
+ },
811
+ ],
812
+ }),
813
+ };
814
+
815
+ el.aggregations = aggs;
816
+ await el.updateComplete;
817
+
818
+ const moreLink = el.shadowRoot?.querySelector(
819
+ '.more-link',
820
+ ) as HTMLButtonElement;
821
+
822
+ expect(moreLink).to.exist; // has link
823
+
824
+ moreLink?.click();
825
+ await el.updateComplete;
826
+
827
+ expect(mockAnalyticsHandler.callCategory).to.equal('collection-browser');
828
+ expect(mockAnalyticsHandler.callAction).to.equal('showMoreFacetsModal');
829
+ expect(mockAnalyticsHandler.callLabel).to.equal('subject');
830
+ });
831
+
832
+ it('includes Part Of section for collections', async () => {
833
+ const el = await fixture<CollectionFacets>(
834
+ html`<collection-facets
835
+ .baseNavigationUrl=${''}
836
+ .withinCollection=${'foo'}
837
+ .parentCollections=${['bar', 'baz']}
838
+ .collectionTitles=${new Map([
839
+ ['foo', 'foo-name'],
840
+ ['bar', 'bar-name'],
841
+ ['baz', 'baz-name'],
842
+ ])}
843
+ ></collection-facets>`,
844
+ );
845
+
846
+ const partOfSection = el.shadowRoot?.querySelector('.partof-collections');
847
+ expect(partOfSection).to.exist;
848
+
849
+ const partOfLinks = partOfSection?.querySelectorAll('a[href]');
850
+ expect(partOfLinks?.length).to.equal(2);
851
+
852
+ expect(partOfLinks?.[0]?.textContent?.trim()).to.equal('bar-name');
853
+ expect(partOfLinks?.[0]?.getAttribute('href')).to.equal('/details/bar');
854
+ expect(partOfLinks?.[1]?.textContent?.trim()).to.equal('baz-name');
855
+ expect(partOfLinks?.[1]?.getAttribute('href')).to.equal('/details/baz');
856
+ });
857
+
858
+ it('does not include Part Of section without parent collections', async () => {
859
+ // No parentCollections prop
860
+ const el = await fixture<CollectionFacets>(
861
+ html`<collection-facets .withinCollection=${'foo'}></collection-facets>`,
862
+ );
863
+
864
+ const partOfSection = el.shadowRoot?.querySelector('.partof-collections');
865
+ expect(partOfSection).not.to.exist;
866
+ });
867
+
868
+ it('fires analytics on expanding date picker', async () => {
869
+ const mockAnalyticsHandler = new MockAnalyticsHandler();
870
+
871
+ const el = await fixture<CollectionFacets>(
872
+ html`<collection-facets
873
+ .analyticsHandler=${mockAnalyticsHandler}
874
+ ></collection-facets>`,
875
+ );
876
+
877
+ el.histogramAggregationLoading = false;
878
+ el.showHistogramDatePicker = true;
879
+ el.allowExpandingDatePicker = true;
880
+ el.histogramAggregation = new Aggregation({
881
+ buckets: [1, 2, 3],
882
+ first_bucket_key: 0,
883
+ last_bucket_key: 2,
884
+ });
885
+ await el.updateComplete;
886
+
887
+ const expandBtn = el.shadowRoot?.querySelector(
888
+ '.expand-date-picker-btn',
889
+ ) as HTMLButtonElement;
890
+ expect(expandBtn).to.exist;
891
+
892
+ // Click the expand button to open the modal
893
+ expandBtn?.click();
894
+ await el.updateComplete;
895
+
896
+ expect(mockAnalyticsHandler.callCategory).to.equal('collection-browser');
897
+ expect(mockAnalyticsHandler.callAction).to.equal('histogramExpanded');
898
+ expect(mockAnalyticsHandler.callLabel).to.equal(window.location.href);
899
+ });
900
+
901
+ it('fires analytics on clicking Part Of collection link', async () => {
902
+ const mockAnalyticsHandler = new MockAnalyticsHandler();
903
+
904
+ const el = await fixture<CollectionFacets>(
905
+ html`<collection-facets
906
+ .baseNavigationUrl=${''}
907
+ .withinCollection=${'foo'}
908
+ .parentCollections=${['bar']}
909
+ .analyticsHandler=${mockAnalyticsHandler}
910
+ ></collection-facets>`,
911
+ );
912
+
913
+ const partOfLinks = el.shadowRoot?.querySelectorAll(
914
+ '.partof-collections a[href]',
915
+ );
916
+ expect(partOfLinks?.length).to.equal(1);
917
+
918
+ // Click the expand button to open the modal
919
+ const link = partOfLinks?.[0] as HTMLAnchorElement;
920
+ link?.addEventListener('click', e => e.preventDefault());
921
+ link?.click();
922
+ await el.updateComplete;
923
+
924
+ expect(mockAnalyticsHandler.callCategory).to.equal('collection-browser');
925
+ expect(mockAnalyticsHandler.callAction).to.equal('partOfCollectionClicked');
926
+ expect(mockAnalyticsHandler.callLabel).to.equal('bar');
927
+ });
928
+ });