@internetarchive/collection-browser 2.13.2-alpha-webdev7687.7 → 2.14.1-alpha-webdev7680.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/test/collection-browser.test.js +36 -0
- package/dist/test/collection-browser.test.js.map +1 -1
- package/dist/test/mocks/mock-search-responses.d.ts +1 -0
- package/dist/test/mocks/mock-search-responses.js +64 -0
- package/dist/test/mocks/mock-search-responses.js.map +1 -1
- package/dist/test/mocks/mock-search-service.js +2 -1
- package/dist/test/mocks/mock-search-service.js.map +1 -1
- package/dist/test/restoration-state-handler.test.js +1 -1
- package/dist/test/restoration-state-handler.test.js.map +1 -1
- package/package.json +3 -3
- package/test/collection-browser.test.ts +54 -0
- package/test/mocks/mock-search-responses.ts +68 -0
- package/test/mocks/mock-search-service.ts +2 -0
- package/test/restoration-state-handler.test.ts +1 -4
|
@@ -972,6 +972,60 @@ describe('Collection Browser', () => {
|
|
|
972
972
|
});
|
|
973
973
|
});
|
|
974
974
|
|
|
975
|
+
it('applies correct search filter when TV clip filter set to commercials', async () => {
|
|
976
|
+
const searchService = new MockSearchService();
|
|
977
|
+
const el = await fixture<CollectionBrowser>(
|
|
978
|
+
html`<collection-browser .searchService=${searchService}>
|
|
979
|
+
</collection-browser>`,
|
|
980
|
+
);
|
|
981
|
+
|
|
982
|
+
el.baseQuery = 'tv-fields';
|
|
983
|
+
el.searchType = SearchType.TV;
|
|
984
|
+
el.tvClipFilter = 'commercials';
|
|
985
|
+
await el.updateComplete;
|
|
986
|
+
await el.initialSearchComplete;
|
|
987
|
+
|
|
988
|
+
expect(searchService.searchParams?.filters?.ad_id?.['*']).to.equal(
|
|
989
|
+
FilterConstraint.INCLUDE,
|
|
990
|
+
);
|
|
991
|
+
});
|
|
992
|
+
|
|
993
|
+
it('applies correct search filter when TV clip filter set to factchecks', async () => {
|
|
994
|
+
const searchService = new MockSearchService();
|
|
995
|
+
const el = await fixture<CollectionBrowser>(
|
|
996
|
+
html`<collection-browser .searchService=${searchService}>
|
|
997
|
+
</collection-browser>`,
|
|
998
|
+
);
|
|
999
|
+
|
|
1000
|
+
el.baseQuery = 'tv-fields';
|
|
1001
|
+
el.searchType = SearchType.TV;
|
|
1002
|
+
el.tvClipFilter = 'factchecks';
|
|
1003
|
+
await el.updateComplete;
|
|
1004
|
+
await el.initialSearchComplete;
|
|
1005
|
+
|
|
1006
|
+
expect(searchService.searchParams?.filters?.factcheck?.['*']).to.equal(
|
|
1007
|
+
FilterConstraint.INCLUDE,
|
|
1008
|
+
);
|
|
1009
|
+
});
|
|
1010
|
+
|
|
1011
|
+
it('applies correct search filter when TV clip filter set to quotes', async () => {
|
|
1012
|
+
const searchService = new MockSearchService();
|
|
1013
|
+
const el = await fixture<CollectionBrowser>(
|
|
1014
|
+
html`<collection-browser .searchService=${searchService}>
|
|
1015
|
+
</collection-browser>`,
|
|
1016
|
+
);
|
|
1017
|
+
|
|
1018
|
+
el.baseQuery = 'tv-fields';
|
|
1019
|
+
el.searchType = SearchType.TV;
|
|
1020
|
+
el.tvClipFilter = 'quotes';
|
|
1021
|
+
await el.updateComplete;
|
|
1022
|
+
await el.initialSearchComplete;
|
|
1023
|
+
|
|
1024
|
+
expect(searchService.searchParams?.filters?.clip?.['1']).to.equal(
|
|
1025
|
+
FilterConstraint.INCLUDE,
|
|
1026
|
+
);
|
|
1027
|
+
});
|
|
1028
|
+
|
|
975
1029
|
it('resets letter filters when query changes', async () => {
|
|
976
1030
|
const searchService = new MockSearchService();
|
|
977
1031
|
const el = await fixture<CollectionBrowser>(
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
SearchServiceError,
|
|
8
8
|
TextHit,
|
|
9
9
|
} from '@internetarchive/search-service';
|
|
10
|
+
import { TvClipHit } from '@internetarchive/search-service/dist/src/models/hit-types/tv-clip-hit';
|
|
10
11
|
import { WebArchiveHit } from '@internetarchive/search-service/dist/src/models/hit-types/web-archive-hit';
|
|
11
12
|
import { SearchServiceErrorType } from '@internetarchive/search-service/dist/src/search-service-error';
|
|
12
13
|
|
|
@@ -117,6 +118,73 @@ export const getMockSuccessManyFields: () => Result<
|
|
|
117
118
|
},
|
|
118
119
|
});
|
|
119
120
|
|
|
121
|
+
export const getMockSuccessTvFields: () => Result<
|
|
122
|
+
SearchResponse,
|
|
123
|
+
SearchServiceError
|
|
124
|
+
> = () => ({
|
|
125
|
+
success: {
|
|
126
|
+
request: {
|
|
127
|
+
kind: 'hits',
|
|
128
|
+
clientParameters: {
|
|
129
|
+
user_query: 'tv-fields',
|
|
130
|
+
sort: [],
|
|
131
|
+
},
|
|
132
|
+
backendRequests: {
|
|
133
|
+
primary: {
|
|
134
|
+
kind: 'hits',
|
|
135
|
+
finalized_parameters: {
|
|
136
|
+
user_query: 'tv-fields',
|
|
137
|
+
sort: [],
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
rawResponse: {},
|
|
143
|
+
sessionContext: {},
|
|
144
|
+
response: {
|
|
145
|
+
totalResults: 1,
|
|
146
|
+
returnedCount: 1,
|
|
147
|
+
results: [
|
|
148
|
+
new TvClipHit({
|
|
149
|
+
fields: {
|
|
150
|
+
identifier: 'foo',
|
|
151
|
+
ad_id: ['foo-ad'],
|
|
152
|
+
clip: true,
|
|
153
|
+
collection: ['foo', 'bar', 'tvnews'],
|
|
154
|
+
creator: ['baz', 'boop'],
|
|
155
|
+
date: '2010-01-03T01:23:45Z',
|
|
156
|
+
addeddate: '2010-01-01T01:23:45Z',
|
|
157
|
+
publicdate: '2010-01-02T01:23:45Z',
|
|
158
|
+
reviewdate: '2010-01-04T01:23:45Z',
|
|
159
|
+
description: 'foo bar baz',
|
|
160
|
+
downloads: 246,
|
|
161
|
+
factcheck: ['https://foo.bar'],
|
|
162
|
+
files_count: 75,
|
|
163
|
+
indexflag: ['index', 'nonoindex'],
|
|
164
|
+
item_size: 123456,
|
|
165
|
+
language: 'eng',
|
|
166
|
+
mediatype: 'movies',
|
|
167
|
+
num_favorites: 12,
|
|
168
|
+
nclips: 34,
|
|
169
|
+
source: 'foo bar',
|
|
170
|
+
start: '1234',
|
|
171
|
+
subject: ['baz', 'quux'],
|
|
172
|
+
title: 'Foo Bar',
|
|
173
|
+
week: 50,
|
|
174
|
+
year: 2010,
|
|
175
|
+
__href__: 'https://archive.org/details/foo',
|
|
176
|
+
__img__: '//services/img/foo',
|
|
177
|
+
},
|
|
178
|
+
}),
|
|
179
|
+
],
|
|
180
|
+
},
|
|
181
|
+
responseHeader: {
|
|
182
|
+
succeeded: true,
|
|
183
|
+
query_time: 0,
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
});
|
|
187
|
+
|
|
120
188
|
export const getMockSuccessWithYearHistogramAggs: () => Result<
|
|
121
189
|
SearchResponse,
|
|
122
190
|
SearchServiceError
|
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
getMockSuccessNoResults,
|
|
32
32
|
getMockSuccessWithWebArchiveHits,
|
|
33
33
|
getMockSuccessWithManyAggregations,
|
|
34
|
+
getMockSuccessTvFields,
|
|
34
35
|
} from './mock-search-responses';
|
|
35
36
|
|
|
36
37
|
const responses: Record<
|
|
@@ -56,6 +57,7 @@ const responses: Record<
|
|
|
56
57
|
'web-archive': getMockSuccessWithWebArchiveHits,
|
|
57
58
|
'more-facets': getMockSuccessWithManyAggregations,
|
|
58
59
|
'many-fields': getMockSuccessManyFields,
|
|
60
|
+
'tv-fields': getMockSuccessTvFields,
|
|
59
61
|
'no-results': getMockSuccessNoResults,
|
|
60
62
|
error: getMockErrorResult,
|
|
61
63
|
malformed: getMockMalformedResult,
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { SearchType } from '@internetarchive/search-service';
|
|
2
2
|
import { expect } from '@open-wc/testing';
|
|
3
3
|
import { SortField, getDefaultSelectedFacets } from '../src/models';
|
|
4
|
-
import {
|
|
5
|
-
RestorationState,
|
|
6
|
-
RestorationStateHandler,
|
|
7
|
-
} from '../src/restoration-state-handler';
|
|
4
|
+
import { RestorationStateHandler } from '../src/restoration-state-handler';
|
|
8
5
|
|
|
9
6
|
describe('Restoration state handler', () => {
|
|
10
7
|
it('should restore query from URL', async () => {
|