@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.
- package/.editorconfig +29 -29
- package/.github/workflows/ci.yml +27 -27
- package/.github/workflows/gh-pages-main.yml +39 -39
- package/.github/workflows/npm-publish.yml +39 -39
- package/.github/workflows/pr-preview.yml +38 -38
- package/.husky/pre-commit +4 -4
- package/.prettierignore +1 -1
- package/LICENSE +661 -661
- package/README.md +83 -83
- package/dist/index.d.ts +16 -0
- package/dist/index.js.map +1 -0
- package/dist/src/app-root.d.ts +105 -0
- package/dist/src/app-root.js +1076 -0
- package/dist/src/app-root.js.map +1 -0
- package/dist/src/assets/img/icons/arrow-left.d.ts +2 -0
- package/dist/src/assets/img/icons/arrow-left.js +10 -0
- package/dist/src/assets/img/icons/arrow-left.js.map +1 -0
- package/dist/src/assets/img/icons/arrow-right.d.ts +2 -0
- package/dist/src/assets/img/icons/arrow-right.js +10 -0
- package/dist/src/assets/img/icons/arrow-right.js.map +1 -0
- package/dist/src/assets/img/icons/chevron.d.ts +2 -0
- package/dist/src/assets/img/icons/chevron.js +4 -0
- package/dist/src/assets/img/icons/chevron.js.map +1 -0
- package/dist/src/assets/img/icons/close-circle-dark.d.ts +2 -0
- package/dist/src/assets/img/icons/close-circle-dark.js +5 -0
- package/dist/src/assets/img/icons/close-circle-dark.js.map +1 -0
- package/dist/src/assets/img/icons/contract.d.ts +2 -0
- package/dist/src/assets/img/icons/contract.js +9 -0
- package/dist/src/assets/img/icons/contract.js.map +1 -0
- package/dist/src/assets/img/icons/empty-query.d.ts +2 -0
- package/dist/src/assets/img/icons/empty-query.js +5 -0
- package/dist/src/assets/img/icons/empty-query.js.map +1 -0
- package/dist/src/assets/img/icons/expand.d.ts +2 -0
- package/dist/src/assets/img/icons/expand.js +9 -0
- package/dist/src/assets/img/icons/expand.js.map +1 -0
- package/dist/src/assets/img/icons/eye-closed.d.ts +2 -0
- package/dist/src/assets/img/icons/eye-closed.js +5 -0
- package/dist/src/assets/img/icons/eye-closed.js.map +1 -0
- package/dist/src/assets/img/icons/eye.d.ts +2 -0
- package/dist/src/assets/img/icons/eye.js +5 -0
- package/dist/src/assets/img/icons/eye.js.map +1 -0
- package/dist/src/assets/img/icons/favorite-filled.d.ts +1 -0
- package/dist/src/assets/img/icons/favorite-filled.js +10 -0
- package/dist/src/assets/img/icons/favorite-filled.js.map +1 -0
- package/dist/src/assets/img/icons/favorite-unfilled.d.ts +1 -0
- package/dist/src/assets/img/icons/favorite-unfilled.js +9 -0
- package/dist/src/assets/img/icons/favorite-unfilled.js.map +1 -0
- package/dist/src/assets/img/icons/filter.d.ts +2 -0
- package/dist/src/assets/img/icons/filter.js +10 -0
- package/dist/src/assets/img/icons/filter.js.map +1 -0
- package/dist/src/assets/img/icons/login-required.d.ts +1 -0
- package/dist/src/assets/img/icons/login-required.js +18 -0
- package/dist/src/assets/img/icons/login-required.js.map +1 -0
- package/dist/src/assets/img/icons/mediatype/account.d.ts +1 -0
- package/dist/src/assets/img/icons/mediatype/account.js +14 -0
- package/dist/src/assets/img/icons/mediatype/account.js.map +1 -0
- package/dist/src/assets/img/icons/mediatype/audio.d.ts +1 -0
- package/dist/src/assets/img/icons/mediatype/audio.js +14 -0
- package/dist/src/assets/img/icons/mediatype/audio.js.map +1 -0
- package/dist/src/assets/img/icons/mediatype/collection.d.ts +1 -0
- package/dist/src/assets/img/icons/mediatype/collection.js +12 -0
- package/dist/src/assets/img/icons/mediatype/collection.js.map +1 -0
- package/dist/src/assets/img/icons/mediatype/data.d.ts +1 -0
- package/dist/src/assets/img/icons/mediatype/data.js +15 -0
- package/dist/src/assets/img/icons/mediatype/data.js.map +1 -0
- package/dist/src/assets/img/icons/mediatype/etree.d.ts +1 -0
- package/dist/src/assets/img/icons/mediatype/etree.js +14 -0
- package/dist/src/assets/img/icons/mediatype/etree.js.map +1 -0
- package/dist/src/assets/img/icons/mediatype/film.d.ts +1 -0
- package/dist/src/assets/img/icons/mediatype/film.js +14 -0
- package/dist/src/assets/img/icons/mediatype/film.js.map +1 -0
- package/dist/src/assets/img/icons/mediatype/images.d.ts +1 -0
- package/dist/src/assets/img/icons/mediatype/images.js +13 -0
- package/dist/src/assets/img/icons/mediatype/images.js.map +1 -0
- package/dist/src/assets/img/icons/mediatype/radio.d.ts +1 -0
- package/dist/src/assets/img/icons/mediatype/radio.js +15 -0
- package/dist/src/assets/img/icons/mediatype/radio.js.map +1 -0
- package/dist/src/assets/img/icons/mediatype/search.d.ts +1 -0
- package/dist/src/assets/img/icons/mediatype/search.js +14 -0
- package/dist/src/assets/img/icons/mediatype/search.js.map +1 -0
- package/dist/src/assets/img/icons/mediatype/software.d.ts +1 -0
- package/dist/src/assets/img/icons/mediatype/software.js +13 -0
- package/dist/src/assets/img/icons/mediatype/software.js.map +1 -0
- package/dist/src/assets/img/icons/mediatype/texts.d.ts +1 -0
- package/dist/src/assets/img/icons/mediatype/texts.js +13 -0
- package/dist/src/assets/img/icons/mediatype/texts.js.map +1 -0
- package/dist/src/assets/img/icons/mediatype/tv-commercial.d.ts +1 -0
- package/dist/src/assets/img/icons/mediatype/tv-commercial.js +12 -0
- package/dist/src/assets/img/icons/mediatype/tv-commercial.js.map +1 -0
- package/dist/src/assets/img/icons/mediatype/tv-fact-check.d.ts +1 -0
- package/dist/src/assets/img/icons/mediatype/tv-fact-check.js +12 -0
- package/dist/src/assets/img/icons/mediatype/tv-fact-check.js.map +1 -0
- package/dist/src/assets/img/icons/mediatype/tv-quote.d.ts +1 -0
- package/dist/src/assets/img/icons/mediatype/tv-quote.js +12 -0
- package/dist/src/assets/img/icons/mediatype/tv-quote.js.map +1 -0
- package/dist/src/assets/img/icons/mediatype/tv.d.ts +1 -0
- package/dist/src/assets/img/icons/mediatype/tv.js +14 -0
- package/dist/src/assets/img/icons/mediatype/tv.js.map +1 -0
- package/dist/src/assets/img/icons/mediatype/video.d.ts +1 -0
- package/dist/src/assets/img/icons/mediatype/video.js +14 -0
- package/dist/src/assets/img/icons/mediatype/video.js.map +1 -0
- package/dist/src/assets/img/icons/mediatype/web.d.ts +1 -0
- package/dist/src/assets/img/icons/mediatype/web.js +13 -0
- package/dist/src/assets/img/icons/mediatype/web.js.map +1 -0
- package/dist/src/assets/img/icons/null-result.d.ts +2 -0
- package/dist/src/assets/img/icons/null-result.js +5 -0
- package/dist/src/assets/img/icons/null-result.js.map +1 -0
- package/dist/src/assets/img/icons/quote.d.ts +1 -0
- package/dist/src/assets/img/icons/quote.js +7 -0
- package/dist/src/assets/img/icons/quote.js.map +1 -0
- package/dist/src/assets/img/icons/restricted.d.ts +1 -0
- package/dist/src/assets/img/icons/restricted.js +13 -0
- package/dist/src/assets/img/icons/restricted.js.map +1 -0
- package/dist/src/assets/img/icons/reviews.d.ts +1 -0
- package/dist/src/assets/img/icons/reviews.js +11 -0
- package/dist/src/assets/img/icons/reviews.js.map +1 -0
- package/dist/src/assets/img/icons/upload.d.ts +1 -0
- package/dist/src/assets/img/icons/upload.js +12 -0
- package/dist/src/assets/img/icons/upload.js.map +1 -0
- package/dist/src/assets/img/icons/views.d.ts +1 -0
- package/dist/src/assets/img/icons/views.js +11 -0
- package/dist/src/assets/img/icons/views.js.map +1 -0
- package/dist/src/circular-activity-indicator.d.ts +5 -0
- package/dist/src/circular-activity-indicator.js +66 -0
- package/dist/src/circular-activity-indicator.js.map +1 -0
- package/dist/src/collection-browser.d.ts +692 -0
- package/dist/src/collection-browser.js +2669 -0
- package/dist/src/collection-browser.js.map +1 -0
- package/dist/src/collection-facets/facet-row.d.ts +30 -0
- package/dist/src/collection-facets/facet-row.js +266 -0
- package/dist/src/collection-facets/facet-row.js.map +1 -0
- package/dist/src/collection-facets/facet-tombstone-row.d.ts +5 -0
- package/dist/src/collection-facets/facet-tombstone-row.js +43 -0
- package/dist/src/collection-facets/facet-tombstone-row.js.map +1 -0
- package/dist/src/collection-facets/facets-template.d.ts +13 -0
- package/dist/src/collection-facets/facets-template.js +68 -0
- package/dist/src/collection-facets/facets-template.js.map +1 -0
- package/dist/src/collection-facets/models.d.ts +9 -0
- package/dist/src/collection-facets/models.js +10 -0
- package/dist/src/collection-facets/models.js.map +1 -0
- package/dist/src/collection-facets/more-facets-content.d.ts +109 -0
- package/dist/src/collection-facets/more-facets-content.js +547 -0
- package/dist/src/collection-facets/more-facets-content.js.map +1 -0
- package/dist/src/collection-facets/more-facets-pagination.d.ts +36 -0
- package/dist/src/collection-facets/more-facets-pagination.js +264 -0
- package/dist/src/collection-facets/more-facets-pagination.js.map +1 -0
- package/dist/src/collection-facets/smart-facets/dedupe.d.ts +10 -0
- package/dist/src/collection-facets/smart-facets/dedupe.js +35 -0
- package/dist/src/collection-facets/smart-facets/dedupe.js.map +1 -0
- package/dist/src/collection-facets/smart-facets/heuristics/browser-language/browser-language-heuristic.d.ts +5 -0
- package/dist/src/collection-facets/smart-facets/heuristics/browser-language/browser-language-heuristic.js +24 -0
- package/dist/src/collection-facets/smart-facets/heuristics/browser-language/browser-language-heuristic.js.map +1 -0
- package/dist/src/collection-facets/smart-facets/heuristics/index.d.ts +3 -0
- package/dist/src/collection-facets/smart-facets/heuristics/index.js +4 -0
- package/dist/src/collection-facets/smart-facets/heuristics/index.js.map +1 -0
- package/dist/src/collection-facets/smart-facets/heuristics/query-keywords/query-keywords-heuristic.d.ts +4 -0
- package/dist/src/collection-facets/smart-facets/heuristics/query-keywords/query-keywords-heuristic.js +14 -0
- package/dist/src/collection-facets/smart-facets/heuristics/query-keywords/query-keywords-heuristic.js.map +1 -0
- package/dist/src/collection-facets/smart-facets/heuristics/query-keywords/query-keywords-map.d.ts +6 -0
- package/dist/src/collection-facets/smart-facets/heuristics/query-keywords/query-keywords-map.js +68 -0
- package/dist/src/collection-facets/smart-facets/heuristics/query-keywords/query-keywords-map.js.map +1 -0
- package/dist/src/collection-facets/smart-facets/heuristics/wikidata/wikidata-entity-map.d.ts +9 -0
- package/dist/src/collection-facets/smart-facets/heuristics/wikidata/wikidata-entity-map.js +69 -0
- package/dist/src/collection-facets/smart-facets/heuristics/wikidata/wikidata-entity-map.js.map +1 -0
- package/dist/src/collection-facets/smart-facets/heuristics/wikidata/wikidata-heuristic.d.ts +21 -0
- package/dist/src/collection-facets/smart-facets/heuristics/wikidata/wikidata-heuristic.js +76 -0
- package/dist/src/collection-facets/smart-facets/heuristics/wikidata/wikidata-heuristic.js.map +1 -0
- package/dist/src/collection-facets/smart-facets/models.d.ts +30 -0
- package/dist/src/collection-facets/smart-facets/models.js +2 -0
- package/dist/src/collection-facets/smart-facets/models.js.map +1 -0
- package/dist/src/collection-facets/smart-facets/smart-facet-bar.d.ts +54 -0
- package/dist/src/collection-facets/smart-facets/smart-facet-bar.js +383 -0
- package/dist/src/collection-facets/smart-facets/smart-facet-bar.js.map +1 -0
- package/dist/src/collection-facets/smart-facets/smart-facet-button.d.ts +11 -0
- package/dist/src/collection-facets/smart-facets/smart-facet-button.js +133 -0
- package/dist/src/collection-facets/smart-facets/smart-facet-button.js.map +1 -0
- package/dist/src/collection-facets/smart-facets/smart-facet-dropdown.d.ts +28 -0
- package/dist/src/collection-facets/smart-facets/smart-facet-dropdown.js +172 -0
- package/dist/src/collection-facets/smart-facets/smart-facet-dropdown.js.map +1 -0
- package/dist/src/collection-facets/smart-facets/smart-facet-equals.d.ts +2 -0
- package/dist/src/collection-facets/smart-facets/smart-facet-equals.js +13 -0
- package/dist/src/collection-facets/smart-facets/smart-facet-equals.js.map +1 -0
- package/dist/src/collection-facets/smart-facets/smart-facet-heuristics.d.ts +5 -0
- package/dist/src/collection-facets/smart-facets/smart-facet-heuristics.js +18 -0
- package/dist/src/collection-facets/smart-facets/smart-facet-heuristics.js.map +1 -0
- package/dist/src/collection-facets/toggle-switch.d.ts +41 -0
- package/dist/src/collection-facets/toggle-switch.js +174 -0
- package/dist/src/collection-facets/toggle-switch.js.map +1 -0
- package/dist/src/collection-facets.d.ts +113 -0
- package/dist/src/collection-facets.js +884 -0
- package/dist/src/collection-facets.js.map +1 -0
- package/dist/src/data-source/collection-browser-data-source-interface.d.ts +270 -0
- package/dist/src/data-source/collection-browser-data-source-interface.js +2 -0
- package/dist/src/data-source/collection-browser-data-source-interface.js.map +1 -0
- package/dist/src/data-source/collection-browser-data-source.d.ts +418 -0
- package/dist/src/data-source/collection-browser-data-source.js +1121 -0
- package/dist/src/data-source/collection-browser-data-source.js.map +1 -0
- package/dist/src/data-source/collection-browser-query-state.d.ts +48 -0
- package/dist/src/data-source/collection-browser-query-state.js +2 -0
- package/dist/src/data-source/collection-browser-query-state.js.map +1 -0
- package/dist/src/data-source/models.d.ts +43 -0
- package/dist/src/data-source/models.js +9 -0
- package/dist/src/data-source/models.js.map +1 -0
- package/dist/src/empty-placeholder.d.ts +23 -0
- package/dist/src/empty-placeholder.js +165 -0
- package/dist/src/empty-placeholder.js.map +1 -0
- package/dist/src/expanded-date-picker.d.ts +50 -0
- package/dist/src/expanded-date-picker.js +182 -0
- package/dist/src/expanded-date-picker.js.map +1 -0
- package/dist/src/language-code-handler/language-code-handler.d.ts +37 -0
- package/dist/src/language-code-handler/language-code-handler.js +27 -0
- package/dist/src/language-code-handler/language-code-handler.js.map +1 -0
- package/dist/src/language-code-handler/language-code-mapping.d.ts +1 -0
- package/dist/src/language-code-handler/language-code-mapping.js +563 -0
- package/dist/src/language-code-handler/language-code-mapping.js.map +1 -0
- package/dist/src/manage/manage-bar.d.ts +58 -0
- package/dist/src/manage/manage-bar.js +237 -0
- package/dist/src/manage/manage-bar.js.map +1 -0
- package/dist/src/manage/remove-items-modal-content.d.ts +9 -0
- package/dist/src/manage/remove-items-modal-content.js +104 -0
- package/dist/src/manage/remove-items-modal-content.js.map +1 -0
- package/dist/src/mediatype/mediatype-config.d.ts +11 -0
- package/dist/src/mediatype/mediatype-config.js +116 -0
- package/dist/src/mediatype/mediatype-config.js.map +1 -0
- package/dist/src/models.d.ts +298 -0
- package/dist/src/models.js +507 -0
- package/dist/src/models.js.map +1 -0
- package/dist/src/restoration-state-handler.d.ts +74 -0
- package/dist/src/restoration-state-handler.js +397 -0
- package/dist/src/restoration-state-handler.js.map +1 -0
- package/dist/src/sort-filter-bar/alpha-bar-tooltip.d.ts +6 -0
- package/dist/src/sort-filter-bar/alpha-bar-tooltip.js +60 -0
- package/dist/src/sort-filter-bar/alpha-bar-tooltip.js.map +1 -0
- package/dist/src/sort-filter-bar/alpha-bar.d.ts +21 -0
- package/dist/src/sort-filter-bar/alpha-bar.js +241 -0
- package/dist/src/sort-filter-bar/alpha-bar.js.map +1 -0
- package/dist/src/sort-filter-bar/img/compact.d.ts +1 -0
- package/dist/src/sort-filter-bar/img/compact.js +5 -0
- package/dist/src/sort-filter-bar/img/compact.js.map +1 -0
- package/dist/src/sort-filter-bar/img/list.d.ts +1 -0
- package/dist/src/sort-filter-bar/img/list.js +5 -0
- package/dist/src/sort-filter-bar/img/list.js.map +1 -0
- package/dist/src/sort-filter-bar/img/sort-toggle-disabled.d.ts +1 -0
- package/dist/src/sort-filter-bar/img/sort-toggle-disabled.js +15 -0
- package/dist/src/sort-filter-bar/img/sort-toggle-disabled.js.map +1 -0
- package/dist/src/sort-filter-bar/img/sort-toggle-down.d.ts +1 -0
- package/dist/src/sort-filter-bar/img/sort-toggle-down.js +17 -0
- package/dist/src/sort-filter-bar/img/sort-toggle-down.js.map +1 -0
- package/dist/src/sort-filter-bar/img/sort-toggle-up.d.ts +1 -0
- package/dist/src/sort-filter-bar/img/sort-toggle-up.js +17 -0
- package/dist/src/sort-filter-bar/img/sort-toggle-up.js.map +1 -0
- package/dist/src/sort-filter-bar/img/sort-triangle.d.ts +1 -0
- package/dist/src/sort-filter-bar/img/sort-triangle.js +5 -0
- package/dist/src/sort-filter-bar/img/sort-triangle.js.map +1 -0
- package/dist/src/sort-filter-bar/img/tile.d.ts +1 -0
- package/dist/src/sort-filter-bar/img/tile.js +5 -0
- package/dist/src/sort-filter-bar/img/tile.js.map +1 -0
- package/dist/src/sort-filter-bar/sort-filter-bar.d.ts +278 -0
- package/dist/src/sort-filter-bar/sort-filter-bar.js +1161 -0
- package/dist/src/sort-filter-bar/sort-filter-bar.js.map +1 -0
- package/dist/src/styles/ia-button.d.ts +2 -0
- package/dist/src/styles/ia-button.js +134 -0
- package/dist/src/styles/ia-button.js.map +1 -0
- package/dist/src/styles/item-image-styles.d.ts +8 -0
- package/dist/src/styles/item-image-styles.js +123 -0
- package/dist/src/styles/item-image-styles.js.map +1 -0
- package/dist/src/styles/sr-only.d.ts +1 -0
- package/dist/src/styles/sr-only.js +18 -0
- package/dist/src/styles/sr-only.js.map +1 -0
- package/dist/src/tiles/base-tile-component.d.ts +27 -0
- package/dist/src/tiles/base-tile-component.js +82 -0
- package/dist/src/tiles/base-tile-component.js.map +1 -0
- package/dist/src/tiles/collection-browser-loading-tile.d.ts +5 -0
- package/dist/src/tiles/collection-browser-loading-tile.js +29 -0
- package/dist/src/tiles/collection-browser-loading-tile.js.map +1 -0
- package/dist/src/tiles/grid/account-tile.d.ts +18 -0
- package/dist/src/tiles/grid/account-tile.js +111 -0
- package/dist/src/tiles/grid/account-tile.js.map +1 -0
- package/dist/src/tiles/grid/collection-tile.d.ts +15 -0
- package/dist/src/tiles/grid/collection-tile.js +160 -0
- package/dist/src/tiles/grid/collection-tile.js.map +1 -0
- package/dist/src/tiles/grid/item-tile.d.ts +41 -0
- package/dist/src/tiles/grid/item-tile.js +321 -0
- package/dist/src/tiles/grid/item-tile.js.map +1 -0
- package/dist/src/tiles/grid/search-tile.d.ts +10 -0
- package/dist/src/tiles/grid/search-tile.js +95 -0
- package/dist/src/tiles/grid/search-tile.js.map +1 -0
- package/dist/src/tiles/grid/styles/tile-grid-shared-styles.d.ts +1 -0
- package/dist/src/tiles/grid/styles/tile-grid-shared-styles.js +128 -0
- package/dist/src/tiles/grid/styles/tile-grid-shared-styles.js.map +1 -0
- package/dist/src/tiles/grid/tile-stats.d.ts +58 -0
- package/dist/src/tiles/grid/tile-stats.js +204 -0
- package/dist/src/tiles/grid/tile-stats.js.map +1 -0
- package/dist/src/tiles/hover/hover-pane-controller.d.ts +228 -0
- package/dist/src/tiles/hover/hover-pane-controller.js +446 -0
- package/dist/src/tiles/hover/hover-pane-controller.js.map +1 -0
- package/dist/src/tiles/hover/tile-hover-pane.d.ts +20 -0
- package/dist/src/tiles/hover/tile-hover-pane.js +185 -0
- package/dist/src/tiles/hover/tile-hover-pane.js.map +1 -0
- package/dist/src/tiles/image-block.d.ts +19 -0
- package/dist/src/tiles/image-block.js +175 -0
- package/dist/src/tiles/image-block.js.map +1 -0
- package/dist/src/tiles/item-image.d.ts +40 -0
- package/dist/src/tiles/item-image.js +191 -0
- package/dist/src/tiles/item-image.js.map +1 -0
- package/dist/src/tiles/list/tile-list-compact-header.d.ts +6 -0
- package/dist/src/tiles/list/tile-list-compact-header.js +85 -0
- package/dist/src/tiles/list/tile-list-compact-header.js.map +1 -0
- package/dist/src/tiles/list/tile-list-compact.d.ts +19 -0
- package/dist/src/tiles/list/tile-list-compact.js +223 -0
- package/dist/src/tiles/list/tile-list-compact.js.map +1 -0
- package/dist/src/tiles/list/tile-list.d.ts +54 -0
- package/dist/src/tiles/list/tile-list.js +621 -0
- package/dist/src/tiles/list/tile-list.js.map +1 -0
- package/dist/src/tiles/models.d.ts +1 -0
- package/dist/src/tiles/models.js +2 -0
- package/dist/src/tiles/models.js.map +1 -0
- package/dist/src/tiles/overlay/icon-overlay.d.ts +8 -0
- package/dist/src/tiles/overlay/icon-overlay.js +55 -0
- package/dist/src/tiles/overlay/icon-overlay.js.map +1 -0
- package/dist/src/tiles/overlay/text-overlay.d.ts +9 -0
- package/dist/src/tiles/overlay/text-overlay.js +74 -0
- package/dist/src/tiles/overlay/text-overlay.js.map +1 -0
- package/dist/src/tiles/review-block.d.ts +12 -0
- package/dist/src/tiles/review-block.js +134 -0
- package/dist/src/tiles/review-block.js.map +1 -0
- package/dist/src/tiles/text-snippet-block.d.ts +27 -0
- package/dist/src/tiles/text-snippet-block.js +132 -0
- package/dist/src/tiles/text-snippet-block.js.map +1 -0
- package/dist/src/tiles/tile-dispatcher.d.ts +71 -0
- package/dist/src/tiles/tile-dispatcher.js +472 -0
- package/dist/src/tiles/tile-dispatcher.js.map +1 -0
- package/dist/src/tiles/tile-display-value-provider.d.ts +47 -0
- package/dist/src/tiles/tile-display-value-provider.js +95 -0
- package/dist/src/tiles/tile-display-value-provider.js.map +1 -0
- package/dist/src/tiles/tile-mediatype-icon.d.ts +27 -0
- package/dist/src/tiles/tile-mediatype-icon.js +130 -0
- package/dist/src/tiles/tile-mediatype-icon.js.map +1 -0
- package/dist/src/utils/analytics-events.d.ts +28 -0
- package/dist/src/utils/analytics-events.js +31 -0
- package/dist/src/utils/analytics-events.js.map +1 -0
- package/dist/src/utils/array-equals.d.ts +4 -0
- package/dist/src/utils/array-equals.js +11 -0
- package/dist/src/utils/array-equals.js.map +1 -0
- package/dist/src/utils/collapse-repeated-quotes.d.ts +11 -0
- package/dist/src/utils/collapse-repeated-quotes.js +14 -0
- package/dist/src/utils/collapse-repeated-quotes.js.map +1 -0
- package/dist/src/utils/facet-utils.d.ts +83 -0
- package/dist/src/utils/facet-utils.js +152 -0
- package/dist/src/utils/facet-utils.js.map +1 -0
- package/dist/src/utils/format-count.d.ts +7 -0
- package/dist/src/utils/format-count.js +76 -0
- package/dist/src/utils/format-count.js.map +1 -0
- package/dist/src/utils/format-date.d.ts +16 -0
- package/dist/src/utils/format-date.js +33 -0
- package/dist/src/utils/format-date.js.map +1 -0
- package/dist/src/utils/format-unit-size.d.ts +2 -0
- package/dist/src/utils/format-unit-size.js +34 -0
- package/dist/src/utils/format-unit-size.js.map +1 -0
- package/dist/src/utils/local-date-from-utc.d.ts +9 -0
- package/dist/src/utils/local-date-from-utc.js +16 -0
- package/dist/src/utils/local-date-from-utc.js.map +1 -0
- package/dist/src/utils/log.d.ts +7 -0
- package/dist/src/utils/log.js +14 -0
- package/dist/src/utils/log.js.map +1 -0
- package/dist/src/utils/resolve-mediatype.d.ts +8 -0
- package/dist/src/utils/resolve-mediatype.js +24 -0
- package/dist/src/utils/resolve-mediatype.js.map +1 -0
- package/dist/src/utils/sha1.d.ts +2 -0
- package/dist/src/utils/sha1.js +9 -0
- package/dist/src/utils/sha1.js.map +1 -0
- package/dist/test/collection-browser.test.d.ts +1 -0
- package/dist/test/collection-browser.test.js +1721 -0
- package/dist/test/collection-browser.test.js.map +1 -0
- package/dist/test/collection-facets/facet-row.test.d.ts +1 -0
- package/dist/test/collection-facets/facet-row.test.js +274 -0
- package/dist/test/collection-facets/facet-row.test.js.map +1 -0
- package/dist/test/collection-facets/facets-template.test.d.ts +1 -0
- package/dist/test/collection-facets/facets-template.test.js +101 -0
- package/dist/test/collection-facets/facets-template.test.js.map +1 -0
- package/dist/test/collection-facets/more-facets-content.test.d.ts +1 -0
- package/dist/test/collection-facets/more-facets-content.test.js +169 -0
- package/dist/test/collection-facets/more-facets-content.test.js.map +1 -0
- package/dist/test/collection-facets/more-facets-pagination.test.d.ts +1 -0
- package/dist/test/collection-facets/more-facets-pagination.test.js +132 -0
- package/dist/test/collection-facets/more-facets-pagination.test.js.map +1 -0
- package/dist/test/collection-facets/toggle-switch.test.d.ts +1 -0
- package/dist/test/collection-facets/toggle-switch.test.js +96 -0
- package/dist/test/collection-facets/toggle-switch.test.js.map +1 -0
- package/dist/test/collection-facets.test.d.ts +2 -0
- package/dist/test/collection-facets.test.js +745 -0
- package/dist/test/collection-facets.test.js.map +1 -0
- package/dist/test/data-source/collection-browser-data-source.test.d.ts +1 -0
- package/dist/test/data-source/collection-browser-data-source.test.js +102 -0
- package/dist/test/data-source/collection-browser-data-source.test.js.map +1 -0
- package/dist/test/empty-placeholder.test.d.ts +1 -0
- package/dist/test/empty-placeholder.test.js +63 -0
- package/dist/test/empty-placeholder.test.js.map +1 -0
- package/dist/test/expanded-date-picker.test.d.ts +1 -0
- package/dist/test/expanded-date-picker.test.js +130 -0
- package/dist/test/expanded-date-picker.test.js.map +1 -0
- package/dist/test/icon-overlay.test.d.ts +1 -0
- package/dist/test/icon-overlay.test.js +30 -0
- package/dist/test/icon-overlay.test.js.map +1 -0
- package/dist/test/image-block.test.d.ts +1 -0
- package/dist/test/image-block.test.js +218 -0
- package/dist/test/image-block.test.js.map +1 -0
- package/dist/test/item-image.test.d.ts +1 -0
- package/dist/test/item-image.test.js +196 -0
- package/dist/test/item-image.test.js.map +1 -0
- package/dist/test/manage/manage-bar.test.d.ts +2 -0
- package/dist/test/manage/manage-bar.test.js +106 -0
- package/dist/test/manage/manage-bar.test.js.map +1 -0
- package/dist/test/manage/remove-items-modal-content.test.d.ts +1 -0
- package/dist/test/manage/remove-items-modal-content.test.js +65 -0
- package/dist/test/manage/remove-items-modal-content.test.js.map +1 -0
- package/dist/test/mediatype-config.test.d.ts +1 -0
- package/dist/test/mediatype-config.test.js +11 -0
- package/dist/test/mediatype-config.test.js.map +1 -0
- package/dist/test/mocks/mock-analytics-handler.d.ts +10 -0
- package/dist/test/mocks/mock-analytics-handler.js +16 -0
- package/dist/test/mocks/mock-analytics-handler.js.map +1 -0
- package/dist/test/mocks/mock-search-responses.d.ts +31 -0
- package/dist/test/mocks/mock-search-responses.js +1241 -0
- package/dist/test/mocks/mock-search-responses.js.map +1 -0
- package/dist/test/mocks/mock-search-service.d.ts +16 -0
- package/dist/test/mocks/mock-search-service.js +65 -0
- package/dist/test/mocks/mock-search-service.js.map +1 -0
- package/dist/test/restoration-state-handler.test.d.ts +1 -0
- package/dist/test/restoration-state-handler.test.js +343 -0
- package/dist/test/restoration-state-handler.test.js.map +1 -0
- package/dist/test/review-block.test.d.ts +1 -0
- package/dist/test/review-block.test.js +48 -0
- package/dist/test/review-block.test.js.map +1 -0
- package/dist/test/sort-filter-bar/alpha-bar-tooltip.test.d.ts +1 -0
- package/dist/test/sort-filter-bar/alpha-bar-tooltip.test.js +13 -0
- package/dist/test/sort-filter-bar/alpha-bar-tooltip.test.js.map +1 -0
- package/dist/test/sort-filter-bar/alpha-bar.test.d.ts +1 -0
- package/dist/test/sort-filter-bar/alpha-bar.test.js +74 -0
- package/dist/test/sort-filter-bar/alpha-bar.test.js.map +1 -0
- package/dist/test/sort-filter-bar/sort-filter-bar.test.d.ts +1 -0
- package/dist/test/sort-filter-bar/sort-filter-bar.test.js +609 -0
- package/dist/test/sort-filter-bar/sort-filter-bar.test.js.map +1 -0
- package/dist/test/text-overlay.test.d.ts +1 -0
- package/dist/test/text-overlay.test.js +42 -0
- package/dist/test/text-overlay.test.js.map +1 -0
- package/dist/test/text-snippet-block.test.d.ts +1 -0
- package/dist/test/text-snippet-block.test.js +63 -0
- package/dist/test/text-snippet-block.test.js.map +1 -0
- package/dist/test/tile-stats.test.d.ts +1 -0
- package/dist/test/tile-stats.test.js +128 -0
- package/dist/test/tile-stats.test.js.map +1 -0
- package/dist/test/tiles/grid/account-tile.test.d.ts +1 -0
- package/dist/test/tiles/grid/account-tile.test.js +96 -0
- package/dist/test/tiles/grid/account-tile.test.js.map +1 -0
- package/dist/test/tiles/grid/collection-tile.test.d.ts +1 -0
- package/dist/test/tiles/grid/collection-tile.test.js +96 -0
- package/dist/test/tiles/grid/collection-tile.test.js.map +1 -0
- package/dist/test/tiles/grid/item-tile.test.d.ts +1 -0
- package/dist/test/tiles/grid/item-tile.test.js +427 -0
- package/dist/test/tiles/grid/item-tile.test.js.map +1 -0
- package/dist/test/tiles/grid/search-tile.test.d.ts +1 -0
- package/dist/test/tiles/grid/search-tile.test.js +66 -0
- package/dist/test/tiles/grid/search-tile.test.js.map +1 -0
- package/dist/test/tiles/hover/hover-pane-controller.test.d.ts +1 -0
- package/dist/test/tiles/hover/hover-pane-controller.test.js +329 -0
- package/dist/test/tiles/hover/hover-pane-controller.test.js.map +1 -0
- package/dist/test/tiles/hover/tile-hover-pane.test.d.ts +1 -0
- package/dist/test/tiles/hover/tile-hover-pane.test.js +57 -0
- package/dist/test/tiles/hover/tile-hover-pane.test.js.map +1 -0
- package/dist/test/tiles/list/tile-list-compact.test.d.ts +1 -0
- package/dist/test/tiles/list/tile-list-compact.test.js +251 -0
- package/dist/test/tiles/list/tile-list-compact.test.js.map +1 -0
- package/dist/test/tiles/list/tile-list.test.d.ts +1 -0
- package/dist/test/tiles/list/tile-list.test.js +469 -0
- package/dist/test/tiles/list/tile-list.test.js.map +1 -0
- package/dist/test/tiles/tile-dispatcher.test.d.ts +1 -0
- package/dist/test/tiles/tile-dispatcher.test.js +231 -0
- package/dist/test/tiles/tile-dispatcher.test.js.map +1 -0
- package/dist/test/tiles/tile-display-value-provider.test.d.ts +1 -0
- package/dist/test/tiles/tile-display-value-provider.test.js +142 -0
- package/dist/test/tiles/tile-display-value-provider.test.js.map +1 -0
- package/dist/test/tiles/tile-mediatype-icon.test.d.ts +1 -0
- package/dist/test/tiles/tile-mediatype-icon.test.js +145 -0
- package/dist/test/tiles/tile-mediatype-icon.test.js.map +1 -0
- package/dist/test/utils/array-equals.test.d.ts +1 -0
- package/dist/test/utils/array-equals.test.js +27 -0
- package/dist/test/utils/array-equals.test.js.map +1 -0
- package/dist/test/utils/format-count.test.d.ts +1 -0
- package/dist/test/utils/format-count.test.js +24 -0
- package/dist/test/utils/format-count.test.js.map +1 -0
- package/dist/test/utils/format-date.test.d.ts +1 -0
- package/dist/test/utils/format-date.test.js +61 -0
- package/dist/test/utils/format-date.test.js.map +1 -0
- package/dist/test/utils/format-unit-size.test.d.ts +1 -0
- package/dist/test/utils/format-unit-size.test.js +18 -0
- package/dist/test/utils/format-unit-size.test.js.map +1 -0
- package/dist/test/utils/local-date-from-utc.test.d.ts +1 -0
- package/dist/test/utils/local-date-from-utc.test.js +27 -0
- package/dist/test/utils/local-date-from-utc.test.js.map +1 -0
- package/eslint.config.mjs +53 -53
- package/index.html +24 -24
- package/local.archive.org.cert +86 -86
- package/local.archive.org.key +27 -27
- package/package.json +118 -117
- package/renovate.json +6 -6
- package/src/collection-browser.ts +2954 -2829
- package/src/collection-facets/facet-row.ts +299 -296
- package/src/collection-facets/models.ts +10 -10
- package/src/collection-facets/more-facets-content.ts +639 -639
- package/src/collection-facets.ts +1005 -995
- package/src/data-source/collection-browser-data-source-interface.ts +345 -333
- package/src/data-source/collection-browser-data-source.ts +1441 -1401
- package/src/data-source/collection-browser-query-state.ts +59 -65
- package/src/data-source/models.ts +56 -43
- package/src/manage/manage-bar.ts +247 -247
- package/src/models.ts +866 -870
- package/src/restoration-state-handler.ts +542 -544
- package/src/tiles/base-tile-component.ts +65 -65
- package/src/tiles/grid/account-tile.ts +113 -113
- package/src/tiles/grid/collection-tile.ts +163 -163
- package/src/tiles/grid/item-tile.ts +340 -340
- package/src/tiles/grid/search-tile.ts +90 -90
- package/src/tiles/grid/styles/tile-grid-shared-styles.ts +130 -130
- package/src/tiles/hover/hover-pane-controller.ts +613 -517
- package/src/tiles/hover/tile-hover-pane.ts +184 -180
- package/src/tiles/list/tile-list-compact.ts +239 -239
- package/src/tiles/list/tile-list.ts +700 -700
- package/src/tiles/tile-dispatcher.ts +517 -490
- package/src/utils/format-date.ts +62 -62
- package/test/collection-browser.test.ts +2413 -2403
- package/test/collection-facets/facet-row.test.ts +375 -375
- package/test/collection-facets.test.ts +928 -928
- package/test/restoration-state-handler.test.ts +480 -510
- package/test/tiles/grid/item-tile.test.ts +520 -520
- package/test/tiles/hover/hover-pane-controller.test.ts +418 -353
- package/test/tiles/list/tile-list-compact.test.ts +282 -282
- package/test/tiles/list/tile-list.test.ts +552 -552
- package/test/tiles/tile-dispatcher.test.ts +283 -187
- package/test/utils/format-date.test.ts +89 -89
- package/tsconfig.json +20 -20
- package/web-dev-server.config.mjs +30 -30
- package/web-test-runner.config.mjs +41 -41
|
@@ -1,510 +1,480 @@
|
|
|
1
|
-
import { SearchType } from '@internetarchive/search-service';
|
|
2
|
-
import { expect } from '@open-wc/testing';
|
|
3
|
-
import { SortField, getDefaultSelectedFacets } from '../src/models';
|
|
4
|
-
import { RestorationStateHandler } from '../src/restoration-state-handler';
|
|
5
|
-
|
|
6
|
-
describe('Restoration state handler', () => {
|
|
7
|
-
it('should restore query from URL', async () => {
|
|
8
|
-
const handler = new RestorationStateHandler({ context: 'search' });
|
|
9
|
-
|
|
10
|
-
const url = new URL(window.location.href);
|
|
11
|
-
url.search = '?query=boop';
|
|
12
|
-
window.history.replaceState({ path: url.href }, '', url.href);
|
|
13
|
-
|
|
14
|
-
const restorationState = handler.getRestorationState();
|
|
15
|
-
expect(restorationState.baseQuery).to.equal('boop');
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('should restore default search type from URL without valid sin', async () => {
|
|
19
|
-
const handler = new RestorationStateHandler({ context: 'search' });
|
|
20
|
-
|
|
21
|
-
const url = new URL(window.location.href);
|
|
22
|
-
url.search = '?sin=foo';
|
|
23
|
-
window.history.replaceState({ path: url.href }, '', url.href);
|
|
24
|
-
|
|
25
|
-
const restorationState = handler.getRestorationState();
|
|
26
|
-
expect(restorationState.searchType).to.equal(SearchType.DEFAULT);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it('should restore default search type if sin explicitly empty in URL', async () => {
|
|
30
|
-
const handler = new RestorationStateHandler({ context: 'search' });
|
|
31
|
-
|
|
32
|
-
const url = new URL(window.location.href);
|
|
33
|
-
url.search = '?sin=';
|
|
34
|
-
window.history.replaceState({ path: url.href }, '', url.href);
|
|
35
|
-
|
|
36
|
-
const restorationState = handler.getRestorationState();
|
|
37
|
-
expect(restorationState.searchType).to.equal(SearchType.DEFAULT);
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it('should restore full text search type from URL', async () => {
|
|
41
|
-
const handler = new RestorationStateHandler({ context: 'search' });
|
|
42
|
-
|
|
43
|
-
const url = new URL(window.location.href);
|
|
44
|
-
url.search = '?sin=TXT';
|
|
45
|
-
window.history.replaceState({ path: url.href }, '', url.href);
|
|
46
|
-
|
|
47
|
-
const restorationState = handler.getRestorationState();
|
|
48
|
-
expect(restorationState.searchType).to.equal(SearchType.FULLTEXT);
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it('should restore radio search type from URL', async () => {
|
|
52
|
-
const handler = new RestorationStateHandler({ context: 'search' });
|
|
53
|
-
|
|
54
|
-
const url = new URL(window.location.href);
|
|
55
|
-
url.search = '?sin=RADIO';
|
|
56
|
-
window.history.replaceState({ path: url.href }, '', url.href);
|
|
57
|
-
|
|
58
|
-
const restorationState = handler.getRestorationState();
|
|
59
|
-
expect(restorationState.searchType).to.equal(SearchType.RADIO);
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it('should restore TV search type from URL', async () => {
|
|
63
|
-
const handler = new RestorationStateHandler({ context: 'search' });
|
|
64
|
-
|
|
65
|
-
const url = new URL(window.location.href);
|
|
66
|
-
url.search = '?sin=TV';
|
|
67
|
-
window.history.replaceState({ path: url.href }, '', url.href);
|
|
68
|
-
|
|
69
|
-
const restorationState = handler.getRestorationState();
|
|
70
|
-
expect(restorationState.searchType).to.equal(SearchType.TV);
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it('should restore metadata search type from URL', async () => {
|
|
74
|
-
const handler = new RestorationStateHandler({ context: 'search' });
|
|
75
|
-
|
|
76
|
-
const url = new URL(window.location.href);
|
|
77
|
-
url.search = '?sin=MD';
|
|
78
|
-
window.history.replaceState({ path: url.href }, '', url.href);
|
|
79
|
-
|
|
80
|
-
const restorationState = handler.getRestorationState();
|
|
81
|
-
expect(restorationState.searchType).to.equal(SearchType.METADATA);
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it('should restore page number from URL', async () => {
|
|
85
|
-
const handler = new RestorationStateHandler({ context: 'search' });
|
|
86
|
-
|
|
87
|
-
const url = new URL(window.location.href);
|
|
88
|
-
url.search = '?page=42';
|
|
89
|
-
window.history.replaceState({ path: url.href }, '', url.href);
|
|
90
|
-
|
|
91
|
-
const restorationState = handler.getRestorationState();
|
|
92
|
-
expect(restorationState.currentPage).to.equal(42);
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it('should restore selected year facets from URL', async () => {
|
|
96
|
-
const handler = new RestorationStateHandler({ context: 'search' });
|
|
97
|
-
|
|
98
|
-
const url = new URL(window.location.href);
|
|
99
|
-
url.search = '?and[]=year:"2018"';
|
|
100
|
-
window.history.replaceState({ path: url.href }, '', url.href);
|
|
101
|
-
|
|
102
|
-
const restorationState = handler.getRestorationState();
|
|
103
|
-
expect(restorationState.selectedFacets.year?.['2018'].state).to.equal(
|
|
104
|
-
'selected',
|
|
105
|
-
);
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
it('should ignore unrecognized facet types in URL', async () => {
|
|
109
|
-
const handler = new RestorationStateHandler({ context: 'search' });
|
|
110
|
-
|
|
111
|
-
const url = new URL(window.location.href);
|
|
112
|
-
url.search = '?and[]=foo:"bar"';
|
|
113
|
-
window.history.replaceState({ path: url.href }, '', url.href);
|
|
114
|
-
|
|
115
|
-
const restorationState = handler.getRestorationState();
|
|
116
|
-
expect(restorationState.selectedFacets).to.deep.equal(
|
|
117
|
-
getDefaultSelectedFacets(),
|
|
118
|
-
);
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
it('should restore selected date range facets from URL', async () => {
|
|
122
|
-
const handler = new RestorationStateHandler({ context: 'search' });
|
|
123
|
-
|
|
124
|
-
const url = new URL(window.location.href);
|
|
125
|
-
url.search = '?and[]=year:"2018+TO+2021"';
|
|
126
|
-
window.history.replaceState({ path: url.href }, '', url.href);
|
|
127
|
-
|
|
128
|
-
const restorationState = handler.getRestorationState();
|
|
129
|
-
expect(restorationState.minSelectedDate).to.equal('2018');
|
|
130
|
-
expect(restorationState.maxSelectedDate).to.equal('2021');
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
it('should restore creator filter from URL', async () => {
|
|
134
|
-
const handler = new RestorationStateHandler({ context: 'search' });
|
|
135
|
-
|
|
136
|
-
const url = new URL(window.location.href);
|
|
137
|
-
url.search = '?and[]=firstCreator:F';
|
|
138
|
-
window.history.replaceState({ path: url.href }, '', url.href);
|
|
139
|
-
|
|
140
|
-
const restorationState = handler.getRestorationState();
|
|
141
|
-
expect(restorationState.selectedCreatorFilter).to.equal('F');
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
it('should restore title filter from URL', async () => {
|
|
145
|
-
const handler = new RestorationStateHandler({ context: 'search' });
|
|
146
|
-
|
|
147
|
-
const url = new URL(window.location.href);
|
|
148
|
-
url.search = '?and[]=firstTitle:F';
|
|
149
|
-
window.history.replaceState({ path: url.href }, '', url.href);
|
|
150
|
-
|
|
151
|
-
const restorationState = handler.getRestorationState();
|
|
152
|
-
expect(restorationState.selectedTitleFilter).to.equal('F');
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
it('should restore other selected facets from URL', async () => {
|
|
156
|
-
const handler = new RestorationStateHandler({ context: 'search' });
|
|
157
|
-
|
|
158
|
-
const url = new URL(window.location.href);
|
|
159
|
-
url.search = '?and[]=subject:"foo"';
|
|
160
|
-
window.history.replaceState({ path: url.href }, '', url.href);
|
|
161
|
-
|
|
162
|
-
const restorationState = handler.getRestorationState();
|
|
163
|
-
expect(restorationState.selectedFacets.subject?.foo.state).to.equal(
|
|
164
|
-
'selected',
|
|
165
|
-
);
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
it('should restore negative facets from URL', async () => {
|
|
169
|
-
const handler = new RestorationStateHandler({ context: 'search' });
|
|
170
|
-
|
|
171
|
-
const url = new URL(window.location.href);
|
|
172
|
-
url.search = '?not[]=year:2018';
|
|
173
|
-
window.history.replaceState({ path: url.href }, '', url.href);
|
|
174
|
-
|
|
175
|
-
const restorationState = handler.getRestorationState();
|
|
176
|
-
expect(restorationState.selectedFacets.year?.['2018'].state).to.equal(
|
|
177
|
-
'hidden',
|
|
178
|
-
);
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
it('should restore multiple selected/negative facets from URL', async () => {
|
|
182
|
-
const handler = new RestorationStateHandler({ context: 'search' });
|
|
183
|
-
|
|
184
|
-
const url = new URL(window.location.href);
|
|
185
|
-
url.search =
|
|
186
|
-
'?and[]=collection:"foo"&and[]=collection:"bar"¬[]=collection:"baz"¬[]=collection:"boop"';
|
|
187
|
-
window.history.replaceState({ path: url.href }, '', url.href);
|
|
188
|
-
|
|
189
|
-
const restorationState = handler.getRestorationState();
|
|
190
|
-
|
|
191
|
-
expect(restorationState.selectedFacets.collection?.foo.state).to.equal(
|
|
192
|
-
'selected',
|
|
193
|
-
);
|
|
194
|
-
expect(restorationState.selectedFacets.collection?.bar.state).to.equal(
|
|
195
|
-
'selected',
|
|
196
|
-
);
|
|
197
|
-
|
|
198
|
-
expect(restorationState.selectedFacets.collection?.baz.state).to.equal(
|
|
199
|
-
'hidden',
|
|
200
|
-
);
|
|
201
|
-
expect(restorationState.selectedFacets.collection?.boop.state).to.equal(
|
|
202
|
-
'hidden',
|
|
203
|
-
);
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
it('negative facets take precedence if both present in URL', async () => {
|
|
207
|
-
const handler = new RestorationStateHandler({ context: 'search' });
|
|
208
|
-
|
|
209
|
-
const url = new URL(window.location.href);
|
|
210
|
-
url.search = '?and[]=collection:"foo"¬[]=collection:"foo"';
|
|
211
|
-
window.history.replaceState({ path: url.href }, '', url.href);
|
|
212
|
-
|
|
213
|
-
const restorationState = handler.getRestorationState();
|
|
214
|
-
expect(restorationState.selectedFacets.collection?.foo.state).to.equal(
|
|
215
|
-
'hidden',
|
|
216
|
-
);
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
it('should restore selected facets with numbers in the square brackets', async () => {
|
|
220
|
-
const handler = new RestorationStateHandler({ context: 'search' });
|
|
221
|
-
|
|
222
|
-
const url = new URL(window.location.href);
|
|
223
|
-
url.search = '?and[12]=subject:"foo"';
|
|
224
|
-
window.history.replaceState({ path: url.href }, '', url.href);
|
|
225
|
-
|
|
226
|
-
const restorationState = handler.getRestorationState();
|
|
227
|
-
expect(restorationState.selectedFacets.subject?.foo.state).to.equal(
|
|
228
|
-
'selected',
|
|
229
|
-
);
|
|
230
|
-
});
|
|
231
|
-
|
|
232
|
-
it('should restore negative facets with numbers in the square brackets', async () => {
|
|
233
|
-
const handler = new RestorationStateHandler({ context: 'search' });
|
|
234
|
-
|
|
235
|
-
const url = new URL(window.location.href);
|
|
236
|
-
url.search = '?not[12]=year:2018';
|
|
237
|
-
window.history.replaceState({ path: url.href }, '', url.href);
|
|
238
|
-
|
|
239
|
-
const restorationState = handler.getRestorationState();
|
|
240
|
-
expect(restorationState.selectedFacets.year?.['2018'].state).to.equal(
|
|
241
|
-
'hidden',
|
|
242
|
-
);
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
it('should restore any TV clip filters from URL', async () => {
|
|
246
|
-
const handler = new RestorationStateHandler({ context: 'search' });
|
|
247
|
-
const url = new URL(window.location.href);
|
|
248
|
-
|
|
249
|
-
// Commercials
|
|
250
|
-
url.search = '?only_commercials=1';
|
|
251
|
-
window.history.replaceState({ path: url.href }, '', url.href);
|
|
252
|
-
const commercialsRestorationState = handler.getRestorationState();
|
|
253
|
-
expect(
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
const
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
const
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
const
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
const
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
});
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
expect(window.location.search).to.equal('');
|
|
482
|
-
|
|
483
|
-
handler.persistState(
|
|
484
|
-
{
|
|
485
|
-
selectedFacets: getDefaultSelectedFacets(),
|
|
486
|
-
searchType: SearchType.METADATA,
|
|
487
|
-
},
|
|
488
|
-
{ persistMetadataSearchType: true },
|
|
489
|
-
);
|
|
490
|
-
expect(window.location.search).to.equal('?sin=MD');
|
|
491
|
-
});
|
|
492
|
-
|
|
493
|
-
it('round trip load/persist should erase numbers in square brackets', async () => {
|
|
494
|
-
const handler = new RestorationStateHandler({ context: 'search' });
|
|
495
|
-
|
|
496
|
-
const url = new URL(window.location.href);
|
|
497
|
-
url.search = '?and[0]=subject:"foo"';
|
|
498
|
-
window.history.replaceState({ path: url.href }, '', url.href);
|
|
499
|
-
|
|
500
|
-
// Load state from the URL and immediately persist it back to the URL
|
|
501
|
-
const restorationState = handler.getRestorationState();
|
|
502
|
-
handler.persistState(restorationState);
|
|
503
|
-
|
|
504
|
-
// Ensure the new URL includes the "normalized" facet parameter and not the numbered one
|
|
505
|
-
expect(decodeURIComponent(window.location.search)).to.include(
|
|
506
|
-
'and[]=subject:"foo"',
|
|
507
|
-
);
|
|
508
|
-
expect(new URL(window.location.href).searchParams.get('and[0]')).to.be.null;
|
|
509
|
-
});
|
|
510
|
-
});
|
|
1
|
+
import { SearchType } from '@internetarchive/search-service';
|
|
2
|
+
import { expect } from '@open-wc/testing';
|
|
3
|
+
import { SortField, getDefaultSelectedFacets } from '../src/models';
|
|
4
|
+
import { RestorationStateHandler } from '../src/restoration-state-handler';
|
|
5
|
+
|
|
6
|
+
describe('Restoration state handler', () => {
|
|
7
|
+
it('should restore query from URL', async () => {
|
|
8
|
+
const handler = new RestorationStateHandler({ context: 'search' });
|
|
9
|
+
|
|
10
|
+
const url = new URL(window.location.href);
|
|
11
|
+
url.search = '?query=boop';
|
|
12
|
+
window.history.replaceState({ path: url.href }, '', url.href);
|
|
13
|
+
|
|
14
|
+
const restorationState = handler.getRestorationState();
|
|
15
|
+
expect(restorationState.baseQuery).to.equal('boop');
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('should restore default search type from URL without valid sin', async () => {
|
|
19
|
+
const handler = new RestorationStateHandler({ context: 'search' });
|
|
20
|
+
|
|
21
|
+
const url = new URL(window.location.href);
|
|
22
|
+
url.search = '?sin=foo';
|
|
23
|
+
window.history.replaceState({ path: url.href }, '', url.href);
|
|
24
|
+
|
|
25
|
+
const restorationState = handler.getRestorationState();
|
|
26
|
+
expect(restorationState.searchType).to.equal(SearchType.DEFAULT);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('should restore default search type if sin explicitly empty in URL', async () => {
|
|
30
|
+
const handler = new RestorationStateHandler({ context: 'search' });
|
|
31
|
+
|
|
32
|
+
const url = new URL(window.location.href);
|
|
33
|
+
url.search = '?sin=';
|
|
34
|
+
window.history.replaceState({ path: url.href }, '', url.href);
|
|
35
|
+
|
|
36
|
+
const restorationState = handler.getRestorationState();
|
|
37
|
+
expect(restorationState.searchType).to.equal(SearchType.DEFAULT);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('should restore full text search type from URL', async () => {
|
|
41
|
+
const handler = new RestorationStateHandler({ context: 'search' });
|
|
42
|
+
|
|
43
|
+
const url = new URL(window.location.href);
|
|
44
|
+
url.search = '?sin=TXT';
|
|
45
|
+
window.history.replaceState({ path: url.href }, '', url.href);
|
|
46
|
+
|
|
47
|
+
const restorationState = handler.getRestorationState();
|
|
48
|
+
expect(restorationState.searchType).to.equal(SearchType.FULLTEXT);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('should restore radio search type from URL', async () => {
|
|
52
|
+
const handler = new RestorationStateHandler({ context: 'search' });
|
|
53
|
+
|
|
54
|
+
const url = new URL(window.location.href);
|
|
55
|
+
url.search = '?sin=RADIO';
|
|
56
|
+
window.history.replaceState({ path: url.href }, '', url.href);
|
|
57
|
+
|
|
58
|
+
const restorationState = handler.getRestorationState();
|
|
59
|
+
expect(restorationState.searchType).to.equal(SearchType.RADIO);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('should restore TV search type from URL', async () => {
|
|
63
|
+
const handler = new RestorationStateHandler({ context: 'search' });
|
|
64
|
+
|
|
65
|
+
const url = new URL(window.location.href);
|
|
66
|
+
url.search = '?sin=TV';
|
|
67
|
+
window.history.replaceState({ path: url.href }, '', url.href);
|
|
68
|
+
|
|
69
|
+
const restorationState = handler.getRestorationState();
|
|
70
|
+
expect(restorationState.searchType).to.equal(SearchType.TV);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('should restore metadata search type from URL', async () => {
|
|
74
|
+
const handler = new RestorationStateHandler({ context: 'search' });
|
|
75
|
+
|
|
76
|
+
const url = new URL(window.location.href);
|
|
77
|
+
url.search = '?sin=MD';
|
|
78
|
+
window.history.replaceState({ path: url.href }, '', url.href);
|
|
79
|
+
|
|
80
|
+
const restorationState = handler.getRestorationState();
|
|
81
|
+
expect(restorationState.searchType).to.equal(SearchType.METADATA);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('should restore page number from URL', async () => {
|
|
85
|
+
const handler = new RestorationStateHandler({ context: 'search' });
|
|
86
|
+
|
|
87
|
+
const url = new URL(window.location.href);
|
|
88
|
+
url.search = '?page=42';
|
|
89
|
+
window.history.replaceState({ path: url.href }, '', url.href);
|
|
90
|
+
|
|
91
|
+
const restorationState = handler.getRestorationState();
|
|
92
|
+
expect(restorationState.currentPage).to.equal(42);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it('should restore selected year facets from URL', async () => {
|
|
96
|
+
const handler = new RestorationStateHandler({ context: 'search' });
|
|
97
|
+
|
|
98
|
+
const url = new URL(window.location.href);
|
|
99
|
+
url.search = '?and[]=year:"2018"';
|
|
100
|
+
window.history.replaceState({ path: url.href }, '', url.href);
|
|
101
|
+
|
|
102
|
+
const restorationState = handler.getRestorationState();
|
|
103
|
+
expect(restorationState.selectedFacets.year?.['2018'].state).to.equal(
|
|
104
|
+
'selected',
|
|
105
|
+
);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it('should ignore unrecognized facet types in URL', async () => {
|
|
109
|
+
const handler = new RestorationStateHandler({ context: 'search' });
|
|
110
|
+
|
|
111
|
+
const url = new URL(window.location.href);
|
|
112
|
+
url.search = '?and[]=foo:"bar"';
|
|
113
|
+
window.history.replaceState({ path: url.href }, '', url.href);
|
|
114
|
+
|
|
115
|
+
const restorationState = handler.getRestorationState();
|
|
116
|
+
expect(restorationState.selectedFacets).to.deep.equal(
|
|
117
|
+
getDefaultSelectedFacets(),
|
|
118
|
+
);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it('should restore selected date range facets from URL', async () => {
|
|
122
|
+
const handler = new RestorationStateHandler({ context: 'search' });
|
|
123
|
+
|
|
124
|
+
const url = new URL(window.location.href);
|
|
125
|
+
url.search = '?and[]=year:"2018+TO+2021"';
|
|
126
|
+
window.history.replaceState({ path: url.href }, '', url.href);
|
|
127
|
+
|
|
128
|
+
const restorationState = handler.getRestorationState();
|
|
129
|
+
expect(restorationState.minSelectedDate).to.equal('2018');
|
|
130
|
+
expect(restorationState.maxSelectedDate).to.equal('2021');
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it('should restore creator filter from URL', async () => {
|
|
134
|
+
const handler = new RestorationStateHandler({ context: 'search' });
|
|
135
|
+
|
|
136
|
+
const url = new URL(window.location.href);
|
|
137
|
+
url.search = '?and[]=firstCreator:F';
|
|
138
|
+
window.history.replaceState({ path: url.href }, '', url.href);
|
|
139
|
+
|
|
140
|
+
const restorationState = handler.getRestorationState();
|
|
141
|
+
expect(restorationState.selectedCreatorFilter).to.equal('F');
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it('should restore title filter from URL', async () => {
|
|
145
|
+
const handler = new RestorationStateHandler({ context: 'search' });
|
|
146
|
+
|
|
147
|
+
const url = new URL(window.location.href);
|
|
148
|
+
url.search = '?and[]=firstTitle:F';
|
|
149
|
+
window.history.replaceState({ path: url.href }, '', url.href);
|
|
150
|
+
|
|
151
|
+
const restorationState = handler.getRestorationState();
|
|
152
|
+
expect(restorationState.selectedTitleFilter).to.equal('F');
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
it('should restore other selected facets from URL', async () => {
|
|
156
|
+
const handler = new RestorationStateHandler({ context: 'search' });
|
|
157
|
+
|
|
158
|
+
const url = new URL(window.location.href);
|
|
159
|
+
url.search = '?and[]=subject:"foo"';
|
|
160
|
+
window.history.replaceState({ path: url.href }, '', url.href);
|
|
161
|
+
|
|
162
|
+
const restorationState = handler.getRestorationState();
|
|
163
|
+
expect(restorationState.selectedFacets.subject?.foo.state).to.equal(
|
|
164
|
+
'selected',
|
|
165
|
+
);
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
it('should restore negative facets from URL', async () => {
|
|
169
|
+
const handler = new RestorationStateHandler({ context: 'search' });
|
|
170
|
+
|
|
171
|
+
const url = new URL(window.location.href);
|
|
172
|
+
url.search = '?not[]=year:2018';
|
|
173
|
+
window.history.replaceState({ path: url.href }, '', url.href);
|
|
174
|
+
|
|
175
|
+
const restorationState = handler.getRestorationState();
|
|
176
|
+
expect(restorationState.selectedFacets.year?.['2018'].state).to.equal(
|
|
177
|
+
'hidden',
|
|
178
|
+
);
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
it('should restore multiple selected/negative facets from URL', async () => {
|
|
182
|
+
const handler = new RestorationStateHandler({ context: 'search' });
|
|
183
|
+
|
|
184
|
+
const url = new URL(window.location.href);
|
|
185
|
+
url.search =
|
|
186
|
+
'?and[]=collection:"foo"&and[]=collection:"bar"¬[]=collection:"baz"¬[]=collection:"boop"';
|
|
187
|
+
window.history.replaceState({ path: url.href }, '', url.href);
|
|
188
|
+
|
|
189
|
+
const restorationState = handler.getRestorationState();
|
|
190
|
+
|
|
191
|
+
expect(restorationState.selectedFacets.collection?.foo.state).to.equal(
|
|
192
|
+
'selected',
|
|
193
|
+
);
|
|
194
|
+
expect(restorationState.selectedFacets.collection?.bar.state).to.equal(
|
|
195
|
+
'selected',
|
|
196
|
+
);
|
|
197
|
+
|
|
198
|
+
expect(restorationState.selectedFacets.collection?.baz.state).to.equal(
|
|
199
|
+
'hidden',
|
|
200
|
+
);
|
|
201
|
+
expect(restorationState.selectedFacets.collection?.boop.state).to.equal(
|
|
202
|
+
'hidden',
|
|
203
|
+
);
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
it('negative facets take precedence if both present in URL', async () => {
|
|
207
|
+
const handler = new RestorationStateHandler({ context: 'search' });
|
|
208
|
+
|
|
209
|
+
const url = new URL(window.location.href);
|
|
210
|
+
url.search = '?and[]=collection:"foo"¬[]=collection:"foo"';
|
|
211
|
+
window.history.replaceState({ path: url.href }, '', url.href);
|
|
212
|
+
|
|
213
|
+
const restorationState = handler.getRestorationState();
|
|
214
|
+
expect(restorationState.selectedFacets.collection?.foo.state).to.equal(
|
|
215
|
+
'hidden',
|
|
216
|
+
);
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
it('should restore selected facets with numbers in the square brackets', async () => {
|
|
220
|
+
const handler = new RestorationStateHandler({ context: 'search' });
|
|
221
|
+
|
|
222
|
+
const url = new URL(window.location.href);
|
|
223
|
+
url.search = '?and[12]=subject:"foo"';
|
|
224
|
+
window.history.replaceState({ path: url.href }, '', url.href);
|
|
225
|
+
|
|
226
|
+
const restorationState = handler.getRestorationState();
|
|
227
|
+
expect(restorationState.selectedFacets.subject?.foo.state).to.equal(
|
|
228
|
+
'selected',
|
|
229
|
+
);
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
it('should restore negative facets with numbers in the square brackets', async () => {
|
|
233
|
+
const handler = new RestorationStateHandler({ context: 'search' });
|
|
234
|
+
|
|
235
|
+
const url = new URL(window.location.href);
|
|
236
|
+
url.search = '?not[12]=year:2018';
|
|
237
|
+
window.history.replaceState({ path: url.href }, '', url.href);
|
|
238
|
+
|
|
239
|
+
const restorationState = handler.getRestorationState();
|
|
240
|
+
expect(restorationState.selectedFacets.year?.['2018'].state).to.equal(
|
|
241
|
+
'hidden',
|
|
242
|
+
);
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
it('should restore any TV clip filters from URL', async () => {
|
|
246
|
+
const handler = new RestorationStateHandler({ context: 'search' });
|
|
247
|
+
const url = new URL(window.location.href);
|
|
248
|
+
|
|
249
|
+
// Commercials
|
|
250
|
+
url.search = '?only_commercials=1';
|
|
251
|
+
window.history.replaceState({ path: url.href }, '', url.href);
|
|
252
|
+
const commercialsRestorationState = handler.getRestorationState();
|
|
253
|
+
expect(
|
|
254
|
+
commercialsRestorationState.selectedFacets.clip_type?.commercial.state,
|
|
255
|
+
).to.equal('selected');
|
|
256
|
+
|
|
257
|
+
// Fact checks
|
|
258
|
+
url.search = '?only_factchecks=1';
|
|
259
|
+
window.history.replaceState({ path: url.href }, '', url.href);
|
|
260
|
+
const factchecksRestorationState = handler.getRestorationState();
|
|
261
|
+
expect(
|
|
262
|
+
factchecksRestorationState.selectedFacets.clip_type?.['fact check'].state,
|
|
263
|
+
).to.equal('selected');
|
|
264
|
+
|
|
265
|
+
// Quotes
|
|
266
|
+
url.search = '?only_quotes=1';
|
|
267
|
+
window.history.replaceState({ path: url.href }, '', url.href);
|
|
268
|
+
const quotesRestorationState = handler.getRestorationState();
|
|
269
|
+
expect(
|
|
270
|
+
quotesRestorationState.selectedFacets.clip_type?.quote.state,
|
|
271
|
+
).to.equal('selected');
|
|
272
|
+
|
|
273
|
+
// No filter param
|
|
274
|
+
url.search = '';
|
|
275
|
+
window.history.replaceState({ path: url.href }, '', url.href);
|
|
276
|
+
const unfilteredRestorationState = handler.getRestorationState();
|
|
277
|
+
expect(unfilteredRestorationState.selectedFacets.clip_type).to.deep.equal(
|
|
278
|
+
{},
|
|
279
|
+
);
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
it('should restore sort from URL (space format)', async () => {
|
|
283
|
+
const handler = new RestorationStateHandler({ context: 'search' });
|
|
284
|
+
|
|
285
|
+
const url = new URL(window.location.href);
|
|
286
|
+
url.search = '?sort=date+desc';
|
|
287
|
+
window.history.replaceState({ path: url.href }, '', url.href);
|
|
288
|
+
|
|
289
|
+
const restorationState = handler.getRestorationState();
|
|
290
|
+
expect(restorationState.selectedSort).to.equal('date');
|
|
291
|
+
expect(restorationState.sortDirection).to.equal('desc');
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
it('should restore sort from URL (prefix format, desc)', async () => {
|
|
295
|
+
const handler = new RestorationStateHandler({ context: 'search' });
|
|
296
|
+
|
|
297
|
+
const url = new URL(window.location.href);
|
|
298
|
+
url.search = '?sort=-date';
|
|
299
|
+
window.history.replaceState({ path: url.href }, '', url.href);
|
|
300
|
+
|
|
301
|
+
const restorationState = handler.getRestorationState();
|
|
302
|
+
expect(restorationState.selectedSort).to.equal('date');
|
|
303
|
+
expect(restorationState.sortDirection).to.equal('desc');
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
it('should restore sort from URL (prefix format, asc)', async () => {
|
|
307
|
+
const handler = new RestorationStateHandler({ context: 'search' });
|
|
308
|
+
|
|
309
|
+
const url = new URL(window.location.href);
|
|
310
|
+
url.search = '?sort=date';
|
|
311
|
+
window.history.replaceState({ path: url.href }, '', url.href);
|
|
312
|
+
|
|
313
|
+
const restorationState = handler.getRestorationState();
|
|
314
|
+
expect(restorationState.selectedSort).to.equal('date');
|
|
315
|
+
expect(restorationState.sortDirection).to.equal('asc');
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
it('should restore sort from URL (space format)', async () => {
|
|
319
|
+
const handler = new RestorationStateHandler({ context: 'search' });
|
|
320
|
+
|
|
321
|
+
const url = new URL(window.location.href);
|
|
322
|
+
url.search = '?sort=foo+desc';
|
|
323
|
+
window.history.replaceState({ path: url.href }, '', url.href);
|
|
324
|
+
|
|
325
|
+
const restorationState = handler.getRestorationState();
|
|
326
|
+
expect(restorationState.selectedSort).to.equal('unrecognized');
|
|
327
|
+
expect(restorationState.sortDirection).to.equal('desc');
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
it('should restore unrecognized sort from URL (prefix format)', async () => {
|
|
331
|
+
const handler = new RestorationStateHandler({ context: 'search' });
|
|
332
|
+
|
|
333
|
+
const url = new URL(window.location.href);
|
|
334
|
+
url.search = '?sort=-foo';
|
|
335
|
+
window.history.replaceState({ path: url.href }, '', url.href);
|
|
336
|
+
|
|
337
|
+
const restorationState = handler.getRestorationState();
|
|
338
|
+
expect(restorationState.selectedSort).to.equal('unrecognized');
|
|
339
|
+
expect(restorationState.sortDirection).to.equal('desc');
|
|
340
|
+
});
|
|
341
|
+
|
|
342
|
+
it('should save direction to URL even for unrecognized sort fields', async () => {
|
|
343
|
+
const url = new URL(window.location.href);
|
|
344
|
+
url.search = '?sort=foo';
|
|
345
|
+
window.history.replaceState({ path: url.href }, '', url.href);
|
|
346
|
+
|
|
347
|
+
const handler = new RestorationStateHandler({ context: 'search' });
|
|
348
|
+
handler.persistState({
|
|
349
|
+
selectedSort: SortField.unrecognized,
|
|
350
|
+
sortDirection: 'desc',
|
|
351
|
+
selectedFacets: getDefaultSelectedFacets(),
|
|
352
|
+
});
|
|
353
|
+
|
|
354
|
+
expect(window.location.search).to.equal('?sort=-foo');
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
it('should keep existing direction for unrecognized sort fields when unspecified in state', async () => {
|
|
358
|
+
const url = new URL(window.location.href);
|
|
359
|
+
url.search = '?sort=foo+desc';
|
|
360
|
+
window.history.replaceState({ path: url.href }, '', url.href);
|
|
361
|
+
|
|
362
|
+
const handler = new RestorationStateHandler({ context: 'search' });
|
|
363
|
+
handler.persistState({
|
|
364
|
+
selectedSort: SortField.unrecognized,
|
|
365
|
+
selectedFacets: getDefaultSelectedFacets(),
|
|
366
|
+
});
|
|
367
|
+
|
|
368
|
+
expect(window.location.search).to.equal('?sort=-foo');
|
|
369
|
+
});
|
|
370
|
+
|
|
371
|
+
it('should just ignore unrecognized sort fields w/ unknown formats', async () => {
|
|
372
|
+
const url = new URL(window.location.href);
|
|
373
|
+
url.search = '?sort=+foo';
|
|
374
|
+
window.history.replaceState({ path: url.href }, '', url.href);
|
|
375
|
+
|
|
376
|
+
const handler = new RestorationStateHandler({ context: 'search' });
|
|
377
|
+
handler.persistState({
|
|
378
|
+
selectedSort: SortField.unrecognized,
|
|
379
|
+
selectedFacets: getDefaultSelectedFacets(),
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
expect(window.location.search).to.equal('?sort=+foo');
|
|
383
|
+
});
|
|
384
|
+
|
|
385
|
+
it('should not save current page state to the URL for page 1', async () => {
|
|
386
|
+
const url = new URL(window.location.href);
|
|
387
|
+
url.search = '';
|
|
388
|
+
window.history.replaceState({ path: url.href }, '', url.href);
|
|
389
|
+
|
|
390
|
+
const handler = new RestorationStateHandler({ context: 'search' });
|
|
391
|
+
handler.persistState({
|
|
392
|
+
currentPage: 1,
|
|
393
|
+
selectedFacets: getDefaultSelectedFacets(),
|
|
394
|
+
});
|
|
395
|
+
|
|
396
|
+
expect(window.location.search).to.be.empty;
|
|
397
|
+
});
|
|
398
|
+
|
|
399
|
+
it('should save current page state to the URL when page > 1', async () => {
|
|
400
|
+
const url = new URL(window.location.href);
|
|
401
|
+
url.search = '';
|
|
402
|
+
window.history.replaceState({ path: url.href }, '', url.href);
|
|
403
|
+
|
|
404
|
+
const handler = new RestorationStateHandler({ context: 'search' });
|
|
405
|
+
handler.persistState({
|
|
406
|
+
currentPage: 2,
|
|
407
|
+
selectedFacets: getDefaultSelectedFacets(),
|
|
408
|
+
});
|
|
409
|
+
|
|
410
|
+
expect(window.location.search).to.equal('?page=2');
|
|
411
|
+
});
|
|
412
|
+
|
|
413
|
+
it('should upgrade legacy search params to new ones', async () => {
|
|
414
|
+
const url = new URL(window.location.href);
|
|
415
|
+
url.search = '?q=foo';
|
|
416
|
+
window.history.replaceState({ path: url.href }, '', url.href);
|
|
417
|
+
|
|
418
|
+
const handler = new RestorationStateHandler({ context: 'search' });
|
|
419
|
+
const restorationState = handler.getRestorationState();
|
|
420
|
+
expect(restorationState.baseQuery).to.equal('foo');
|
|
421
|
+
|
|
422
|
+
handler.persistState(restorationState);
|
|
423
|
+
expect(window.location.search).to.equal('?query=foo');
|
|
424
|
+
});
|
|
425
|
+
|
|
426
|
+
it('should remove empty sin param', async () => {
|
|
427
|
+
const url = new URL(window.location.href);
|
|
428
|
+
url.search = '?sin=';
|
|
429
|
+
window.history.replaceState({ path: url.href }, '', url.href);
|
|
430
|
+
|
|
431
|
+
const handler = new RestorationStateHandler({ context: 'search' });
|
|
432
|
+
|
|
433
|
+
handler.persistState({ selectedFacets: getDefaultSelectedFacets() });
|
|
434
|
+
expect(window.location.search).to.equal('');
|
|
435
|
+
});
|
|
436
|
+
|
|
437
|
+
it('should persist metadata search type only when option is true', async () => {
|
|
438
|
+
const url = new URL(window.location.href);
|
|
439
|
+
url.search = '?sin=';
|
|
440
|
+
window.history.replaceState({ path: url.href }, '', url.href);
|
|
441
|
+
|
|
442
|
+
const handler = new RestorationStateHandler({ context: 'search' });
|
|
443
|
+
|
|
444
|
+
handler.persistState(
|
|
445
|
+
{
|
|
446
|
+
selectedFacets: getDefaultSelectedFacets(),
|
|
447
|
+
searchType: SearchType.METADATA,
|
|
448
|
+
},
|
|
449
|
+
{ persistMetadataSearchType: false },
|
|
450
|
+
);
|
|
451
|
+
expect(window.location.search).to.equal('');
|
|
452
|
+
|
|
453
|
+
handler.persistState(
|
|
454
|
+
{
|
|
455
|
+
selectedFacets: getDefaultSelectedFacets(),
|
|
456
|
+
searchType: SearchType.METADATA,
|
|
457
|
+
},
|
|
458
|
+
{ persistMetadataSearchType: true },
|
|
459
|
+
);
|
|
460
|
+
expect(window.location.search).to.equal('?sin=MD');
|
|
461
|
+
});
|
|
462
|
+
|
|
463
|
+
it('round trip load/persist should erase numbers in square brackets', async () => {
|
|
464
|
+
const handler = new RestorationStateHandler({ context: 'search' });
|
|
465
|
+
|
|
466
|
+
const url = new URL(window.location.href);
|
|
467
|
+
url.search = '?and[0]=subject:"foo"';
|
|
468
|
+
window.history.replaceState({ path: url.href }, '', url.href);
|
|
469
|
+
|
|
470
|
+
// Load state from the URL and immediately persist it back to the URL
|
|
471
|
+
const restorationState = handler.getRestorationState();
|
|
472
|
+
handler.persistState(restorationState);
|
|
473
|
+
|
|
474
|
+
// Ensure the new URL includes the "normalized" facet parameter and not the numbered one
|
|
475
|
+
expect(decodeURIComponent(window.location.search)).to.include(
|
|
476
|
+
'and[]=subject:"foo"',
|
|
477
|
+
);
|
|
478
|
+
expect(new URL(window.location.href).searchParams.get('and[0]')).to.be.null;
|
|
479
|
+
});
|
|
480
|
+
});
|