@internetarchive/collection-browser 1.14.17-beta.5 → 1.14.18-alpha.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/.husky/pre-commit +4 -4
- package/LICENSE +661 -661
- package/README.md +83 -83
- package/dist/index.d.ts +12 -11
- package/dist/index.js +12 -11
- package/dist/index.js.map +1 -1
- package/dist/src/app-root.d.ts +83 -83
- package/dist/src/app-root.js +438 -489
- package/dist/src/app-root.js.map +1 -1
- package/dist/src/assets/img/icons/arrow-left.d.ts +2 -2
- package/dist/src/assets/img/icons/arrow-left.js +2 -2
- package/dist/src/assets/img/icons/arrow-right.d.ts +2 -2
- package/dist/src/assets/img/icons/arrow-right.js +2 -2
- package/dist/src/assets/img/icons/chevron.d.ts +2 -2
- package/dist/src/assets/img/icons/chevron.js +2 -2
- package/dist/src/assets/img/icons/contract.d.ts +2 -2
- package/dist/src/assets/img/icons/contract.js +2 -2
- package/dist/src/assets/img/icons/empty-query.d.ts +2 -2
- package/dist/src/assets/img/icons/empty-query.js +2 -2
- package/dist/src/assets/img/icons/expand.d.ts +2 -2
- package/dist/src/assets/img/icons/expand.js +2 -2
- package/dist/src/assets/img/icons/eye-closed.d.ts +2 -2
- package/dist/src/assets/img/icons/eye-closed.js +2 -2
- package/dist/src/assets/img/icons/eye.d.ts +2 -2
- package/dist/src/assets/img/icons/eye.js +2 -2
- package/dist/src/assets/img/icons/favorite-filled.d.ts +1 -1
- package/dist/src/assets/img/icons/favorite-filled.js +2 -2
- package/dist/src/assets/img/icons/login-required.d.ts +1 -1
- package/dist/src/assets/img/icons/login-required.js +2 -2
- package/dist/src/assets/img/icons/mediatype/account.d.ts +1 -1
- package/dist/src/assets/img/icons/mediatype/account.js +2 -2
- package/dist/src/assets/img/icons/mediatype/audio.d.ts +1 -1
- package/dist/src/assets/img/icons/mediatype/audio.js +2 -2
- package/dist/src/assets/img/icons/mediatype/collection.d.ts +1 -1
- package/dist/src/assets/img/icons/mediatype/collection.js +2 -2
- package/dist/src/assets/img/icons/mediatype/data.d.ts +1 -1
- package/dist/src/assets/img/icons/mediatype/data.js +2 -2
- package/dist/src/assets/img/icons/mediatype/etree.d.ts +1 -1
- package/dist/src/assets/img/icons/mediatype/etree.js +2 -2
- package/dist/src/assets/img/icons/mediatype/film.d.ts +1 -1
- package/dist/src/assets/img/icons/mediatype/film.js +2 -2
- package/dist/src/assets/img/icons/mediatype/images.d.ts +1 -1
- package/dist/src/assets/img/icons/mediatype/images.js +2 -2
- package/dist/src/assets/img/icons/mediatype/radio.d.ts +1 -1
- package/dist/src/assets/img/icons/mediatype/radio.js +2 -2
- package/dist/src/assets/img/icons/mediatype/search.d.ts +1 -1
- package/dist/src/assets/img/icons/mediatype/search.js +2 -2
- package/dist/src/assets/img/icons/mediatype/software.d.ts +1 -1
- package/dist/src/assets/img/icons/mediatype/software.js +2 -2
- package/dist/src/assets/img/icons/mediatype/texts.d.ts +1 -1
- package/dist/src/assets/img/icons/mediatype/texts.js +2 -2
- package/dist/src/assets/img/icons/mediatype/tv.d.ts +1 -1
- package/dist/src/assets/img/icons/mediatype/tv.js +2 -2
- package/dist/src/assets/img/icons/mediatype/video.d.ts +1 -1
- package/dist/src/assets/img/icons/mediatype/video.js +2 -2
- package/dist/src/assets/img/icons/mediatype/web.d.ts +1 -1
- package/dist/src/assets/img/icons/mediatype/web.js +2 -2
- package/dist/src/assets/img/icons/null-result.d.ts +2 -2
- package/dist/src/assets/img/icons/null-result.js +2 -2
- package/dist/src/assets/img/icons/restricted.d.ts +1 -1
- package/dist/src/assets/img/icons/restricted.js +2 -2
- package/dist/src/assets/img/icons/reviews.d.ts +1 -1
- package/dist/src/assets/img/icons/reviews.js +2 -2
- package/dist/src/assets/img/icons/upload.d.ts +1 -1
- package/dist/src/assets/img/icons/upload.js +2 -2
- package/dist/src/assets/img/icons/views.d.ts +1 -1
- package/dist/src/assets/img/icons/views.js +2 -2
- package/dist/src/circular-activity-indicator.d.ts +5 -5
- package/dist/src/circular-activity-indicator.js +17 -17
- package/dist/src/collection-browser.d.ts +384 -406
- package/dist/src/collection-browser.js +1342 -1363
- package/dist/src/collection-browser.js.map +1 -1
- package/dist/src/collection-facets/facet-row.d.ts +30 -30
- package/dist/src/collection-facets/facet-row.js +114 -114
- package/dist/src/collection-facets/facet-tombstone-row.d.ts +5 -5
- package/dist/src/collection-facets/facet-tombstone-row.js +15 -15
- package/dist/src/collection-facets/facets-template.d.ts +17 -17
- package/dist/src/collection-facets/facets-template.js +114 -114
- package/dist/src/collection-facets/more-facets-content.d.ts +70 -70
- package/dist/src/collection-facets/more-facets-content.js +354 -369
- package/dist/src/collection-facets/more-facets-content.js.map +1 -1
- package/dist/src/collection-facets/more-facets-pagination.d.ts +36 -36
- package/dist/src/collection-facets/more-facets-pagination.js +196 -196
- package/dist/src/collection-facets/toggle-switch.d.ts +41 -41
- package/dist/src/collection-facets/toggle-switch.js +94 -94
- package/dist/src/collection-facets.d.ts +103 -103
- package/dist/src/collection-facets.js +513 -510
- package/dist/src/collection-facets.js.map +1 -1
- package/dist/src/data-source/collection-browser-data-source-interface.d.ts +217 -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 +352 -434
- package/dist/src/data-source/collection-browser-data-source.js +911 -800
- package/dist/src/data-source/collection-browser-data-source.js.map +1 -1
- package/dist/src/data-source/collection-browser-query-state.d.ts +43 -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 +28 -62
- package/dist/src/data-source/models.js +8 -1
- package/dist/src/data-source/models.js.map +1 -1
- package/dist/src/empty-placeholder.d.ts +23 -23
- package/dist/src/empty-placeholder.js +74 -74
- package/dist/src/expanded-date-picker.d.ts +43 -43
- package/dist/src/expanded-date-picker.js +109 -109
- package/dist/src/language-code-handler/language-code-handler.d.ts +37 -37
- package/dist/src/language-code-handler/language-code-handler.js +26 -26
- package/dist/src/language-code-handler/language-code-mapping.d.ts +1 -1
- package/dist/src/language-code-handler/language-code-mapping.js +562 -562
- package/dist/src/manage/manage-bar.d.ts +26 -26
- package/dist/src/manage/manage-bar.js +53 -53
- package/dist/src/manage/manage-bar.js.map +1 -1
- package/dist/src/mediatype/mediatype-config.d.ts +3 -3
- package/dist/src/mediatype/mediatype-config.js +91 -91
- package/dist/src/models.d.ts +197 -180
- package/dist/src/models.js +380 -269
- package/dist/src/models.js.map +1 -1
- package/dist/src/restoration-state-handler.d.ts +70 -70
- package/dist/src/restoration-state-handler.js +355 -355
- package/dist/src/sort-filter-bar/alpha-bar-tooltip.d.ts +6 -6
- package/dist/src/sort-filter-bar/alpha-bar-tooltip.js +24 -24
- package/dist/src/sort-filter-bar/alpha-bar.d.ts +21 -21
- package/dist/src/sort-filter-bar/alpha-bar.js +128 -128
- package/dist/src/sort-filter-bar/img/compact.d.ts +1 -1
- package/dist/src/sort-filter-bar/img/compact.js +2 -2
- package/dist/src/sort-filter-bar/img/list.d.ts +1 -1
- package/dist/src/sort-filter-bar/img/list.js +2 -2
- package/dist/src/sort-filter-bar/img/sort-toggle-disabled.d.ts +1 -1
- package/dist/src/sort-filter-bar/img/sort-toggle-disabled.js +2 -2
- package/dist/src/sort-filter-bar/img/sort-toggle-down.d.ts +1 -1
- package/dist/src/sort-filter-bar/img/sort-toggle-down.js +2 -2
- package/dist/src/sort-filter-bar/img/sort-toggle-up.d.ts +1 -1
- package/dist/src/sort-filter-bar/img/sort-toggle-up.js +2 -2
- package/dist/src/sort-filter-bar/img/sort-triangle.d.ts +1 -1
- package/dist/src/sort-filter-bar/img/sort-triangle.js +2 -2
- package/dist/src/sort-filter-bar/img/tile.d.ts +1 -1
- package/dist/src/sort-filter-bar/img/tile.js +2 -2
- package/dist/src/sort-filter-bar/sort-filter-bar.d.ts +210 -210
- package/dist/src/sort-filter-bar/sort-filter-bar.js +653 -652
- package/dist/src/sort-filter-bar/sort-filter-bar.js.map +1 -1
- package/dist/src/styles/item-image-styles.d.ts +8 -8
- package/dist/src/styles/item-image-styles.js +9 -9
- package/dist/src/styles/sr-only.d.ts +1 -1
- package/dist/src/styles/sr-only.js +2 -2
- package/dist/src/tiles/base-tile-component.d.ts +19 -19
- package/dist/src/tiles/base-tile-component.js +63 -63
- package/dist/src/tiles/collection-browser-loading-tile.d.ts +5 -5
- package/dist/src/tiles/collection-browser-loading-tile.js +15 -15
- package/dist/src/tiles/grid/account-tile.d.ts +18 -18
- package/dist/src/tiles/grid/account-tile.js +72 -72
- package/dist/src/tiles/grid/collection-tile.d.ts +15 -15
- package/dist/src/tiles/grid/collection-tile.js +80 -80
- package/dist/src/tiles/grid/item-tile.d.ts +28 -27
- package/dist/src/tiles/grid/item-tile.js +162 -135
- package/dist/src/tiles/grid/item-tile.js.map +1 -1
- package/dist/src/tiles/grid/search-tile.d.ts +10 -10
- package/dist/src/tiles/grid/search-tile.js +51 -51
- package/dist/src/tiles/grid/styles/tile-grid-shared-styles.d.ts +1 -1
- package/dist/src/tiles/grid/styles/tile-grid-shared-styles.js +8 -8
- package/dist/src/tiles/grid/tile-stats.d.ts +11 -11
- package/dist/src/tiles/grid/tile-stats.js +58 -53
- package/dist/src/tiles/grid/tile-stats.js.map +1 -1
- package/dist/src/tiles/hover/hover-pane-controller.d.ts +219 -219
- package/dist/src/tiles/hover/hover-pane-controller.js +352 -352
- package/dist/src/tiles/hover/tile-hover-pane.d.ts +15 -15
- package/dist/src/tiles/hover/tile-hover-pane.js +38 -38
- package/dist/src/tiles/image-block.d.ts +17 -17
- package/dist/src/tiles/image-block.js +73 -73
- package/dist/src/tiles/item-image.d.ts +39 -36
- package/dist/src/tiles/item-image.js +155 -127
- package/dist/src/tiles/item-image.js.map +1 -1
- package/dist/src/tiles/list/tile-list-compact-header.d.ts +6 -6
- package/dist/src/tiles/list/tile-list-compact-header.js +38 -38
- package/dist/src/tiles/list/tile-list-compact.d.ts +15 -15
- package/dist/src/tiles/list/tile-list-compact.js +115 -115
- package/dist/src/tiles/list/tile-list-compact.js.map +1 -1
- package/dist/src/tiles/list/tile-list.d.ts +47 -46
- package/dist/src/tiles/list/tile-list.js +327 -296
- package/dist/src/tiles/list/tile-list.js.map +1 -1
- package/dist/src/tiles/mediatype-icon.d.ts +9 -9
- package/dist/src/tiles/mediatype-icon.js +47 -47
- package/dist/src/tiles/overlay/icon-overlay.d.ts +10 -10
- package/dist/src/tiles/overlay/icon-overlay.js +40 -40
- package/dist/src/tiles/overlay/icon-text-overlay.d.ts +9 -9
- package/dist/src/tiles/overlay/icon-text-overlay.js +38 -38
- package/dist/src/tiles/overlay/text-overlay.d.ts +10 -10
- package/dist/src/tiles/overlay/text-overlay.js +42 -42
- package/dist/src/tiles/text-snippet-block.d.ts +27 -27
- package/dist/src/tiles/text-snippet-block.js +73 -73
- package/dist/src/tiles/tile-dispatcher.d.ts +64 -64
- package/dist/src/tiles/tile-dispatcher.js +232 -231
- package/dist/src/tiles/tile-dispatcher.js.map +1 -1
- package/dist/src/tiles/tile-display-value-provider.d.ts +47 -43
- package/dist/src/tiles/tile-display-value-provider.js +94 -80
- package/dist/src/tiles/tile-display-value-provider.js.map +1 -1
- package/dist/src/utils/analytics-events.d.ts +25 -25
- package/dist/src/utils/analytics-events.js +27 -27
- package/dist/src/utils/array-equals.d.ts +4 -4
- package/dist/src/utils/array-equals.js +10 -10
- 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/format-count.d.ts +7 -7
- package/dist/src/utils/format-count.js +76 -76
- package/dist/src/utils/format-date.d.ts +2 -2
- package/dist/src/utils/format-date.js +25 -25
- package/dist/src/utils/format-unit-size.d.ts +2 -2
- package/dist/src/utils/format-unit-size.js +33 -33
- package/dist/src/utils/local-date-from-utc.d.ts +9 -9
- package/dist/src/utils/local-date-from-utc.js +15 -15
- package/dist/src/utils/log.d.ts +7 -0
- package/dist/src/utils/log.js +16 -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 -2
- package/dist/src/utils/sha1.js +8 -8
- package/dist/test/collection-browser.test.d.ts +1 -1
- package/dist/test/collection-browser.test.js +1211 -1149
- package/dist/test/collection-browser.test.js.map +1 -1
- package/dist/test/collection-facets/facet-row.test.d.ts +1 -1
- package/dist/test/collection-facets/facet-row.test.js +203 -203
- package/dist/test/collection-facets/facets-template.test.d.ts +1 -1
- package/dist/test/collection-facets/facets-template.test.js +105 -105
- package/dist/test/collection-facets/more-facets-content.test.d.ts +1 -1
- package/dist/test/collection-facets/more-facets-content.test.js +133 -133
- package/dist/test/collection-facets/more-facets-content.test.js.map +1 -1
- package/dist/test/collection-facets/more-facets-pagination.test.d.ts +1 -1
- package/dist/test/collection-facets/more-facets-pagination.test.js +117 -117
- package/dist/test/collection-facets/toggle-switch.test.d.ts +1 -1
- package/dist/test/collection-facets/toggle-switch.test.js +73 -73
- package/dist/test/collection-facets.test.d.ts +2 -2
- package/dist/test/collection-facets.test.js +653 -648
- package/dist/test/collection-facets.test.js.map +1 -1
- 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 +80 -0
- package/dist/test/data-source/collection-browser-data-source.test.js.map +1 -0
- package/dist/test/empty-placeholder.test.d.ts +1 -1
- package/dist/test/empty-placeholder.test.js +63 -63
- package/dist/test/expanded-date-picker.test.d.ts +1 -1
- package/dist/test/expanded-date-picker.test.js +95 -95
- package/dist/test/icon-overlay.test.d.ts +1 -1
- package/dist/test/icon-overlay.test.js +24 -24
- package/dist/test/image-block.test.d.ts +1 -1
- package/dist/test/image-block.test.js +48 -48
- package/dist/test/item-image.test.d.ts +1 -1
- package/dist/test/item-image.test.js +85 -86
- package/dist/test/item-image.test.js.map +1 -1
- package/dist/test/manage/manage-bar.test.d.ts +1 -1
- package/dist/test/manage/manage-bar.test.js +72 -72
- package/dist/test/mediatype-config.test.d.ts +1 -1
- package/dist/test/mediatype-config.test.js +16 -16
- package/dist/test/mocks/mock-analytics-handler.d.ts +10 -10
- package/dist/test/mocks/mock-analytics-handler.js +15 -15
- package/dist/test/mocks/mock-search-responses.d.ts +24 -21
- package/dist/test/mocks/mock-search-responses.js +840 -709
- package/dist/test/mocks/mock-search-responses.js.map +1 -1
- package/dist/test/mocks/mock-search-service.d.ts +15 -15
- package/dist/test/mocks/mock-search-service.js +53 -50
- package/dist/test/mocks/mock-search-service.js.map +1 -1
- package/dist/test/restoration-state-handler.test.d.ts +1 -1
- package/dist/test/restoration-state-handler.test.js +270 -270
- package/dist/test/sort-filter-bar/alpha-bar-tooltip.test.d.ts +1 -1
- package/dist/test/sort-filter-bar/alpha-bar-tooltip.test.js +12 -12
- package/dist/test/sort-filter-bar/alpha-bar.test.d.ts +1 -1
- package/dist/test/sort-filter-bar/alpha-bar.test.js +73 -73
- package/dist/test/sort-filter-bar/sort-filter-bar.test.d.ts +1 -1
- package/dist/test/sort-filter-bar/sort-filter-bar.test.js +418 -418
- package/dist/test/text-overlay.test.d.ts +1 -1
- package/dist/test/text-overlay.test.js +48 -48
- package/dist/test/text-snippet-block.test.d.ts +1 -1
- package/dist/test/text-snippet-block.test.js +57 -57
- package/dist/test/tile-stats.test.d.ts +1 -1
- package/dist/test/tile-stats.test.js +95 -33
- package/dist/test/tile-stats.test.js.map +1 -1
- package/dist/test/tiles/grid/account-tile.test.d.ts +1 -1
- package/dist/test/tiles/grid/account-tile.test.js +76 -76
- package/dist/test/tiles/grid/collection-tile.test.d.ts +1 -1
- package/dist/test/tiles/grid/collection-tile.test.js +73 -73
- package/dist/test/tiles/grid/item-tile.test.d.ts +1 -1
- package/dist/test/tiles/grid/item-tile.test.js +298 -254
- package/dist/test/tiles/grid/item-tile.test.js.map +1 -1
- package/dist/test/tiles/grid/search-tile.test.d.ts +1 -1
- package/dist/test/tiles/grid/search-tile.test.js +51 -51
- package/dist/test/tiles/hover/hover-pane-controller.test.d.ts +1 -1
- package/dist/test/tiles/hover/hover-pane-controller.test.js +259 -258
- package/dist/test/tiles/hover/hover-pane-controller.test.js.map +1 -1
- package/dist/test/tiles/hover/tile-hover-pane.test.d.ts +1 -1
- package/dist/test/tiles/hover/tile-hover-pane.test.js +13 -13
- package/dist/test/tiles/list/tile-list-compact.test.d.ts +1 -1
- package/dist/test/tiles/list/tile-list-compact.test.js +143 -143
- package/dist/test/tiles/list/tile-list.test.d.ts +1 -1
- package/dist/test/tiles/list/tile-list.test.js +283 -239
- package/dist/test/tiles/list/tile-list.test.js.map +1 -1
- package/dist/test/tiles/tile-dispatcher.test.d.ts +1 -1
- package/dist/test/tiles/tile-dispatcher.test.js +106 -94
- package/dist/test/tiles/tile-dispatcher.test.js.map +1 -1
- package/dist/test/tiles/tile-display-value-provider.test.d.ts +1 -1
- package/dist/test/tiles/tile-display-value-provider.test.js +141 -141
- package/dist/test/utils/array-equals.test.d.ts +1 -1
- package/dist/test/utils/array-equals.test.js +26 -26
- package/dist/test/utils/format-count.test.d.ts +1 -1
- package/dist/test/utils/format-count.test.js +23 -23
- package/dist/test/utils/format-date.test.d.ts +1 -1
- package/dist/test/utils/format-date.test.js +17 -17
- package/dist/test/utils/format-unit-size.test.d.ts +1 -1
- package/dist/test/utils/format-unit-size.test.js +17 -17
- package/dist/test/utils/local-date-from-utc.test.d.ts +1 -1
- package/dist/test/utils/local-date-from-utc.test.js +26 -26
- package/index.ts +3 -5
- package/local.archive.org.cert +86 -86
- package/local.archive.org.key +27 -27
- package/package.json +3 -4
- package/renovate.json +6 -6
- package/src/app-root.ts +30 -85
- package/src/collection-browser.ts +112 -139
- package/src/collection-facets/more-facets-content.ts +0 -19
- package/src/collection-facets.ts +6 -4
- package/src/data-source/collection-browser-data-source-interface.ts +272 -0
- package/src/data-source/collection-browser-data-source.ts +314 -379
- package/src/data-source/collection-browser-query-state.ts +54 -0
- package/src/data-source/models.ts +8 -45
- package/src/manage/manage-bar.ts +1 -1
- package/src/models.ts +164 -3
- package/src/sort-filter-bar/sort-filter-bar.ts +2 -1
- package/src/tiles/grid/item-tile.ts +36 -1
- package/src/tiles/grid/tile-stats.ts +12 -7
- package/src/tiles/item-image.ts +28 -0
- package/src/tiles/list/tile-list-compact.ts +1 -1
- package/src/tiles/list/tile-list.ts +43 -5
- package/src/tiles/tile-dispatcher.ts +2 -1
- package/src/tiles/tile-display-value-provider.ts +20 -2
- package/src/utils/collapse-repeated-quotes.ts +13 -0
- package/src/utils/log.ts +16 -0
- package/src/utils/resolve-mediatype.ts +26 -0
- package/test/collection-browser.test.ts +161 -50
- package/test/collection-facets/more-facets-content.test.ts +4 -2
- package/test/collection-facets.test.ts +5 -0
- package/test/data-source/collection-browser-data-source.test.ts +103 -0
- package/test/item-image.test.ts +34 -36
- package/test/mocks/mock-search-responses.ts +144 -0
- package/test/mocks/mock-search-service.ts +6 -0
- package/test/tile-stats.test.ts +104 -0
- package/test/tiles/grid/item-tile.test.ts +55 -0
- package/test/tiles/hover/hover-pane-controller.test.ts +19 -17
- package/test/tiles/list/tile-list.test.ts +55 -0
- package/test/tiles/tile-dispatcher.test.ts +13 -0
- package/tsconfig.json +21 -21
- package/web-dev-server.config.mjs +30 -30
- package/web-test-runner.config.mjs +41 -41
- package/types/sentry.d.ts +0 -1
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { nothing } from 'lit';
|
|
1
|
+
import { TemplateResult, html, nothing } from 'lit';
|
|
2
2
|
import { msg, str } from '@lit/localize';
|
|
3
3
|
import type { SortParam } from '@internetarchive/search-service';
|
|
4
4
|
import type { TileModel } from '../models';
|
|
5
|
+
import { formatDate } from '../utils/format-date';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* A class encapsulating shared logic for converting model values into display values
|
|
@@ -96,11 +97,28 @@ export class TileDisplayValueProvider {
|
|
|
96
97
|
* item is specified to be a collection (default false).
|
|
97
98
|
*/
|
|
98
99
|
itemPageUrl(
|
|
99
|
-
identifier
|
|
100
|
+
identifier?: string,
|
|
100
101
|
isCollection = false
|
|
101
102
|
): string | typeof nothing {
|
|
102
103
|
if (!identifier || this.baseNavigationUrl == null) return nothing;
|
|
103
104
|
const basePath = isCollection ? this.collectionPagePath : '/details/';
|
|
104
105
|
return `${this.baseNavigationUrl}${basePath}${identifier}`;
|
|
105
106
|
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Produces a template for a link to a single web capture of the given URL and date
|
|
110
|
+
*/
|
|
111
|
+
webArchivesCaptureLink(url: string, date: Date): TemplateResult {
|
|
112
|
+
// Convert the date into the format used to identify wayback captures (e.g., '20150102124550')
|
|
113
|
+
const captureDateStr = date
|
|
114
|
+
.toISOString()
|
|
115
|
+
.replace(/[TZ:-]/g, '')
|
|
116
|
+
.replace(/\..*/, '');
|
|
117
|
+
const captureHref = `https://web.archive.org/web/${captureDateStr}/${encodeURIComponent(
|
|
118
|
+
url
|
|
119
|
+
)}`;
|
|
120
|
+
const captureText = formatDate(date, 'long');
|
|
121
|
+
|
|
122
|
+
return html` <a href=${captureHref}> ${captureText} </a> `;
|
|
123
|
+
}
|
|
106
124
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the input string, but removing one set of quotes from all instances of
|
|
3
|
+
* ""clauses wrapped in two sets of quotes"". This assumes the quotes are already
|
|
4
|
+
* URL-encoded.
|
|
5
|
+
*
|
|
6
|
+
* This should be a temporary measure to address the fact that the __href__ field
|
|
7
|
+
* sometimes acquires extra quotation marks during query rewriting. Once there is a
|
|
8
|
+
* full Lucene parser in place that handles quoted queries correctly, this can likely
|
|
9
|
+
* be removed.
|
|
10
|
+
*/
|
|
11
|
+
export function collapseRepeatedQuotes(str?: string): string | undefined {
|
|
12
|
+
return str?.replace(/%22%22(?!%22%22)(.+?)%22%22/g, '%22$1%22');
|
|
13
|
+
}
|
package/src/utils/log.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/* eslint-disable semi */
|
|
2
|
+
/**
|
|
3
|
+
* console.log() utility -- production ignores 'log()' JS calls; dev invokes 'console.log()'
|
|
4
|
+
*/
|
|
5
|
+
export const log =
|
|
6
|
+
window.location &&
|
|
7
|
+
(window.location.hostname === 'localhost' ||
|
|
8
|
+
window.location.host.match(/^(www|cat)-[a-z0-9]+\.archive\.org$/) ||
|
|
9
|
+
window.location.host.match(/\.code\.archive\.org$/) ||
|
|
10
|
+
window.location.host.match(/\.dev\.archive\.org$/) ||
|
|
11
|
+
window.location.host.match(/^ia-petabox-/) ||
|
|
12
|
+
window.location.host.match(/^local\.archive\.org/) ||
|
|
13
|
+
window.location.host.match(/^internetarchive\.github\.io$/))
|
|
14
|
+
? // eslint-disable-next-line no-console
|
|
15
|
+
console.log.bind(console) // convenient, no? Stateless function
|
|
16
|
+
: () => {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { MediaType } from '@internetarchive/field-parsers';
|
|
2
|
+
import type { SearchResult } from '@internetarchive/search-service';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Returns the mediatype string for the given search result, taking into account
|
|
6
|
+
* the special `favorited_search` hit type.
|
|
7
|
+
* @param result The search result to extract a mediatype from
|
|
8
|
+
*/
|
|
9
|
+
export function resolveMediatype(result: SearchResult): MediaType {
|
|
10
|
+
/**
|
|
11
|
+
* hit_type == 'favorited_search' is basically a new hit_type
|
|
12
|
+
* - we are getting from PPS.
|
|
13
|
+
* - which gives response for fav- collection
|
|
14
|
+
* - having favorited items like account/collection/item etc..
|
|
15
|
+
* - as user can also favorite a search result (a search page)
|
|
16
|
+
* - so we need to have response (having fav- items and fav- search results)
|
|
17
|
+
*
|
|
18
|
+
* if backend hit_type == 'favorited_search'
|
|
19
|
+
* - let's assume a "search" as new mediatype
|
|
20
|
+
*/
|
|
21
|
+
if (result?.rawMetadata?.hit_type === 'favorited_search') {
|
|
22
|
+
return 'search';
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return result.mediatype?.value ?? 'data';
|
|
26
|
+
}
|
|
@@ -268,10 +268,7 @@ describe('Collection Browser', () => {
|
|
|
268
268
|
expect(mockAnalyticsHandler.callLabel).to.equal('mediatype');
|
|
269
269
|
});
|
|
270
270
|
|
|
271
|
-
|
|
272
|
-
// SKIPPING FOR NOW TO GET CI GREEN.
|
|
273
|
-
// this one has placeholder type issue
|
|
274
|
-
it.skip('should render with a sort bar, facets, and infinite scroller', async () => {
|
|
271
|
+
it('should render with a sort bar, facets, and infinite scroller', async () => {
|
|
275
272
|
const searchService = new MockSearchService();
|
|
276
273
|
|
|
277
274
|
const el = await fixture<CollectionBrowser>(
|
|
@@ -281,6 +278,7 @@ describe('Collection Browser', () => {
|
|
|
281
278
|
|
|
282
279
|
el.baseQuery = 'hello';
|
|
283
280
|
await el.updateComplete;
|
|
281
|
+
await nextTick();
|
|
284
282
|
|
|
285
283
|
const facets = el.shadowRoot?.querySelector('collection-facets');
|
|
286
284
|
const sortBar = el.shadowRoot?.querySelector('sort-filter-bar');
|
|
@@ -451,6 +449,44 @@ describe('Collection Browser', () => {
|
|
|
451
449
|
expect(el.searchType).to.equal(SearchType.FULLTEXT);
|
|
452
450
|
});
|
|
453
451
|
|
|
452
|
+
it('can construct tile models with many fields present', async () => {
|
|
453
|
+
const searchService = new MockSearchService();
|
|
454
|
+
|
|
455
|
+
const el = await fixture<CollectionBrowser>(
|
|
456
|
+
html`<collection-browser .searchService=${searchService}>
|
|
457
|
+
</collection-browser>`
|
|
458
|
+
);
|
|
459
|
+
|
|
460
|
+
el.baseQuery = 'many-fields';
|
|
461
|
+
await el.updateComplete;
|
|
462
|
+
await el.initialSearchComplete;
|
|
463
|
+
|
|
464
|
+
const cellTemplate = el.cellForIndex(0);
|
|
465
|
+
expect(cellTemplate).to.exist;
|
|
466
|
+
|
|
467
|
+
const cell = await fixture<TileDispatcher>(cellTemplate!);
|
|
468
|
+
expect(cell).to.exist;
|
|
469
|
+
});
|
|
470
|
+
|
|
471
|
+
it('emits empty results event when search fetches no results', async () => {
|
|
472
|
+
const searchService = new MockSearchService();
|
|
473
|
+
const emptyResultsSpy = sinon.spy();
|
|
474
|
+
|
|
475
|
+
const el = await fixture<CollectionBrowser>(
|
|
476
|
+
html`<collection-browser
|
|
477
|
+
.searchService=${searchService}
|
|
478
|
+
@emptyResults=${emptyResultsSpy}
|
|
479
|
+
>
|
|
480
|
+
</collection-browser>`
|
|
481
|
+
);
|
|
482
|
+
|
|
483
|
+
el.baseQuery = 'no-results';
|
|
484
|
+
await el.updateComplete;
|
|
485
|
+
await el.initialSearchComplete;
|
|
486
|
+
|
|
487
|
+
expect(emptyResultsSpy.callCount).to.equal(1);
|
|
488
|
+
});
|
|
489
|
+
|
|
454
490
|
it('applies loggedin flag to tile models if needed', async () => {
|
|
455
491
|
const searchService = new MockSearchService();
|
|
456
492
|
|
|
@@ -777,10 +813,7 @@ describe('Collection Browser', () => {
|
|
|
777
813
|
it('sets sort properties when user changes sort', async () => {
|
|
778
814
|
const searchService = new MockSearchService();
|
|
779
815
|
const el = await fixture<CollectionBrowser>(
|
|
780
|
-
html`<collection-browser
|
|
781
|
-
.searchService=${searchService}
|
|
782
|
-
.suppressPlaceholders=${true}
|
|
783
|
-
>
|
|
816
|
+
html`<collection-browser .searchService=${searchService}>
|
|
784
817
|
</collection-browser>`
|
|
785
818
|
);
|
|
786
819
|
|
|
@@ -788,6 +821,7 @@ describe('Collection Browser', () => {
|
|
|
788
821
|
|
|
789
822
|
el.baseQuery = 'foo';
|
|
790
823
|
await el.updateComplete;
|
|
824
|
+
await nextTick();
|
|
791
825
|
|
|
792
826
|
const sortBar = el.shadowRoot?.querySelector(
|
|
793
827
|
'#content-container sort-filter-bar'
|
|
@@ -902,7 +936,7 @@ describe('Collection Browser', () => {
|
|
|
902
936
|
el.sortDirection = 'asc';
|
|
903
937
|
el.selectedCreatorFilter = 'X';
|
|
904
938
|
await el.updateComplete;
|
|
905
|
-
await
|
|
939
|
+
await nextTick();
|
|
906
940
|
|
|
907
941
|
expect(searchService.searchParams?.query).to.equal('first-creator');
|
|
908
942
|
expect(searchService.searchParams?.filters?.firstCreator?.X).to.equal(
|
|
@@ -911,18 +945,19 @@ describe('Collection Browser', () => {
|
|
|
911
945
|
|
|
912
946
|
el.baseQuery = 'collection:foo';
|
|
913
947
|
await el.updateComplete;
|
|
914
|
-
await
|
|
948
|
+
await nextTick();
|
|
915
949
|
|
|
916
950
|
expect(searchService.searchParams?.query).to.equal('collection:foo');
|
|
917
951
|
expect(searchService.searchParams?.filters?.firstCreator).not.to.exist;
|
|
918
952
|
});
|
|
919
953
|
|
|
920
|
-
|
|
921
|
-
// SKIPPING FOR NOW TO GET CI GREEN.
|
|
922
|
-
it.skip('sets date range query when date picker selection changed', async () => {
|
|
954
|
+
it('sets date range query when date picker selection changed', async () => {
|
|
923
955
|
const searchService = new MockSearchService();
|
|
924
956
|
const el = await fixture<CollectionBrowser>(
|
|
925
|
-
html`<collection-browser
|
|
957
|
+
html`<collection-browser
|
|
958
|
+
.searchService=${searchService}
|
|
959
|
+
.suppressPlaceholders=${true}
|
|
960
|
+
>
|
|
926
961
|
</collection-browser>`
|
|
927
962
|
);
|
|
928
963
|
|
|
@@ -1064,6 +1099,20 @@ describe('Collection Browser', () => {
|
|
|
1064
1099
|
expect(sortBar.sortDirection).to.be.null;
|
|
1065
1100
|
});
|
|
1066
1101
|
|
|
1102
|
+
it('falls back to weekly views default sorting on profiles when tab not set', async () => {
|
|
1103
|
+
const el = await fixture<CollectionBrowser>(
|
|
1104
|
+
html`<collection-browser
|
|
1105
|
+
.withinProfile=${'@foobar'}
|
|
1106
|
+
></collection-browser>`
|
|
1107
|
+
);
|
|
1108
|
+
|
|
1109
|
+
el.applyDefaultProfileSort();
|
|
1110
|
+
expect(el.defaultSortParam).to.deep.equal({
|
|
1111
|
+
field: SortField.weeklyview,
|
|
1112
|
+
direction: 'desc',
|
|
1113
|
+
});
|
|
1114
|
+
});
|
|
1115
|
+
|
|
1067
1116
|
it('uses relevance sort as default when a query is set', async () => {
|
|
1068
1117
|
const searchService = new MockSearchService();
|
|
1069
1118
|
const el = await fixture<CollectionBrowser>(
|
|
@@ -1130,6 +1179,7 @@ describe('Collection Browser', () => {
|
|
|
1130
1179
|
// infinite scroller does exist.
|
|
1131
1180
|
el.baseQuery = 'collection:foo';
|
|
1132
1181
|
await el.updateComplete;
|
|
1182
|
+
await nextTick();
|
|
1133
1183
|
|
|
1134
1184
|
const infiniteScroller = el.shadowRoot?.querySelector(
|
|
1135
1185
|
'infinite-scroller'
|
|
@@ -1141,10 +1191,7 @@ describe('Collection Browser', () => {
|
|
|
1141
1191
|
infiniteScroller.scrollToCell = spy;
|
|
1142
1192
|
|
|
1143
1193
|
await el.goToPage(1);
|
|
1144
|
-
|
|
1145
|
-
// TODO: FIX THIS AS IT BROKE IN MAIN REFACTOR. (WEBDEV-6081 @latonv)
|
|
1146
|
-
// COMMENTING OUT FOR NOW TO GET CI GREEN.
|
|
1147
|
-
// expect(spy.callCount, 'scroll to page fires once').to.equal(1);
|
|
1194
|
+
expect(spy.callCount, 'scroll to page fires once').to.equal(1);
|
|
1148
1195
|
|
|
1149
1196
|
infiniteScroller.scrollToCell = oldScrollToCell;
|
|
1150
1197
|
});
|
|
@@ -1211,6 +1258,7 @@ describe('Collection Browser', () => {
|
|
|
1211
1258
|
// Infinite scroller won't exist unless there's a base query
|
|
1212
1259
|
el.baseQuery = 'collection:foo';
|
|
1213
1260
|
await el.updateComplete;
|
|
1261
|
+
await nextTick();
|
|
1214
1262
|
|
|
1215
1263
|
const infiniteScroller = el.shadowRoot?.querySelector('infinite-scroller');
|
|
1216
1264
|
(infiniteScroller as InfiniteScroller).reload = infiniteScrollerRefreshSpy;
|
|
@@ -1221,25 +1269,29 @@ describe('Collection Browser', () => {
|
|
|
1221
1269
|
el.loggedIn = true;
|
|
1222
1270
|
await el.updateComplete;
|
|
1223
1271
|
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1272
|
+
expect(infiniteScrollerRefreshSpy.called, 'Infinite Scroller Refresh').to.be
|
|
1273
|
+
.true;
|
|
1274
|
+
expect(
|
|
1275
|
+
infiniteScrollerRefreshSpy.callCount,
|
|
1276
|
+
'Infinite Scroller Refresh call count'
|
|
1277
|
+
).to.equal(1);
|
|
1228
1278
|
|
|
1229
1279
|
el.loggedIn = false;
|
|
1230
1280
|
await el.updateComplete;
|
|
1231
1281
|
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1282
|
+
expect(
|
|
1283
|
+
infiniteScrollerRefreshSpy.callCount,
|
|
1284
|
+
'2nd Infinite Scroller Refresh'
|
|
1285
|
+
).to.equal(2);
|
|
1235
1286
|
|
|
1236
1287
|
// testing: `displayMode`
|
|
1237
1288
|
el.displayMode = 'list-compact';
|
|
1238
1289
|
el.searchContext = 'beta-search';
|
|
1239
1290
|
await el.updateComplete;
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1291
|
+
expect(
|
|
1292
|
+
infiniteScrollerRefreshSpy.callCount,
|
|
1293
|
+
'3rd Infinite Scroller Refresh'
|
|
1294
|
+
).to.equal(3);
|
|
1243
1295
|
|
|
1244
1296
|
expect(mockAnalyticsHandler.callCategory).to.equal('beta-search');
|
|
1245
1297
|
expect(mockAnalyticsHandler.callAction).to.equal('displayMode');
|
|
@@ -1247,10 +1299,10 @@ describe('Collection Browser', () => {
|
|
|
1247
1299
|
|
|
1248
1300
|
el.displayMode = 'list-detail';
|
|
1249
1301
|
await el.updateComplete;
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1302
|
+
expect(
|
|
1303
|
+
infiniteScrollerRefreshSpy.callCount,
|
|
1304
|
+
'4th Infinite Scroller Refresh'
|
|
1305
|
+
).to.equal(4);
|
|
1254
1306
|
|
|
1255
1307
|
expect(mockAnalyticsHandler.callCategory).to.equal('beta-search');
|
|
1256
1308
|
expect(mockAnalyticsHandler.callAction).to.equal('displayMode');
|
|
@@ -1259,18 +1311,18 @@ describe('Collection Browser', () => {
|
|
|
1259
1311
|
// testing: `baseNavigationUrl`
|
|
1260
1312
|
el.baseNavigationUrl = 'https://funtestsite.com';
|
|
1261
1313
|
await el.updateComplete;
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1314
|
+
expect(
|
|
1315
|
+
infiniteScrollerRefreshSpy.callCount,
|
|
1316
|
+
'5th Infinite Scroller Refresh'
|
|
1317
|
+
).to.equal(5);
|
|
1266
1318
|
|
|
1267
1319
|
// testing: `baseImageUrl`
|
|
1268
1320
|
el.baseImageUrl = 'https://funtestsiteforimages.com';
|
|
1269
1321
|
await el.updateComplete;
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1322
|
+
expect(
|
|
1323
|
+
infiniteScrollerRefreshSpy.callCount,
|
|
1324
|
+
'6th Infinite Scroller Refresh'
|
|
1325
|
+
).to.equal(6);
|
|
1274
1326
|
});
|
|
1275
1327
|
|
|
1276
1328
|
it('query the search service for single result', async () => {
|
|
@@ -1372,6 +1424,40 @@ describe('Collection Browser', () => {
|
|
|
1372
1424
|
expect(el.maxSelectedDate).to.equal('2010');
|
|
1373
1425
|
});
|
|
1374
1426
|
|
|
1427
|
+
it('respects the initial set of URL parameters within a profile page', async () => {
|
|
1428
|
+
const url = new URL(window.location.href);
|
|
1429
|
+
const { searchParams } = url;
|
|
1430
|
+
searchParams.set('query', 'foo');
|
|
1431
|
+
searchParams.append('not[]', 'mediatype:"data"');
|
|
1432
|
+
searchParams.append('and[]', 'subject:"baz"');
|
|
1433
|
+
searchParams.append('and[]', 'firstTitle:X');
|
|
1434
|
+
searchParams.append('and[]', 'year:[2000 TO 2010]');
|
|
1435
|
+
window.history.replaceState({}, '', url);
|
|
1436
|
+
|
|
1437
|
+
const searchService = new MockSearchService();
|
|
1438
|
+
const el = await fixture<CollectionBrowser>(
|
|
1439
|
+
html`<collection-browser
|
|
1440
|
+
.searchService=${searchService}
|
|
1441
|
+
.withinProfile=${'@foobar'}
|
|
1442
|
+
.profileElement=${'uploads'}
|
|
1443
|
+
>
|
|
1444
|
+
</collection-browser>`
|
|
1445
|
+
);
|
|
1446
|
+
|
|
1447
|
+
await el.initialSearchComplete;
|
|
1448
|
+
await el.updateComplete;
|
|
1449
|
+
|
|
1450
|
+
expect(el.withinProfile).to.equal('@foobar');
|
|
1451
|
+
expect(el.profileElement).to.equal('uploads');
|
|
1452
|
+
expect(el.baseQuery).to.equal('foo');
|
|
1453
|
+
expect(el.searchType).to.equal(SearchType.METADATA);
|
|
1454
|
+
expect(el.selectedFacets?.mediatype?.data?.state).to.equal('hidden');
|
|
1455
|
+
expect(el.selectedFacets?.subject?.baz?.state).to.equal('selected');
|
|
1456
|
+
expect(el.selectedTitleFilter).to.equal('X');
|
|
1457
|
+
expect(el.minSelectedDate).to.equal('2000');
|
|
1458
|
+
expect(el.maxSelectedDate).to.equal('2010');
|
|
1459
|
+
});
|
|
1460
|
+
|
|
1375
1461
|
it('clears filters except sort when query changes for a general search', async () => {
|
|
1376
1462
|
const url = new URL(window.location.href);
|
|
1377
1463
|
const { searchParams } = url;
|
|
@@ -1427,9 +1513,6 @@ describe('Collection Browser', () => {
|
|
|
1427
1513
|
</collection-browser>`
|
|
1428
1514
|
);
|
|
1429
1515
|
|
|
1430
|
-
await el.initialSearchComplete;
|
|
1431
|
-
await el.updateComplete;
|
|
1432
|
-
|
|
1433
1516
|
el.baseQuery = 'bar';
|
|
1434
1517
|
await el.updateComplete;
|
|
1435
1518
|
|
|
@@ -1465,9 +1548,6 @@ describe('Collection Browser', () => {
|
|
|
1465
1548
|
</collection-browser>`
|
|
1466
1549
|
);
|
|
1467
1550
|
|
|
1468
|
-
await el.initialSearchComplete;
|
|
1469
|
-
await el.updateComplete;
|
|
1470
|
-
|
|
1471
1551
|
el.withinCollection = 'bar';
|
|
1472
1552
|
await el.updateComplete;
|
|
1473
1553
|
|
|
@@ -1482,6 +1562,37 @@ describe('Collection Browser', () => {
|
|
|
1482
1562
|
expect(el.maxSelectedDate).not.to.exist;
|
|
1483
1563
|
});
|
|
1484
1564
|
|
|
1565
|
+
it('correctly retrieves web archive hits', async () => {
|
|
1566
|
+
const searchService = new MockSearchService();
|
|
1567
|
+
const el = await fixture<CollectionBrowser>(
|
|
1568
|
+
html`<collection-browser
|
|
1569
|
+
.searchService=${searchService}
|
|
1570
|
+
.withinProfile=${'@foo'}
|
|
1571
|
+
.profileElement=${'web_archives'}
|
|
1572
|
+
>
|
|
1573
|
+
</collection-browser>`
|
|
1574
|
+
);
|
|
1575
|
+
|
|
1576
|
+
el.baseQuery = 'web-archive';
|
|
1577
|
+
await el.updateComplete;
|
|
1578
|
+
await el.initialSearchComplete;
|
|
1579
|
+
await nextTick();
|
|
1580
|
+
|
|
1581
|
+
console.log(
|
|
1582
|
+
'\n\n*****\n\n*****\n\n',
|
|
1583
|
+
el.dataSource.getAllPages(),
|
|
1584
|
+
'\n\n*****\n\n*****\n\n'
|
|
1585
|
+
);
|
|
1586
|
+
expect(el.dataSource.totalResults, 'total results').to.equal(1);
|
|
1587
|
+
expect(el.dataSource.getTileModelAt(0)?.title).to.equal(
|
|
1588
|
+
'https://example.com'
|
|
1589
|
+
);
|
|
1590
|
+
expect(
|
|
1591
|
+
el.dataSource.getTileModelAt(0)?.captureDates?.length,
|
|
1592
|
+
'capture dates'
|
|
1593
|
+
).to.equal(1);
|
|
1594
|
+
});
|
|
1595
|
+
|
|
1485
1596
|
it('shows temporarily unavailable message when facets suppressed', async () => {
|
|
1486
1597
|
const searchService = new MockSearchService();
|
|
1487
1598
|
const el = await fixture<CollectionBrowser>(
|
|
@@ -1594,10 +1705,10 @@ describe('Collection Browser', () => {
|
|
|
1594
1705
|
?.querySelector('infinite-scroller')!
|
|
1595
1706
|
.shadowRoot?.querySelectorAll('tile-dispatcher');
|
|
1596
1707
|
expect(tiles).to.exist;
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1708
|
+
expect(
|
|
1709
|
+
tiles!.length,
|
|
1710
|
+
'tile count after `el.removeCheckedTiles()`'
|
|
1711
|
+
).to.equal(1);
|
|
1601
1712
|
});
|
|
1602
1713
|
|
|
1603
1714
|
it('can check/uncheck all tiles', async () => {
|
|
@@ -80,10 +80,12 @@ describe('More facets content', () => {
|
|
|
80
80
|
);
|
|
81
81
|
|
|
82
82
|
el.facetKey = 'collection';
|
|
83
|
-
el.query = '
|
|
83
|
+
el.query = 'collection-aggregations';
|
|
84
84
|
await el.updateComplete;
|
|
85
85
|
|
|
86
|
-
expect(searchService.searchParams?.query).to.equal(
|
|
86
|
+
expect(searchService.searchParams?.query).to.equal(
|
|
87
|
+
'collection-aggregations'
|
|
88
|
+
);
|
|
87
89
|
});
|
|
88
90
|
|
|
89
91
|
it('queries for more facets using search service within a collection (no query)', async () => {
|
|
@@ -788,6 +788,11 @@ describe('Collection Facets', () => {
|
|
|
788
788
|
.baseNavigationUrl=${''}
|
|
789
789
|
.withinCollection=${'foo'}
|
|
790
790
|
.parentCollections=${['bar', 'baz']}
|
|
791
|
+
.collectionTitles=${new Map([
|
|
792
|
+
['foo', 'foo-name'],
|
|
793
|
+
['bar', 'bar-name'],
|
|
794
|
+
['baz', 'baz-name'],
|
|
795
|
+
])}
|
|
791
796
|
></collection-facets>`
|
|
792
797
|
);
|
|
793
798
|
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { expect, fixture } from '@open-wc/testing';
|
|
2
|
+
import { html } from 'lit';
|
|
3
|
+
import sinon from 'sinon';
|
|
4
|
+
import { ItemHit, SearchType } from '@internetarchive/search-service';
|
|
5
|
+
import { CollectionBrowserDataSource } from '../../src/data-source/collection-browser-data-source';
|
|
6
|
+
import { TileModel } from '../../src/models';
|
|
7
|
+
import type { CollectionBrowser } from '../../src/collection-browser';
|
|
8
|
+
import '../../src/collection-browser';
|
|
9
|
+
import { MockSearchService } from '../mocks/mock-search-service';
|
|
10
|
+
|
|
11
|
+
const dataPage: TileModel[] = [
|
|
12
|
+
new TileModel(
|
|
13
|
+
new ItemHit({
|
|
14
|
+
fields: {
|
|
15
|
+
identifier: 'foo',
|
|
16
|
+
},
|
|
17
|
+
})
|
|
18
|
+
),
|
|
19
|
+
new TileModel(
|
|
20
|
+
new ItemHit({
|
|
21
|
+
fields: {
|
|
22
|
+
identifier: 'bar',
|
|
23
|
+
},
|
|
24
|
+
})
|
|
25
|
+
),
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
describe('Collection Browser Data Source', () => {
|
|
29
|
+
let host: CollectionBrowser;
|
|
30
|
+
|
|
31
|
+
beforeEach(async () => {
|
|
32
|
+
host = await fixture<CollectionBrowser>(html`
|
|
33
|
+
<collection-browser></collection-browser>
|
|
34
|
+
`);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('can add and retrieve data pages', () => {
|
|
38
|
+
const dataSource = new CollectionBrowserDataSource(host);
|
|
39
|
+
dataSource.addPage(1, dataPage);
|
|
40
|
+
|
|
41
|
+
expect(Object.keys(dataSource.getAllPages()).length).to.equal(1);
|
|
42
|
+
expect(dataSource.getPage(1).length).to.equal(2);
|
|
43
|
+
expect(dataSource.getPage(1)[0].identifier).to.equal('foo');
|
|
44
|
+
expect(dataSource.getPage(1)[1].identifier).to.equal('bar');
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('resets data when changing page size', () => {
|
|
48
|
+
const dataSource = new CollectionBrowserDataSource(host);
|
|
49
|
+
dataSource.addPage(1, dataPage);
|
|
50
|
+
|
|
51
|
+
dataSource.setPageSize(100);
|
|
52
|
+
expect(Object.keys(dataSource.getAllPages()).length).to.equal(0);
|
|
53
|
+
expect(dataSource.getPageSize()).to.equal(100);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('can be installed on the host', async () => {
|
|
57
|
+
const dataSource = new CollectionBrowserDataSource(host);
|
|
58
|
+
dataSource.addPage(1, dataPage);
|
|
59
|
+
|
|
60
|
+
host.installDataSourceAndQueryState(dataSource, {
|
|
61
|
+
searchType: SearchType.METADATA,
|
|
62
|
+
sortDirection: null,
|
|
63
|
+
selectedTitleFilter: null,
|
|
64
|
+
selectedCreatorFilter: null,
|
|
65
|
+
baseQuery: 'foobar',
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
await host.updateComplete;
|
|
69
|
+
|
|
70
|
+
expect(host.dataSource).to.equal(dataSource);
|
|
71
|
+
expect(host.baseQuery).to.equal('foobar');
|
|
72
|
+
|
|
73
|
+
host.removeController(dataSource);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it('can suppress further fetches', async () => {
|
|
77
|
+
host.searchService = new MockSearchService();
|
|
78
|
+
|
|
79
|
+
const pageFetchSpy = sinon.spy();
|
|
80
|
+
const dataSource = new CollectionBrowserDataSource(host);
|
|
81
|
+
dataSource.fetchPage = pageFetchSpy;
|
|
82
|
+
|
|
83
|
+
dataSource.addPage(1, dataPage);
|
|
84
|
+
dataSource.setFetchesSuppressed(true);
|
|
85
|
+
dataSource.handleQueryChange();
|
|
86
|
+
|
|
87
|
+
expect(pageFetchSpy.callCount).to.equal(0);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it('refreshes prefix filter counts', () => {
|
|
91
|
+
const dataSource = new CollectionBrowserDataSource(host);
|
|
92
|
+
dataSource.addPage(1, dataPage);
|
|
93
|
+
|
|
94
|
+
dataSource.prefixFilterCountMap = {
|
|
95
|
+
title: {
|
|
96
|
+
X: 10,
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
dataSource.refreshLetterCounts();
|
|
101
|
+
expect(dataSource.prefixFilterCountMap).to.deep.equal({});
|
|
102
|
+
});
|
|
103
|
+
});
|
package/test/item-image.test.ts
CHANGED
|
@@ -2,47 +2,45 @@
|
|
|
2
2
|
import { expect, fixture } from '@open-wc/testing';
|
|
3
3
|
import { html } from 'lit';
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import { TileModel } from '../src/models';
|
|
6
6
|
import type { ItemImage } from '../src/tiles/item-image';
|
|
7
7
|
|
|
8
8
|
import '../src/tiles/item-image';
|
|
9
9
|
|
|
10
10
|
const baseImageUrl = 'https://archive.org';
|
|
11
|
-
const testBookModel: TileModel = {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
collectionSize: 0,
|
|
45
|
-
};
|
|
11
|
+
const testBookModel: TileModel = new TileModel({});
|
|
12
|
+
testBookModel.checked = false;
|
|
13
|
+
testBookModel.collections = [];
|
|
14
|
+
testBookModel.commentCount = 0;
|
|
15
|
+
testBookModel.creators = [];
|
|
16
|
+
testBookModel.favCount = 0;
|
|
17
|
+
testBookModel.identifier = '18730130BloomfieldRecordCompleteIssue';
|
|
18
|
+
testBookModel.itemCount = 0;
|
|
19
|
+
testBookModel.mediatype = 'texts';
|
|
20
|
+
testBookModel.subjects = [];
|
|
21
|
+
testBookModel.title = 'Sample Waveform';
|
|
22
|
+
testBookModel.viewCount = 0;
|
|
23
|
+
testBookModel.loginRequired = false;
|
|
24
|
+
testBookModel.contentWarning = false;
|
|
25
|
+
testBookModel.collectionFilesCount = 0;
|
|
26
|
+
testBookModel.collectionSize = 0;
|
|
27
|
+
|
|
28
|
+
const testAudioModel: TileModel = new TileModel({});
|
|
29
|
+
testAudioModel.checked = false;
|
|
30
|
+
testAudioModel.collections = [];
|
|
31
|
+
testAudioModel.commentCount = 0;
|
|
32
|
+
testAudioModel.creators = [];
|
|
33
|
+
testAudioModel.favCount = 0;
|
|
34
|
+
testAudioModel.identifier = 'dwd2015-01-24';
|
|
35
|
+
testAudioModel.itemCount = 0;
|
|
36
|
+
testAudioModel.mediatype = 'audio';
|
|
37
|
+
testAudioModel.subjects = [];
|
|
38
|
+
testAudioModel.title = 'Sample Waveform';
|
|
39
|
+
testAudioModel.viewCount = 0;
|
|
40
|
+
testAudioModel.loginRequired = false;
|
|
41
|
+
testAudioModel.contentWarning = false;
|
|
42
|
+
testAudioModel.collectionFilesCount = 0;
|
|
43
|
+
testAudioModel.collectionSize = 0;
|
|
46
44
|
|
|
47
45
|
describe('ItemImage component', () => {
|
|
48
46
|
it('should render initial component', async () => {
|