@internetarchive/collection-browser 1.14.17-alpha.3 → 1.14.17-alpha.30
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/collection-browser.d.ts +6 -13
- package/dist/src/collection-browser.js +54 -25
- package/dist/src/collection-browser.js.map +1 -1
- package/dist/src/data-source/collection-browser-data-source.d.ts +48 -30
- package/dist/src/data-source/collection-browser-data-source.js +106 -116
- package/dist/src/data-source/collection-browser-data-source.js.map +1 -1
- package/dist/src/data-source/models.d.ts +7 -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 +1 -0
- 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.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 +37 -25
- 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/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/collection-browser.ts +62 -42
- package/src/data-source/collection-browser-data-source.ts +170 -140
- package/src/data-source/models.ts +7 -2
- package/src/manage/manage-bar.ts +1 -1
- package/src/models.ts +154 -3
- package/src/sort-filter-bar/sort-filter-bar.ts +1 -0
- package/src/tiles/grid/item-tile.ts +36 -1
- package/src/tiles/grid/tile-stats.ts +12 -7
- 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 +72 -27
- package/test/collection-facets/more-facets-content.test.ts +4 -2
- 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
|
@@ -283,9 +283,9 @@ describe('Collection Browser', () => {
|
|
|
283
283
|
const facets = el.shadowRoot?.querySelector('collection-facets');
|
|
284
284
|
const sortBar = el.shadowRoot?.querySelector('sort-filter-bar');
|
|
285
285
|
const infiniteScroller = el.shadowRoot?.querySelector('infinite-scroller');
|
|
286
|
-
expect(facets).to.exist;
|
|
287
|
-
expect(sortBar).to.exist;
|
|
288
|
-
expect(infiniteScroller).to.exist;
|
|
286
|
+
expect(facets, 'facets').to.exist;
|
|
287
|
+
expect(sortBar, 'sort bar').to.exist;
|
|
288
|
+
expect(infiniteScroller, 'infinite scroller').to.exist;
|
|
289
289
|
});
|
|
290
290
|
|
|
291
291
|
it('queries the search service when given a base query', async () => {
|
|
@@ -449,6 +449,25 @@ describe('Collection Browser', () => {
|
|
|
449
449
|
expect(el.searchType).to.equal(SearchType.FULLTEXT);
|
|
450
450
|
});
|
|
451
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
|
+
|
|
452
471
|
it('applies loggedin flag to tile models if needed', async () => {
|
|
453
472
|
const searchService = new MockSearchService();
|
|
454
473
|
|
|
@@ -785,11 +804,13 @@ describe('Collection Browser', () => {
|
|
|
785
804
|
await el.updateComplete;
|
|
786
805
|
await nextTick();
|
|
787
806
|
|
|
788
|
-
const sortBar = el.shadowRoot?.querySelector(
|
|
807
|
+
const sortBar = el.shadowRoot?.querySelector(
|
|
808
|
+
'#content-container sort-filter-bar'
|
|
809
|
+
);
|
|
789
810
|
const sortSelector = sortBar?.shadowRoot?.querySelector(
|
|
790
811
|
'#desktop-sort-selector'
|
|
791
812
|
);
|
|
792
|
-
expect(sortSelector).to.exist;
|
|
813
|
+
expect(sortSelector, 'sort bar').to.exist;
|
|
793
814
|
|
|
794
815
|
// Click the title sorter
|
|
795
816
|
[...(sortSelector?.children as HTMLCollection & Iterable<any>)] // tsc doesn't know children is iterable
|
|
@@ -896,7 +917,7 @@ describe('Collection Browser', () => {
|
|
|
896
917
|
el.sortDirection = 'asc';
|
|
897
918
|
el.selectedCreatorFilter = 'X';
|
|
898
919
|
await el.updateComplete;
|
|
899
|
-
await
|
|
920
|
+
await nextTick();
|
|
900
921
|
|
|
901
922
|
expect(searchService.searchParams?.query).to.equal('first-creator');
|
|
902
923
|
expect(searchService.searchParams?.filters?.firstCreator?.X).to.equal(
|
|
@@ -905,7 +926,7 @@ describe('Collection Browser', () => {
|
|
|
905
926
|
|
|
906
927
|
el.baseQuery = 'collection:foo';
|
|
907
928
|
await el.updateComplete;
|
|
908
|
-
await
|
|
929
|
+
await nextTick();
|
|
909
930
|
|
|
910
931
|
expect(searchService.searchParams?.query).to.equal('collection:foo');
|
|
911
932
|
expect(searchService.searchParams?.filters?.firstCreator).not.to.exist;
|
|
@@ -914,7 +935,10 @@ describe('Collection Browser', () => {
|
|
|
914
935
|
it('sets date range query when date picker selection changed', async () => {
|
|
915
936
|
const searchService = new MockSearchService();
|
|
916
937
|
const el = await fixture<CollectionBrowser>(
|
|
917
|
-
html`<collection-browser
|
|
938
|
+
html`<collection-browser
|
|
939
|
+
.searchService=${searchService}
|
|
940
|
+
.suppressPlaceholders=${true}
|
|
941
|
+
>
|
|
918
942
|
</collection-browser>`
|
|
919
943
|
);
|
|
920
944
|
|
|
@@ -933,7 +957,8 @@ describe('Collection Browser', () => {
|
|
|
933
957
|
const histogram = facets?.shadowRoot?.querySelector(
|
|
934
958
|
'histogram-date-range'
|
|
935
959
|
) as HistogramDateRange;
|
|
936
|
-
|
|
960
|
+
|
|
961
|
+
expect(histogram, 'histogram exists').to.exist;
|
|
937
962
|
|
|
938
963
|
// Enter a new min date into the date picker
|
|
939
964
|
const minDateInput = histogram.shadowRoot?.querySelector(
|
|
@@ -1133,8 +1158,7 @@ describe('Collection Browser', () => {
|
|
|
1133
1158
|
infiniteScroller.scrollToCell = spy;
|
|
1134
1159
|
|
|
1135
1160
|
await el.goToPage(1);
|
|
1136
|
-
|
|
1137
|
-
expect(spy.callCount).to.equal(1);
|
|
1161
|
+
expect(spy.callCount, 'scroll to page fires once').to.equal(1);
|
|
1138
1162
|
|
|
1139
1163
|
infiniteScroller.scrollToCell = oldScrollToCell;
|
|
1140
1164
|
});
|
|
@@ -1211,18 +1235,30 @@ describe('Collection Browser', () => {
|
|
|
1211
1235
|
// testing: `loggedIn`
|
|
1212
1236
|
el.loggedIn = true;
|
|
1213
1237
|
await el.updateComplete;
|
|
1214
|
-
|
|
1215
|
-
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);
|
|
1216
1245
|
|
|
1217
1246
|
el.loggedIn = false;
|
|
1218
1247
|
await el.updateComplete;
|
|
1219
|
-
|
|
1248
|
+
|
|
1249
|
+
expect(
|
|
1250
|
+
infiniteScrollerRefreshSpy.callCount,
|
|
1251
|
+
'2nd Infinite Scroller Refresh'
|
|
1252
|
+
).to.equal(2);
|
|
1220
1253
|
|
|
1221
1254
|
// testing: `displayMode`
|
|
1222
1255
|
el.displayMode = 'list-compact';
|
|
1223
1256
|
el.searchContext = 'beta-search';
|
|
1224
1257
|
await el.updateComplete;
|
|
1225
|
-
expect(
|
|
1258
|
+
expect(
|
|
1259
|
+
infiniteScrollerRefreshSpy.callCount,
|
|
1260
|
+
'3rd Infinite Scroller Refresh'
|
|
1261
|
+
).to.equal(3);
|
|
1226
1262
|
|
|
1227
1263
|
expect(mockAnalyticsHandler.callCategory).to.equal('beta-search');
|
|
1228
1264
|
expect(mockAnalyticsHandler.callAction).to.equal('displayMode');
|
|
@@ -1230,7 +1266,10 @@ describe('Collection Browser', () => {
|
|
|
1230
1266
|
|
|
1231
1267
|
el.displayMode = 'list-detail';
|
|
1232
1268
|
await el.updateComplete;
|
|
1233
|
-
expect(
|
|
1269
|
+
expect(
|
|
1270
|
+
infiniteScrollerRefreshSpy.callCount,
|
|
1271
|
+
'4th Infinite Scroller Refresh'
|
|
1272
|
+
).to.equal(4);
|
|
1234
1273
|
|
|
1235
1274
|
expect(mockAnalyticsHandler.callCategory).to.equal('beta-search');
|
|
1236
1275
|
expect(mockAnalyticsHandler.callAction).to.equal('displayMode');
|
|
@@ -1239,12 +1278,18 @@ describe('Collection Browser', () => {
|
|
|
1239
1278
|
// testing: `baseNavigationUrl`
|
|
1240
1279
|
el.baseNavigationUrl = 'https://funtestsite.com';
|
|
1241
1280
|
await el.updateComplete;
|
|
1242
|
-
expect(
|
|
1281
|
+
expect(
|
|
1282
|
+
infiniteScrollerRefreshSpy.callCount,
|
|
1283
|
+
'5th Infinite Scroller Refresh'
|
|
1284
|
+
).to.equal(5);
|
|
1243
1285
|
|
|
1244
1286
|
// testing: `baseImageUrl`
|
|
1245
1287
|
el.baseImageUrl = 'https://funtestsiteforimages.com';
|
|
1246
1288
|
await el.updateComplete;
|
|
1247
|
-
expect(
|
|
1289
|
+
expect(
|
|
1290
|
+
infiniteScrollerRefreshSpy.callCount,
|
|
1291
|
+
'6th Infinite Scroller Refresh'
|
|
1292
|
+
).to.equal(6);
|
|
1248
1293
|
});
|
|
1249
1294
|
|
|
1250
1295
|
it('query the search service for single result', async () => {
|
|
@@ -1401,9 +1446,6 @@ describe('Collection Browser', () => {
|
|
|
1401
1446
|
</collection-browser>`
|
|
1402
1447
|
);
|
|
1403
1448
|
|
|
1404
|
-
await el.initialSearchComplete;
|
|
1405
|
-
await el.updateComplete;
|
|
1406
|
-
|
|
1407
1449
|
el.baseQuery = 'bar';
|
|
1408
1450
|
await el.updateComplete;
|
|
1409
1451
|
|
|
@@ -1439,9 +1481,6 @@ describe('Collection Browser', () => {
|
|
|
1439
1481
|
</collection-browser>`
|
|
1440
1482
|
);
|
|
1441
1483
|
|
|
1442
|
-
await el.initialSearchComplete;
|
|
1443
|
-
await el.updateComplete;
|
|
1444
|
-
|
|
1445
1484
|
el.withinCollection = 'bar';
|
|
1446
1485
|
await el.updateComplete;
|
|
1447
1486
|
|
|
@@ -1562,10 +1601,16 @@ describe('Collection Browser', () => {
|
|
|
1562
1601
|
// Remove checked tiles and verify that we only kept the second tile
|
|
1563
1602
|
el.removeCheckedTiles();
|
|
1564
1603
|
await el.updateComplete;
|
|
1565
|
-
|
|
1604
|
+
expect(el?.dataSource?.size, 'data source count').to.equal(1);
|
|
1605
|
+
|
|
1606
|
+
tiles = el.shadowRoot
|
|
1607
|
+
?.querySelector('infinite-scroller')!
|
|
1608
|
+
.shadowRoot?.querySelectorAll('tile-dispatcher');
|
|
1566
1609
|
expect(tiles).to.exist;
|
|
1567
|
-
expect(
|
|
1568
|
-
|
|
1610
|
+
expect(
|
|
1611
|
+
tiles!.length,
|
|
1612
|
+
'tile count after `el.removeCheckedTiles()`'
|
|
1613
|
+
).to.equal(1);
|
|
1569
1614
|
});
|
|
1570
1615
|
|
|
1571
1616
|
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 () => {
|
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
|
};
|