@internetarchive/collection-browser 1.6.0 → 1.7.0
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/src/collection-browser.d.ts +13 -0
- package/dist/src/collection-browser.js +62 -5
- package/dist/src/collection-browser.js.map +1 -1
- package/dist/src/models.d.ts +2 -1
- package/dist/src/models.js +5 -1
- package/dist/src/models.js.map +1 -1
- package/dist/src/sort-filter-bar/sort-filter-bar.d.ts +9 -0
- package/dist/src/sort-filter-bar/sort-filter-bar.js +62 -24
- package/dist/src/sort-filter-bar/sort-filter-bar.js.map +1 -1
- package/dist/src/tiles/list/tile-list.js +7 -3
- package/dist/src/tiles/list/tile-list.js.map +1 -1
- package/dist/test/collection-browser.test.js +60 -2
- package/dist/test/collection-browser.test.js.map +1 -1
- package/dist/test/mocks/mock-search-responses.d.ts +2 -0
- package/dist/test/mocks/mock-search-responses.js +84 -0
- package/dist/test/mocks/mock-search-responses.js.map +1 -1
- package/dist/test/mocks/mock-search-service.js +6 -3
- package/dist/test/mocks/mock-search-service.js.map +1 -1
- package/package.json +1 -1
- package/src/collection-browser.ts +64 -4
- package/src/models.ts +6 -2
- package/src/sort-filter-bar/sort-filter-bar.ts +73 -26
- package/src/tiles/list/tile-list.ts +7 -3
- package/test/collection-browser.test.ts +79 -2
- package/test/mocks/mock-search-responses.ts +92 -0
- package/test/mocks/mock-search-service.ts +7 -1
|
@@ -590,6 +590,98 @@ export const getMockSuccessExtraQuotedHref: () => Result<
|
|
|
590
590
|
},
|
|
591
591
|
});
|
|
592
592
|
|
|
593
|
+
export const getMockSuccessWithDefaultSort: () => Result<
|
|
594
|
+
SearchResponse,
|
|
595
|
+
SearchServiceError
|
|
596
|
+
> = () => ({
|
|
597
|
+
success: {
|
|
598
|
+
request: {
|
|
599
|
+
kind: 'hits',
|
|
600
|
+
clientParameters: {
|
|
601
|
+
user_query: 'default-sort',
|
|
602
|
+
sort: [],
|
|
603
|
+
},
|
|
604
|
+
backendRequests: {
|
|
605
|
+
primary: {
|
|
606
|
+
kind: 'hits',
|
|
607
|
+
finalized_parameters: {
|
|
608
|
+
user_query: 'default-sort',
|
|
609
|
+
sort: ['titleSorter', 'identifier'],
|
|
610
|
+
},
|
|
611
|
+
},
|
|
612
|
+
},
|
|
613
|
+
},
|
|
614
|
+
rawResponse: {},
|
|
615
|
+
response: {
|
|
616
|
+
totalResults: 1,
|
|
617
|
+
returnedCount: 1,
|
|
618
|
+
results: [
|
|
619
|
+
new ItemHit({
|
|
620
|
+
fields: {
|
|
621
|
+
identifier: 'foo',
|
|
622
|
+
title: 'Foo',
|
|
623
|
+
},
|
|
624
|
+
}),
|
|
625
|
+
],
|
|
626
|
+
collectionExtraInfo: {
|
|
627
|
+
public_metadata: {
|
|
628
|
+
'sort-by': 'titleSorter',
|
|
629
|
+
},
|
|
630
|
+
},
|
|
631
|
+
},
|
|
632
|
+
responseHeader: {
|
|
633
|
+
succeeded: true,
|
|
634
|
+
query_time: 0,
|
|
635
|
+
},
|
|
636
|
+
},
|
|
637
|
+
});
|
|
638
|
+
|
|
639
|
+
export const getMockSuccessWithConciseDefaultSort: () => Result<
|
|
640
|
+
SearchResponse,
|
|
641
|
+
SearchServiceError
|
|
642
|
+
> = () => ({
|
|
643
|
+
success: {
|
|
644
|
+
request: {
|
|
645
|
+
kind: 'hits',
|
|
646
|
+
clientParameters: {
|
|
647
|
+
user_query: 'default-sort-concise',
|
|
648
|
+
sort: [],
|
|
649
|
+
},
|
|
650
|
+
backendRequests: {
|
|
651
|
+
primary: {
|
|
652
|
+
kind: 'hits',
|
|
653
|
+
finalized_parameters: {
|
|
654
|
+
user_query: 'default-sort-concise',
|
|
655
|
+
sort: ['addeddate:desc', 'identifier'],
|
|
656
|
+
},
|
|
657
|
+
},
|
|
658
|
+
},
|
|
659
|
+
},
|
|
660
|
+
rawResponse: {},
|
|
661
|
+
response: {
|
|
662
|
+
totalResults: 1,
|
|
663
|
+
returnedCount: 1,
|
|
664
|
+
results: [
|
|
665
|
+
new ItemHit({
|
|
666
|
+
fields: {
|
|
667
|
+
identifier: 'foo',
|
|
668
|
+
title: 'Foo',
|
|
669
|
+
},
|
|
670
|
+
}),
|
|
671
|
+
],
|
|
672
|
+
collectionExtraInfo: {
|
|
673
|
+
public_metadata: {
|
|
674
|
+
'sort-by': '-addeddate',
|
|
675
|
+
},
|
|
676
|
+
},
|
|
677
|
+
},
|
|
678
|
+
responseHeader: {
|
|
679
|
+
succeeded: true,
|
|
680
|
+
query_time: 0,
|
|
681
|
+
},
|
|
682
|
+
},
|
|
683
|
+
});
|
|
684
|
+
|
|
593
685
|
export const getMockErrorResult: () => Result<
|
|
594
686
|
SearchResponse,
|
|
595
687
|
SearchServiceError
|
|
@@ -22,6 +22,8 @@ import {
|
|
|
22
22
|
getMockSuccessWithCollectionTitles,
|
|
23
23
|
getMockSuccessWithCollectionAggregations,
|
|
24
24
|
getMockSuccessExtraQuotedHref,
|
|
25
|
+
getMockSuccessWithDefaultSort,
|
|
26
|
+
getMockSuccessWithConciseDefaultSort,
|
|
25
27
|
} from './mock-search-responses';
|
|
26
28
|
|
|
27
29
|
const responses: Record<
|
|
@@ -39,6 +41,8 @@ const responses: Record<
|
|
|
39
41
|
'collection-titles': getMockSuccessWithCollectionTitles,
|
|
40
42
|
'collection-aggregations': getMockSuccessWithCollectionAggregations,
|
|
41
43
|
'extra-quoted-href': getMockSuccessExtraQuotedHref,
|
|
44
|
+
'default-sort': getMockSuccessWithDefaultSort,
|
|
45
|
+
'default-sort-concise': getMockSuccessWithConciseDefaultSort,
|
|
42
46
|
error: getMockErrorResult,
|
|
43
47
|
malformed: getMockMalformedResult,
|
|
44
48
|
};
|
|
@@ -78,8 +82,10 @@ export class MockSearchService implements SearchServiceInterface {
|
|
|
78
82
|
});
|
|
79
83
|
}
|
|
80
84
|
|
|
85
|
+
const responseKey =
|
|
86
|
+
(this.searchParams.query || this.searchParams.pageTarget) ?? '';
|
|
81
87
|
const resultFn: () => Result<SearchResponse, SearchServiceError> =
|
|
82
|
-
responses[
|
|
88
|
+
responses[responseKey] ?? getMockSuccessMultipleResults;
|
|
83
89
|
let result = resultFn();
|
|
84
90
|
|
|
85
91
|
// with-sort query has special handling
|