@internetarchive/collection-browser 1.14.17-alpha.2 → 1.14.17-alpha.21
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/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/src/app-root.d.ts +1 -0
- package/dist/src/app-root.js +38 -0
- package/dist/src/app-root.js.map +1 -1
- package/dist/src/collection-browser.d.ts +2 -15
- package/dist/src/collection-browser.js +22 -29
- package/dist/src/collection-browser.js.map +1 -1
- package/dist/src/data-source/collection-browser-data-source.d.ts +55 -32
- package/dist/src/data-source/collection-browser-data-source.js +155 -162
- package/dist/src/data-source/collection-browser-data-source.js.map +1 -1
- package/dist/src/data-source/models.d.ts +6 -3
- package/dist/src/data-source/models.js.map +1 -1
- package/dist/src/manage/manage-bar.d.ts +1 -1
- package/dist/src/manage/manage-bar.js.map +1 -1
- package/dist/src/models.d.ts +20 -4
- package/dist/src/models.js +105 -0
- package/dist/src/models.js.map +1 -1
- package/dist/src/sort-filter-bar/sort-filter-bar.js +25 -16
- package/dist/src/sort-filter-bar/sort-filter-bar.js.map +1 -1
- package/dist/src/tiles/grid/item-tile.d.ts +1 -0
- package/dist/src/tiles/grid/item-tile.js +28 -1
- package/dist/src/tiles/grid/item-tile.js.map +1 -1
- package/dist/src/tiles/grid/tile-stats.js +13 -8
- package/dist/src/tiles/grid/tile-stats.js.map +1 -1
- package/dist/src/tiles/list/tile-list-compact.js +1 -1
- package/dist/src/tiles/list/tile-list-compact.js.map +1 -1
- package/dist/src/tiles/list/tile-list.d.ts +1 -0
- package/dist/src/tiles/list/tile-list.js +32 -1
- package/dist/src/tiles/list/tile-list.js.map +1 -1
- package/dist/src/tiles/tile-dispatcher.js +3 -2
- package/dist/src/tiles/tile-dispatcher.js.map +1 -1
- package/dist/src/tiles/tile-display-value-provider.d.ts +6 -2
- package/dist/src/tiles/tile-display-value-provider.js +15 -1
- package/dist/src/tiles/tile-display-value-provider.js.map +1 -1
- package/dist/src/utils/collapse-repeated-quotes.d.ts +11 -0
- package/dist/src/utils/collapse-repeated-quotes.js +14 -0
- package/dist/src/utils/collapse-repeated-quotes.js.map +1 -0
- package/dist/src/utils/resolve-mediatype.d.ts +8 -0
- package/dist/src/utils/resolve-mediatype.js +24 -0
- package/dist/src/utils/resolve-mediatype.js.map +1 -0
- package/dist/test/collection-browser.test.js +39 -19
- package/dist/test/collection-browser.test.js.map +1 -1
- package/dist/test/collection-facets/more-facets-content.test.js +2 -2
- package/dist/test/collection-facets/more-facets-content.test.js.map +1 -1
- package/dist/test/collection-facets.test.js +5 -0
- package/dist/test/collection-facets.test.js.map +1 -1
- package/dist/test/item-image.test.js +33 -34
- package/dist/test/item-image.test.js.map +1 -1
- package/dist/test/mocks/mock-search-responses.d.ts +1 -0
- package/dist/test/mocks/mock-search-responses.js +62 -0
- package/dist/test/mocks/mock-search-responses.js.map +1 -1
- package/dist/test/sort-filter-bar/sort-filter-bar.test.js +41 -4
- package/dist/test/sort-filter-bar/sort-filter-bar.test.js.map +1 -1
- package/dist/test/tiles/hover/hover-pane-controller.test.js +18 -17
- package/dist/test/tiles/hover/hover-pane-controller.test.js.map +1 -1
- package/package.json +2 -2
- package/src/app-root.ts +39 -0
- package/src/collection-browser.ts +24 -40
- package/src/data-source/collection-browser-data-source.ts +160 -132
- package/src/data-source/models.ts +6 -2
- package/src/manage/manage-bar.ts +1 -1
- package/src/models.ts +154 -3
- package/src/sort-filter-bar/sort-filter-bar.ts +26 -16
- package/src/tiles/grid/item-tile.ts +36 -1
- package/src/tiles/grid/tile-stats.ts +12 -7
- package/src/tiles/list/tile-list-compact.ts +1 -1
- package/src/tiles/list/tile-list.ts +43 -5
- package/src/tiles/tile-dispatcher.ts +2 -1
- package/src/tiles/tile-display-value-provider.ts +20 -2
- package/src/utils/collapse-repeated-quotes.ts +13 -0
- package/src/utils/resolve-mediatype.ts +26 -0
- package/test/collection-browser.test.ts +74 -19
- package/test/collection-facets/more-facets-content.test.ts +4 -2
- package/test/collection-facets.test.ts +5 -0
- package/test/item-image.test.ts +34 -36
- package/test/mocks/mock-search-responses.ts +66 -0
- package/test/sort-filter-bar/sort-filter-bar.test.ts +50 -4
- package/test/tiles/hover/hover-pane-controller.test.ts +19 -17
- package/dist/src/data-source/data-source-fetch-provider.d.ts +0 -13
- package/dist/src/data-source/data-source-fetch-provider.js +0 -61
- package/dist/src/data-source/data-source-fetch-provider.js.map +0 -1
- package/dist/src/selected-facets.d.ts +0 -67
- package/dist/src/selected-facets.js +0 -149
- package/dist/src/selected-facets.js.map +0 -1
- package/src/data-source/data-source-fetch-provider.ts +0 -79
- package/src/selected-facets.ts +0 -216
|
@@ -278,13 +278,14 @@ describe('Collection Browser', () => {
|
|
|
278
278
|
|
|
279
279
|
el.baseQuery = 'hello';
|
|
280
280
|
await el.updateComplete;
|
|
281
|
+
await nextTick();
|
|
281
282
|
|
|
282
283
|
const facets = el.shadowRoot?.querySelector('collection-facets');
|
|
283
284
|
const sortBar = el.shadowRoot?.querySelector('sort-filter-bar');
|
|
284
285
|
const infiniteScroller = el.shadowRoot?.querySelector('infinite-scroller');
|
|
285
|
-
expect(facets).to.exist;
|
|
286
|
-
expect(sortBar).to.exist;
|
|
287
|
-
expect(infiniteScroller).to.exist;
|
|
286
|
+
expect(facets, 'facets').to.exist;
|
|
287
|
+
expect(sortBar, 'sort bar').to.exist;
|
|
288
|
+
expect(infiniteScroller, 'infinite scroller').to.exist;
|
|
288
289
|
});
|
|
289
290
|
|
|
290
291
|
it('queries the search service when given a base query', async () => {
|
|
@@ -448,6 +449,25 @@ describe('Collection Browser', () => {
|
|
|
448
449
|
expect(el.searchType).to.equal(SearchType.FULLTEXT);
|
|
449
450
|
});
|
|
450
451
|
|
|
452
|
+
it('can construct tile models with many fields present', async () => {
|
|
453
|
+
const searchService = new MockSearchService();
|
|
454
|
+
|
|
455
|
+
const el = await fixture<CollectionBrowser>(
|
|
456
|
+
html`<collection-browser .searchService=${searchService}>
|
|
457
|
+
</collection-browser>`
|
|
458
|
+
);
|
|
459
|
+
|
|
460
|
+
el.baseQuery = 'many-fields';
|
|
461
|
+
await el.updateComplete;
|
|
462
|
+
await el.initialSearchComplete;
|
|
463
|
+
|
|
464
|
+
const cellTemplate = el.cellForIndex(0);
|
|
465
|
+
expect(cellTemplate).to.exist;
|
|
466
|
+
|
|
467
|
+
const cell = await fixture<TileDispatcher>(cellTemplate!);
|
|
468
|
+
expect(cell).to.exist;
|
|
469
|
+
});
|
|
470
|
+
|
|
451
471
|
it('applies loggedin flag to tile models if needed', async () => {
|
|
452
472
|
const searchService = new MockSearchService();
|
|
453
473
|
|
|
@@ -782,12 +802,15 @@ describe('Collection Browser', () => {
|
|
|
782
802
|
|
|
783
803
|
el.baseQuery = 'foo';
|
|
784
804
|
await el.updateComplete;
|
|
805
|
+
await nextTick();
|
|
785
806
|
|
|
786
|
-
const sortBar = el.shadowRoot?.querySelector(
|
|
807
|
+
const sortBar = el.shadowRoot?.querySelector(
|
|
808
|
+
'#content-container sort-filter-bar'
|
|
809
|
+
);
|
|
787
810
|
const sortSelector = sortBar?.shadowRoot?.querySelector(
|
|
788
811
|
'#desktop-sort-selector'
|
|
789
812
|
);
|
|
790
|
-
expect(sortSelector).to.exist;
|
|
813
|
+
expect(sortSelector, 'sort bar').to.exist;
|
|
791
814
|
|
|
792
815
|
// Click the title sorter
|
|
793
816
|
[...(sortSelector?.children as HTMLCollection & Iterable<any>)] // tsc doesn't know children is iterable
|
|
@@ -912,7 +935,10 @@ describe('Collection Browser', () => {
|
|
|
912
935
|
it('sets date range query when date picker selection changed', async () => {
|
|
913
936
|
const searchService = new MockSearchService();
|
|
914
937
|
const el = await fixture<CollectionBrowser>(
|
|
915
|
-
html`<collection-browser
|
|
938
|
+
html`<collection-browser
|
|
939
|
+
.searchService=${searchService}
|
|
940
|
+
.suppressPlaceholders=${true}
|
|
941
|
+
>
|
|
916
942
|
</collection-browser>`
|
|
917
943
|
);
|
|
918
944
|
|
|
@@ -931,7 +957,8 @@ describe('Collection Browser', () => {
|
|
|
931
957
|
const histogram = facets?.shadowRoot?.querySelector(
|
|
932
958
|
'histogram-date-range'
|
|
933
959
|
) as HistogramDateRange;
|
|
934
|
-
|
|
960
|
+
|
|
961
|
+
expect(histogram, 'histogram exists').to.exist;
|
|
935
962
|
|
|
936
963
|
// Enter a new min date into the date picker
|
|
937
964
|
const minDateInput = histogram.shadowRoot?.querySelector(
|
|
@@ -1119,6 +1146,7 @@ describe('Collection Browser', () => {
|
|
|
1119
1146
|
// infinite scroller does exist.
|
|
1120
1147
|
el.baseQuery = 'collection:foo';
|
|
1121
1148
|
await el.updateComplete;
|
|
1149
|
+
await nextTick();
|
|
1122
1150
|
|
|
1123
1151
|
const infiniteScroller = el.shadowRoot?.querySelector(
|
|
1124
1152
|
'infinite-scroller'
|
|
@@ -1130,8 +1158,7 @@ describe('Collection Browser', () => {
|
|
|
1130
1158
|
infiniteScroller.scrollToCell = spy;
|
|
1131
1159
|
|
|
1132
1160
|
await el.goToPage(1);
|
|
1133
|
-
|
|
1134
|
-
expect(spy.callCount).to.equal(1);
|
|
1161
|
+
expect(spy.callCount, 'scroll to page fires once').to.equal(1);
|
|
1135
1162
|
|
|
1136
1163
|
infiniteScroller.scrollToCell = oldScrollToCell;
|
|
1137
1164
|
});
|
|
@@ -1198,6 +1225,7 @@ describe('Collection Browser', () => {
|
|
|
1198
1225
|
// Infinite scroller won't exist unless there's a base query
|
|
1199
1226
|
el.baseQuery = 'collection:foo';
|
|
1200
1227
|
await el.updateComplete;
|
|
1228
|
+
await nextTick();
|
|
1201
1229
|
|
|
1202
1230
|
const infiniteScroller = el.shadowRoot?.querySelector('infinite-scroller');
|
|
1203
1231
|
(infiniteScroller as InfiniteScroller).reload = infiniteScrollerRefreshSpy;
|
|
@@ -1207,18 +1235,30 @@ describe('Collection Browser', () => {
|
|
|
1207
1235
|
// testing: `loggedIn`
|
|
1208
1236
|
el.loggedIn = true;
|
|
1209
1237
|
await el.updateComplete;
|
|
1210
|
-
|
|
1211
|
-
expect(infiniteScrollerRefreshSpy.
|
|
1238
|
+
|
|
1239
|
+
expect(infiniteScrollerRefreshSpy.called, 'Infinite Scroller Refresh').to.be
|
|
1240
|
+
.true;
|
|
1241
|
+
expect(
|
|
1242
|
+
infiniteScrollerRefreshSpy.callCount,
|
|
1243
|
+
'Infinite Scroller Refresh call count'
|
|
1244
|
+
).to.equal(1);
|
|
1212
1245
|
|
|
1213
1246
|
el.loggedIn = false;
|
|
1214
1247
|
await el.updateComplete;
|
|
1215
|
-
|
|
1248
|
+
|
|
1249
|
+
expect(
|
|
1250
|
+
infiniteScrollerRefreshSpy.callCount,
|
|
1251
|
+
'2nd Infinite Scroller Refresh'
|
|
1252
|
+
).to.equal(2);
|
|
1216
1253
|
|
|
1217
1254
|
// testing: `displayMode`
|
|
1218
1255
|
el.displayMode = 'list-compact';
|
|
1219
1256
|
el.searchContext = 'beta-search';
|
|
1220
1257
|
await el.updateComplete;
|
|
1221
|
-
expect(
|
|
1258
|
+
expect(
|
|
1259
|
+
infiniteScrollerRefreshSpy.callCount,
|
|
1260
|
+
'3rd Infinite Scroller Refresh'
|
|
1261
|
+
).to.equal(3);
|
|
1222
1262
|
|
|
1223
1263
|
expect(mockAnalyticsHandler.callCategory).to.equal('beta-search');
|
|
1224
1264
|
expect(mockAnalyticsHandler.callAction).to.equal('displayMode');
|
|
@@ -1226,7 +1266,10 @@ describe('Collection Browser', () => {
|
|
|
1226
1266
|
|
|
1227
1267
|
el.displayMode = 'list-detail';
|
|
1228
1268
|
await el.updateComplete;
|
|
1229
|
-
expect(
|
|
1269
|
+
expect(
|
|
1270
|
+
infiniteScrollerRefreshSpy.callCount,
|
|
1271
|
+
'4th Infinite Scroller Refresh'
|
|
1272
|
+
).to.equal(4);
|
|
1230
1273
|
|
|
1231
1274
|
expect(mockAnalyticsHandler.callCategory).to.equal('beta-search');
|
|
1232
1275
|
expect(mockAnalyticsHandler.callAction).to.equal('displayMode');
|
|
@@ -1235,12 +1278,18 @@ describe('Collection Browser', () => {
|
|
|
1235
1278
|
// testing: `baseNavigationUrl`
|
|
1236
1279
|
el.baseNavigationUrl = 'https://funtestsite.com';
|
|
1237
1280
|
await el.updateComplete;
|
|
1238
|
-
expect(
|
|
1281
|
+
expect(
|
|
1282
|
+
infiniteScrollerRefreshSpy.callCount,
|
|
1283
|
+
'5th Infinite Scroller Refresh'
|
|
1284
|
+
).to.equal(5);
|
|
1239
1285
|
|
|
1240
1286
|
// testing: `baseImageUrl`
|
|
1241
1287
|
el.baseImageUrl = 'https://funtestsiteforimages.com';
|
|
1242
1288
|
await el.updateComplete;
|
|
1243
|
-
expect(
|
|
1289
|
+
expect(
|
|
1290
|
+
infiniteScrollerRefreshSpy.callCount,
|
|
1291
|
+
'6th Infinite Scroller Refresh'
|
|
1292
|
+
).to.equal(6);
|
|
1244
1293
|
});
|
|
1245
1294
|
|
|
1246
1295
|
it('query the search service for single result', async () => {
|
|
@@ -1558,10 +1607,16 @@ describe('Collection Browser', () => {
|
|
|
1558
1607
|
// Remove checked tiles and verify that we only kept the second tile
|
|
1559
1608
|
el.removeCheckedTiles();
|
|
1560
1609
|
await el.updateComplete;
|
|
1561
|
-
|
|
1610
|
+
expect(el?.dataSource?.size, 'data source count').to.equal(1);
|
|
1611
|
+
|
|
1612
|
+
tiles = el.shadowRoot
|
|
1613
|
+
?.querySelector('infinite-scroller')!
|
|
1614
|
+
.shadowRoot?.querySelectorAll('tile-dispatcher');
|
|
1562
1615
|
expect(tiles).to.exist;
|
|
1563
|
-
expect(
|
|
1564
|
-
|
|
1616
|
+
expect(
|
|
1617
|
+
tiles!.length,
|
|
1618
|
+
'tile count after `el.removeCheckedTiles()`'
|
|
1619
|
+
).to.equal(1);
|
|
1565
1620
|
});
|
|
1566
1621
|
|
|
1567
1622
|
it('can check/uncheck all tiles', async () => {
|
|
@@ -80,10 +80,12 @@ describe('More facets content', () => {
|
|
|
80
80
|
);
|
|
81
81
|
|
|
82
82
|
el.facetKey = 'collection';
|
|
83
|
-
el.query = '
|
|
83
|
+
el.query = 'collection-aggregations';
|
|
84
84
|
await el.updateComplete;
|
|
85
85
|
|
|
86
|
-
expect(searchService.searchParams?.query).to.equal(
|
|
86
|
+
expect(searchService.searchParams?.query).to.equal(
|
|
87
|
+
'collection-aggregations'
|
|
88
|
+
);
|
|
87
89
|
});
|
|
88
90
|
|
|
89
91
|
it('queries for more facets using search service within a collection (no query)', async () => {
|
|
@@ -788,6 +788,11 @@ describe('Collection Facets', () => {
|
|
|
788
788
|
.baseNavigationUrl=${''}
|
|
789
789
|
.withinCollection=${'foo'}
|
|
790
790
|
.parentCollections=${['bar', 'baz']}
|
|
791
|
+
.collectionTitles=${new Map([
|
|
792
|
+
['foo', 'foo-name'],
|
|
793
|
+
['bar', 'bar-name'],
|
|
794
|
+
['baz', 'baz-name'],
|
|
795
|
+
])}
|
|
791
796
|
></collection-facets>`
|
|
792
797
|
);
|
|
793
798
|
|
package/test/item-image.test.ts
CHANGED
|
@@ -2,47 +2,45 @@
|
|
|
2
2
|
import { expect, fixture } from '@open-wc/testing';
|
|
3
3
|
import { html } from 'lit';
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import { TileModel } from '../src/models';
|
|
6
6
|
import type { ItemImage } from '../src/tiles/item-image';
|
|
7
7
|
|
|
8
8
|
import '../src/tiles/item-image';
|
|
9
9
|
|
|
10
10
|
const baseImageUrl = 'https://archive.org';
|
|
11
|
-
const testBookModel: TileModel = {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
collectionSize: 0,
|
|
45
|
-
};
|
|
11
|
+
const testBookModel: TileModel = new TileModel({});
|
|
12
|
+
testBookModel.checked = false;
|
|
13
|
+
testBookModel.collections = [];
|
|
14
|
+
testBookModel.commentCount = 0;
|
|
15
|
+
testBookModel.creators = [];
|
|
16
|
+
testBookModel.favCount = 0;
|
|
17
|
+
testBookModel.identifier = '18730130BloomfieldRecordCompleteIssue';
|
|
18
|
+
testBookModel.itemCount = 0;
|
|
19
|
+
testBookModel.mediatype = 'texts';
|
|
20
|
+
testBookModel.subjects = [];
|
|
21
|
+
testBookModel.title = 'Sample Waveform';
|
|
22
|
+
testBookModel.viewCount = 0;
|
|
23
|
+
testBookModel.loginRequired = false;
|
|
24
|
+
testBookModel.contentWarning = false;
|
|
25
|
+
testBookModel.collectionFilesCount = 0;
|
|
26
|
+
testBookModel.collectionSize = 0;
|
|
27
|
+
|
|
28
|
+
const testAudioModel: TileModel = new TileModel({});
|
|
29
|
+
testAudioModel.checked = false;
|
|
30
|
+
testAudioModel.collections = [];
|
|
31
|
+
testAudioModel.commentCount = 0;
|
|
32
|
+
testAudioModel.creators = [];
|
|
33
|
+
testAudioModel.favCount = 0;
|
|
34
|
+
testAudioModel.identifier = 'dwd2015-01-24';
|
|
35
|
+
testAudioModel.itemCount = 0;
|
|
36
|
+
testAudioModel.mediatype = 'audio';
|
|
37
|
+
testAudioModel.subjects = [];
|
|
38
|
+
testAudioModel.title = 'Sample Waveform';
|
|
39
|
+
testAudioModel.viewCount = 0;
|
|
40
|
+
testAudioModel.loginRequired = false;
|
|
41
|
+
testAudioModel.contentWarning = false;
|
|
42
|
+
testAudioModel.collectionFilesCount = 0;
|
|
43
|
+
testAudioModel.collectionSize = 0;
|
|
46
44
|
|
|
47
45
|
describe('ItemImage component', () => {
|
|
48
46
|
it('should render initial component', async () => {
|
|
@@ -49,6 +49,68 @@ export const getMockSuccessSingleResult: () => Result<
|
|
|
49
49
|
},
|
|
50
50
|
});
|
|
51
51
|
|
|
52
|
+
export const getMockSuccessManyFields: () => Result<
|
|
53
|
+
SearchResponse,
|
|
54
|
+
SearchServiceError
|
|
55
|
+
> = () => ({
|
|
56
|
+
success: {
|
|
57
|
+
request: {
|
|
58
|
+
kind: 'hits',
|
|
59
|
+
clientParameters: {
|
|
60
|
+
user_query: 'many-fields',
|
|
61
|
+
sort: [],
|
|
62
|
+
},
|
|
63
|
+
backendRequests: {
|
|
64
|
+
primary: {
|
|
65
|
+
kind: 'hits',
|
|
66
|
+
finalized_parameters: {
|
|
67
|
+
user_query: 'many-fields',
|
|
68
|
+
sort: [],
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
rawResponse: {},
|
|
74
|
+
response: {
|
|
75
|
+
totalResults: 1,
|
|
76
|
+
returnedCount: 1,
|
|
77
|
+
results: [
|
|
78
|
+
new ItemHit({
|
|
79
|
+
fields: {
|
|
80
|
+
identifier: 'foo',
|
|
81
|
+
avg_rating: 3.5,
|
|
82
|
+
collection: ['foo', 'bar', 'no-preview', 'loggedin'],
|
|
83
|
+
collection_files_count: 123,
|
|
84
|
+
collection_size: 234,
|
|
85
|
+
creator: ['baz', 'boop'],
|
|
86
|
+
date: '2010-01-03T01:23:45Z',
|
|
87
|
+
addeddate: '2010-01-01T01:23:45Z',
|
|
88
|
+
publicdate: '2010-01-02T01:23:45Z',
|
|
89
|
+
reviewdate: '2010-01-04T01:23:45Z',
|
|
90
|
+
description: 'foo bar baz',
|
|
91
|
+
downloads: 246,
|
|
92
|
+
issue: 1,
|
|
93
|
+
item_count: 20,
|
|
94
|
+
mediatype: 'texts',
|
|
95
|
+
num_favorites: 12,
|
|
96
|
+
num_reviews: 23,
|
|
97
|
+
source: 'foo bar',
|
|
98
|
+
subject: ['baz', 'quux'],
|
|
99
|
+
title: 'Foo Bar',
|
|
100
|
+
volume: 2,
|
|
101
|
+
week: 50,
|
|
102
|
+
__href__: 'https://archive.org/details/foo',
|
|
103
|
+
},
|
|
104
|
+
}),
|
|
105
|
+
],
|
|
106
|
+
},
|
|
107
|
+
responseHeader: {
|
|
108
|
+
succeeded: true,
|
|
109
|
+
query_time: 0,
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
|
|
52
114
|
export const getMockSuccessWithYearHistogramAggs: () => Result<
|
|
53
115
|
SearchResponse,
|
|
54
116
|
SearchServiceError
|
|
@@ -408,6 +470,10 @@ export const getMockSuccessWithCollectionAggregations: () => Result<
|
|
|
408
470
|
],
|
|
409
471
|
}),
|
|
410
472
|
},
|
|
473
|
+
collection_titles: {
|
|
474
|
+
foo: 'Foo',
|
|
475
|
+
bar: 'Bar',
|
|
476
|
+
},
|
|
411
477
|
},
|
|
412
478
|
responseHeader: {
|
|
413
479
|
succeeded: true,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/* eslint-disable import/no-duplicates */
|
|
2
2
|
import { expect, fixture } from '@open-wc/testing';
|
|
3
|
+
import sinon from 'sinon';
|
|
3
4
|
import { html } from 'lit';
|
|
4
5
|
import type { IaDropdown } from '@internetarchive/ia-dropdown';
|
|
5
6
|
import { SharedResizeObserver } from '@internetarchive/shared-resize-observer';
|
|
@@ -19,11 +20,16 @@ describe('Sort selector default buttons', async () => {
|
|
|
19
20
|
'#desktop-sort-selector'
|
|
20
21
|
);
|
|
21
22
|
|
|
22
|
-
|
|
23
|
+
beforeEach(async () => {
|
|
23
24
|
el.resizeObserver = new SharedResizeObserver();
|
|
24
25
|
await el.updateComplete;
|
|
25
26
|
});
|
|
26
27
|
|
|
28
|
+
afterEach(async () => {
|
|
29
|
+
el.resizeObserver = undefined;
|
|
30
|
+
await el.updateComplete;
|
|
31
|
+
});
|
|
32
|
+
|
|
27
33
|
it('should render basic component', async () => {
|
|
28
34
|
expect(sortSelectorContainer).to.exist;
|
|
29
35
|
expect(desktopSortSelector).to.exist;
|
|
@@ -617,15 +623,55 @@ describe('Sort/filter bar mobile view', () => {
|
|
|
617
623
|
expect(backdrop).not.to.exist;
|
|
618
624
|
});
|
|
619
625
|
|
|
620
|
-
it('shows loansTab top-bar slot', async () => {
|
|
626
|
+
it('shows loansTab top-bar slot Default View', async () => {
|
|
627
|
+
const resizeStub = new SharedResizeObserver();
|
|
628
|
+
const addSpy = sinon.spy(resizeStub, 'addObserver');
|
|
629
|
+
const removeSpy = sinon.spy(resizeStub, 'removeObserver');
|
|
630
|
+
|
|
621
631
|
const el = await fixture<SortFilterBar>(html`
|
|
622
|
-
<sort-filter-bar></sort-filter-bar>
|
|
632
|
+
<sort-filter-bar .resizeObserver=${resizeStub}></sort-filter-bar>
|
|
633
|
+
`);
|
|
634
|
+
|
|
635
|
+
// this element exists
|
|
636
|
+
expect(el?.shadowRoot?.querySelector('#sort-selector-container')).to.exist;
|
|
637
|
+
|
|
638
|
+
// loads & unloads twice when [re]setting ResizeObserver
|
|
639
|
+
expect(addSpy.callCount).to.equal(2);
|
|
640
|
+
|
|
641
|
+
const resizeStub2 = new SharedResizeObserver();
|
|
642
|
+
el.resizeObserver = resizeStub2;
|
|
643
|
+
await el.updateComplete;
|
|
644
|
+
expect(removeSpy.callCount).to.equal(2);
|
|
645
|
+
});
|
|
646
|
+
|
|
647
|
+
it('shows loansTab top-bar slot Custom Slotted View', async () => {
|
|
648
|
+
const resizeStub = new SharedResizeObserver();
|
|
649
|
+
const addSpy = sinon.spy(resizeStub, 'addObserver');
|
|
650
|
+
const removeSpy = sinon.spy(resizeStub, 'removeObserver');
|
|
651
|
+
|
|
652
|
+
const el = await fixture<SortFilterBar>(html`
|
|
653
|
+
<sort-filter-bar
|
|
654
|
+
.resizeObserver=${resizeStub}
|
|
655
|
+
.showLoansTopBar=${true}
|
|
656
|
+
></sort-filter-bar>
|
|
623
657
|
`);
|
|
624
658
|
|
|
625
|
-
el.showLoansTopBar = true;
|
|
626
659
|
await el.updateComplete;
|
|
627
660
|
|
|
661
|
+
// slot exists
|
|
628
662
|
const loansTabSlot = el?.shadowRoot?.querySelector('slot');
|
|
629
663
|
expect(loansTabSlot).to.exist;
|
|
664
|
+
|
|
665
|
+
// sort bar does not exist
|
|
666
|
+
expect(el?.shadowRoot?.querySelector('#sort-selector-container')).to.not
|
|
667
|
+
.exist;
|
|
668
|
+
|
|
669
|
+
const resizeStub2 = new SharedResizeObserver();
|
|
670
|
+
el.resizeObserver = resizeStub2;
|
|
671
|
+
await el.updateComplete;
|
|
672
|
+
|
|
673
|
+
// there's no need for resize observer
|
|
674
|
+
expect(addSpy.callCount).to.equal(0);
|
|
675
|
+
expect(removeSpy.callCount).to.equal(0);
|
|
630
676
|
});
|
|
631
677
|
});
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
HoverPaneProviderInterface,
|
|
10
10
|
} from '../../../src/tiles/hover/hover-pane-controller';
|
|
11
11
|
import type { TileHoverPane } from '../../../src/tiles/hover/tile-hover-pane';
|
|
12
|
+
import { TileModel } from '../../../src/models';
|
|
12
13
|
|
|
13
14
|
@customElement('host-element')
|
|
14
15
|
class HostElement extends LitElement implements HoverPaneProviderInterface {
|
|
@@ -33,24 +34,25 @@ class HostElement extends LitElement implements HoverPaneProviderInterface {
|
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
getHoverPaneProps(): HoverPaneProperties {
|
|
37
|
+
const tileModel = new TileModel({});
|
|
38
|
+
tileModel.checked = false;
|
|
39
|
+
tileModel.collectionFilesCount = 1;
|
|
40
|
+
tileModel.collections = ['foo', 'bar'];
|
|
41
|
+
tileModel.collectionSize = 1;
|
|
42
|
+
tileModel.commentCount = 1;
|
|
43
|
+
tileModel.contentWarning = false;
|
|
44
|
+
tileModel.creators = ['foo', 'bar'];
|
|
45
|
+
tileModel.favCount = 1;
|
|
46
|
+
tileModel.identifier = 'foo';
|
|
47
|
+
tileModel.itemCount = 1;
|
|
48
|
+
tileModel.loginRequired = false;
|
|
49
|
+
tileModel.mediatype = 'data';
|
|
50
|
+
tileModel.subjects = ['foo', 'bar'];
|
|
51
|
+
tileModel.title = 'foo';
|
|
52
|
+
tileModel.viewCount = 1;
|
|
53
|
+
|
|
36
54
|
return {
|
|
37
|
-
model:
|
|
38
|
-
checked: false,
|
|
39
|
-
collectionFilesCount: 1,
|
|
40
|
-
collections: ['foo', 'bar'],
|
|
41
|
-
collectionSize: 1,
|
|
42
|
-
commentCount: 1,
|
|
43
|
-
contentWarning: false,
|
|
44
|
-
creators: ['foo', 'bar'],
|
|
45
|
-
favCount: 1,
|
|
46
|
-
identifier: 'foo',
|
|
47
|
-
itemCount: 1,
|
|
48
|
-
loginRequired: false,
|
|
49
|
-
mediatype: 'data',
|
|
50
|
-
subjects: ['foo', 'bar'],
|
|
51
|
-
title: 'foo',
|
|
52
|
-
viewCount: 1,
|
|
53
|
-
},
|
|
55
|
+
model: tileModel,
|
|
54
56
|
loggedIn: false,
|
|
55
57
|
sortParam: null,
|
|
56
58
|
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { CollectionBrowserDataSourceInterface } from "./collection-browser-data-source";
|
|
2
|
-
export interface DataSourceFetchProviderInterface {
|
|
3
|
-
fetchPage(dataSource: CollectionBrowserDataSourceInterface, pageNumber: number, initialPageNumber?: number): Promise<void>;
|
|
4
|
-
fetchFacets(dataSource: CollectionBrowserDataSourceInterface): Promise<void>;
|
|
5
|
-
fetchPrefixFilterBuckets(dataSource: CollectionBrowserDataSourceInterface): Promise<void>;
|
|
6
|
-
}
|
|
7
|
-
export declare class DataSourceFetchProvider {
|
|
8
|
-
/**
|
|
9
|
-
* Fires a backend request to fetch a set of aggregations (representing UI facets) for
|
|
10
|
-
* the current search state.
|
|
11
|
-
*/
|
|
12
|
-
private fetchFacets;
|
|
13
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
export class DataSourceFetchProvider {
|
|
2
|
-
/**
|
|
3
|
-
* Fires a backend request to fetch a set of aggregations (representing UI facets) for
|
|
4
|
-
* the current search state.
|
|
5
|
-
*/
|
|
6
|
-
async fetchFacets(dataSource) {
|
|
7
|
-
// const trimmedQuery = dataSource.host.baseQuery?.trim();
|
|
8
|
-
// if (!dataSource.canPerformSearch) return;
|
|
9
|
-
// const { facetFetchQueryKey } = this;
|
|
10
|
-
// const sortParams = this.host.sortParam ? [this.host.sortParam] : [];
|
|
11
|
-
// const params: SearchParams = {
|
|
12
|
-
// ...this.collectionParams,
|
|
13
|
-
// query: trimmedQuery || '',
|
|
14
|
-
// rows: 0,
|
|
15
|
-
// filters: this.filterMap,
|
|
16
|
-
// // Fetch a few extra buckets beyond the 6 we show, in case some get suppressed
|
|
17
|
-
// aggregationsSize: 10,
|
|
18
|
-
// // Note: we don't need an aggregations param to fetch the default aggregations from the PPS.
|
|
19
|
-
// // The default aggregations for the search_results page type should be what we need here.
|
|
20
|
-
// };
|
|
21
|
-
// params.uid = await this.requestUID(
|
|
22
|
-
// { ...params, sort: sortParams },
|
|
23
|
-
// 'aggregations'
|
|
24
|
-
// );
|
|
25
|
-
// this.host.setFacetsLoading(true);
|
|
26
|
-
// const searchResponse = await this.host.searchService?.search(
|
|
27
|
-
// params,
|
|
28
|
-
// this.host.searchType
|
|
29
|
-
// );
|
|
30
|
-
// const success = searchResponse?.success;
|
|
31
|
-
// // This is checking to see if the query has changed since the data was fetched.
|
|
32
|
-
// // If so, we just want to discard this set of aggregations because they are
|
|
33
|
-
// // likely no longer valid for the newer query.
|
|
34
|
-
// const queryChangedSinceFetch =
|
|
35
|
-
// facetFetchQueryKey !== this.facetFetchQueryKey;
|
|
36
|
-
// if (queryChangedSinceFetch) return;
|
|
37
|
-
// if (!success) {
|
|
38
|
-
// const errorMsg = searchResponse?.error?.message;
|
|
39
|
-
// const detailMsg = searchResponse?.error?.details?.message;
|
|
40
|
-
// if (!errorMsg && !detailMsg) {
|
|
41
|
-
// // @ts-ignore: Property 'Sentry' does not exist on type 'Window & typeof globalThis'
|
|
42
|
-
// window?.Sentry?.captureMessage?.(
|
|
43
|
-
// 'Missing or malformed facet response from backend',
|
|
44
|
-
// 'error'
|
|
45
|
-
// );
|
|
46
|
-
// }
|
|
47
|
-
// return;
|
|
48
|
-
// }
|
|
49
|
-
// const { aggregations, collectionTitles } = success.response;
|
|
50
|
-
// this.aggregations = aggregations;
|
|
51
|
-
// if (collectionTitles) {
|
|
52
|
-
// for (const [id, title] of Object.entries(collectionTitles)) {
|
|
53
|
-
// this.collectionTitles.set(id, title);
|
|
54
|
-
// }
|
|
55
|
-
// }
|
|
56
|
-
// this.yearHistogramAggregation =
|
|
57
|
-
// success?.response?.aggregations?.year_histogram;
|
|
58
|
-
// this.host.setFacetsLoading(false);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
//# sourceMappingURL=data-source-fetch-provider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"data-source-fetch-provider.js","sourceRoot":"","sources":["../../../src/data-source/data-source-fetch-provider.ts"],"names":[],"mappings":"AAQA,MAAM,OAAO,uBAAuB;IAClC;;;OAGG;IACK,KAAK,CAAC,WAAW,CAAC,UAAgD;QACxE,0DAA0D;QAC1D,4CAA4C;QAE5C,uCAAuC;QAEvC,uEAAuE;QACvE,iCAAiC;QACjC,8BAA8B;QAC9B,+BAA+B;QAC/B,aAAa;QACb,6BAA6B;QAC7B,mFAAmF;QACnF,0BAA0B;QAC1B,iGAAiG;QACjG,8FAA8F;QAC9F,KAAK;QACL,sCAAsC;QACtC,qCAAqC;QACrC,mBAAmB;QACnB,KAAK;QAEL,oCAAoC;QACpC,gEAAgE;QAChE,YAAY;QACZ,yBAAyB;QACzB,KAAK;QACL,2CAA2C;QAE3C,kFAAkF;QAClF,8EAA8E;QAC9E,iDAAiD;QACjD,iCAAiC;QACjC,oDAAoD;QACpD,sCAAsC;QAEtC,kBAAkB;QAClB,qDAAqD;QACrD,+DAA+D;QAE/D,mCAAmC;QACnC,2FAA2F;QAC3F,wCAAwC;QACxC,4DAA4D;QAC5D,gBAAgB;QAChB,SAAS;QACT,MAAM;QAEN,YAAY;QACZ,IAAI;QAEJ,+DAA+D;QAC/D,oCAAoC;QAEpC,0BAA0B;QAC1B,kEAAkE;QAClE,4CAA4C;QAC5C,MAAM;QACN,IAAI;QAEJ,kCAAkC;QAClC,qDAAqD;QAErD,qCAAqC;IACvC,CAAC;CACF","sourcesContent":["import type { CollectionBrowserDataSourceInterface } from \"./collection-browser-data-source\";\n\nexport interface DataSourceFetchProviderInterface {\n fetchPage(dataSource: CollectionBrowserDataSourceInterface, pageNumber: number, initialPageNumber?: number): Promise<void>;\n fetchFacets(dataSource: CollectionBrowserDataSourceInterface): Promise<void>;\n fetchPrefixFilterBuckets(dataSource: CollectionBrowserDataSourceInterface): Promise<void>;\n}\n\nexport class DataSourceFetchProvider {\n /**\n * Fires a backend request to fetch a set of aggregations (representing UI facets) for\n * the current search state.\n */\n private async fetchFacets(dataSource: CollectionBrowserDataSourceInterface): Promise<void> {\n // const trimmedQuery = dataSource.host.baseQuery?.trim();\n // if (!dataSource.canPerformSearch) return;\n\n // const { facetFetchQueryKey } = this;\n\n // const sortParams = this.host.sortParam ? [this.host.sortParam] : [];\n // const params: SearchParams = {\n // ...this.collectionParams,\n // query: trimmedQuery || '',\n // rows: 0,\n // filters: this.filterMap,\n // // Fetch a few extra buckets beyond the 6 we show, in case some get suppressed\n // aggregationsSize: 10,\n // // Note: we don't need an aggregations param to fetch the default aggregations from the PPS.\n // // The default aggregations for the search_results page type should be what we need here.\n // };\n // params.uid = await this.requestUID(\n // { ...params, sort: sortParams },\n // 'aggregations'\n // );\n\n // this.host.setFacetsLoading(true);\n // const searchResponse = await this.host.searchService?.search(\n // params,\n // this.host.searchType\n // );\n // const success = searchResponse?.success;\n\n // // This is checking to see if the query has changed since the data was fetched.\n // // If so, we just want to discard this set of aggregations because they are\n // // likely no longer valid for the newer query.\n // const queryChangedSinceFetch =\n // facetFetchQueryKey !== this.facetFetchQueryKey;\n // if (queryChangedSinceFetch) return;\n\n // if (!success) {\n // const errorMsg = searchResponse?.error?.message;\n // const detailMsg = searchResponse?.error?.details?.message;\n\n // if (!errorMsg && !detailMsg) {\n // // @ts-ignore: Property 'Sentry' does not exist on type 'Window & typeof globalThis'\n // window?.Sentry?.captureMessage?.(\n // 'Missing or malformed facet response from backend',\n // 'error'\n // );\n // }\n\n // return;\n // }\n\n // const { aggregations, collectionTitles } = success.response;\n // this.aggregations = aggregations;\n\n // if (collectionTitles) {\n // for (const [id, title] of Object.entries(collectionTitles)) {\n // this.collectionTitles.set(id, title);\n // }\n // }\n\n // this.yearHistogramAggregation =\n // success?.response?.aggregations?.year_histogram;\n\n // this.host.setFacetsLoading(false);\n }\n}"]}
|