@internetarchive/collection-browser 4.1.1-alpha-webdev8185.1 → 4.1.1

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.
@@ -13,7 +13,6 @@ import type { SortDirection } from '@internetarchive/search-service';
13
13
  import {
14
14
  CollectionDisplayMode,
15
15
  defaultSortAvailability,
16
- type ExplicitSortField,
17
16
  PrefixFilterCounts,
18
17
  PrefixFilterType,
19
18
  SORT_OPTIONS,
@@ -43,8 +42,10 @@ export class SortFilterBar extends LitElement {
43
42
  @property({ type: String }) defaultSortDirection: SortDirection | null = null;
44
43
 
45
44
  /** The default sort field to use if none is set */
46
- @property({ type: String }) defaultSortField: ExplicitSortField =
47
- SortField.relevance;
45
+ @property({ type: String }) defaultSortField: Exclude<
46
+ SortField,
47
+ SortField.default
48
+ > = SortField.relevance;
48
49
 
49
50
  /** The current sort direction (asc/desc), or null if none is set */
50
51
  @property({ type: String }) sortDirection: SortDirection | null = null;
@@ -1313,19 +1313,20 @@ describe('Collection Browser', () => {
1313
1313
  );
1314
1314
  });
1315
1315
 
1316
- it('sets default sort from externally-provided values', async () => {
1316
+ it('sets default sort from collection metadata', async () => {
1317
1317
  const searchService = new MockSearchService();
1318
1318
  const el = await fixture<CollectionBrowser>(
1319
1319
  html`<collection-browser
1320
1320
  .searchService=${searchService}
1321
1321
  .baseNavigationUrl=${''}
1322
- .withinCollection=${'test-collection'}
1323
- .defaultSortField=${SortField.title}
1324
- .defaultSortDirection=${'asc'}
1325
1322
  ></collection-browser>`,
1326
1323
  );
1327
1324
 
1325
+ el.withinCollection = 'default-sort';
1326
+ await el.updateComplete;
1327
+ await el.initialSearchComplete;
1328
1328
  await el.updateComplete;
1329
+ await aTimeout(50);
1329
1330
 
1330
1331
  const sortBar = el.shadowRoot?.querySelector(
1331
1332
  'sort-filter-bar',
@@ -1337,19 +1338,20 @@ describe('Collection Browser', () => {
1337
1338
  expect(sortBar.sortDirection).to.be.null;
1338
1339
  });
1339
1340
 
1340
- it('reflects updated default sort field/direction on sort bar', async () => {
1341
+ it('sets default sort from collection metadata in "-field" format', async () => {
1341
1342
  const searchService = new MockSearchService();
1342
1343
  const el = await fixture<CollectionBrowser>(
1343
1344
  html`<collection-browser
1344
1345
  .searchService=${searchService}
1345
1346
  .baseNavigationUrl=${''}
1346
- .withinCollection=${'test-collection'}
1347
- .defaultSortField=${SortField.dateadded}
1348
- .defaultSortDirection=${'desc'}
1349
1347
  ></collection-browser>`,
1350
1348
  );
1351
1349
 
1350
+ el.withinCollection = 'default-sort-concise';
1351
+ await el.updateComplete;
1352
+ await el.initialSearchComplete;
1352
1353
  await el.updateComplete;
1354
+ await aTimeout(50);
1353
1355
 
1354
1356
  const sortBar = el.shadowRoot?.querySelector(
1355
1357
  'sort-filter-bar',
@@ -1361,15 +1363,14 @@ describe('Collection Browser', () => {
1361
1363
  expect(sortBar.sortDirection).to.be.null;
1362
1364
  });
1363
1365
 
1364
- it('uses weekly views as default sort when set externally for profiles', async () => {
1366
+ it('falls back to weekly views default sorting on profiles when tab not set', async () => {
1365
1367
  const el = await fixture<CollectionBrowser>(
1366
1368
  html`<collection-browser
1367
1369
  .withinProfile=${'@foobar'}
1368
- .defaultSortField=${SortField.weeklyview}
1369
- .defaultSortDirection=${'desc'}
1370
1370
  ></collection-browser>`,
1371
1371
  );
1372
1372
 
1373
+ el.applyDefaultProfileSort();
1373
1374
  expect(el.defaultSortParam).to.deep.equal({
1374
1375
  field: 'week',
1375
1376
  direction: 'desc',
@@ -1402,19 +1403,20 @@ describe('Collection Browser', () => {
1402
1403
  expect(sortBar.sortDirection).to.be.null;
1403
1404
  });
1404
1405
 
1405
- it('uses date favorited sort as default when set externally for fav- collection', async () => {
1406
+ it('uses date favorited sort as default when targeting fav- collection', async () => {
1406
1407
  const searchService = new MockSearchService();
1407
1408
  const el = await fixture<CollectionBrowser>(
1408
1409
  html`<collection-browser
1409
1410
  .searchService=${searchService}
1410
1411
  .baseNavigationUrl=${''}
1411
- .withinCollection=${'fav-sort'}
1412
- .defaultSortField=${SortField.datefavorited}
1413
- .defaultSortDirection=${'desc'}
1414
1412
  ></collection-browser>`,
1415
1413
  );
1416
1414
 
1415
+ el.withinCollection = 'fav-sort';
1417
1416
  await el.updateComplete;
1417
+ await el.initialSearchComplete;
1418
+ await el.updateComplete;
1419
+ await aTimeout(50);
1418
1420
 
1419
1421
  const sortBar = el.shadowRoot?.querySelector(
1420
1422
  'sort-filter-bar',