@internetarchive/collection-browser 1.14.4 → 1.14.5-alpha2
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 +26 -26
- 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/LICENSE +661 -661
- package/README.md +83 -83
- package/dist/index.d.ts +9 -9
- package/dist/index.js +9 -9
- package/dist/src/app-root.d.ts +64 -64
- package/dist/src/app-root.js +311 -311
- 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 +525 -524
- package/dist/src/collection-browser.js +1871 -1859
- package/dist/src/collection-browser.js.map +1 -1
- 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 +20 -20
- package/dist/src/collection-facets/facets-template.js +152 -152
- package/dist/src/collection-facets/more-facets-content.d.ts +77 -77
- package/dist/src/collection-facets/more-facets-content.js +359 -359
- 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 +104 -104
- package/dist/src/collection-facets.js +507 -506
- package/dist/src/collection-facets.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/mediatype/mediatype-config.d.ts +3 -3
- package/dist/src/mediatype/mediatype-config.js +91 -91
- package/dist/src/models.d.ts +164 -164
- package/dist/src/models.js +269 -269
- 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 +208 -208
- package/dist/src/sort-filter-bar/sort-filter-bar.js +637 -637
- 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 -18
- package/dist/src/tiles/base-tile-component.js +63 -59
- package/dist/src/tiles/base-tile-component.js.map +1 -1
- 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 +27 -27
- package/dist/src/tiles/grid/item-tile.js +134 -134
- 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 +48 -48
- 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 +36 -36
- package/dist/src/tiles/item-image.js +127 -127
- 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 +114 -114
- package/dist/src/tiles/list/tile-list.d.ts +46 -46
- package/dist/src/tiles/list/tile-list.js +302 -302
- 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 +235 -235
- package/dist/src/tiles/tile-dispatcher.js.map +1 -1
- package/dist/src/tiles/tile-display-value-provider.d.ts +43 -43
- package/dist/src/tiles/tile-display-value-provider.js +80 -80
- 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/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/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 +1098 -1098
- package/dist/test/collection-facets/facets-template.test.d.ts +1 -1
- package/dist/test/collection-facets/facets-template.test.js +134 -134
- 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-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 +682 -682
- 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 +86 -86
- 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-collection-name-cache.d.ts +9 -9
- package/dist/test/mocks/mock-collection-name-cache.js +17 -17
- package/dist/test/mocks/mock-search-responses.d.ts +21 -21
- package/dist/test/mocks/mock-search-responses.js +709 -709
- package/dist/test/mocks/mock-search-service.d.ts +15 -15
- package/dist/test/mocks/mock-search-service.js +50 -50
- 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 +378 -378
- 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 +33 -33
- 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 +254 -254
- 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 +258 -258
- 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 +242 -242
- package/dist/test/tiles/tile-dispatcher.test.d.ts +1 -1
- package/dist/test/tiles/tile-dispatcher.test.js +94 -94
- 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/local.archive.org.cert +86 -86
- package/local.archive.org.key +27 -27
- package/package.json +1 -1
- package/renovate.json +6 -6
- package/src/collection-browser.ts +11 -1
- package/src/collection-facets.ts +1 -0
- package/src/tiles/base-tile-component.ts +2 -0
- package/src/tiles/tile-dispatcher.ts +7 -5
- package/tsconfig.json +21 -21
- package/web-dev-server.config.mjs +30 -30
- package/web-test-runner.config.mjs +41 -41
|
@@ -1,1213 +1,1213 @@
|
|
|
1
|
-
/* eslint-disable import/no-duplicates */
|
|
2
|
-
import { aTimeout, expect, fixture } from '@open-wc/testing';
|
|
3
|
-
import { html } from 'lit';
|
|
4
|
-
import sinon from 'sinon';
|
|
5
|
-
import { FilterConstraint, SearchType } from '@internetarchive/search-service';
|
|
6
|
-
import '../src/collection-browser';
|
|
7
|
-
import { getDefaultSelectedFacets, SortField, } from '../src/models';
|
|
8
|
-
import { MockSearchService } from './mocks/mock-search-service';
|
|
9
|
-
import { MockCollectionNameCache } from './mocks/mock-collection-name-cache';
|
|
10
|
-
import { MockAnalyticsHandler } from './mocks/mock-analytics-handler';
|
|
11
|
-
import { analyticsCategories } from '../src/utils/analytics-events';
|
|
12
|
-
/**
|
|
13
|
-
* Wait for the next tick of the event loop.
|
|
14
|
-
*
|
|
15
|
-
* This is necessary in some of the tests because certain collection browser
|
|
16
|
-
* updates take more than one tick to render (e.g., date picker & query changes).
|
|
17
|
-
* These delays are non-ideal and should eventually be investigated and fixed,
|
|
18
|
-
* but they are minor enough that waiting for the next tick is a reasonable
|
|
19
|
-
* testing solution for now.
|
|
20
|
-
*/
|
|
21
|
-
const nextTick = () => aTimeout(0);
|
|
22
|
-
describe('Collection Browser', () => {
|
|
23
|
-
beforeEach(async () => {
|
|
24
|
-
// Apparently query params set by one test can bleed into other tests.
|
|
25
|
-
// Since collection browser restores its state from certain query params, we need
|
|
26
|
-
// to clear these before each test to ensure they run in isolation from one another.
|
|
27
|
-
const url = new URL(window.location.href);
|
|
28
|
-
const { searchParams } = url;
|
|
29
|
-
searchParams.delete('sin');
|
|
30
|
-
searchParams.delete('sort');
|
|
31
|
-
searchParams.delete('query');
|
|
32
|
-
searchParams.delete('page');
|
|
33
|
-
searchParams.delete('and[]');
|
|
34
|
-
searchParams.delete('not[]');
|
|
35
|
-
window.history.replaceState({}, '', url);
|
|
36
|
-
});
|
|
37
|
-
it('clears selected facets when requested', async () => {
|
|
38
|
-
const selectedFacets = getDefaultSelectedFacets();
|
|
39
|
-
selectedFacets.creator.foo = { count: 1, key: 'foo', state: 'selected' };
|
|
40
|
-
const el = await fixture(html `<collection-browser></collection-browser>`);
|
|
41
|
-
el.selectedFacets = selectedFacets;
|
|
42
|
-
await el.updateComplete;
|
|
43
|
-
el.clearFilters(); // By default, sort is not cleared
|
|
44
|
-
expect(el.selectedFacets).to.deep.equal(getDefaultSelectedFacets());
|
|
45
|
-
});
|
|
46
|
-
it('clears existing filters but not sort by default', async () => {
|
|
47
|
-
const el = await fixture(html `<collection-browser></collection-browser>`);
|
|
48
|
-
el.selectedSort = 'title';
|
|
49
|
-
el.sortDirection = 'asc';
|
|
50
|
-
await el.updateComplete;
|
|
51
|
-
el.clearFilters(); // By default, sort is not cleared
|
|
52
|
-
expect(el.selectedFacets).to.deep.equal(getDefaultSelectedFacets());
|
|
53
|
-
expect(el.selectedSort).to.equal('title');
|
|
54
|
-
expect(el.sortDirection).to.equal('asc');
|
|
55
|
-
expect(el.sortParam).to.deep.equal({
|
|
56
|
-
field: 'titleSorter',
|
|
57
|
-
direction: 'asc',
|
|
58
|
-
});
|
|
59
|
-
expect(el.selectedCreatorFilter).to.be.null;
|
|
60
|
-
expect(el.selectedTitleFilter).to.be.null;
|
|
61
|
-
});
|
|
62
|
-
it('clears existing filters for facets & sort via option', async () => {
|
|
63
|
-
const el = await fixture(html `<collection-browser></collection-browser>`);
|
|
64
|
-
el.selectedSort = 'title';
|
|
65
|
-
await el.updateComplete;
|
|
66
|
-
el.clearFilters({ sort: true }); // Sort is reset too due to the option
|
|
67
|
-
expect(el.selectedFacets).to.deep.equal(getDefaultSelectedFacets());
|
|
68
|
-
expect(el.selectedSort).to.equal(SortField.default);
|
|
69
|
-
expect(el.sortDirection).to.be.null;
|
|
70
|
-
expect(el.sortParam).to.be.null;
|
|
71
|
-
expect(el.selectedCreatorFilter).to.be.null;
|
|
72
|
-
expect(el.selectedTitleFilter).to.be.null;
|
|
73
|
-
});
|
|
74
|
-
it('filterBy creator with analytics', async () => {
|
|
75
|
-
const mockAnalyticsHandler = new MockAnalyticsHandler();
|
|
1
|
+
/* eslint-disable import/no-duplicates */
|
|
2
|
+
import { aTimeout, expect, fixture } from '@open-wc/testing';
|
|
3
|
+
import { html } from 'lit';
|
|
4
|
+
import sinon from 'sinon';
|
|
5
|
+
import { FilterConstraint, SearchType } from '@internetarchive/search-service';
|
|
6
|
+
import '../src/collection-browser';
|
|
7
|
+
import { getDefaultSelectedFacets, SortField, } from '../src/models';
|
|
8
|
+
import { MockSearchService } from './mocks/mock-search-service';
|
|
9
|
+
import { MockCollectionNameCache } from './mocks/mock-collection-name-cache';
|
|
10
|
+
import { MockAnalyticsHandler } from './mocks/mock-analytics-handler';
|
|
11
|
+
import { analyticsCategories } from '../src/utils/analytics-events';
|
|
12
|
+
/**
|
|
13
|
+
* Wait for the next tick of the event loop.
|
|
14
|
+
*
|
|
15
|
+
* This is necessary in some of the tests because certain collection browser
|
|
16
|
+
* updates take more than one tick to render (e.g., date picker & query changes).
|
|
17
|
+
* These delays are non-ideal and should eventually be investigated and fixed,
|
|
18
|
+
* but they are minor enough that waiting for the next tick is a reasonable
|
|
19
|
+
* testing solution for now.
|
|
20
|
+
*/
|
|
21
|
+
const nextTick = () => aTimeout(0);
|
|
22
|
+
describe('Collection Browser', () => {
|
|
23
|
+
beforeEach(async () => {
|
|
24
|
+
// Apparently query params set by one test can bleed into other tests.
|
|
25
|
+
// Since collection browser restores its state from certain query params, we need
|
|
26
|
+
// to clear these before each test to ensure they run in isolation from one another.
|
|
27
|
+
const url = new URL(window.location.href);
|
|
28
|
+
const { searchParams } = url;
|
|
29
|
+
searchParams.delete('sin');
|
|
30
|
+
searchParams.delete('sort');
|
|
31
|
+
searchParams.delete('query');
|
|
32
|
+
searchParams.delete('page');
|
|
33
|
+
searchParams.delete('and[]');
|
|
34
|
+
searchParams.delete('not[]');
|
|
35
|
+
window.history.replaceState({}, '', url);
|
|
36
|
+
});
|
|
37
|
+
it('clears selected facets when requested', async () => {
|
|
38
|
+
const selectedFacets = getDefaultSelectedFacets();
|
|
39
|
+
selectedFacets.creator.foo = { count: 1, key: 'foo', state: 'selected' };
|
|
40
|
+
const el = await fixture(html `<collection-browser></collection-browser>`);
|
|
41
|
+
el.selectedFacets = selectedFacets;
|
|
42
|
+
await el.updateComplete;
|
|
43
|
+
el.clearFilters(); // By default, sort is not cleared
|
|
44
|
+
expect(el.selectedFacets).to.deep.equal(getDefaultSelectedFacets());
|
|
45
|
+
});
|
|
46
|
+
it('clears existing filters but not sort by default', async () => {
|
|
47
|
+
const el = await fixture(html `<collection-browser></collection-browser>`);
|
|
48
|
+
el.selectedSort = 'title';
|
|
49
|
+
el.sortDirection = 'asc';
|
|
50
|
+
await el.updateComplete;
|
|
51
|
+
el.clearFilters(); // By default, sort is not cleared
|
|
52
|
+
expect(el.selectedFacets).to.deep.equal(getDefaultSelectedFacets());
|
|
53
|
+
expect(el.selectedSort).to.equal('title');
|
|
54
|
+
expect(el.sortDirection).to.equal('asc');
|
|
55
|
+
expect(el.sortParam).to.deep.equal({
|
|
56
|
+
field: 'titleSorter',
|
|
57
|
+
direction: 'asc',
|
|
58
|
+
});
|
|
59
|
+
expect(el.selectedCreatorFilter).to.be.null;
|
|
60
|
+
expect(el.selectedTitleFilter).to.be.null;
|
|
61
|
+
});
|
|
62
|
+
it('clears existing filters for facets & sort via option', async () => {
|
|
63
|
+
const el = await fixture(html `<collection-browser></collection-browser>`);
|
|
64
|
+
el.selectedSort = 'title';
|
|
65
|
+
await el.updateComplete;
|
|
66
|
+
el.clearFilters({ sort: true }); // Sort is reset too due to the option
|
|
67
|
+
expect(el.selectedFacets).to.deep.equal(getDefaultSelectedFacets());
|
|
68
|
+
expect(el.selectedSort).to.equal(SortField.default);
|
|
69
|
+
expect(el.sortDirection).to.be.null;
|
|
70
|
+
expect(el.sortParam).to.be.null;
|
|
71
|
+
expect(el.selectedCreatorFilter).to.be.null;
|
|
72
|
+
expect(el.selectedTitleFilter).to.be.null;
|
|
73
|
+
});
|
|
74
|
+
it('filterBy creator with analytics', async () => {
|
|
75
|
+
const mockAnalyticsHandler = new MockAnalyticsHandler();
|
|
76
76
|
const el = await fixture(html `<collection-browser .analyticsHandler=${mockAnalyticsHandler}>
|
|
77
|
-
</collection-browser>`);
|
|
78
|
-
el.searchContext = 'betaSearchService';
|
|
79
|
-
el.selectedSort = 'creator';
|
|
80
|
-
el.sortDirection = 'asc';
|
|
81
|
-
el.selectedCreatorFilter = 'A';
|
|
82
|
-
await el.updateComplete;
|
|
83
|
-
expect(mockAnalyticsHandler.callCategory).to.equal('betaSearchService');
|
|
84
|
-
expect(mockAnalyticsHandler.callAction).to.equal('filterByCreator');
|
|
85
|
-
expect(mockAnalyticsHandler.callLabel).to.equal('start-A');
|
|
86
|
-
el.clearFilters();
|
|
87
|
-
await el.updateComplete;
|
|
88
|
-
expect(el.selectedTitleFilter).to.be.null;
|
|
89
|
-
expect(mockAnalyticsHandler.callCategory).to.equal('betaSearchService');
|
|
90
|
-
expect(mockAnalyticsHandler.callAction).to.equal('filterByCreator');
|
|
91
|
-
expect(mockAnalyticsHandler.callLabel).to.equal('clear-A');
|
|
92
|
-
});
|
|
93
|
-
it('filterBy title with analytics', async () => {
|
|
94
|
-
const mockAnalyticsHandler = new MockAnalyticsHandler();
|
|
77
|
+
</collection-browser>`);
|
|
78
|
+
el.searchContext = 'betaSearchService';
|
|
79
|
+
el.selectedSort = 'creator';
|
|
80
|
+
el.sortDirection = 'asc';
|
|
81
|
+
el.selectedCreatorFilter = 'A';
|
|
82
|
+
await el.updateComplete;
|
|
83
|
+
expect(mockAnalyticsHandler.callCategory).to.equal('betaSearchService');
|
|
84
|
+
expect(mockAnalyticsHandler.callAction).to.equal('filterByCreator');
|
|
85
|
+
expect(mockAnalyticsHandler.callLabel).to.equal('start-A');
|
|
86
|
+
el.clearFilters();
|
|
87
|
+
await el.updateComplete;
|
|
88
|
+
expect(el.selectedTitleFilter).to.be.null;
|
|
89
|
+
expect(mockAnalyticsHandler.callCategory).to.equal('betaSearchService');
|
|
90
|
+
expect(mockAnalyticsHandler.callAction).to.equal('filterByCreator');
|
|
91
|
+
expect(mockAnalyticsHandler.callLabel).to.equal('clear-A');
|
|
92
|
+
});
|
|
93
|
+
it('filterBy title with analytics', async () => {
|
|
94
|
+
const mockAnalyticsHandler = new MockAnalyticsHandler();
|
|
95
95
|
const el = await fixture(html `<collection-browser .analyticsHandler=${mockAnalyticsHandler}>
|
|
96
|
-
</collection-browser>`);
|
|
97
|
-
el.searchContext = 'beta-search-service';
|
|
98
|
-
el.selectedSort = 'title';
|
|
99
|
-
el.sortDirection = 'asc';
|
|
100
|
-
el.selectedTitleFilter = 'A';
|
|
101
|
-
await el.updateComplete;
|
|
102
|
-
expect(mockAnalyticsHandler.callCategory).to.equal('beta-search-service');
|
|
103
|
-
expect(mockAnalyticsHandler.callAction).to.equal('filterByTitle');
|
|
104
|
-
expect(mockAnalyticsHandler.callLabel).to.equal('start-A');
|
|
105
|
-
el.clearFilters();
|
|
106
|
-
await el.updateComplete;
|
|
107
|
-
expect(el.selectedTitleFilter).to.be.null;
|
|
108
|
-
expect(mockAnalyticsHandler.callCategory).to.equal('beta-search-service');
|
|
109
|
-
expect(mockAnalyticsHandler.callAction).to.equal('filterByTitle');
|
|
110
|
-
expect(mockAnalyticsHandler.callLabel).to.equal('clear-A');
|
|
111
|
-
});
|
|
112
|
-
it('selected facets with analytics - not negative facets', async () => {
|
|
113
|
-
const mockAnalyticsHandler = new MockAnalyticsHandler();
|
|
114
|
-
const mediaTypeBucket = { count: 123, state: 'selected' };
|
|
115
|
-
const mockedSelectedFacets = {
|
|
116
|
-
subject: {},
|
|
117
|
-
lending: {},
|
|
118
|
-
mediatype: { data: mediaTypeBucket },
|
|
119
|
-
language: {},
|
|
120
|
-
creator: {},
|
|
121
|
-
collection: {},
|
|
122
|
-
year: {},
|
|
123
|
-
};
|
|
96
|
+
</collection-browser>`);
|
|
97
|
+
el.searchContext = 'beta-search-service';
|
|
98
|
+
el.selectedSort = 'title';
|
|
99
|
+
el.sortDirection = 'asc';
|
|
100
|
+
el.selectedTitleFilter = 'A';
|
|
101
|
+
await el.updateComplete;
|
|
102
|
+
expect(mockAnalyticsHandler.callCategory).to.equal('beta-search-service');
|
|
103
|
+
expect(mockAnalyticsHandler.callAction).to.equal('filterByTitle');
|
|
104
|
+
expect(mockAnalyticsHandler.callLabel).to.equal('start-A');
|
|
105
|
+
el.clearFilters();
|
|
106
|
+
await el.updateComplete;
|
|
107
|
+
expect(el.selectedTitleFilter).to.be.null;
|
|
108
|
+
expect(mockAnalyticsHandler.callCategory).to.equal('beta-search-service');
|
|
109
|
+
expect(mockAnalyticsHandler.callAction).to.equal('filterByTitle');
|
|
110
|
+
expect(mockAnalyticsHandler.callLabel).to.equal('clear-A');
|
|
111
|
+
});
|
|
112
|
+
it('selected facets with analytics - not negative facets', async () => {
|
|
113
|
+
const mockAnalyticsHandler = new MockAnalyticsHandler();
|
|
114
|
+
const mediaTypeBucket = { count: 123, state: 'selected' };
|
|
115
|
+
const mockedSelectedFacets = {
|
|
116
|
+
subject: {},
|
|
117
|
+
lending: {},
|
|
118
|
+
mediatype: { data: mediaTypeBucket },
|
|
119
|
+
language: {},
|
|
120
|
+
creator: {},
|
|
121
|
+
collection: {},
|
|
122
|
+
year: {},
|
|
123
|
+
};
|
|
124
124
|
const el = await fixture(html `<collection-browser .analyticsHandler=${mockAnalyticsHandler}>
|
|
125
|
-
</collection-browser>`);
|
|
126
|
-
el.searchContext = 'search-service';
|
|
127
|
-
el.selectedFacets = mockedSelectedFacets;
|
|
128
|
-
await el.updateComplete;
|
|
129
|
-
el.facetClickHandler(new CustomEvent('facetClick', {
|
|
130
|
-
detail: { key: 'mediatype', state: 'selected', negative: false },
|
|
131
|
-
}));
|
|
132
|
-
expect(mockAnalyticsHandler.callCategory).to.equal('search-service');
|
|
133
|
-
expect(mockAnalyticsHandler.callAction).to.equal('facetSelected');
|
|
134
|
-
expect(mockAnalyticsHandler.callLabel).to.equal('mediatype');
|
|
135
|
-
el.facetClickHandler(new CustomEvent('facetClick', {
|
|
136
|
-
detail: { key: 'mediatype', state: 'none', negative: false },
|
|
137
|
-
}));
|
|
138
|
-
expect(el.selectedFacets).to.equal(mockedSelectedFacets);
|
|
139
|
-
expect(mockAnalyticsHandler.callCategory).to.equal('search-service');
|
|
140
|
-
expect(mockAnalyticsHandler.callAction).to.equal('facetDeselected');
|
|
141
|
-
expect(mockAnalyticsHandler.callLabel).to.equal('mediatype');
|
|
142
|
-
});
|
|
143
|
-
it('selected facets with analytics - negative facets', async () => {
|
|
144
|
-
const mockAnalyticsHandler = new MockAnalyticsHandler();
|
|
145
|
-
const mediaTypeBucket = { count: 123, state: 'selected' };
|
|
146
|
-
const mockedSelectedFacets = {
|
|
147
|
-
subject: {},
|
|
148
|
-
lending: {},
|
|
149
|
-
mediatype: { data: mediaTypeBucket },
|
|
150
|
-
language: {},
|
|
151
|
-
creator: {},
|
|
152
|
-
collection: {},
|
|
153
|
-
year: {},
|
|
154
|
-
};
|
|
125
|
+
</collection-browser>`);
|
|
126
|
+
el.searchContext = 'search-service';
|
|
127
|
+
el.selectedFacets = mockedSelectedFacets;
|
|
128
|
+
await el.updateComplete;
|
|
129
|
+
el.facetClickHandler(new CustomEvent('facetClick', {
|
|
130
|
+
detail: { key: 'mediatype', state: 'selected', negative: false },
|
|
131
|
+
}));
|
|
132
|
+
expect(mockAnalyticsHandler.callCategory).to.equal('search-service');
|
|
133
|
+
expect(mockAnalyticsHandler.callAction).to.equal('facetSelected');
|
|
134
|
+
expect(mockAnalyticsHandler.callLabel).to.equal('mediatype');
|
|
135
|
+
el.facetClickHandler(new CustomEvent('facetClick', {
|
|
136
|
+
detail: { key: 'mediatype', state: 'none', negative: false },
|
|
137
|
+
}));
|
|
138
|
+
expect(el.selectedFacets).to.equal(mockedSelectedFacets);
|
|
139
|
+
expect(mockAnalyticsHandler.callCategory).to.equal('search-service');
|
|
140
|
+
expect(mockAnalyticsHandler.callAction).to.equal('facetDeselected');
|
|
141
|
+
expect(mockAnalyticsHandler.callLabel).to.equal('mediatype');
|
|
142
|
+
});
|
|
143
|
+
it('selected facets with analytics - negative facets', async () => {
|
|
144
|
+
const mockAnalyticsHandler = new MockAnalyticsHandler();
|
|
145
|
+
const mediaTypeBucket = { count: 123, state: 'selected' };
|
|
146
|
+
const mockedSelectedFacets = {
|
|
147
|
+
subject: {},
|
|
148
|
+
lending: {},
|
|
149
|
+
mediatype: { data: mediaTypeBucket },
|
|
150
|
+
language: {},
|
|
151
|
+
creator: {},
|
|
152
|
+
collection: {},
|
|
153
|
+
year: {},
|
|
154
|
+
};
|
|
155
155
|
const el = await fixture(html `<collection-browser .analyticsHandler=${mockAnalyticsHandler}>
|
|
156
|
-
</collection-browser>`);
|
|
157
|
-
el.searchContext = 'beta-search-service';
|
|
158
|
-
el.selectedFacets = mockedSelectedFacets;
|
|
159
|
-
await el.updateComplete;
|
|
160
|
-
el.facetClickHandler(new CustomEvent('facetClick', {
|
|
161
|
-
detail: { key: 'mediatype', state: 'hidden', negative: true },
|
|
162
|
-
}));
|
|
163
|
-
expect(mockAnalyticsHandler.callCategory).to.equal('beta-search-service');
|
|
164
|
-
expect(mockAnalyticsHandler.callAction).to.equal('facetNegativeSelected');
|
|
165
|
-
expect(mockAnalyticsHandler.callLabel).to.equal('mediatype');
|
|
166
|
-
el.facetClickHandler(new CustomEvent('facetClick', {
|
|
167
|
-
detail: { key: 'mediatype', state: 'none', negative: true },
|
|
168
|
-
}));
|
|
169
|
-
expect(el.selectedFacets).to.equal(mockedSelectedFacets);
|
|
170
|
-
expect(mockAnalyticsHandler.callCategory).to.equal('beta-search-service');
|
|
171
|
-
expect(mockAnalyticsHandler.callAction).to.equal('facetNegativeDeselected');
|
|
172
|
-
expect(mockAnalyticsHandler.callLabel).to.equal('mediatype');
|
|
173
|
-
});
|
|
174
|
-
it('should render with a sort bar, facets, and infinite scroller', async () => {
|
|
175
|
-
var _a, _b, _c;
|
|
176
|
-
const searchService = new MockSearchService();
|
|
156
|
+
</collection-browser>`);
|
|
157
|
+
el.searchContext = 'beta-search-service';
|
|
158
|
+
el.selectedFacets = mockedSelectedFacets;
|
|
159
|
+
await el.updateComplete;
|
|
160
|
+
el.facetClickHandler(new CustomEvent('facetClick', {
|
|
161
|
+
detail: { key: 'mediatype', state: 'hidden', negative: true },
|
|
162
|
+
}));
|
|
163
|
+
expect(mockAnalyticsHandler.callCategory).to.equal('beta-search-service');
|
|
164
|
+
expect(mockAnalyticsHandler.callAction).to.equal('facetNegativeSelected');
|
|
165
|
+
expect(mockAnalyticsHandler.callLabel).to.equal('mediatype');
|
|
166
|
+
el.facetClickHandler(new CustomEvent('facetClick', {
|
|
167
|
+
detail: { key: 'mediatype', state: 'none', negative: true },
|
|
168
|
+
}));
|
|
169
|
+
expect(el.selectedFacets).to.equal(mockedSelectedFacets);
|
|
170
|
+
expect(mockAnalyticsHandler.callCategory).to.equal('beta-search-service');
|
|
171
|
+
expect(mockAnalyticsHandler.callAction).to.equal('facetNegativeDeselected');
|
|
172
|
+
expect(mockAnalyticsHandler.callLabel).to.equal('mediatype');
|
|
173
|
+
});
|
|
174
|
+
it('should render with a sort bar, facets, and infinite scroller', async () => {
|
|
175
|
+
var _a, _b, _c;
|
|
176
|
+
const searchService = new MockSearchService();
|
|
177
177
|
const el = await fixture(html `<collection-browser .searchService=${searchService}>
|
|
178
|
-
</collection-browser>`);
|
|
179
|
-
el.baseQuery = 'hello';
|
|
180
|
-
await el.updateComplete;
|
|
181
|
-
const facets = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('collection-facets');
|
|
182
|
-
const sortBar = (_b = el.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('sort-filter-bar');
|
|
183
|
-
const infiniteScroller = (_c = el.shadowRoot) === null || _c === void 0 ? void 0 : _c.querySelector('infinite-scroller');
|
|
184
|
-
expect(facets).to.exist;
|
|
185
|
-
expect(sortBar).to.exist;
|
|
186
|
-
expect(infiniteScroller).to.exist;
|
|
187
|
-
});
|
|
188
|
-
it('queries the search service when given a base query', async () => {
|
|
189
|
-
var _a, _b, _c;
|
|
190
|
-
const searchService = new MockSearchService();
|
|
178
|
+
</collection-browser>`);
|
|
179
|
+
el.baseQuery = 'hello';
|
|
180
|
+
await el.updateComplete;
|
|
181
|
+
const facets = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('collection-facets');
|
|
182
|
+
const sortBar = (_b = el.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('sort-filter-bar');
|
|
183
|
+
const infiniteScroller = (_c = el.shadowRoot) === null || _c === void 0 ? void 0 : _c.querySelector('infinite-scroller');
|
|
184
|
+
expect(facets).to.exist;
|
|
185
|
+
expect(sortBar).to.exist;
|
|
186
|
+
expect(infiniteScroller).to.exist;
|
|
187
|
+
});
|
|
188
|
+
it('queries the search service when given a base query', async () => {
|
|
189
|
+
var _a, _b, _c;
|
|
190
|
+
const searchService = new MockSearchService();
|
|
191
191
|
const el = await fixture(html `<collection-browser .searchService=${searchService}>
|
|
192
|
-
</collection-browser>`);
|
|
193
|
-
el.baseQuery = 'collection:foo';
|
|
194
|
-
await el.updateComplete;
|
|
195
|
-
await el.initialSearchComplete;
|
|
196
|
-
expect((_a = searchService.searchParams) === null || _a === void 0 ? void 0 : _a.query).to.equal('collection:foo');
|
|
197
|
-
expect((_c = (_b = el.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('#big-results-label')) === null || _c === void 0 ? void 0 : _c.textContent).to.contains('Results');
|
|
198
|
-
});
|
|
199
|
-
it('queries the search service with a metadata search', async () => {
|
|
200
|
-
var _a, _b, _c;
|
|
201
|
-
const searchService = new MockSearchService();
|
|
192
|
+
</collection-browser>`);
|
|
193
|
+
el.baseQuery = 'collection:foo';
|
|
194
|
+
await el.updateComplete;
|
|
195
|
+
await el.initialSearchComplete;
|
|
196
|
+
expect((_a = searchService.searchParams) === null || _a === void 0 ? void 0 : _a.query).to.equal('collection:foo');
|
|
197
|
+
expect((_c = (_b = el.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('#big-results-label')) === null || _c === void 0 ? void 0 : _c.textContent).to.contains('Results');
|
|
198
|
+
});
|
|
199
|
+
it('queries the search service with a metadata search', async () => {
|
|
200
|
+
var _a, _b, _c;
|
|
201
|
+
const searchService = new MockSearchService();
|
|
202
202
|
const el = await fixture(html ` <collection-browser .searchService=${searchService}>
|
|
203
|
-
</collection-browser>`);
|
|
204
|
-
el.searchType = SearchType.METADATA;
|
|
205
|
-
await el.updateComplete;
|
|
206
|
-
el.baseQuery = 'collection:foo';
|
|
207
|
-
await el.updateComplete;
|
|
208
|
-
await el.initialSearchComplete;
|
|
209
|
-
expect((_a = searchService.searchParams) === null || _a === void 0 ? void 0 : _a.query).to.equal('collection:foo');
|
|
210
|
-
expect(searchService.searchType).to.equal(SearchType.METADATA);
|
|
211
|
-
expect((_c = (_b = el.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('#big-results-label')) === null || _c === void 0 ? void 0 : _c.textContent).to.contains('Results');
|
|
212
|
-
});
|
|
213
|
-
it('can change search type', async () => {
|
|
214
|
-
const searchService = new MockSearchService();
|
|
203
|
+
</collection-browser>`);
|
|
204
|
+
el.searchType = SearchType.METADATA;
|
|
205
|
+
await el.updateComplete;
|
|
206
|
+
el.baseQuery = 'collection:foo';
|
|
207
|
+
await el.updateComplete;
|
|
208
|
+
await el.initialSearchComplete;
|
|
209
|
+
expect((_a = searchService.searchParams) === null || _a === void 0 ? void 0 : _a.query).to.equal('collection:foo');
|
|
210
|
+
expect(searchService.searchType).to.equal(SearchType.METADATA);
|
|
211
|
+
expect((_c = (_b = el.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('#big-results-label')) === null || _c === void 0 ? void 0 : _c.textContent).to.contains('Results');
|
|
212
|
+
});
|
|
213
|
+
it('can change search type', async () => {
|
|
214
|
+
const searchService = new MockSearchService();
|
|
215
215
|
const el = await fixture(html `<collection-browser .searchService=${searchService}>
|
|
216
|
-
</collection-browser>`);
|
|
217
|
-
el.baseQuery = 'collection:foo';
|
|
218
|
-
await el.updateComplete;
|
|
219
|
-
el.searchType = SearchType.FULLTEXT;
|
|
220
|
-
await el.updateComplete;
|
|
221
|
-
await el.initialSearchComplete;
|
|
222
|
-
expect(searchService.searchType).to.equal(SearchType.FULLTEXT);
|
|
223
|
-
});
|
|
224
|
-
it('queries the search service with a fulltext search', async () => {
|
|
225
|
-
var _a, _b, _c;
|
|
226
|
-
const searchService = new MockSearchService();
|
|
216
|
+
</collection-browser>`);
|
|
217
|
+
el.baseQuery = 'collection:foo';
|
|
218
|
+
await el.updateComplete;
|
|
219
|
+
el.searchType = SearchType.FULLTEXT;
|
|
220
|
+
await el.updateComplete;
|
|
221
|
+
await el.initialSearchComplete;
|
|
222
|
+
expect(searchService.searchType).to.equal(SearchType.FULLTEXT);
|
|
223
|
+
});
|
|
224
|
+
it('queries the search service with a fulltext search', async () => {
|
|
225
|
+
var _a, _b, _c;
|
|
226
|
+
const searchService = new MockSearchService();
|
|
227
227
|
const el = await fixture(html ` <collection-browser .searchService=${searchService}>
|
|
228
|
-
</collection-browser>`);
|
|
229
|
-
el.searchType = SearchType.FULLTEXT;
|
|
230
|
-
await el.updateComplete;
|
|
231
|
-
el.baseQuery = 'collection:foo';
|
|
232
|
-
await el.updateComplete;
|
|
233
|
-
await nextTick();
|
|
234
|
-
expect((_a = searchService.searchParams) === null || _a === void 0 ? void 0 : _a.query).to.equal('collection:foo');
|
|
235
|
-
expect(searchService.searchType).to.equal(SearchType.FULLTEXT);
|
|
236
|
-
expect((_c = (_b = el.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('#big-results-label')) === null || _c === void 0 ? void 0 : _c.textContent).to.contains('Results');
|
|
237
|
-
});
|
|
238
|
-
it('queries the search service with facets selected/negated', async () => {
|
|
239
|
-
var _a, _b;
|
|
240
|
-
const searchService = new MockSearchService();
|
|
241
|
-
const selectedFacets = {
|
|
242
|
-
subject: {
|
|
243
|
-
foo: {
|
|
244
|
-
key: 'foo',
|
|
245
|
-
count: 1,
|
|
246
|
-
state: 'selected',
|
|
247
|
-
},
|
|
248
|
-
bar: {
|
|
249
|
-
key: 'bar',
|
|
250
|
-
count: 2,
|
|
251
|
-
state: 'hidden',
|
|
252
|
-
},
|
|
253
|
-
},
|
|
254
|
-
lending: {},
|
|
255
|
-
mediatype: {},
|
|
256
|
-
language: {
|
|
257
|
-
en: {
|
|
258
|
-
key: 'en',
|
|
259
|
-
count: 1,
|
|
260
|
-
state: 'selected',
|
|
261
|
-
},
|
|
262
|
-
},
|
|
263
|
-
creator: {},
|
|
264
|
-
collection: {},
|
|
265
|
-
year: {},
|
|
266
|
-
};
|
|
228
|
+
</collection-browser>`);
|
|
229
|
+
el.searchType = SearchType.FULLTEXT;
|
|
230
|
+
await el.updateComplete;
|
|
231
|
+
el.baseQuery = 'collection:foo';
|
|
232
|
+
await el.updateComplete;
|
|
233
|
+
await nextTick();
|
|
234
|
+
expect((_a = searchService.searchParams) === null || _a === void 0 ? void 0 : _a.query).to.equal('collection:foo');
|
|
235
|
+
expect(searchService.searchType).to.equal(SearchType.FULLTEXT);
|
|
236
|
+
expect((_c = (_b = el.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('#big-results-label')) === null || _c === void 0 ? void 0 : _c.textContent).to.contains('Results');
|
|
237
|
+
});
|
|
238
|
+
it('queries the search service with facets selected/negated', async () => {
|
|
239
|
+
var _a, _b;
|
|
240
|
+
const searchService = new MockSearchService();
|
|
241
|
+
const selectedFacets = {
|
|
242
|
+
subject: {
|
|
243
|
+
foo: {
|
|
244
|
+
key: 'foo',
|
|
245
|
+
count: 1,
|
|
246
|
+
state: 'selected',
|
|
247
|
+
},
|
|
248
|
+
bar: {
|
|
249
|
+
key: 'bar',
|
|
250
|
+
count: 2,
|
|
251
|
+
state: 'hidden',
|
|
252
|
+
},
|
|
253
|
+
},
|
|
254
|
+
lending: {},
|
|
255
|
+
mediatype: {},
|
|
256
|
+
language: {
|
|
257
|
+
en: {
|
|
258
|
+
key: 'en',
|
|
259
|
+
count: 1,
|
|
260
|
+
state: 'selected',
|
|
261
|
+
},
|
|
262
|
+
},
|
|
263
|
+
creator: {},
|
|
264
|
+
collection: {},
|
|
265
|
+
year: {},
|
|
266
|
+
};
|
|
267
267
|
const el = await fixture(html `<collection-browser .searchService=${searchService}>
|
|
268
|
-
</collection-browser>`);
|
|
269
|
-
el.baseQuery = 'collection:foo';
|
|
270
|
-
el.selectedFacets = selectedFacets;
|
|
271
|
-
await el.updateComplete;
|
|
272
|
-
await el.initialSearchComplete;
|
|
273
|
-
expect((_a = searchService.searchParams) === null || _a === void 0 ? void 0 : _a.query).to.equal('collection:foo');
|
|
274
|
-
expect((_b = searchService.searchParams) === null || _b === void 0 ? void 0 : _b.filters).to.deep.equal({
|
|
275
|
-
subject: {
|
|
276
|
-
foo: 'inc',
|
|
277
|
-
bar: 'exc',
|
|
278
|
-
},
|
|
279
|
-
language: {
|
|
280
|
-
en: 'inc',
|
|
281
|
-
},
|
|
282
|
-
});
|
|
283
|
-
});
|
|
284
|
-
it('fails gracefully if no search service provided', async () => {
|
|
285
|
-
var _a;
|
|
286
|
-
const el = await fixture(html `<collection-browser></collection-browser>`);
|
|
287
|
-
el.baseQuery = 'collection:foo';
|
|
288
|
-
await el.updateComplete;
|
|
289
|
-
// This shouldn't throw an error
|
|
290
|
-
expect(el.fetchPage(3)).to.exist;
|
|
291
|
-
// Should continue showing the empty placeholder
|
|
292
|
-
expect((_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('empty-placeholder')).to.exist;
|
|
293
|
-
});
|
|
294
|
-
it('restores search type from URL param', async () => {
|
|
295
|
-
// Add a sin=TXT param to the URL
|
|
296
|
-
const url = new URL(window.location.href);
|
|
297
|
-
url.searchParams.append('sin', 'TXT');
|
|
298
|
-
window.history.replaceState({}, '', url);
|
|
299
|
-
const searchService = new MockSearchService();
|
|
268
|
+
</collection-browser>`);
|
|
269
|
+
el.baseQuery = 'collection:foo';
|
|
270
|
+
el.selectedFacets = selectedFacets;
|
|
271
|
+
await el.updateComplete;
|
|
272
|
+
await el.initialSearchComplete;
|
|
273
|
+
expect((_a = searchService.searchParams) === null || _a === void 0 ? void 0 : _a.query).to.equal('collection:foo');
|
|
274
|
+
expect((_b = searchService.searchParams) === null || _b === void 0 ? void 0 : _b.filters).to.deep.equal({
|
|
275
|
+
subject: {
|
|
276
|
+
foo: 'inc',
|
|
277
|
+
bar: 'exc',
|
|
278
|
+
},
|
|
279
|
+
language: {
|
|
280
|
+
en: 'inc',
|
|
281
|
+
},
|
|
282
|
+
});
|
|
283
|
+
});
|
|
284
|
+
it('fails gracefully if no search service provided', async () => {
|
|
285
|
+
var _a;
|
|
286
|
+
const el = await fixture(html `<collection-browser></collection-browser>`);
|
|
287
|
+
el.baseQuery = 'collection:foo';
|
|
288
|
+
await el.updateComplete;
|
|
289
|
+
// This shouldn't throw an error
|
|
290
|
+
expect(el.fetchPage(3)).to.exist;
|
|
291
|
+
// Should continue showing the empty placeholder
|
|
292
|
+
expect((_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('empty-placeholder')).to.exist;
|
|
293
|
+
});
|
|
294
|
+
it('restores search type from URL param', async () => {
|
|
295
|
+
// Add a sin=TXT param to the URL
|
|
296
|
+
const url = new URL(window.location.href);
|
|
297
|
+
url.searchParams.append('sin', 'TXT');
|
|
298
|
+
window.history.replaceState({}, '', url);
|
|
299
|
+
const searchService = new MockSearchService();
|
|
300
300
|
const el = await fixture(html `<collection-browser .searchService=${searchService}>
|
|
301
|
-
</collection-browser>`);
|
|
302
|
-
expect(el.searchType).to.equal(SearchType.FULLTEXT);
|
|
303
|
-
});
|
|
304
|
-
it('applies loggedin flag to tile models if needed', async () => {
|
|
305
|
-
var _a;
|
|
306
|
-
const searchService = new MockSearchService();
|
|
301
|
+
</collection-browser>`);
|
|
302
|
+
expect(el.searchType).to.equal(SearchType.FULLTEXT);
|
|
303
|
+
});
|
|
304
|
+
it('applies loggedin flag to tile models if needed', async () => {
|
|
305
|
+
var _a;
|
|
306
|
+
const searchService = new MockSearchService();
|
|
307
307
|
const el = await fixture(html `<collection-browser .searchService=${searchService}>
|
|
308
|
-
</collection-browser>`);
|
|
309
|
-
el.baseQuery = 'loggedin';
|
|
310
|
-
await el.updateComplete;
|
|
311
|
-
await el.initialSearchComplete;
|
|
312
|
-
const cellTemplate = el.cellForIndex(0);
|
|
313
|
-
expect(cellTemplate).to.exist;
|
|
314
|
-
const cell = await fixture(cellTemplate);
|
|
315
|
-
expect(cell).to.exist;
|
|
316
|
-
expect((_a = cell.model) === null || _a === void 0 ? void 0 : _a.loginRequired).to.be.true;
|
|
317
|
-
});
|
|
318
|
-
it('applies no-preview flag to tile models if needed', async () => {
|
|
319
|
-
var _a;
|
|
320
|
-
const searchService = new MockSearchService();
|
|
308
|
+
</collection-browser>`);
|
|
309
|
+
el.baseQuery = 'loggedin';
|
|
310
|
+
await el.updateComplete;
|
|
311
|
+
await el.initialSearchComplete;
|
|
312
|
+
const cellTemplate = el.cellForIndex(0);
|
|
313
|
+
expect(cellTemplate).to.exist;
|
|
314
|
+
const cell = await fixture(cellTemplate);
|
|
315
|
+
expect(cell).to.exist;
|
|
316
|
+
expect((_a = cell.model) === null || _a === void 0 ? void 0 : _a.loginRequired).to.be.true;
|
|
317
|
+
});
|
|
318
|
+
it('applies no-preview flag to tile models if needed', async () => {
|
|
319
|
+
var _a;
|
|
320
|
+
const searchService = new MockSearchService();
|
|
321
321
|
const el = await fixture(html `<collection-browser .searchService=${searchService}>
|
|
322
|
-
</collection-browser>`);
|
|
323
|
-
el.baseQuery = 'no-preview';
|
|
324
|
-
await el.updateComplete;
|
|
325
|
-
await el.initialSearchComplete;
|
|
326
|
-
const cellTemplate = el.cellForIndex(0);
|
|
327
|
-
expect(cellTemplate).to.exist;
|
|
328
|
-
const cell = await fixture(cellTemplate);
|
|
329
|
-
expect(cell).to.exist;
|
|
330
|
-
expect((_a = cell.model) === null || _a === void 0 ? void 0 : _a.contentWarning).to.be.true;
|
|
331
|
-
});
|
|
332
|
-
it('both loggedin and no-preview flags can be set simultaneously', async () => {
|
|
333
|
-
var _a, _b;
|
|
334
|
-
const searchService = new MockSearchService();
|
|
322
|
+
</collection-browser>`);
|
|
323
|
+
el.baseQuery = 'no-preview';
|
|
324
|
+
await el.updateComplete;
|
|
325
|
+
await el.initialSearchComplete;
|
|
326
|
+
const cellTemplate = el.cellForIndex(0);
|
|
327
|
+
expect(cellTemplate).to.exist;
|
|
328
|
+
const cell = await fixture(cellTemplate);
|
|
329
|
+
expect(cell).to.exist;
|
|
330
|
+
expect((_a = cell.model) === null || _a === void 0 ? void 0 : _a.contentWarning).to.be.true;
|
|
331
|
+
});
|
|
332
|
+
it('both loggedin and no-preview flags can be set simultaneously', async () => {
|
|
333
|
+
var _a, _b;
|
|
334
|
+
const searchService = new MockSearchService();
|
|
335
335
|
const el = await fixture(html `<collection-browser .searchService=${searchService}>
|
|
336
|
-
</collection-browser>`);
|
|
337
|
-
el.baseQuery = 'loggedin-no-preview';
|
|
338
|
-
await el.updateComplete;
|
|
339
|
-
await el.initialSearchComplete;
|
|
340
|
-
const cellTemplate = el.cellForIndex(0);
|
|
341
|
-
expect(cellTemplate).to.exist;
|
|
342
|
-
const cell = await fixture(cellTemplate);
|
|
343
|
-
expect(cell).to.exist;
|
|
344
|
-
expect((_a = cell.model) === null || _a === void 0 ? void 0 : _a.loginRequired).to.be.true;
|
|
345
|
-
expect((_b = cell.model) === null || _b === void 0 ? void 0 : _b.contentWarning).to.be.true;
|
|
346
|
-
});
|
|
347
|
-
it('joins full description array into a single string with line breaks', async () => {
|
|
348
|
-
var _a;
|
|
349
|
-
const searchService = new MockSearchService();
|
|
336
|
+
</collection-browser>`);
|
|
337
|
+
el.baseQuery = 'loggedin-no-preview';
|
|
338
|
+
await el.updateComplete;
|
|
339
|
+
await el.initialSearchComplete;
|
|
340
|
+
const cellTemplate = el.cellForIndex(0);
|
|
341
|
+
expect(cellTemplate).to.exist;
|
|
342
|
+
const cell = await fixture(cellTemplate);
|
|
343
|
+
expect(cell).to.exist;
|
|
344
|
+
expect((_a = cell.model) === null || _a === void 0 ? void 0 : _a.loginRequired).to.be.true;
|
|
345
|
+
expect((_b = cell.model) === null || _b === void 0 ? void 0 : _b.contentWarning).to.be.true;
|
|
346
|
+
});
|
|
347
|
+
it('joins full description array into a single string with line breaks', async () => {
|
|
348
|
+
var _a;
|
|
349
|
+
const searchService = new MockSearchService();
|
|
350
350
|
const el = await fixture(html `<collection-browser .searchService=${searchService}>
|
|
351
|
-
</collection-browser>`);
|
|
352
|
-
// This query receives an array description like ['line1', 'line2']
|
|
353
|
-
el.baseQuery = 'multi-line-description';
|
|
354
|
-
await el.updateComplete;
|
|
355
|
-
await el.initialSearchComplete;
|
|
356
|
-
const cellTemplate = el.cellForIndex(0);
|
|
357
|
-
expect(cellTemplate).to.exist;
|
|
358
|
-
const cell = await fixture(cellTemplate);
|
|
359
|
-
expect(cell).to.exist;
|
|
360
|
-
// Actual model description should be joined
|
|
361
|
-
expect((_a = cell.model) === null || _a === void 0 ? void 0 : _a.description).to.equal('line1\nline2');
|
|
362
|
-
});
|
|
363
|
-
it('can change search type', async () => {
|
|
364
|
-
var _a;
|
|
365
|
-
const searchService = new MockSearchService();
|
|
351
|
+
</collection-browser>`);
|
|
352
|
+
// This query receives an array description like ['line1', 'line2']
|
|
353
|
+
el.baseQuery = 'multi-line-description';
|
|
354
|
+
await el.updateComplete;
|
|
355
|
+
await el.initialSearchComplete;
|
|
356
|
+
const cellTemplate = el.cellForIndex(0);
|
|
357
|
+
expect(cellTemplate).to.exist;
|
|
358
|
+
const cell = await fixture(cellTemplate);
|
|
359
|
+
expect(cell).to.exist;
|
|
360
|
+
// Actual model description should be joined
|
|
361
|
+
expect((_a = cell.model) === null || _a === void 0 ? void 0 : _a.description).to.equal('line1\nline2');
|
|
362
|
+
});
|
|
363
|
+
it('can change search type', async () => {
|
|
364
|
+
var _a;
|
|
365
|
+
const searchService = new MockSearchService();
|
|
366
366
|
const el = await fixture(html `<collection-browser
|
|
367
367
|
.searchService=${searchService}
|
|
368
368
|
.searchType=${SearchType.METADATA}
|
|
369
|
-
></collection-browser>`);
|
|
370
|
-
el.baseQuery = 'collection:foo';
|
|
371
|
-
el.searchType = SearchType.FULLTEXT;
|
|
372
|
-
await el.updateComplete;
|
|
373
|
-
await el.initialSearchComplete;
|
|
374
|
-
expect((_a = searchService.searchParams) === null || _a === void 0 ? void 0 : _a.query).to.equal('collection:foo');
|
|
375
|
-
expect(searchService.searchType).to.equal(SearchType.FULLTEXT);
|
|
376
|
-
});
|
|
377
|
-
it('trims queries of leading/trailing whitespace', async () => {
|
|
378
|
-
var _a;
|
|
379
|
-
const searchService = new MockSearchService();
|
|
369
|
+
></collection-browser>`);
|
|
370
|
+
el.baseQuery = 'collection:foo';
|
|
371
|
+
el.searchType = SearchType.FULLTEXT;
|
|
372
|
+
await el.updateComplete;
|
|
373
|
+
await el.initialSearchComplete;
|
|
374
|
+
expect((_a = searchService.searchParams) === null || _a === void 0 ? void 0 : _a.query).to.equal('collection:foo');
|
|
375
|
+
expect(searchService.searchType).to.equal(SearchType.FULLTEXT);
|
|
376
|
+
});
|
|
377
|
+
it('trims queries of leading/trailing whitespace', async () => {
|
|
378
|
+
var _a;
|
|
379
|
+
const searchService = new MockSearchService();
|
|
380
380
|
const el = await fixture(html `<collection-browser
|
|
381
381
|
.searchService=${searchService}
|
|
382
|
-
></collection-browser>`);
|
|
383
|
-
el.baseQuery = ' collection:foo ';
|
|
384
|
-
await el.updateComplete;
|
|
385
|
-
await el.initialSearchComplete;
|
|
386
|
-
expect((_a = searchService.searchParams) === null || _a === void 0 ? void 0 : _a.query).to.equal('collection:foo');
|
|
387
|
-
});
|
|
388
|
-
it('shows error message when error response received', async () => {
|
|
389
|
-
var _a, _b;
|
|
390
|
-
const searchService = new MockSearchService();
|
|
382
|
+
></collection-browser>`);
|
|
383
|
+
el.baseQuery = ' collection:foo ';
|
|
384
|
+
await el.updateComplete;
|
|
385
|
+
await el.initialSearchComplete;
|
|
386
|
+
expect((_a = searchService.searchParams) === null || _a === void 0 ? void 0 : _a.query).to.equal('collection:foo');
|
|
387
|
+
});
|
|
388
|
+
it('shows error message when error response received', async () => {
|
|
389
|
+
var _a, _b;
|
|
390
|
+
const searchService = new MockSearchService();
|
|
391
391
|
const el = await fixture(html `<collection-browser
|
|
392
392
|
.searchService=${searchService}
|
|
393
|
-
></collection-browser>`);
|
|
394
|
-
el.baseQuery = 'error';
|
|
395
|
-
await el.updateComplete;
|
|
396
|
-
await el.initialSearchComplete;
|
|
397
|
-
const errorPlaceholder = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('empty-placeholder');
|
|
398
|
-
const errorDetails = (_b = errorPlaceholder === null || errorPlaceholder === void 0 ? void 0 : errorPlaceholder.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('.error-details');
|
|
399
|
-
expect(errorDetails).to.exist;
|
|
400
|
-
expect(errorDetails.textContent).to.contain('foo');
|
|
401
|
-
});
|
|
402
|
-
it('shows error message when error response received for a collection', async () => {
|
|
403
|
-
var _a, _b;
|
|
404
|
-
const searchService = new MockSearchService();
|
|
393
|
+
></collection-browser>`);
|
|
394
|
+
el.baseQuery = 'error';
|
|
395
|
+
await el.updateComplete;
|
|
396
|
+
await el.initialSearchComplete;
|
|
397
|
+
const errorPlaceholder = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('empty-placeholder');
|
|
398
|
+
const errorDetails = (_b = errorPlaceholder === null || errorPlaceholder === void 0 ? void 0 : errorPlaceholder.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('.error-details');
|
|
399
|
+
expect(errorDetails).to.exist;
|
|
400
|
+
expect(errorDetails.textContent).to.contain('foo');
|
|
401
|
+
});
|
|
402
|
+
it('shows error message when error response received for a collection', async () => {
|
|
403
|
+
var _a, _b;
|
|
404
|
+
const searchService = new MockSearchService();
|
|
405
405
|
const el = await fixture(html `<collection-browser
|
|
406
406
|
.searchService=${searchService}
|
|
407
|
-
></collection-browser>`);
|
|
408
|
-
el.withinCollection = 'error';
|
|
409
|
-
await el.updateComplete;
|
|
410
|
-
await el.initialSearchComplete;
|
|
411
|
-
const errorPlaceholder = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('empty-placeholder');
|
|
412
|
-
const errorDetails = (_b = errorPlaceholder === null || errorPlaceholder === void 0 ? void 0 : errorPlaceholder.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('.error-details');
|
|
413
|
-
expect(errorDetails).to.exist;
|
|
414
|
-
expect(errorDetails.textContent).to.contain('foo');
|
|
415
|
-
});
|
|
416
|
-
it('reports malformed response errors to Sentry', async () => {
|
|
417
|
-
const sentrySpy = sinon.spy();
|
|
418
|
-
window.Sentry = { captureMessage: sentrySpy };
|
|
419
|
-
const searchService = new MockSearchService();
|
|
407
|
+
></collection-browser>`);
|
|
408
|
+
el.withinCollection = 'error';
|
|
409
|
+
await el.updateComplete;
|
|
410
|
+
await el.initialSearchComplete;
|
|
411
|
+
const errorPlaceholder = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('empty-placeholder');
|
|
412
|
+
const errorDetails = (_b = errorPlaceholder === null || errorPlaceholder === void 0 ? void 0 : errorPlaceholder.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('.error-details');
|
|
413
|
+
expect(errorDetails).to.exist;
|
|
414
|
+
expect(errorDetails.textContent).to.contain('foo');
|
|
415
|
+
});
|
|
416
|
+
it('reports malformed response errors to Sentry', async () => {
|
|
417
|
+
const sentrySpy = sinon.spy();
|
|
418
|
+
window.Sentry = { captureMessage: sentrySpy };
|
|
419
|
+
const searchService = new MockSearchService();
|
|
420
420
|
const el = await fixture(html `<collection-browser
|
|
421
421
|
.searchService=${searchService}
|
|
422
|
-
></collection-browser>`);
|
|
423
|
-
el.baseQuery = 'malformed';
|
|
424
|
-
await el.updateComplete;
|
|
425
|
-
await el.initialSearchComplete;
|
|
426
|
-
expect(sentrySpy.callCount).to.be.greaterThanOrEqual(1);
|
|
427
|
-
});
|
|
428
|
-
it('queries for collection names after a fetch', async () => {
|
|
429
|
-
const searchService = new MockSearchService();
|
|
430
|
-
const collectionNameCache = new MockCollectionNameCache();
|
|
422
|
+
></collection-browser>`);
|
|
423
|
+
el.baseQuery = 'malformed';
|
|
424
|
+
await el.updateComplete;
|
|
425
|
+
await el.initialSearchComplete;
|
|
426
|
+
expect(sentrySpy.callCount).to.be.greaterThanOrEqual(1);
|
|
427
|
+
});
|
|
428
|
+
it('queries for collection names after a fetch', async () => {
|
|
429
|
+
const searchService = new MockSearchService();
|
|
430
|
+
const collectionNameCache = new MockCollectionNameCache();
|
|
431
431
|
const el = await fixture(html `<collection-browser
|
|
432
432
|
.searchService=${searchService}
|
|
433
433
|
.collectionNameCache=${collectionNameCache}
|
|
434
434
|
>
|
|
435
|
-
</collection-browser>`);
|
|
436
|
-
el.baseQuery = 'collection:foo';
|
|
437
|
-
await el.updateComplete;
|
|
438
|
-
await el.initialSearchComplete;
|
|
439
|
-
expect(collectionNameCache.preloadIdentifiersRequested).to.deep.equal([
|
|
440
|
-
'foo',
|
|
441
|
-
'bar',
|
|
442
|
-
'baz',
|
|
443
|
-
'boop',
|
|
444
|
-
]);
|
|
445
|
-
});
|
|
446
|
-
it('queries for collection names after an aggregations fetch', async () => {
|
|
447
|
-
const searchService = new MockSearchService();
|
|
448
|
-
const collectionNameCache = new MockCollectionNameCache();
|
|
435
|
+
</collection-browser>`);
|
|
436
|
+
el.baseQuery = 'collection:foo';
|
|
437
|
+
await el.updateComplete;
|
|
438
|
+
await el.initialSearchComplete;
|
|
439
|
+
expect(collectionNameCache.preloadIdentifiersRequested).to.deep.equal([
|
|
440
|
+
'foo',
|
|
441
|
+
'bar',
|
|
442
|
+
'baz',
|
|
443
|
+
'boop',
|
|
444
|
+
]);
|
|
445
|
+
});
|
|
446
|
+
it('queries for collection names after an aggregations fetch', async () => {
|
|
447
|
+
const searchService = new MockSearchService();
|
|
448
|
+
const collectionNameCache = new MockCollectionNameCache();
|
|
449
449
|
const el = await fixture(html `<collection-browser
|
|
450
450
|
.searchService=${searchService}
|
|
451
451
|
.collectionNameCache=${collectionNameCache}
|
|
452
452
|
>
|
|
453
|
-
</collection-browser>`);
|
|
454
|
-
el.baseQuery = 'collection-aggregations';
|
|
455
|
-
await el.updateComplete;
|
|
456
|
-
await el.initialSearchComplete;
|
|
457
|
-
expect(collectionNameCache.preloadIdentifiersRequested).to.deep.equal([
|
|
458
|
-
'foo',
|
|
459
|
-
'bar',
|
|
460
|
-
]);
|
|
461
|
-
});
|
|
462
|
-
it('adds collection names to cache when present on response', async () => {
|
|
463
|
-
const searchService = new MockSearchService();
|
|
464
|
-
const collectionNameCache = new MockCollectionNameCache();
|
|
453
|
+
</collection-browser>`);
|
|
454
|
+
el.baseQuery = 'collection-aggregations';
|
|
455
|
+
await el.updateComplete;
|
|
456
|
+
await el.initialSearchComplete;
|
|
457
|
+
expect(collectionNameCache.preloadIdentifiersRequested).to.deep.equal([
|
|
458
|
+
'foo',
|
|
459
|
+
'bar',
|
|
460
|
+
]);
|
|
461
|
+
});
|
|
462
|
+
it('adds collection names to cache when present on response', async () => {
|
|
463
|
+
const searchService = new MockSearchService();
|
|
464
|
+
const collectionNameCache = new MockCollectionNameCache();
|
|
465
465
|
const el = await fixture(html `<collection-browser
|
|
466
466
|
.searchService=${searchService}
|
|
467
467
|
.collectionNameCache=${collectionNameCache}
|
|
468
468
|
>
|
|
469
|
-
</collection-browser>`);
|
|
470
|
-
el.baseQuery = 'collection-titles';
|
|
471
|
-
await el.updateComplete;
|
|
472
|
-
await el.initialSearchComplete;
|
|
473
|
-
expect(collectionNameCache.knownTitlesAdded).to.deep.equal({
|
|
474
|
-
foo: 'Foo Collection',
|
|
475
|
-
bar: 'Bar Collection',
|
|
476
|
-
baz: 'Baz Collection',
|
|
477
|
-
boop: 'Boop Collection',
|
|
478
|
-
});
|
|
479
|
-
});
|
|
480
|
-
it('keeps search results from fetch if no change to query or sort param', async () => {
|
|
481
|
-
const resultsSpy = sinon.spy();
|
|
482
|
-
const searchService = new MockSearchService({
|
|
483
|
-
asyncResponse: true,
|
|
484
|
-
resultsSpy,
|
|
485
|
-
});
|
|
469
|
+
</collection-browser>`);
|
|
470
|
+
el.baseQuery = 'collection-titles';
|
|
471
|
+
await el.updateComplete;
|
|
472
|
+
await el.initialSearchComplete;
|
|
473
|
+
expect(collectionNameCache.knownTitlesAdded).to.deep.equal({
|
|
474
|
+
foo: 'Foo Collection',
|
|
475
|
+
bar: 'Bar Collection',
|
|
476
|
+
baz: 'Baz Collection',
|
|
477
|
+
boop: 'Boop Collection',
|
|
478
|
+
});
|
|
479
|
+
});
|
|
480
|
+
it('keeps search results from fetch if no change to query or sort param', async () => {
|
|
481
|
+
const resultsSpy = sinon.spy();
|
|
482
|
+
const searchService = new MockSearchService({
|
|
483
|
+
asyncResponse: true,
|
|
484
|
+
resultsSpy,
|
|
485
|
+
});
|
|
486
486
|
const el = await fixture(html `<collection-browser .searchService=${searchService}>
|
|
487
|
-
</collection-browser>`);
|
|
488
|
-
el.baseQuery = 'with-sort';
|
|
489
|
-
el.sortParam = { field: 'foo', direction: 'asc' };
|
|
490
|
-
await el.updateComplete;
|
|
491
|
-
await el.fetchPage(3);
|
|
492
|
-
// If there is no change to the query or sort param during the fetch, the results
|
|
493
|
-
// should be read.
|
|
494
|
-
expect(resultsSpy.callCount).to.be.greaterThanOrEqual(1);
|
|
495
|
-
});
|
|
496
|
-
it('discards obsolete search results if sort params changed before arrival', async () => {
|
|
497
|
-
const resultsSpy = sinon.spy();
|
|
498
|
-
const searchService = new MockSearchService({
|
|
499
|
-
asyncResponse: true,
|
|
500
|
-
resultsSpy,
|
|
501
|
-
});
|
|
487
|
+
</collection-browser>`);
|
|
488
|
+
el.baseQuery = 'with-sort';
|
|
489
|
+
el.sortParam = { field: 'foo', direction: 'asc' };
|
|
490
|
+
await el.updateComplete;
|
|
491
|
+
await el.fetchPage(3);
|
|
492
|
+
// If there is no change to the query or sort param during the fetch, the results
|
|
493
|
+
// should be read.
|
|
494
|
+
expect(resultsSpy.callCount).to.be.greaterThanOrEqual(1);
|
|
495
|
+
});
|
|
496
|
+
it('discards obsolete search results if sort params changed before arrival', async () => {
|
|
497
|
+
const resultsSpy = sinon.spy();
|
|
498
|
+
const searchService = new MockSearchService({
|
|
499
|
+
asyncResponse: true,
|
|
500
|
+
resultsSpy,
|
|
501
|
+
});
|
|
502
502
|
const el = await fixture(html `<collection-browser .searchService=${searchService}>
|
|
503
|
-
</collection-browser>`);
|
|
504
|
-
el.baseQuery = 'with-sort';
|
|
505
|
-
el.sortParam = { field: 'foo', direction: 'asc' };
|
|
506
|
-
await el.updateComplete;
|
|
507
|
-
// We want to spy exclusively on the first set of results, not the second
|
|
508
|
-
searchService.asyncResponse = false;
|
|
509
|
-
searchService.resultsSpy = () => { };
|
|
510
|
-
el.sortParam = { field: 'foo', direction: 'desc' };
|
|
511
|
-
await el.updateComplete;
|
|
512
|
-
await el.initialSearchComplete;
|
|
513
|
-
// If the different sort param causes the results to be discarded,
|
|
514
|
-
// the first results array should never be read.
|
|
515
|
-
expect(resultsSpy.callCount).to.equal(0);
|
|
516
|
-
});
|
|
517
|
-
it('discards obsolete search results if sort param added before arrival', async () => {
|
|
518
|
-
const resultsSpy = sinon.spy();
|
|
519
|
-
const searchService = new MockSearchService({
|
|
520
|
-
asyncResponse: true,
|
|
521
|
-
resultsSpy,
|
|
522
|
-
});
|
|
503
|
+
</collection-browser>`);
|
|
504
|
+
el.baseQuery = 'with-sort';
|
|
505
|
+
el.sortParam = { field: 'foo', direction: 'asc' };
|
|
506
|
+
await el.updateComplete;
|
|
507
|
+
// We want to spy exclusively on the first set of results, not the second
|
|
508
|
+
searchService.asyncResponse = false;
|
|
509
|
+
searchService.resultsSpy = () => { };
|
|
510
|
+
el.sortParam = { field: 'foo', direction: 'desc' };
|
|
511
|
+
await el.updateComplete;
|
|
512
|
+
await el.initialSearchComplete;
|
|
513
|
+
// If the different sort param causes the results to be discarded,
|
|
514
|
+
// the first results array should never be read.
|
|
515
|
+
expect(resultsSpy.callCount).to.equal(0);
|
|
516
|
+
});
|
|
517
|
+
it('discards obsolete search results if sort param added before arrival', async () => {
|
|
518
|
+
const resultsSpy = sinon.spy();
|
|
519
|
+
const searchService = new MockSearchService({
|
|
520
|
+
asyncResponse: true,
|
|
521
|
+
resultsSpy,
|
|
522
|
+
});
|
|
523
523
|
const el = await fixture(html `<collection-browser .searchService=${searchService}>
|
|
524
|
-
</collection-browser>`);
|
|
525
|
-
el.baseQuery = 'single-result';
|
|
526
|
-
await el.updateComplete;
|
|
527
|
-
// We want to spy exclusively on the first set of results, not the second
|
|
528
|
-
searchService.asyncResponse = false;
|
|
529
|
-
searchService.resultsSpy = () => { };
|
|
530
|
-
el.sortParam = { field: 'foo', direction: 'asc' };
|
|
531
|
-
await el.updateComplete;
|
|
532
|
-
await el.initialSearchComplete;
|
|
533
|
-
// If the different sort param causes the results to be discarded,
|
|
534
|
-
// the first results array should never be read.
|
|
535
|
-
expect(resultsSpy.callCount).to.equal(0);
|
|
536
|
-
});
|
|
537
|
-
it('discards obsolete search results if sort param cleared before arrival', async () => {
|
|
538
|
-
const resultsSpy = sinon.spy();
|
|
539
|
-
const searchService = new MockSearchService({
|
|
540
|
-
asyncResponse: true,
|
|
541
|
-
resultsSpy,
|
|
542
|
-
});
|
|
524
|
+
</collection-browser>`);
|
|
525
|
+
el.baseQuery = 'single-result';
|
|
526
|
+
await el.updateComplete;
|
|
527
|
+
// We want to spy exclusively on the first set of results, not the second
|
|
528
|
+
searchService.asyncResponse = false;
|
|
529
|
+
searchService.resultsSpy = () => { };
|
|
530
|
+
el.sortParam = { field: 'foo', direction: 'asc' };
|
|
531
|
+
await el.updateComplete;
|
|
532
|
+
await el.initialSearchComplete;
|
|
533
|
+
// If the different sort param causes the results to be discarded,
|
|
534
|
+
// the first results array should never be read.
|
|
535
|
+
expect(resultsSpy.callCount).to.equal(0);
|
|
536
|
+
});
|
|
537
|
+
it('discards obsolete search results if sort param cleared before arrival', async () => {
|
|
538
|
+
const resultsSpy = sinon.spy();
|
|
539
|
+
const searchService = new MockSearchService({
|
|
540
|
+
asyncResponse: true,
|
|
541
|
+
resultsSpy,
|
|
542
|
+
});
|
|
543
543
|
const el = await fixture(html `<collection-browser .searchService=${searchService}>
|
|
544
|
-
</collection-browser>`);
|
|
545
|
-
el.baseQuery = 'with-sort';
|
|
546
|
-
el.sortParam = { field: 'foo', direction: 'asc' };
|
|
547
|
-
await el.updateComplete;
|
|
548
|
-
// We want to spy exclusively on the first set of results, not the second
|
|
549
|
-
searchService.asyncResponse = false;
|
|
550
|
-
searchService.resultsSpy = () => { };
|
|
551
|
-
el.sortParam = null;
|
|
552
|
-
await el.updateComplete;
|
|
553
|
-
await el.initialSearchComplete;
|
|
554
|
-
// If the different sort param causes the results to be discarded,
|
|
555
|
-
// the first results array should never be read.
|
|
556
|
-
expect(resultsSpy.callCount).to.equal(0);
|
|
557
|
-
});
|
|
558
|
-
it('sets sort properties when user changes sort', async () => {
|
|
559
|
-
var _a, _b, _c, _d;
|
|
560
|
-
const searchService = new MockSearchService();
|
|
544
|
+
</collection-browser>`);
|
|
545
|
+
el.baseQuery = 'with-sort';
|
|
546
|
+
el.sortParam = { field: 'foo', direction: 'asc' };
|
|
547
|
+
await el.updateComplete;
|
|
548
|
+
// We want to spy exclusively on the first set of results, not the second
|
|
549
|
+
searchService.asyncResponse = false;
|
|
550
|
+
searchService.resultsSpy = () => { };
|
|
551
|
+
el.sortParam = null;
|
|
552
|
+
await el.updateComplete;
|
|
553
|
+
await el.initialSearchComplete;
|
|
554
|
+
// If the different sort param causes the results to be discarded,
|
|
555
|
+
// the first results array should never be read.
|
|
556
|
+
expect(resultsSpy.callCount).to.equal(0);
|
|
557
|
+
});
|
|
558
|
+
it('sets sort properties when user changes sort', async () => {
|
|
559
|
+
var _a, _b, _c, _d;
|
|
560
|
+
const searchService = new MockSearchService();
|
|
561
561
|
const el = await fixture(html `<collection-browser .searchService=${searchService}>
|
|
562
|
-
</collection-browser>`);
|
|
563
|
-
expect(el.selectedSort).to.equal(SortField.default);
|
|
564
|
-
el.baseQuery = 'foo';
|
|
565
|
-
await el.updateComplete;
|
|
566
|
-
const sortBar = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('sort-filter-bar');
|
|
567
|
-
const sortSelector = (_b = sortBar === null || sortBar === void 0 ? void 0 : sortBar.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('#desktop-sort-selector');
|
|
568
|
-
expect(sortSelector).to.exist;
|
|
569
|
-
// Click the title sorter
|
|
570
|
-
(_d = (_c = [...sortSelector === null || sortSelector === void 0 ? void 0 : sortSelector.children] // tsc doesn't know children is iterable
|
|
571
|
-
.find(child => { var _a; return ((_a = child.textContent) === null || _a === void 0 ? void 0 : _a.trim()) === 'Title'; })) === null || _c === void 0 ? void 0 : _c.querySelector('button')) === null || _d === void 0 ? void 0 : _d.click();
|
|
572
|
-
await el.updateComplete;
|
|
573
|
-
expect(el.selectedSort).to.equal(SortField.title);
|
|
574
|
-
});
|
|
575
|
-
it('sets sort filter properties when user selects title filter', async () => {
|
|
576
|
-
var _a, _b, _c, _d;
|
|
577
|
-
const searchService = new MockSearchService();
|
|
562
|
+
</collection-browser>`);
|
|
563
|
+
expect(el.selectedSort).to.equal(SortField.default);
|
|
564
|
+
el.baseQuery = 'foo';
|
|
565
|
+
await el.updateComplete;
|
|
566
|
+
const sortBar = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('sort-filter-bar');
|
|
567
|
+
const sortSelector = (_b = sortBar === null || sortBar === void 0 ? void 0 : sortBar.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('#desktop-sort-selector');
|
|
568
|
+
expect(sortSelector).to.exist;
|
|
569
|
+
// Click the title sorter
|
|
570
|
+
(_d = (_c = [...sortSelector === null || sortSelector === void 0 ? void 0 : sortSelector.children] // tsc doesn't know children is iterable
|
|
571
|
+
.find(child => { var _a; return ((_a = child.textContent) === null || _a === void 0 ? void 0 : _a.trim()) === 'Title'; })) === null || _c === void 0 ? void 0 : _c.querySelector('button')) === null || _d === void 0 ? void 0 : _d.click();
|
|
572
|
+
await el.updateComplete;
|
|
573
|
+
expect(el.selectedSort).to.equal(SortField.title);
|
|
574
|
+
});
|
|
575
|
+
it('sets sort filter properties when user selects title filter', async () => {
|
|
576
|
+
var _a, _b, _c, _d;
|
|
577
|
+
const searchService = new MockSearchService();
|
|
578
578
|
const el = await fixture(html `<collection-browser .searchService=${searchService}>
|
|
579
|
-
</collection-browser>`);
|
|
580
|
-
el.baseQuery = 'first-title';
|
|
581
|
-
el.selectedSort = 'title';
|
|
582
|
-
el.sortDirection = 'asc';
|
|
583
|
-
el.selectedTitleFilter = 'X';
|
|
584
|
-
await el.updateComplete;
|
|
585
|
-
await el.initialSearchComplete;
|
|
586
|
-
expect((_a = searchService.searchParams) === null || _a === void 0 ? void 0 : _a.query).to.equal('first-title');
|
|
587
|
-
expect((_d = (_c = (_b = searchService.searchParams) === null || _b === void 0 ? void 0 : _b.filters) === null || _c === void 0 ? void 0 : _c.firstTitle) === null || _d === void 0 ? void 0 : _d.X).to.equal(FilterConstraint.INCLUDE);
|
|
588
|
-
});
|
|
589
|
-
it('sets sort filter properties when user selects creator filter', async () => {
|
|
590
|
-
var _a, _b, _c, _d;
|
|
591
|
-
const searchService = new MockSearchService();
|
|
579
|
+
</collection-browser>`);
|
|
580
|
+
el.baseQuery = 'first-title';
|
|
581
|
+
el.selectedSort = 'title';
|
|
582
|
+
el.sortDirection = 'asc';
|
|
583
|
+
el.selectedTitleFilter = 'X';
|
|
584
|
+
await el.updateComplete;
|
|
585
|
+
await el.initialSearchComplete;
|
|
586
|
+
expect((_a = searchService.searchParams) === null || _a === void 0 ? void 0 : _a.query).to.equal('first-title');
|
|
587
|
+
expect((_d = (_c = (_b = searchService.searchParams) === null || _b === void 0 ? void 0 : _b.filters) === null || _c === void 0 ? void 0 : _c.firstTitle) === null || _d === void 0 ? void 0 : _d.X).to.equal(FilterConstraint.INCLUDE);
|
|
588
|
+
});
|
|
589
|
+
it('sets sort filter properties when user selects creator filter', async () => {
|
|
590
|
+
var _a, _b, _c, _d;
|
|
591
|
+
const searchService = new MockSearchService();
|
|
592
592
|
const el = await fixture(html `<collection-browser .searchService=${searchService}>
|
|
593
|
-
</collection-browser>`);
|
|
594
|
-
el.baseQuery = 'first-creator';
|
|
595
|
-
el.selectedSort = 'creator';
|
|
596
|
-
el.sortDirection = 'asc';
|
|
597
|
-
el.selectedCreatorFilter = 'X';
|
|
598
|
-
await el.updateComplete;
|
|
599
|
-
await el.initialSearchComplete;
|
|
600
|
-
expect((_a = searchService.searchParams) === null || _a === void 0 ? void 0 : _a.query).to.equal('first-creator');
|
|
601
|
-
expect((_d = (_c = (_b = searchService.searchParams) === null || _b === void 0 ? void 0 : _b.filters) === null || _c === void 0 ? void 0 : _c.firstCreator) === null || _d === void 0 ? void 0 : _d.X).to.equal(FilterConstraint.INCLUDE);
|
|
602
|
-
});
|
|
603
|
-
it('sets sort filter properties simultaneous with facets and date range', async () => {
|
|
604
|
-
var _a, _b;
|
|
605
|
-
const searchService = new MockSearchService();
|
|
606
|
-
const selectedFacets = {
|
|
607
|
-
collection: { foo: { key: 'foo', state: 'selected', count: 1 } },
|
|
608
|
-
creator: {},
|
|
609
|
-
language: {},
|
|
610
|
-
lending: {},
|
|
611
|
-
mediatype: {},
|
|
612
|
-
subject: {},
|
|
613
|
-
year: {},
|
|
614
|
-
};
|
|
593
|
+
</collection-browser>`);
|
|
594
|
+
el.baseQuery = 'first-creator';
|
|
595
|
+
el.selectedSort = 'creator';
|
|
596
|
+
el.sortDirection = 'asc';
|
|
597
|
+
el.selectedCreatorFilter = 'X';
|
|
598
|
+
await el.updateComplete;
|
|
599
|
+
await el.initialSearchComplete;
|
|
600
|
+
expect((_a = searchService.searchParams) === null || _a === void 0 ? void 0 : _a.query).to.equal('first-creator');
|
|
601
|
+
expect((_d = (_c = (_b = searchService.searchParams) === null || _b === void 0 ? void 0 : _b.filters) === null || _c === void 0 ? void 0 : _c.firstCreator) === null || _d === void 0 ? void 0 : _d.X).to.equal(FilterConstraint.INCLUDE);
|
|
602
|
+
});
|
|
603
|
+
it('sets sort filter properties simultaneous with facets and date range', async () => {
|
|
604
|
+
var _a, _b;
|
|
605
|
+
const searchService = new MockSearchService();
|
|
606
|
+
const selectedFacets = {
|
|
607
|
+
collection: { foo: { key: 'foo', state: 'selected', count: 1 } },
|
|
608
|
+
creator: {},
|
|
609
|
+
language: {},
|
|
610
|
+
lending: {},
|
|
611
|
+
mediatype: {},
|
|
612
|
+
subject: {},
|
|
613
|
+
year: {},
|
|
614
|
+
};
|
|
615
615
|
const el = await fixture(html `<collection-browser .searchService=${searchService}>
|
|
616
|
-
</collection-browser>`);
|
|
617
|
-
el.baseQuery = 'first-creator';
|
|
618
|
-
el.selectedSort = 'creator';
|
|
619
|
-
el.selectedFacets = selectedFacets;
|
|
620
|
-
el.minSelectedDate = '1950';
|
|
621
|
-
el.maxSelectedDate = '1970';
|
|
622
|
-
el.sortDirection = 'asc';
|
|
623
|
-
el.selectedCreatorFilter = 'X';
|
|
624
|
-
await el.updateComplete;
|
|
625
|
-
await el.initialSearchComplete;
|
|
626
|
-
expect((_a = searchService.searchParams) === null || _a === void 0 ? void 0 : _a.query).to.equal('first-creator');
|
|
627
|
-
expect((_b = searchService.searchParams) === null || _b === void 0 ? void 0 : _b.filters).to.deep.equal({
|
|
628
|
-
collection: {
|
|
629
|
-
foo: 'inc',
|
|
630
|
-
},
|
|
631
|
-
year: {
|
|
632
|
-
'1950': 'gte',
|
|
633
|
-
'1970': 'lte',
|
|
634
|
-
},
|
|
635
|
-
firstCreator: {
|
|
636
|
-
X: 'inc',
|
|
637
|
-
},
|
|
638
|
-
});
|
|
639
|
-
});
|
|
640
|
-
it('resets letter filters when query changes', async () => {
|
|
641
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
642
|
-
const searchService = new MockSearchService();
|
|
616
|
+
</collection-browser>`);
|
|
617
|
+
el.baseQuery = 'first-creator';
|
|
618
|
+
el.selectedSort = 'creator';
|
|
619
|
+
el.selectedFacets = selectedFacets;
|
|
620
|
+
el.minSelectedDate = '1950';
|
|
621
|
+
el.maxSelectedDate = '1970';
|
|
622
|
+
el.sortDirection = 'asc';
|
|
623
|
+
el.selectedCreatorFilter = 'X';
|
|
624
|
+
await el.updateComplete;
|
|
625
|
+
await el.initialSearchComplete;
|
|
626
|
+
expect((_a = searchService.searchParams) === null || _a === void 0 ? void 0 : _a.query).to.equal('first-creator');
|
|
627
|
+
expect((_b = searchService.searchParams) === null || _b === void 0 ? void 0 : _b.filters).to.deep.equal({
|
|
628
|
+
collection: {
|
|
629
|
+
foo: 'inc',
|
|
630
|
+
},
|
|
631
|
+
year: {
|
|
632
|
+
'1950': 'gte',
|
|
633
|
+
'1970': 'lte',
|
|
634
|
+
},
|
|
635
|
+
firstCreator: {
|
|
636
|
+
X: 'inc',
|
|
637
|
+
},
|
|
638
|
+
});
|
|
639
|
+
});
|
|
640
|
+
it('resets letter filters when query changes', async () => {
|
|
641
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
642
|
+
const searchService = new MockSearchService();
|
|
643
643
|
const el = await fixture(html `<collection-browser .searchService=${searchService}>
|
|
644
|
-
</collection-browser>`);
|
|
645
|
-
el.baseQuery = 'first-creator';
|
|
646
|
-
el.selectedSort = 'creator';
|
|
647
|
-
el.sortDirection = 'asc';
|
|
648
|
-
el.selectedCreatorFilter = 'X';
|
|
649
|
-
await el.updateComplete;
|
|
650
|
-
await el.initialSearchComplete;
|
|
651
|
-
expect((_a = searchService.searchParams) === null || _a === void 0 ? void 0 : _a.query).to.equal('first-creator');
|
|
652
|
-
expect((_d = (_c = (_b = searchService.searchParams) === null || _b === void 0 ? void 0 : _b.filters) === null || _c === void 0 ? void 0 : _c.firstCreator) === null || _d === void 0 ? void 0 : _d.X).to.equal(FilterConstraint.INCLUDE);
|
|
653
|
-
el.baseQuery = 'collection:foo';
|
|
654
|
-
await el.updateComplete;
|
|
655
|
-
await el.initialSearchComplete;
|
|
656
|
-
expect((_e = searchService.searchParams) === null || _e === void 0 ? void 0 : _e.query).to.equal('collection:foo');
|
|
657
|
-
expect((_g = (_f = searchService.searchParams) === null || _f === void 0 ? void 0 : _f.filters) === null || _g === void 0 ? void 0 : _g.firstCreator).not.to.exist;
|
|
658
|
-
});
|
|
659
|
-
it('sets date range query when date picker selection changed', async () => {
|
|
660
|
-
var _a, _b, _c;
|
|
661
|
-
const searchService = new MockSearchService();
|
|
644
|
+
</collection-browser>`);
|
|
645
|
+
el.baseQuery = 'first-creator';
|
|
646
|
+
el.selectedSort = 'creator';
|
|
647
|
+
el.sortDirection = 'asc';
|
|
648
|
+
el.selectedCreatorFilter = 'X';
|
|
649
|
+
await el.updateComplete;
|
|
650
|
+
await el.initialSearchComplete;
|
|
651
|
+
expect((_a = searchService.searchParams) === null || _a === void 0 ? void 0 : _a.query).to.equal('first-creator');
|
|
652
|
+
expect((_d = (_c = (_b = searchService.searchParams) === null || _b === void 0 ? void 0 : _b.filters) === null || _c === void 0 ? void 0 : _c.firstCreator) === null || _d === void 0 ? void 0 : _d.X).to.equal(FilterConstraint.INCLUDE);
|
|
653
|
+
el.baseQuery = 'collection:foo';
|
|
654
|
+
await el.updateComplete;
|
|
655
|
+
await el.initialSearchComplete;
|
|
656
|
+
expect((_e = searchService.searchParams) === null || _e === void 0 ? void 0 : _e.query).to.equal('collection:foo');
|
|
657
|
+
expect((_g = (_f = searchService.searchParams) === null || _f === void 0 ? void 0 : _f.filters) === null || _g === void 0 ? void 0 : _g.firstCreator).not.to.exist;
|
|
658
|
+
});
|
|
659
|
+
it('sets date range query when date picker selection changed', async () => {
|
|
660
|
+
var _a, _b, _c;
|
|
661
|
+
const searchService = new MockSearchService();
|
|
662
662
|
const el = await fixture(html `<collection-browser .searchService=${searchService}>
|
|
663
|
-
</collection-browser>`);
|
|
664
|
-
el.baseQuery = 'years'; // Includes year_histogram aggregation in response
|
|
665
|
-
el.showHistogramDatePicker = true;
|
|
666
|
-
await el.updateComplete;
|
|
667
|
-
const facets = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('collection-facets');
|
|
668
|
-
await (facets === null || facets === void 0 ? void 0 : facets.updateComplete);
|
|
669
|
-
// Wait for the date picker to be rendered (which may take until the next tick)
|
|
670
|
-
await nextTick();
|
|
671
|
-
const histogram = (_b = facets === null || facets === void 0 ? void 0 : facets.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('histogram-date-range');
|
|
672
|
-
expect(histogram).to.exist;
|
|
673
|
-
// Enter a new min date into the date picker
|
|
674
|
-
const minDateInput = (_c = histogram.shadowRoot) === null || _c === void 0 ? void 0 : _c.querySelector('#date-min');
|
|
675
|
-
const pressEnterEvent = new KeyboardEvent('keyup', {
|
|
676
|
-
key: 'Enter',
|
|
677
|
-
});
|
|
678
|
-
minDateInput.value = '1960';
|
|
679
|
-
minDateInput.dispatchEvent(pressEnterEvent);
|
|
680
|
-
// Wait for the histogram's update delay
|
|
681
|
-
await aTimeout(histogram.updateDelay + 50);
|
|
682
|
-
// Ensure that the histogram change propagated to the collection browser's
|
|
683
|
-
// date query correctly.
|
|
684
|
-
await el.updateComplete;
|
|
685
|
-
expect(el.minSelectedDate).to.equal('1960');
|
|
686
|
-
expect(el.maxSelectedDate).to.equal('2000');
|
|
687
|
-
});
|
|
688
|
-
it('emits event when loading state changes', async () => {
|
|
689
|
-
var _a, _b, _c, _d;
|
|
690
|
-
const spy = sinon.spy();
|
|
691
|
-
const searchService = new MockSearchService();
|
|
663
|
+
</collection-browser>`);
|
|
664
|
+
el.baseQuery = 'years'; // Includes year_histogram aggregation in response
|
|
665
|
+
el.showHistogramDatePicker = true;
|
|
666
|
+
await el.updateComplete;
|
|
667
|
+
const facets = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('collection-facets');
|
|
668
|
+
await (facets === null || facets === void 0 ? void 0 : facets.updateComplete);
|
|
669
|
+
// Wait for the date picker to be rendered (which may take until the next tick)
|
|
670
|
+
await nextTick();
|
|
671
|
+
const histogram = (_b = facets === null || facets === void 0 ? void 0 : facets.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('histogram-date-range');
|
|
672
|
+
expect(histogram).to.exist;
|
|
673
|
+
// Enter a new min date into the date picker
|
|
674
|
+
const minDateInput = (_c = histogram.shadowRoot) === null || _c === void 0 ? void 0 : _c.querySelector('#date-min');
|
|
675
|
+
const pressEnterEvent = new KeyboardEvent('keyup', {
|
|
676
|
+
key: 'Enter',
|
|
677
|
+
});
|
|
678
|
+
minDateInput.value = '1960';
|
|
679
|
+
minDateInput.dispatchEvent(pressEnterEvent);
|
|
680
|
+
// Wait for the histogram's update delay
|
|
681
|
+
await aTimeout(histogram.updateDelay + 50);
|
|
682
|
+
// Ensure that the histogram change propagated to the collection browser's
|
|
683
|
+
// date query correctly.
|
|
684
|
+
await el.updateComplete;
|
|
685
|
+
expect(el.minSelectedDate).to.equal('1960');
|
|
686
|
+
expect(el.maxSelectedDate).to.equal('2000');
|
|
687
|
+
});
|
|
688
|
+
it('emits event when loading state changes', async () => {
|
|
689
|
+
var _a, _b, _c, _d;
|
|
690
|
+
const spy = sinon.spy();
|
|
691
|
+
const searchService = new MockSearchService();
|
|
692
692
|
const el = await fixture(html `<collection-browser
|
|
693
693
|
.searchService=${searchService}
|
|
694
|
-
></collection-browser>`);
|
|
695
|
-
el.baseQuery = 'collection:foo';
|
|
696
|
-
el.addEventListener('searchResultsLoadingChanged', spy);
|
|
697
|
-
await el.updateComplete;
|
|
698
|
-
await el.initialSearchComplete;
|
|
699
|
-
// Should initially emit loading=true, then later emit loading=false
|
|
700
|
-
expect(spy.callCount).to.equal(2);
|
|
701
|
-
expect((_b = (_a = spy.firstCall.firstArg) === null || _a === void 0 ? void 0 : _a.detail) === null || _b === void 0 ? void 0 : _b.loading).to.equal(true);
|
|
702
|
-
expect((_d = (_c = spy.secondCall.firstArg) === null || _c === void 0 ? void 0 : _c.detail) === null || _d === void 0 ? void 0 : _d.loading).to.equal(false);
|
|
703
|
-
});
|
|
704
|
-
it('collapses extra set of quotes around href field', async () => {
|
|
705
|
-
var _a, _b, _c, _d;
|
|
706
|
-
const searchService = new MockSearchService();
|
|
694
|
+
></collection-browser>`);
|
|
695
|
+
el.baseQuery = 'collection:foo';
|
|
696
|
+
el.addEventListener('searchResultsLoadingChanged', spy);
|
|
697
|
+
await el.updateComplete;
|
|
698
|
+
await el.initialSearchComplete;
|
|
699
|
+
// Should initially emit loading=true, then later emit loading=false
|
|
700
|
+
expect(spy.callCount).to.equal(2);
|
|
701
|
+
expect((_b = (_a = spy.firstCall.firstArg) === null || _a === void 0 ? void 0 : _a.detail) === null || _b === void 0 ? void 0 : _b.loading).to.equal(true);
|
|
702
|
+
expect((_d = (_c = spy.secondCall.firstArg) === null || _c === void 0 ? void 0 : _c.detail) === null || _d === void 0 ? void 0 : _d.loading).to.equal(false);
|
|
703
|
+
});
|
|
704
|
+
it('collapses extra set of quotes around href field', async () => {
|
|
705
|
+
var _a, _b, _c, _d;
|
|
706
|
+
const searchService = new MockSearchService();
|
|
707
707
|
const el = await fixture(html `<collection-browser
|
|
708
708
|
.searchService=${searchService}
|
|
709
709
|
.baseNavigationUrl=${''}
|
|
710
|
-
></collection-browser>`);
|
|
711
|
-
el.baseQuery = 'extra-quoted-href';
|
|
712
|
-
await el.updateComplete;
|
|
713
|
-
await el.initialSearchComplete;
|
|
714
|
-
await el.updateComplete;
|
|
715
|
-
await aTimeout(50);
|
|
716
|
-
const infiniteScroller = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('infinite-scroller');
|
|
717
|
-
expect(infiniteScroller).to.exist;
|
|
718
|
-
const firstResult = (_b = infiniteScroller.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('tile-dispatcher');
|
|
719
|
-
expect(firstResult).to.exist;
|
|
720
|
-
// Original href q param starts/ends with %22%22, but should be collapsed to %22 before render
|
|
721
|
-
expect((_d = (_c = firstResult.shadowRoot) === null || _c === void 0 ? void 0 : _c.querySelector('a[href]')) === null || _d === void 0 ? void 0 : _d.getAttribute('href')).to.equal('/details/foo?q=%22quoted+query%22');
|
|
722
|
-
});
|
|
723
|
-
it('sets default sort from collection metadata', async () => {
|
|
724
|
-
var _a;
|
|
725
|
-
const searchService = new MockSearchService();
|
|
710
|
+
></collection-browser>`);
|
|
711
|
+
el.baseQuery = 'extra-quoted-href';
|
|
712
|
+
await el.updateComplete;
|
|
713
|
+
await el.initialSearchComplete;
|
|
714
|
+
await el.updateComplete;
|
|
715
|
+
await aTimeout(50);
|
|
716
|
+
const infiniteScroller = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('infinite-scroller');
|
|
717
|
+
expect(infiniteScroller).to.exist;
|
|
718
|
+
const firstResult = (_b = infiniteScroller.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('tile-dispatcher');
|
|
719
|
+
expect(firstResult).to.exist;
|
|
720
|
+
// Original href q param starts/ends with %22%22, but should be collapsed to %22 before render
|
|
721
|
+
expect((_d = (_c = firstResult.shadowRoot) === null || _c === void 0 ? void 0 : _c.querySelector('a[href]')) === null || _d === void 0 ? void 0 : _d.getAttribute('href')).to.equal('/details/foo?q=%22quoted+query%22');
|
|
722
|
+
});
|
|
723
|
+
it('sets default sort from collection metadata', async () => {
|
|
724
|
+
var _a;
|
|
725
|
+
const searchService = new MockSearchService();
|
|
726
726
|
const el = await fixture(html `<collection-browser
|
|
727
727
|
.searchService=${searchService}
|
|
728
728
|
.baseNavigationUrl=${''}
|
|
729
|
-
></collection-browser>`);
|
|
730
|
-
el.withinCollection = 'default-sort';
|
|
731
|
-
await el.updateComplete;
|
|
732
|
-
await el.initialSearchComplete;
|
|
733
|
-
await el.updateComplete;
|
|
734
|
-
await aTimeout(50);
|
|
735
|
-
const sortBar = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('sort-filter-bar');
|
|
736
|
-
expect(sortBar).to.exist;
|
|
737
|
-
expect(sortBar.defaultSortField).to.equal(SortField.title);
|
|
738
|
-
expect(sortBar.defaultSortDirection).to.equal('asc');
|
|
739
|
-
expect(sortBar.selectedSort).to.equal(SortField.default);
|
|
740
|
-
expect(sortBar.sortDirection).to.be.null;
|
|
741
|
-
});
|
|
742
|
-
it('sets default sort from collection metadata in "-field" format', async () => {
|
|
743
|
-
var _a;
|
|
744
|
-
const searchService = new MockSearchService();
|
|
729
|
+
></collection-browser>`);
|
|
730
|
+
el.withinCollection = 'default-sort';
|
|
731
|
+
await el.updateComplete;
|
|
732
|
+
await el.initialSearchComplete;
|
|
733
|
+
await el.updateComplete;
|
|
734
|
+
await aTimeout(50);
|
|
735
|
+
const sortBar = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('sort-filter-bar');
|
|
736
|
+
expect(sortBar).to.exist;
|
|
737
|
+
expect(sortBar.defaultSortField).to.equal(SortField.title);
|
|
738
|
+
expect(sortBar.defaultSortDirection).to.equal('asc');
|
|
739
|
+
expect(sortBar.selectedSort).to.equal(SortField.default);
|
|
740
|
+
expect(sortBar.sortDirection).to.be.null;
|
|
741
|
+
});
|
|
742
|
+
it('sets default sort from collection metadata in "-field" format', async () => {
|
|
743
|
+
var _a;
|
|
744
|
+
const searchService = new MockSearchService();
|
|
745
745
|
const el = await fixture(html `<collection-browser
|
|
746
746
|
.searchService=${searchService}
|
|
747
747
|
.baseNavigationUrl=${''}
|
|
748
|
-
></collection-browser>`);
|
|
749
|
-
el.withinCollection = 'default-sort-concise';
|
|
750
|
-
await el.updateComplete;
|
|
751
|
-
await el.initialSearchComplete;
|
|
752
|
-
await el.updateComplete;
|
|
753
|
-
await aTimeout(50);
|
|
754
|
-
const sortBar = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('sort-filter-bar');
|
|
755
|
-
expect(sortBar).to.exist;
|
|
756
|
-
expect(sortBar.defaultSortField).to.equal(SortField.dateadded);
|
|
757
|
-
expect(sortBar.defaultSortDirection).to.equal('desc');
|
|
758
|
-
expect(sortBar.selectedSort).to.equal(SortField.default);
|
|
759
|
-
expect(sortBar.sortDirection).to.be.null;
|
|
760
|
-
});
|
|
761
|
-
it('uses relevance sort as default when a query is set', async () => {
|
|
762
|
-
var _a;
|
|
763
|
-
const searchService = new MockSearchService();
|
|
748
|
+
></collection-browser>`);
|
|
749
|
+
el.withinCollection = 'default-sort-concise';
|
|
750
|
+
await el.updateComplete;
|
|
751
|
+
await el.initialSearchComplete;
|
|
752
|
+
await el.updateComplete;
|
|
753
|
+
await aTimeout(50);
|
|
754
|
+
const sortBar = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('sort-filter-bar');
|
|
755
|
+
expect(sortBar).to.exist;
|
|
756
|
+
expect(sortBar.defaultSortField).to.equal(SortField.dateadded);
|
|
757
|
+
expect(sortBar.defaultSortDirection).to.equal('desc');
|
|
758
|
+
expect(sortBar.selectedSort).to.equal(SortField.default);
|
|
759
|
+
expect(sortBar.sortDirection).to.be.null;
|
|
760
|
+
});
|
|
761
|
+
it('uses relevance sort as default when a query is set', async () => {
|
|
762
|
+
var _a;
|
|
763
|
+
const searchService = new MockSearchService();
|
|
764
764
|
const el = await fixture(html `<collection-browser
|
|
765
765
|
.searchService=${searchService}
|
|
766
766
|
.baseNavigationUrl=${''}
|
|
767
|
-
></collection-browser>`);
|
|
768
|
-
el.withinCollection = 'default-sort';
|
|
769
|
-
el.baseQuery = 'default-sort';
|
|
770
|
-
await el.updateComplete;
|
|
771
|
-
await el.initialSearchComplete;
|
|
772
|
-
await el.updateComplete;
|
|
773
|
-
await aTimeout(50);
|
|
774
|
-
const sortBar = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('sort-filter-bar');
|
|
775
|
-
expect(sortBar).to.exist;
|
|
776
|
-
expect(sortBar.defaultSortField).to.equal(SortField.relevance);
|
|
777
|
-
expect(sortBar.defaultSortDirection).to.be.null;
|
|
778
|
-
expect(sortBar.selectedSort).to.equal(SortField.default);
|
|
779
|
-
expect(sortBar.sortDirection).to.be.null;
|
|
780
|
-
});
|
|
781
|
-
it('uses date favorited sort as default when targeting fav- collection', async () => {
|
|
782
|
-
var _a;
|
|
783
|
-
const searchService = new MockSearchService();
|
|
767
|
+
></collection-browser>`);
|
|
768
|
+
el.withinCollection = 'default-sort';
|
|
769
|
+
el.baseQuery = 'default-sort';
|
|
770
|
+
await el.updateComplete;
|
|
771
|
+
await el.initialSearchComplete;
|
|
772
|
+
await el.updateComplete;
|
|
773
|
+
await aTimeout(50);
|
|
774
|
+
const sortBar = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('sort-filter-bar');
|
|
775
|
+
expect(sortBar).to.exist;
|
|
776
|
+
expect(sortBar.defaultSortField).to.equal(SortField.relevance);
|
|
777
|
+
expect(sortBar.defaultSortDirection).to.be.null;
|
|
778
|
+
expect(sortBar.selectedSort).to.equal(SortField.default);
|
|
779
|
+
expect(sortBar.sortDirection).to.be.null;
|
|
780
|
+
});
|
|
781
|
+
it('uses date favorited sort as default when targeting fav- collection', async () => {
|
|
782
|
+
var _a;
|
|
783
|
+
const searchService = new MockSearchService();
|
|
784
784
|
const el = await fixture(html `<collection-browser
|
|
785
785
|
.searchService=${searchService}
|
|
786
786
|
.baseNavigationUrl=${''}
|
|
787
|
-
></collection-browser>`);
|
|
788
|
-
el.withinCollection = 'fav-sort';
|
|
789
|
-
await el.updateComplete;
|
|
790
|
-
await el.initialSearchComplete;
|
|
791
|
-
await el.updateComplete;
|
|
792
|
-
await aTimeout(50);
|
|
793
|
-
const sortBar = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('sort-filter-bar');
|
|
794
|
-
expect(sortBar).to.exist;
|
|
795
|
-
expect(sortBar.defaultSortField).to.equal(SortField.datefavorited);
|
|
796
|
-
expect(sortBar.defaultSortDirection).to.equal('desc');
|
|
797
|
-
expect(sortBar.selectedSort).to.equal(SortField.default);
|
|
798
|
-
expect(sortBar.sortDirection).to.be.null;
|
|
799
|
-
});
|
|
800
|
-
it('scrolls to page', async () => {
|
|
801
|
-
var _a;
|
|
802
|
-
const searchService = new MockSearchService();
|
|
787
|
+
></collection-browser>`);
|
|
788
|
+
el.withinCollection = 'fav-sort';
|
|
789
|
+
await el.updateComplete;
|
|
790
|
+
await el.initialSearchComplete;
|
|
791
|
+
await el.updateComplete;
|
|
792
|
+
await aTimeout(50);
|
|
793
|
+
const sortBar = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('sort-filter-bar');
|
|
794
|
+
expect(sortBar).to.exist;
|
|
795
|
+
expect(sortBar.defaultSortField).to.equal(SortField.datefavorited);
|
|
796
|
+
expect(sortBar.defaultSortDirection).to.equal('desc');
|
|
797
|
+
expect(sortBar.selectedSort).to.equal(SortField.default);
|
|
798
|
+
expect(sortBar.sortDirection).to.be.null;
|
|
799
|
+
});
|
|
800
|
+
it('scrolls to page', async () => {
|
|
801
|
+
var _a;
|
|
802
|
+
const searchService = new MockSearchService();
|
|
803
803
|
const el = await fixture(html `<collection-browser .searchService=${searchService}>
|
|
804
|
-
</collection-browser>`);
|
|
805
|
-
// Infinite scroller won't exist unless there's a base query.
|
|
806
|
-
// First ensure that we don't throw errors when it doesn't exist.
|
|
807
|
-
await el.goToPage(1);
|
|
808
|
-
// And make sure it correctly calls scrollToCell when the
|
|
809
|
-
// infinite scroller does exist.
|
|
810
|
-
el.baseQuery = 'collection:foo';
|
|
811
|
-
await el.updateComplete;
|
|
812
|
-
const infiniteScroller = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('infinite-scroller');
|
|
813
|
-
expect(infiniteScroller).to.exist;
|
|
814
|
-
const oldScrollToCell = infiniteScroller.scrollToCell;
|
|
815
|
-
const spy = sinon.spy();
|
|
816
|
-
infiniteScroller.scrollToCell = spy;
|
|
817
|
-
await el.goToPage(1);
|
|
818
|
-
expect(spy.callCount).to.equal(1);
|
|
819
|
-
infiniteScroller.scrollToCell = oldScrollToCell;
|
|
820
|
-
});
|
|
821
|
-
it('shows mobile facets in mobile view', async () => {
|
|
822
|
-
var _a, _b;
|
|
823
|
-
const searchService = new MockSearchService();
|
|
804
|
+
</collection-browser>`);
|
|
805
|
+
// Infinite scroller won't exist unless there's a base query.
|
|
806
|
+
// First ensure that we don't throw errors when it doesn't exist.
|
|
807
|
+
await el.goToPage(1);
|
|
808
|
+
// And make sure it correctly calls scrollToCell when the
|
|
809
|
+
// infinite scroller does exist.
|
|
810
|
+
el.baseQuery = 'collection:foo';
|
|
811
|
+
await el.updateComplete;
|
|
812
|
+
const infiniteScroller = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('infinite-scroller');
|
|
813
|
+
expect(infiniteScroller).to.exist;
|
|
814
|
+
const oldScrollToCell = infiniteScroller.scrollToCell;
|
|
815
|
+
const spy = sinon.spy();
|
|
816
|
+
infiniteScroller.scrollToCell = spy;
|
|
817
|
+
await el.goToPage(1);
|
|
818
|
+
expect(spy.callCount).to.equal(1);
|
|
819
|
+
infiniteScroller.scrollToCell = oldScrollToCell;
|
|
820
|
+
});
|
|
821
|
+
it('shows mobile facets in mobile view', async () => {
|
|
822
|
+
var _a, _b;
|
|
823
|
+
const searchService = new MockSearchService();
|
|
824
824
|
const el = await fixture(html `<collection-browser
|
|
825
825
|
.searchService=${searchService}
|
|
826
826
|
.mobileBreakpoint=${9999}
|
|
827
|
-
></collection-browser>`);
|
|
828
|
-
el.baseQuery = 'collection:foo';
|
|
829
|
-
await el.updateComplete;
|
|
830
|
-
const contentContainer = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('#content-container');
|
|
831
|
-
el.handleResize({
|
|
832
|
-
target: contentContainer,
|
|
833
|
-
contentRect: contentContainer.getBoundingClientRect(),
|
|
834
|
-
borderBoxSize: [],
|
|
835
|
-
contentBoxSize: [],
|
|
836
|
-
devicePixelContentBoxSize: [],
|
|
837
|
-
});
|
|
838
|
-
await el.updateComplete;
|
|
839
|
-
const mobileFacets = (_b = el.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('#mobile-filter-collapse');
|
|
840
|
-
expect(mobileFacets).to.exist;
|
|
841
|
-
});
|
|
842
|
-
it('sets parent collections to prop when searching a collection', async () => {
|
|
843
|
-
const searchService = new MockSearchService();
|
|
827
|
+
></collection-browser>`);
|
|
828
|
+
el.baseQuery = 'collection:foo';
|
|
829
|
+
await el.updateComplete;
|
|
830
|
+
const contentContainer = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('#content-container');
|
|
831
|
+
el.handleResize({
|
|
832
|
+
target: contentContainer,
|
|
833
|
+
contentRect: contentContainer.getBoundingClientRect(),
|
|
834
|
+
borderBoxSize: [],
|
|
835
|
+
contentBoxSize: [],
|
|
836
|
+
devicePixelContentBoxSize: [],
|
|
837
|
+
});
|
|
838
|
+
await el.updateComplete;
|
|
839
|
+
const mobileFacets = (_b = el.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('#mobile-filter-collapse');
|
|
840
|
+
expect(mobileFacets).to.exist;
|
|
841
|
+
});
|
|
842
|
+
it('sets parent collections to prop when searching a collection', async () => {
|
|
843
|
+
const searchService = new MockSearchService();
|
|
844
844
|
const el = await fixture(html `<collection-browser
|
|
845
845
|
.searchService=${searchService}
|
|
846
846
|
.withinCollection=${'fake'}
|
|
847
|
-
></collection-browser>`);
|
|
848
|
-
el.baseQuery = 'parent-collections';
|
|
849
|
-
await el.updateComplete;
|
|
850
|
-
await el.initialSearchComplete;
|
|
851
|
-
await aTimeout(0);
|
|
852
|
-
expect(el.parentCollections).to.deep.equal(['foo', 'bar']);
|
|
853
|
-
});
|
|
854
|
-
it('refreshes when certain properties change - with some analytics event sampling', async () => {
|
|
855
|
-
var _a;
|
|
856
|
-
const mockAnalyticsHandler = new MockAnalyticsHandler();
|
|
857
|
-
const searchService = new MockSearchService();
|
|
858
|
-
const collectionNameCache = new MockCollectionNameCache();
|
|
847
|
+
></collection-browser>`);
|
|
848
|
+
el.baseQuery = 'parent-collections';
|
|
849
|
+
await el.updateComplete;
|
|
850
|
+
await el.initialSearchComplete;
|
|
851
|
+
await aTimeout(0);
|
|
852
|
+
expect(el.parentCollections).to.deep.equal(['foo', 'bar']);
|
|
853
|
+
});
|
|
854
|
+
it('refreshes when certain properties change - with some analytics event sampling', async () => {
|
|
855
|
+
var _a;
|
|
856
|
+
const mockAnalyticsHandler = new MockAnalyticsHandler();
|
|
857
|
+
const searchService = new MockSearchService();
|
|
858
|
+
const collectionNameCache = new MockCollectionNameCache();
|
|
859
859
|
const el = await fixture(html `<collection-browser
|
|
860
860
|
.analyticsHandler=${mockAnalyticsHandler}
|
|
861
861
|
.searchService=${searchService}
|
|
862
862
|
.collectionNameCache=${collectionNameCache}
|
|
863
|
-
></collection-browser>`);
|
|
864
|
-
const infiniteScrollerRefreshSpy = sinon.spy();
|
|
865
|
-
// Infinite scroller won't exist unless there's a base query
|
|
866
|
-
el.baseQuery = 'collection:foo';
|
|
867
|
-
await el.updateComplete;
|
|
868
|
-
const infiniteScroller = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('infinite-scroller');
|
|
869
|
-
infiniteScroller.reload = infiniteScrollerRefreshSpy;
|
|
870
|
-
expect(infiniteScrollerRefreshSpy.called).to.be.false;
|
|
871
|
-
expect(infiniteScrollerRefreshSpy.callCount).to.equal(0);
|
|
872
|
-
// testing: `loggedIn`
|
|
873
|
-
el.loggedIn = true;
|
|
874
|
-
await el.updateComplete;
|
|
875
|
-
expect(infiniteScrollerRefreshSpy.called).to.be.true;
|
|
876
|
-
expect(infiniteScrollerRefreshSpy.callCount).to.equal(1);
|
|
877
|
-
el.loggedIn = false;
|
|
878
|
-
await el.updateComplete;
|
|
879
|
-
expect(infiniteScrollerRefreshSpy.callCount).to.equal(2);
|
|
880
|
-
// testing: `displayMode`
|
|
881
|
-
el.displayMode = 'list-compact';
|
|
882
|
-
el.searchContext = 'beta-search';
|
|
883
|
-
await el.updateComplete;
|
|
884
|
-
expect(infiniteScrollerRefreshSpy.callCount).to.equal(3);
|
|
885
|
-
expect(mockAnalyticsHandler.callCategory).to.equal('beta-search');
|
|
886
|
-
expect(mockAnalyticsHandler.callAction).to.equal('displayMode');
|
|
887
|
-
expect(mockAnalyticsHandler.callLabel).to.equal('list-compact');
|
|
888
|
-
el.displayMode = 'list-detail';
|
|
889
|
-
await el.updateComplete;
|
|
890
|
-
expect(infiniteScrollerRefreshSpy.callCount).to.equal(4);
|
|
891
|
-
expect(mockAnalyticsHandler.callCategory).to.equal('beta-search');
|
|
892
|
-
expect(mockAnalyticsHandler.callAction).to.equal('displayMode');
|
|
893
|
-
expect(mockAnalyticsHandler.callLabel).to.equal('list-detail');
|
|
894
|
-
// testing: `baseNavigationUrl`
|
|
895
|
-
el.baseNavigationUrl = 'https://funtestsite.com';
|
|
896
|
-
await el.updateComplete;
|
|
897
|
-
expect(infiniteScrollerRefreshSpy.callCount).to.equal(5);
|
|
898
|
-
// testing: `baseImageUrl`
|
|
899
|
-
el.baseImageUrl = 'https://funtestsiteforimages.com';
|
|
900
|
-
await el.updateComplete;
|
|
901
|
-
expect(infiniteScrollerRefreshSpy.callCount).to.equal(6);
|
|
902
|
-
});
|
|
903
|
-
it('query the search service for single result', async () => {
|
|
904
|
-
var _a, _b;
|
|
905
|
-
const searchService = new MockSearchService();
|
|
863
|
+
></collection-browser>`);
|
|
864
|
+
const infiniteScrollerRefreshSpy = sinon.spy();
|
|
865
|
+
// Infinite scroller won't exist unless there's a base query
|
|
866
|
+
el.baseQuery = 'collection:foo';
|
|
867
|
+
await el.updateComplete;
|
|
868
|
+
const infiniteScroller = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('infinite-scroller');
|
|
869
|
+
infiniteScroller.reload = infiniteScrollerRefreshSpy;
|
|
870
|
+
expect(infiniteScrollerRefreshSpy.called).to.be.false;
|
|
871
|
+
expect(infiniteScrollerRefreshSpy.callCount).to.equal(0);
|
|
872
|
+
// testing: `loggedIn`
|
|
873
|
+
el.loggedIn = true;
|
|
874
|
+
await el.updateComplete;
|
|
875
|
+
expect(infiniteScrollerRefreshSpy.called).to.be.true;
|
|
876
|
+
expect(infiniteScrollerRefreshSpy.callCount).to.equal(1);
|
|
877
|
+
el.loggedIn = false;
|
|
878
|
+
await el.updateComplete;
|
|
879
|
+
expect(infiniteScrollerRefreshSpy.callCount).to.equal(2);
|
|
880
|
+
// testing: `displayMode`
|
|
881
|
+
el.displayMode = 'list-compact';
|
|
882
|
+
el.searchContext = 'beta-search';
|
|
883
|
+
await el.updateComplete;
|
|
884
|
+
expect(infiniteScrollerRefreshSpy.callCount).to.equal(3);
|
|
885
|
+
expect(mockAnalyticsHandler.callCategory).to.equal('beta-search');
|
|
886
|
+
expect(mockAnalyticsHandler.callAction).to.equal('displayMode');
|
|
887
|
+
expect(mockAnalyticsHandler.callLabel).to.equal('list-compact');
|
|
888
|
+
el.displayMode = 'list-detail';
|
|
889
|
+
await el.updateComplete;
|
|
890
|
+
expect(infiniteScrollerRefreshSpy.callCount).to.equal(4);
|
|
891
|
+
expect(mockAnalyticsHandler.callCategory).to.equal('beta-search');
|
|
892
|
+
expect(mockAnalyticsHandler.callAction).to.equal('displayMode');
|
|
893
|
+
expect(mockAnalyticsHandler.callLabel).to.equal('list-detail');
|
|
894
|
+
// testing: `baseNavigationUrl`
|
|
895
|
+
el.baseNavigationUrl = 'https://funtestsite.com';
|
|
896
|
+
await el.updateComplete;
|
|
897
|
+
expect(infiniteScrollerRefreshSpy.callCount).to.equal(5);
|
|
898
|
+
// testing: `baseImageUrl`
|
|
899
|
+
el.baseImageUrl = 'https://funtestsiteforimages.com';
|
|
900
|
+
await el.updateComplete;
|
|
901
|
+
expect(infiniteScrollerRefreshSpy.callCount).to.equal(6);
|
|
902
|
+
});
|
|
903
|
+
it('query the search service for single result', async () => {
|
|
904
|
+
var _a, _b;
|
|
905
|
+
const searchService = new MockSearchService();
|
|
906
906
|
const el = await fixture(html `<collection-browser .searchService=${searchService}>
|
|
907
|
-
</collection-browser>`);
|
|
908
|
-
el.baseQuery = 'single-result';
|
|
909
|
-
await el.updateComplete;
|
|
910
|
-
await el.initialSearchComplete;
|
|
911
|
-
expect((_b = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('#big-results-label')) === null || _b === void 0 ? void 0 : _b.textContent).to.contains('Result');
|
|
912
|
-
});
|
|
913
|
-
it('`searchContext` prop helps describe where component is being used', async () => {
|
|
914
|
-
const el = await fixture(html `<collection-browser></collection-browser>`);
|
|
915
|
-
expect(el.searchContext).to.equal(analyticsCategories.default);
|
|
916
|
-
el.searchContext = 'unicorn-search';
|
|
917
|
-
await el.updateComplete;
|
|
918
|
-
expect(el.searchContext).to.equal('unicorn-search');
|
|
919
|
-
// property is reflected as attribute
|
|
920
|
-
expect(el.getAttribute('searchcontext')).to.equal('unicorn-search');
|
|
921
|
-
});
|
|
922
|
-
it('respects the initial set of URL parameters for a general search', async () => {
|
|
923
|
-
var _a, _b, _c, _d, _e, _f;
|
|
924
|
-
const url = new URL(window.location.href);
|
|
925
|
-
const { searchParams } = url;
|
|
926
|
-
searchParams.set('query', 'foo');
|
|
927
|
-
searchParams.set('sin', 'TXT');
|
|
928
|
-
searchParams.set('sort', 'title');
|
|
929
|
-
searchParams.append('not[]', 'mediatype:"data"');
|
|
930
|
-
searchParams.append('and[]', 'subject:"baz"');
|
|
931
|
-
searchParams.append('and[]', 'firstTitle:X');
|
|
932
|
-
searchParams.append('and[]', 'year:[2000 TO 2010]');
|
|
933
|
-
window.history.replaceState({}, '', url);
|
|
934
|
-
const searchService = new MockSearchService();
|
|
907
|
+
</collection-browser>`);
|
|
908
|
+
el.baseQuery = 'single-result';
|
|
909
|
+
await el.updateComplete;
|
|
910
|
+
await el.initialSearchComplete;
|
|
911
|
+
expect((_b = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('#big-results-label')) === null || _b === void 0 ? void 0 : _b.textContent).to.contains('Result');
|
|
912
|
+
});
|
|
913
|
+
it('`searchContext` prop helps describe where component is being used', async () => {
|
|
914
|
+
const el = await fixture(html `<collection-browser></collection-browser>`);
|
|
915
|
+
expect(el.searchContext).to.equal(analyticsCategories.default);
|
|
916
|
+
el.searchContext = 'unicorn-search';
|
|
917
|
+
await el.updateComplete;
|
|
918
|
+
expect(el.searchContext).to.equal('unicorn-search');
|
|
919
|
+
// property is reflected as attribute
|
|
920
|
+
expect(el.getAttribute('searchcontext')).to.equal('unicorn-search');
|
|
921
|
+
});
|
|
922
|
+
it('respects the initial set of URL parameters for a general search', async () => {
|
|
923
|
+
var _a, _b, _c, _d, _e, _f;
|
|
924
|
+
const url = new URL(window.location.href);
|
|
925
|
+
const { searchParams } = url;
|
|
926
|
+
searchParams.set('query', 'foo');
|
|
927
|
+
searchParams.set('sin', 'TXT');
|
|
928
|
+
searchParams.set('sort', 'title');
|
|
929
|
+
searchParams.append('not[]', 'mediatype:"data"');
|
|
930
|
+
searchParams.append('and[]', 'subject:"baz"');
|
|
931
|
+
searchParams.append('and[]', 'firstTitle:X');
|
|
932
|
+
searchParams.append('and[]', 'year:[2000 TO 2010]');
|
|
933
|
+
window.history.replaceState({}, '', url);
|
|
934
|
+
const searchService = new MockSearchService();
|
|
935
935
|
const el = await fixture(html `<collection-browser .searchService=${searchService}>
|
|
936
|
-
</collection-browser>`);
|
|
937
|
-
await el.initialSearchComplete;
|
|
938
|
-
await el.updateComplete;
|
|
939
|
-
expect(el.baseQuery).to.equal('foo');
|
|
940
|
-
expect(el.searchType).to.equal(SearchType.FULLTEXT);
|
|
941
|
-
expect(el.selectedSort).to.equal(SortField.title);
|
|
942
|
-
expect((_c = (_b = (_a = el.selectedFacets) === null || _a === void 0 ? void 0 : _a.mediatype) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.state).to.equal('hidden');
|
|
943
|
-
expect((_f = (_e = (_d = el.selectedFacets) === null || _d === void 0 ? void 0 : _d.subject) === null || _e === void 0 ? void 0 : _e.baz) === null || _f === void 0 ? void 0 : _f.state).to.equal('selected');
|
|
944
|
-
expect(el.selectedTitleFilter).to.equal('X');
|
|
945
|
-
expect(el.minSelectedDate).to.equal('2000');
|
|
946
|
-
expect(el.maxSelectedDate).to.equal('2010');
|
|
947
|
-
});
|
|
948
|
-
it('respects the initial set of URL parameters within a collection', async () => {
|
|
949
|
-
var _a, _b, _c, _d, _e, _f;
|
|
950
|
-
const url = new URL(window.location.href);
|
|
951
|
-
const { searchParams } = url;
|
|
952
|
-
searchParams.set('query', 'foo');
|
|
953
|
-
searchParams.set('sin', 'TXT');
|
|
954
|
-
searchParams.set('sort', 'title');
|
|
955
|
-
searchParams.append('not[]', 'mediatype:"data"');
|
|
956
|
-
searchParams.append('and[]', 'subject:"baz"');
|
|
957
|
-
searchParams.append('and[]', 'firstTitle:X');
|
|
958
|
-
searchParams.append('and[]', 'year:[2000 TO 2010]');
|
|
959
|
-
window.history.replaceState({}, '', url);
|
|
960
|
-
const searchService = new MockSearchService();
|
|
936
|
+
</collection-browser>`);
|
|
937
|
+
await el.initialSearchComplete;
|
|
938
|
+
await el.updateComplete;
|
|
939
|
+
expect(el.baseQuery).to.equal('foo');
|
|
940
|
+
expect(el.searchType).to.equal(SearchType.FULLTEXT);
|
|
941
|
+
expect(el.selectedSort).to.equal(SortField.title);
|
|
942
|
+
expect((_c = (_b = (_a = el.selectedFacets) === null || _a === void 0 ? void 0 : _a.mediatype) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.state).to.equal('hidden');
|
|
943
|
+
expect((_f = (_e = (_d = el.selectedFacets) === null || _d === void 0 ? void 0 : _d.subject) === null || _e === void 0 ? void 0 : _e.baz) === null || _f === void 0 ? void 0 : _f.state).to.equal('selected');
|
|
944
|
+
expect(el.selectedTitleFilter).to.equal('X');
|
|
945
|
+
expect(el.minSelectedDate).to.equal('2000');
|
|
946
|
+
expect(el.maxSelectedDate).to.equal('2010');
|
|
947
|
+
});
|
|
948
|
+
it('respects the initial set of URL parameters within a collection', async () => {
|
|
949
|
+
var _a, _b, _c, _d, _e, _f;
|
|
950
|
+
const url = new URL(window.location.href);
|
|
951
|
+
const { searchParams } = url;
|
|
952
|
+
searchParams.set('query', 'foo');
|
|
953
|
+
searchParams.set('sin', 'TXT');
|
|
954
|
+
searchParams.set('sort', 'title');
|
|
955
|
+
searchParams.append('not[]', 'mediatype:"data"');
|
|
956
|
+
searchParams.append('and[]', 'subject:"baz"');
|
|
957
|
+
searchParams.append('and[]', 'firstTitle:X');
|
|
958
|
+
searchParams.append('and[]', 'year:[2000 TO 2010]');
|
|
959
|
+
window.history.replaceState({}, '', url);
|
|
960
|
+
const searchService = new MockSearchService();
|
|
961
961
|
const el = await fixture(html `<collection-browser
|
|
962
962
|
.searchService=${searchService}
|
|
963
963
|
.withinCollection=${'foobar'}
|
|
964
964
|
>
|
|
965
|
-
</collection-browser>`);
|
|
966
|
-
await el.initialSearchComplete;
|
|
967
|
-
await el.updateComplete;
|
|
968
|
-
expect(el.withinCollection).to.equal('foobar');
|
|
969
|
-
expect(el.baseQuery).to.equal('foo');
|
|
970
|
-
expect(el.searchType).to.equal(SearchType.FULLTEXT);
|
|
971
|
-
expect(el.selectedSort).to.equal(SortField.title);
|
|
972
|
-
expect((_c = (_b = (_a = el.selectedFacets) === null || _a === void 0 ? void 0 : _a.mediatype) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.state).to.equal('hidden');
|
|
973
|
-
expect((_f = (_e = (_d = el.selectedFacets) === null || _d === void 0 ? void 0 : _d.subject) === null || _e === void 0 ? void 0 : _e.baz) === null || _f === void 0 ? void 0 : _f.state).to.equal('selected');
|
|
974
|
-
expect(el.selectedTitleFilter).to.equal('X');
|
|
975
|
-
expect(el.minSelectedDate).to.equal('2000');
|
|
976
|
-
expect(el.maxSelectedDate).to.equal('2010');
|
|
977
|
-
});
|
|
978
|
-
it('clears filters except sort when query changes for a general search', async () => {
|
|
979
|
-
var _a, _b, _c, _d;
|
|
980
|
-
const url = new URL(window.location.href);
|
|
981
|
-
const { searchParams } = url;
|
|
982
|
-
searchParams.set('query', 'foo');
|
|
983
|
-
searchParams.set('sin', 'TXT');
|
|
984
|
-
searchParams.set('sort', 'title');
|
|
985
|
-
searchParams.append('not[]', 'mediatype:"data"');
|
|
986
|
-
searchParams.append('and[]', 'subject:"baz"');
|
|
987
|
-
searchParams.append('and[]', 'firstTitle:X');
|
|
988
|
-
searchParams.append('and[]', 'year:[2000 TO 2010]');
|
|
989
|
-
window.history.replaceState({}, '', url);
|
|
990
|
-
const searchService = new MockSearchService();
|
|
965
|
+
</collection-browser>`);
|
|
966
|
+
await el.initialSearchComplete;
|
|
967
|
+
await el.updateComplete;
|
|
968
|
+
expect(el.withinCollection).to.equal('foobar');
|
|
969
|
+
expect(el.baseQuery).to.equal('foo');
|
|
970
|
+
expect(el.searchType).to.equal(SearchType.FULLTEXT);
|
|
971
|
+
expect(el.selectedSort).to.equal(SortField.title);
|
|
972
|
+
expect((_c = (_b = (_a = el.selectedFacets) === null || _a === void 0 ? void 0 : _a.mediatype) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.state).to.equal('hidden');
|
|
973
|
+
expect((_f = (_e = (_d = el.selectedFacets) === null || _d === void 0 ? void 0 : _d.subject) === null || _e === void 0 ? void 0 : _e.baz) === null || _f === void 0 ? void 0 : _f.state).to.equal('selected');
|
|
974
|
+
expect(el.selectedTitleFilter).to.equal('X');
|
|
975
|
+
expect(el.minSelectedDate).to.equal('2000');
|
|
976
|
+
expect(el.maxSelectedDate).to.equal('2010');
|
|
977
|
+
});
|
|
978
|
+
it('clears filters except sort when query changes for a general search', async () => {
|
|
979
|
+
var _a, _b, _c, _d;
|
|
980
|
+
const url = new URL(window.location.href);
|
|
981
|
+
const { searchParams } = url;
|
|
982
|
+
searchParams.set('query', 'foo');
|
|
983
|
+
searchParams.set('sin', 'TXT');
|
|
984
|
+
searchParams.set('sort', 'title');
|
|
985
|
+
searchParams.append('not[]', 'mediatype:"data"');
|
|
986
|
+
searchParams.append('and[]', 'subject:"baz"');
|
|
987
|
+
searchParams.append('and[]', 'firstTitle:X');
|
|
988
|
+
searchParams.append('and[]', 'year:[2000 TO 2010]');
|
|
989
|
+
window.history.replaceState({}, '', url);
|
|
990
|
+
const searchService = new MockSearchService();
|
|
991
991
|
const el = await fixture(html `<collection-browser .searchService=${searchService}>
|
|
992
|
-
</collection-browser>`);
|
|
993
|
-
await el.initialSearchComplete;
|
|
994
|
-
await el.updateComplete;
|
|
995
|
-
el.baseQuery = 'bar';
|
|
996
|
-
await el.updateComplete;
|
|
997
|
-
expect(el.baseQuery).to.equal('bar');
|
|
998
|
-
expect(el.searchType).to.equal(SearchType.FULLTEXT);
|
|
999
|
-
expect(el.selectedSort).to.equal(SortField.title);
|
|
1000
|
-
expect((_b = (_a = el.selectedFacets) === null || _a === void 0 ? void 0 : _a.mediatype) === null || _b === void 0 ? void 0 : _b.data).not.to.exist;
|
|
1001
|
-
expect((_d = (_c = el.selectedFacets) === null || _c === void 0 ? void 0 : _c.subject) === null || _d === void 0 ? void 0 : _d.baz).not.to.exist;
|
|
1002
|
-
expect(el.selectedTitleFilter).not.to.exist;
|
|
1003
|
-
expect(el.minSelectedDate).not.to.exist;
|
|
1004
|
-
expect(el.maxSelectedDate).not.to.exist;
|
|
1005
|
-
});
|
|
1006
|
-
it('clears filters except sort when query changes within a collection', async () => {
|
|
1007
|
-
var _a, _b, _c, _d;
|
|
1008
|
-
const url = new URL(window.location.href);
|
|
1009
|
-
const { searchParams } = url;
|
|
1010
|
-
searchParams.set('query', 'foo');
|
|
1011
|
-
searchParams.set('sin', 'TXT');
|
|
1012
|
-
searchParams.set('sort', 'title');
|
|
1013
|
-
searchParams.append('not[]', 'mediatype:"data"');
|
|
1014
|
-
searchParams.append('and[]', 'subject:"baz"');
|
|
1015
|
-
searchParams.append('and[]', 'firstTitle:X');
|
|
1016
|
-
searchParams.append('and[]', 'year:[2000 TO 2010]');
|
|
1017
|
-
window.history.replaceState({}, '', url);
|
|
1018
|
-
const searchService = new MockSearchService();
|
|
992
|
+
</collection-browser>`);
|
|
993
|
+
await el.initialSearchComplete;
|
|
994
|
+
await el.updateComplete;
|
|
995
|
+
el.baseQuery = 'bar';
|
|
996
|
+
await el.updateComplete;
|
|
997
|
+
expect(el.baseQuery).to.equal('bar');
|
|
998
|
+
expect(el.searchType).to.equal(SearchType.FULLTEXT);
|
|
999
|
+
expect(el.selectedSort).to.equal(SortField.title);
|
|
1000
|
+
expect((_b = (_a = el.selectedFacets) === null || _a === void 0 ? void 0 : _a.mediatype) === null || _b === void 0 ? void 0 : _b.data).not.to.exist;
|
|
1001
|
+
expect((_d = (_c = el.selectedFacets) === null || _c === void 0 ? void 0 : _c.subject) === null || _d === void 0 ? void 0 : _d.baz).not.to.exist;
|
|
1002
|
+
expect(el.selectedTitleFilter).not.to.exist;
|
|
1003
|
+
expect(el.minSelectedDate).not.to.exist;
|
|
1004
|
+
expect(el.maxSelectedDate).not.to.exist;
|
|
1005
|
+
});
|
|
1006
|
+
it('clears filters except sort when query changes within a collection', async () => {
|
|
1007
|
+
var _a, _b, _c, _d;
|
|
1008
|
+
const url = new URL(window.location.href);
|
|
1009
|
+
const { searchParams } = url;
|
|
1010
|
+
searchParams.set('query', 'foo');
|
|
1011
|
+
searchParams.set('sin', 'TXT');
|
|
1012
|
+
searchParams.set('sort', 'title');
|
|
1013
|
+
searchParams.append('not[]', 'mediatype:"data"');
|
|
1014
|
+
searchParams.append('and[]', 'subject:"baz"');
|
|
1015
|
+
searchParams.append('and[]', 'firstTitle:X');
|
|
1016
|
+
searchParams.append('and[]', 'year:[2000 TO 2010]');
|
|
1017
|
+
window.history.replaceState({}, '', url);
|
|
1018
|
+
const searchService = new MockSearchService();
|
|
1019
1019
|
const el = await fixture(html `<collection-browser
|
|
1020
1020
|
.searchService=${searchService}
|
|
1021
1021
|
.withinCollection=${'foobar'}
|
|
1022
1022
|
>
|
|
1023
|
-
</collection-browser>`);
|
|
1024
|
-
await el.initialSearchComplete;
|
|
1025
|
-
await el.updateComplete;
|
|
1026
|
-
el.baseQuery = 'bar';
|
|
1027
|
-
await el.updateComplete;
|
|
1028
|
-
expect(el.withinCollection).to.equal('foobar');
|
|
1029
|
-
expect(el.baseQuery).to.equal('bar');
|
|
1030
|
-
expect(el.searchType).to.equal(SearchType.FULLTEXT);
|
|
1031
|
-
expect(el.selectedSort).to.equal(SortField.title);
|
|
1032
|
-
expect((_b = (_a = el.selectedFacets) === null || _a === void 0 ? void 0 : _a.mediatype) === null || _b === void 0 ? void 0 : _b.data).not.to.exist;
|
|
1033
|
-
expect((_d = (_c = el.selectedFacets) === null || _c === void 0 ? void 0 : _c.subject) === null || _d === void 0 ? void 0 : _d.baz).not.to.exist;
|
|
1034
|
-
expect(el.selectedTitleFilter).not.to.exist;
|
|
1035
|
-
expect(el.minSelectedDate).not.to.exist;
|
|
1036
|
-
expect(el.maxSelectedDate).not.to.exist;
|
|
1037
|
-
});
|
|
1038
|
-
it('clears filters *including* sort when target collection changes', async () => {
|
|
1039
|
-
var _a, _b, _c, _d;
|
|
1040
|
-
const url = new URL(window.location.href);
|
|
1041
|
-
const { searchParams } = url;
|
|
1042
|
-
searchParams.set('query', 'foo');
|
|
1043
|
-
searchParams.set('sin', 'TXT');
|
|
1044
|
-
searchParams.set('sort', 'title');
|
|
1045
|
-
searchParams.append('not[]', 'mediatype:"data"');
|
|
1046
|
-
searchParams.append('and[]', 'subject:"baz"');
|
|
1047
|
-
searchParams.append('and[]', 'firstTitle:X');
|
|
1048
|
-
searchParams.append('and[]', 'year:[2000 TO 2010]');
|
|
1049
|
-
window.history.replaceState({}, '', url);
|
|
1050
|
-
const searchService = new MockSearchService();
|
|
1023
|
+
</collection-browser>`);
|
|
1024
|
+
await el.initialSearchComplete;
|
|
1025
|
+
await el.updateComplete;
|
|
1026
|
+
el.baseQuery = 'bar';
|
|
1027
|
+
await el.updateComplete;
|
|
1028
|
+
expect(el.withinCollection).to.equal('foobar');
|
|
1029
|
+
expect(el.baseQuery).to.equal('bar');
|
|
1030
|
+
expect(el.searchType).to.equal(SearchType.FULLTEXT);
|
|
1031
|
+
expect(el.selectedSort).to.equal(SortField.title);
|
|
1032
|
+
expect((_b = (_a = el.selectedFacets) === null || _a === void 0 ? void 0 : _a.mediatype) === null || _b === void 0 ? void 0 : _b.data).not.to.exist;
|
|
1033
|
+
expect((_d = (_c = el.selectedFacets) === null || _c === void 0 ? void 0 : _c.subject) === null || _d === void 0 ? void 0 : _d.baz).not.to.exist;
|
|
1034
|
+
expect(el.selectedTitleFilter).not.to.exist;
|
|
1035
|
+
expect(el.minSelectedDate).not.to.exist;
|
|
1036
|
+
expect(el.maxSelectedDate).not.to.exist;
|
|
1037
|
+
});
|
|
1038
|
+
it('clears filters *including* sort when target collection changes', async () => {
|
|
1039
|
+
var _a, _b, _c, _d;
|
|
1040
|
+
const url = new URL(window.location.href);
|
|
1041
|
+
const { searchParams } = url;
|
|
1042
|
+
searchParams.set('query', 'foo');
|
|
1043
|
+
searchParams.set('sin', 'TXT');
|
|
1044
|
+
searchParams.set('sort', 'title');
|
|
1045
|
+
searchParams.append('not[]', 'mediatype:"data"');
|
|
1046
|
+
searchParams.append('and[]', 'subject:"baz"');
|
|
1047
|
+
searchParams.append('and[]', 'firstTitle:X');
|
|
1048
|
+
searchParams.append('and[]', 'year:[2000 TO 2010]');
|
|
1049
|
+
window.history.replaceState({}, '', url);
|
|
1050
|
+
const searchService = new MockSearchService();
|
|
1051
1051
|
const el = await fixture(html `<collection-browser
|
|
1052
1052
|
.searchService=${searchService}
|
|
1053
1053
|
.withinCollection=${'foobar'}
|
|
1054
1054
|
>
|
|
1055
|
-
</collection-browser>`);
|
|
1056
|
-
await el.initialSearchComplete;
|
|
1057
|
-
await el.updateComplete;
|
|
1058
|
-
el.withinCollection = 'bar';
|
|
1059
|
-
await el.updateComplete;
|
|
1060
|
-
expect(el.withinCollection).to.equal('bar');
|
|
1061
|
-
expect(el.baseQuery).to.equal('foo');
|
|
1062
|
-
expect(el.searchType).to.equal(SearchType.FULLTEXT);
|
|
1063
|
-
expect(el.selectedSort).to.equal(SortField.default);
|
|
1064
|
-
expect((_b = (_a = el.selectedFacets) === null || _a === void 0 ? void 0 : _a.mediatype) === null || _b === void 0 ? void 0 : _b.data).not.to.exist;
|
|
1065
|
-
expect((_d = (_c = el.selectedFacets) === null || _c === void 0 ? void 0 : _c.subject) === null || _d === void 0 ? void 0 : _d.baz).not.to.exist;
|
|
1066
|
-
expect(el.selectedTitleFilter).not.to.exist;
|
|
1067
|
-
expect(el.minSelectedDate).not.to.exist;
|
|
1068
|
-
expect(el.maxSelectedDate).not.to.exist;
|
|
1069
|
-
});
|
|
1070
|
-
it('shows manage bar interface instead of sort bar when in manage view', async () => {
|
|
1071
|
-
var _a, _b, _c, _d;
|
|
1072
|
-
const searchService = new MockSearchService();
|
|
1055
|
+
</collection-browser>`);
|
|
1056
|
+
await el.initialSearchComplete;
|
|
1057
|
+
await el.updateComplete;
|
|
1058
|
+
el.withinCollection = 'bar';
|
|
1059
|
+
await el.updateComplete;
|
|
1060
|
+
expect(el.withinCollection).to.equal('bar');
|
|
1061
|
+
expect(el.baseQuery).to.equal('foo');
|
|
1062
|
+
expect(el.searchType).to.equal(SearchType.FULLTEXT);
|
|
1063
|
+
expect(el.selectedSort).to.equal(SortField.default);
|
|
1064
|
+
expect((_b = (_a = el.selectedFacets) === null || _a === void 0 ? void 0 : _a.mediatype) === null || _b === void 0 ? void 0 : _b.data).not.to.exist;
|
|
1065
|
+
expect((_d = (_c = el.selectedFacets) === null || _c === void 0 ? void 0 : _c.subject) === null || _d === void 0 ? void 0 : _d.baz).not.to.exist;
|
|
1066
|
+
expect(el.selectedTitleFilter).not.to.exist;
|
|
1067
|
+
expect(el.minSelectedDate).not.to.exist;
|
|
1068
|
+
expect(el.maxSelectedDate).not.to.exist;
|
|
1069
|
+
});
|
|
1070
|
+
it('shows manage bar interface instead of sort bar when in manage view', async () => {
|
|
1071
|
+
var _a, _b, _c, _d;
|
|
1072
|
+
const searchService = new MockSearchService();
|
|
1073
1073
|
const el = await fixture(html `<collection-browser .searchService=${searchService}>
|
|
1074
|
-
</collection-browser>`);
|
|
1075
|
-
el.baseQuery = 'foo';
|
|
1076
|
-
await el.updateComplete;
|
|
1077
|
-
await el.initialSearchComplete;
|
|
1078
|
-
el.isManageView = true;
|
|
1079
|
-
await el.updateComplete;
|
|
1080
|
-
expect((_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('manage-bar')).to.exist;
|
|
1081
|
-
expect((_b = el.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('sort-filter-bar')).not.to.exist;
|
|
1082
|
-
el.isManageView = false;
|
|
1083
|
-
await el.updateComplete;
|
|
1084
|
-
expect((_c = el.shadowRoot) === null || _c === void 0 ? void 0 : _c.querySelector('manage-bar')).not.to.exist;
|
|
1085
|
-
expect((_d = el.shadowRoot) === null || _d === void 0 ? void 0 : _d.querySelector('sort-filter-bar')).to.exist;
|
|
1086
|
-
});
|
|
1087
|
-
it('switches to grid display mode when manage view activated', async () => {
|
|
1088
|
-
const searchService = new MockSearchService();
|
|
1074
|
+
</collection-browser>`);
|
|
1075
|
+
el.baseQuery = 'foo';
|
|
1076
|
+
await el.updateComplete;
|
|
1077
|
+
await el.initialSearchComplete;
|
|
1078
|
+
el.isManageView = true;
|
|
1079
|
+
await el.updateComplete;
|
|
1080
|
+
expect((_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('manage-bar')).to.exist;
|
|
1081
|
+
expect((_b = el.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('sort-filter-bar')).not.to.exist;
|
|
1082
|
+
el.isManageView = false;
|
|
1083
|
+
await el.updateComplete;
|
|
1084
|
+
expect((_c = el.shadowRoot) === null || _c === void 0 ? void 0 : _c.querySelector('manage-bar')).not.to.exist;
|
|
1085
|
+
expect((_d = el.shadowRoot) === null || _d === void 0 ? void 0 : _d.querySelector('sort-filter-bar')).to.exist;
|
|
1086
|
+
});
|
|
1087
|
+
it('switches to grid display mode when manage view activated', async () => {
|
|
1088
|
+
const searchService = new MockSearchService();
|
|
1089
1089
|
const el = await fixture(html `<collection-browser
|
|
1090
1090
|
.searchService=${searchService}
|
|
1091
1091
|
.baseQuery=${'foo'}
|
|
1092
1092
|
.displayMode=${'list-detail'}
|
|
1093
1093
|
>
|
|
1094
|
-
</collection-browser>`);
|
|
1095
|
-
el.isManageView = true;
|
|
1096
|
-
await el.updateComplete;
|
|
1097
|
-
expect(el.displayMode).to.equal('grid');
|
|
1098
|
-
});
|
|
1099
|
-
it('can remove all checked tiles', async () => {
|
|
1100
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1101
|
-
const searchService = new MockSearchService();
|
|
1094
|
+
</collection-browser>`);
|
|
1095
|
+
el.isManageView = true;
|
|
1096
|
+
await el.updateComplete;
|
|
1097
|
+
expect(el.displayMode).to.equal('grid');
|
|
1098
|
+
});
|
|
1099
|
+
it('can remove all checked tiles', async () => {
|
|
1100
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1101
|
+
const searchService = new MockSearchService();
|
|
1102
1102
|
const el = await fixture(html `<collection-browser
|
|
1103
1103
|
.searchService=${searchService}
|
|
1104
1104
|
.baseNavigationUrl=${''}
|
|
1105
1105
|
>
|
|
1106
|
-
</collection-browser>`);
|
|
1107
|
-
el.baseQuery = 'foo';
|
|
1108
|
-
el.pageSize = 1; // To hit the edge case of a page break while offsetting tiles
|
|
1109
|
-
await el.updateComplete;
|
|
1110
|
-
await el.initialSearchComplete;
|
|
1111
|
-
el.isManageView = true;
|
|
1112
|
-
await el.updateComplete;
|
|
1113
|
-
const infiniteScroller = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('infinite-scroller');
|
|
1114
|
-
expect(infiniteScroller).to.exist;
|
|
1115
|
-
let tiles = (_b = infiniteScroller.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelectorAll('tile-dispatcher');
|
|
1116
|
-
expect(tiles).to.exist.and.have.length(2);
|
|
1117
|
-
const firstTile = tiles[0];
|
|
1118
|
-
const firstTileLink = (_c = firstTile.shadowRoot) === null || _c === void 0 ? void 0 : _c.querySelector('a[href]');
|
|
1119
|
-
expect((_d = firstTile.model) === null || _d === void 0 ? void 0 : _d.identifier).to.equal('foo');
|
|
1120
|
-
expect(firstTileLink).to.exist;
|
|
1121
|
-
// No effect if no tiles checked
|
|
1122
|
-
el.removeCheckedTiles();
|
|
1123
|
-
await el.updateComplete;
|
|
1124
|
-
tiles = (_e = infiniteScroller.shadowRoot) === null || _e === void 0 ? void 0 : _e.querySelectorAll('tile-dispatcher');
|
|
1125
|
-
expect(tiles).to.exist.and.have.length(2);
|
|
1126
|
-
// Check the first tile
|
|
1127
|
-
firstTileLink.click();
|
|
1128
|
-
expect((_f = firstTile.model) === null || _f === void 0 ? void 0 : _f.checked).to.be.true;
|
|
1129
|
-
// Remove checked tiles and verify that we only kept the second tile
|
|
1130
|
-
el.removeCheckedTiles();
|
|
1131
|
-
await el.updateComplete;
|
|
1132
|
-
tiles = (_g = infiniteScroller.shadowRoot) === null || _g === void 0 ? void 0 : _g.querySelectorAll('tile-dispatcher');
|
|
1133
|
-
expect(tiles).to.exist.and.have.length(1);
|
|
1134
|
-
expect((_h = tiles[0].model) === null || _h === void 0 ? void 0 : _h.identifier).to.equal('bar');
|
|
1135
|
-
});
|
|
1136
|
-
it('can check/uncheck all tiles', async () => {
|
|
1137
|
-
const searchService = new MockSearchService();
|
|
1106
|
+
</collection-browser>`);
|
|
1107
|
+
el.baseQuery = 'foo';
|
|
1108
|
+
el.pageSize = 1; // To hit the edge case of a page break while offsetting tiles
|
|
1109
|
+
await el.updateComplete;
|
|
1110
|
+
await el.initialSearchComplete;
|
|
1111
|
+
el.isManageView = true;
|
|
1112
|
+
await el.updateComplete;
|
|
1113
|
+
const infiniteScroller = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('infinite-scroller');
|
|
1114
|
+
expect(infiniteScroller).to.exist;
|
|
1115
|
+
let tiles = (_b = infiniteScroller.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelectorAll('tile-dispatcher');
|
|
1116
|
+
expect(tiles).to.exist.and.have.length(2);
|
|
1117
|
+
const firstTile = tiles[0];
|
|
1118
|
+
const firstTileLink = (_c = firstTile.shadowRoot) === null || _c === void 0 ? void 0 : _c.querySelector('a[href]');
|
|
1119
|
+
expect((_d = firstTile.model) === null || _d === void 0 ? void 0 : _d.identifier).to.equal('foo');
|
|
1120
|
+
expect(firstTileLink).to.exist;
|
|
1121
|
+
// No effect if no tiles checked
|
|
1122
|
+
el.removeCheckedTiles();
|
|
1123
|
+
await el.updateComplete;
|
|
1124
|
+
tiles = (_e = infiniteScroller.shadowRoot) === null || _e === void 0 ? void 0 : _e.querySelectorAll('tile-dispatcher');
|
|
1125
|
+
expect(tiles).to.exist.and.have.length(2);
|
|
1126
|
+
// Check the first tile
|
|
1127
|
+
firstTileLink.click();
|
|
1128
|
+
expect((_f = firstTile.model) === null || _f === void 0 ? void 0 : _f.checked).to.be.true;
|
|
1129
|
+
// Remove checked tiles and verify that we only kept the second tile
|
|
1130
|
+
el.removeCheckedTiles();
|
|
1131
|
+
await el.updateComplete;
|
|
1132
|
+
tiles = (_g = infiniteScroller.shadowRoot) === null || _g === void 0 ? void 0 : _g.querySelectorAll('tile-dispatcher');
|
|
1133
|
+
expect(tiles).to.exist.and.have.length(1);
|
|
1134
|
+
expect((_h = tiles[0].model) === null || _h === void 0 ? void 0 : _h.identifier).to.equal('bar');
|
|
1135
|
+
});
|
|
1136
|
+
it('can check/uncheck all tiles', async () => {
|
|
1137
|
+
const searchService = new MockSearchService();
|
|
1138
1138
|
const el = await fixture(html `<collection-browser
|
|
1139
1139
|
.searchService=${searchService}
|
|
1140
1140
|
.baseNavigationUrl=${''}
|
|
1141
1141
|
>
|
|
1142
|
-
</collection-browser>`);
|
|
1143
|
-
el.baseQuery = 'foo';
|
|
1144
|
-
await el.updateComplete;
|
|
1145
|
-
await el.initialSearchComplete;
|
|
1146
|
-
el.isManageView = true;
|
|
1147
|
-
await el.updateComplete;
|
|
1148
|
-
expect(el.checkedTileModels.length).to.equal(0);
|
|
1149
|
-
expect(el.uncheckedTileModels.length).to.equal(2);
|
|
1150
|
-
el.checkAllTiles();
|
|
1151
|
-
expect(el.checkedTileModels.length).to.equal(2);
|
|
1152
|
-
expect(el.uncheckedTileModels.length).to.equal(0);
|
|
1153
|
-
el.uncheckAllTiles();
|
|
1154
|
-
expect(el.checkedTileModels.length).to.equal(0);
|
|
1155
|
-
expect(el.uncheckedTileModels.length).to.equal(2);
|
|
1156
|
-
});
|
|
1157
|
-
it('emits event when item removal requested', async () => {
|
|
1158
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
1159
|
-
const spy = sinon.spy();
|
|
1160
|
-
const searchService = new MockSearchService();
|
|
1142
|
+
</collection-browser>`);
|
|
1143
|
+
el.baseQuery = 'foo';
|
|
1144
|
+
await el.updateComplete;
|
|
1145
|
+
await el.initialSearchComplete;
|
|
1146
|
+
el.isManageView = true;
|
|
1147
|
+
await el.updateComplete;
|
|
1148
|
+
expect(el.checkedTileModels.length).to.equal(0);
|
|
1149
|
+
expect(el.uncheckedTileModels.length).to.equal(2);
|
|
1150
|
+
el.checkAllTiles();
|
|
1151
|
+
expect(el.checkedTileModels.length).to.equal(2);
|
|
1152
|
+
expect(el.uncheckedTileModels.length).to.equal(0);
|
|
1153
|
+
el.uncheckAllTiles();
|
|
1154
|
+
expect(el.checkedTileModels.length).to.equal(0);
|
|
1155
|
+
expect(el.uncheckedTileModels.length).to.equal(2);
|
|
1156
|
+
});
|
|
1157
|
+
it('emits event when item removal requested', async () => {
|
|
1158
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
1159
|
+
const spy = sinon.spy();
|
|
1160
|
+
const searchService = new MockSearchService();
|
|
1161
1161
|
const el = await fixture(html `<collection-browser
|
|
1162
1162
|
.searchService=${searchService}
|
|
1163
1163
|
.baseNavigationUrl=${''}
|
|
1164
1164
|
@itemRemovalRequested=${spy}
|
|
1165
1165
|
>
|
|
1166
|
-
</collection-browser>`);
|
|
1167
|
-
el.baseQuery = 'foo';
|
|
1168
|
-
await el.updateComplete;
|
|
1169
|
-
await el.initialSearchComplete;
|
|
1170
|
-
el.isManageView = true;
|
|
1171
|
-
await el.updateComplete;
|
|
1172
|
-
const infiniteScroller = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('infinite-scroller');
|
|
1173
|
-
expect(infiniteScroller).to.exist;
|
|
1174
|
-
const tiles = (_b = infiniteScroller.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelectorAll('tile-dispatcher');
|
|
1175
|
-
expect(tiles).to.exist.and.have.length(2);
|
|
1176
|
-
const firstTile = tiles[0];
|
|
1177
|
-
const firstTileLink = (_c = firstTile.shadowRoot) === null || _c === void 0 ? void 0 : _c.querySelector('a[href]');
|
|
1178
|
-
expect((_d = firstTile.model) === null || _d === void 0 ? void 0 : _d.identifier).to.equal('foo');
|
|
1179
|
-
expect(firstTileLink).to.exist;
|
|
1180
|
-
// Check the first tile
|
|
1181
|
-
firstTileLink.click();
|
|
1182
|
-
await el.updateComplete;
|
|
1183
|
-
const manageBar = (_e = el.shadowRoot) === null || _e === void 0 ? void 0 : _e.querySelector('manage-bar');
|
|
1184
|
-
expect(manageBar).to.exist;
|
|
1185
|
-
// Emit remove event from manage bar
|
|
1186
|
-
manageBar.dispatchEvent(new CustomEvent('removeItems'));
|
|
1187
|
-
await el.updateComplete;
|
|
1188
|
-
expect(spy.callCount).to.equal(1);
|
|
1189
|
-
expect(spy.args[0].length).to.equal(1);
|
|
1190
|
-
expect((_j = (_h = (_g = (_f = spy.args[0][0]) === null || _f === void 0 ? void 0 : _f.detail) === null || _g === void 0 ? void 0 : _g.items) === null || _h === void 0 ? void 0 : _h[0]) === null || _j === void 0 ? void 0 : _j.identifier).to.equal('foo');
|
|
1191
|
-
});
|
|
1192
|
-
it('disables manage view when manage bar cancelled', async () => {
|
|
1193
|
-
var _a;
|
|
1194
|
-
const searchService = new MockSearchService();
|
|
1166
|
+
</collection-browser>`);
|
|
1167
|
+
el.baseQuery = 'foo';
|
|
1168
|
+
await el.updateComplete;
|
|
1169
|
+
await el.initialSearchComplete;
|
|
1170
|
+
el.isManageView = true;
|
|
1171
|
+
await el.updateComplete;
|
|
1172
|
+
const infiniteScroller = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('infinite-scroller');
|
|
1173
|
+
expect(infiniteScroller).to.exist;
|
|
1174
|
+
const tiles = (_b = infiniteScroller.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelectorAll('tile-dispatcher');
|
|
1175
|
+
expect(tiles).to.exist.and.have.length(2);
|
|
1176
|
+
const firstTile = tiles[0];
|
|
1177
|
+
const firstTileLink = (_c = firstTile.shadowRoot) === null || _c === void 0 ? void 0 : _c.querySelector('a[href]');
|
|
1178
|
+
expect((_d = firstTile.model) === null || _d === void 0 ? void 0 : _d.identifier).to.equal('foo');
|
|
1179
|
+
expect(firstTileLink).to.exist;
|
|
1180
|
+
// Check the first tile
|
|
1181
|
+
firstTileLink.click();
|
|
1182
|
+
await el.updateComplete;
|
|
1183
|
+
const manageBar = (_e = el.shadowRoot) === null || _e === void 0 ? void 0 : _e.querySelector('manage-bar');
|
|
1184
|
+
expect(manageBar).to.exist;
|
|
1185
|
+
// Emit remove event from manage bar
|
|
1186
|
+
manageBar.dispatchEvent(new CustomEvent('removeItems'));
|
|
1187
|
+
await el.updateComplete;
|
|
1188
|
+
expect(spy.callCount).to.equal(1);
|
|
1189
|
+
expect(spy.args[0].length).to.equal(1);
|
|
1190
|
+
expect((_j = (_h = (_g = (_f = spy.args[0][0]) === null || _f === void 0 ? void 0 : _f.detail) === null || _g === void 0 ? void 0 : _g.items) === null || _h === void 0 ? void 0 : _h[0]) === null || _j === void 0 ? void 0 : _j.identifier).to.equal('foo');
|
|
1191
|
+
});
|
|
1192
|
+
it('disables manage view when manage bar cancelled', async () => {
|
|
1193
|
+
var _a;
|
|
1194
|
+
const searchService = new MockSearchService();
|
|
1195
1195
|
const el = await fixture(html `<collection-browser
|
|
1196
1196
|
.searchService=${searchService}
|
|
1197
1197
|
.baseNavigationUrl=${''}
|
|
1198
1198
|
>
|
|
1199
|
-
</collection-browser>`);
|
|
1200
|
-
el.baseQuery = 'foo';
|
|
1201
|
-
await el.updateComplete;
|
|
1202
|
-
await el.initialSearchComplete;
|
|
1203
|
-
el.isManageView = true;
|
|
1204
|
-
await el.updateComplete;
|
|
1205
|
-
const manageBar = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('manage-bar');
|
|
1206
|
-
expect(manageBar).to.exist;
|
|
1207
|
-
// Emit remove event from manage bar
|
|
1208
|
-
manageBar.dispatchEvent(new CustomEvent('cancel'));
|
|
1209
|
-
await el.updateComplete;
|
|
1210
|
-
expect(el.isManageView).to.be.false;
|
|
1211
|
-
});
|
|
1212
|
-
});
|
|
1199
|
+
</collection-browser>`);
|
|
1200
|
+
el.baseQuery = 'foo';
|
|
1201
|
+
await el.updateComplete;
|
|
1202
|
+
await el.initialSearchComplete;
|
|
1203
|
+
el.isManageView = true;
|
|
1204
|
+
await el.updateComplete;
|
|
1205
|
+
const manageBar = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('manage-bar');
|
|
1206
|
+
expect(manageBar).to.exist;
|
|
1207
|
+
// Emit remove event from manage bar
|
|
1208
|
+
manageBar.dispatchEvent(new CustomEvent('cancel'));
|
|
1209
|
+
await el.updateComplete;
|
|
1210
|
+
expect(el.isManageView).to.be.false;
|
|
1211
|
+
});
|
|
1212
|
+
});
|
|
1213
1213
|
//# sourceMappingURL=collection-browser.test.js.map
|