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