@internetarchive/collection-browser 2.13.2-alpha-webdev7687.6 → 2.13.2-alpha-webdev7687.7
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/models.d.ts +6 -0
- package/dist/src/models.js +13 -7
- package/dist/src/models.js.map +1 -1
- package/dist/src/restoration-state-handler.js +3 -0
- package/dist/src/restoration-state-handler.js.map +1 -1
- package/dist/src/tiles/grid/tile-stats.js +1 -6
- package/dist/src/tiles/grid/tile-stats.js.map +1 -1
- package/dist/src/tiles/list/tile-list-compact.js +3 -9
- package/dist/src/tiles/list/tile-list-compact.js.map +1 -1
- package/dist/src/tiles/list/tile-list.js +1 -8
- package/dist/src/tiles/list/tile-list.js.map +1 -1
- package/dist/src/tiles/tile-mediatype-icon.d.ts +0 -4
- package/dist/src/tiles/tile-mediatype-icon.js +21 -26
- package/dist/src/tiles/tile-mediatype-icon.js.map +1 -1
- package/dist/test/restoration-state-handler.test.js +58 -1
- package/dist/test/restoration-state-handler.test.js.map +1 -1
- package/dist/test/tiles/tile-mediatype-icon.test.js +83 -26
- package/dist/test/tiles/tile-mediatype-icon.test.js.map +1 -1
- package/package.json +1 -1
- package/src/models.ts +13 -7
- package/src/restoration-state-handler.ts +3 -0
- package/src/tiles/grid/tile-stats.ts +1 -6
- package/src/tiles/list/tile-list-compact.ts +1 -7
- package/src/tiles/list/tile-list.ts +1 -7
- package/src/tiles/tile-mediatype-icon.ts +21 -19
- package/test/restoration-state-handler.test.ts +71 -1
- package/test/tiles/tile-mediatype-icon.test.ts +89 -26
|
@@ -3,11 +3,19 @@ import { html } from 'lit';
|
|
|
3
3
|
import type { TileMediatypeIcon } from '../../src/tiles/tile-mediatype-icon';
|
|
4
4
|
|
|
5
5
|
import '../../src/tiles/tile-mediatype-icon';
|
|
6
|
+
import { TileModel } from '../../src/models';
|
|
7
|
+
import { MediaType } from '@internetarchive/field-parsers';
|
|
6
8
|
|
|
7
9
|
describe('Mediatype Icon', () => {
|
|
10
|
+
let model: TileModel;
|
|
11
|
+
beforeEach(() => {
|
|
12
|
+
model = new TileModel({});
|
|
13
|
+
});
|
|
14
|
+
|
|
8
15
|
it('renders component', async () => {
|
|
16
|
+
model.mediatype = 'texts';
|
|
9
17
|
const el = await fixture<TileMediatypeIcon>(html`
|
|
10
|
-
<tile-mediatype-icon
|
|
18
|
+
<tile-mediatype-icon .model=${model}></tile-mediatype-icon>
|
|
11
19
|
`);
|
|
12
20
|
|
|
13
21
|
const iconDiv = el.shadowRoot?.querySelector('#icon');
|
|
@@ -15,8 +23,9 @@ describe('Mediatype Icon', () => {
|
|
|
15
23
|
});
|
|
16
24
|
|
|
17
25
|
it('renders basic mediatype correctly', async () => {
|
|
26
|
+
model.mediatype = 'movies';
|
|
18
27
|
const el = await fixture<TileMediatypeIcon>(html`
|
|
19
|
-
<tile-mediatype-icon
|
|
28
|
+
<tile-mediatype-icon .model=${model}></tile-mediatype-icon>
|
|
20
29
|
`);
|
|
21
30
|
|
|
22
31
|
const iconDiv = el.shadowRoot?.querySelector('#icon') as HTMLDivElement;
|
|
@@ -26,36 +35,60 @@ describe('Mediatype Icon', () => {
|
|
|
26
35
|
});
|
|
27
36
|
|
|
28
37
|
it('renders TV mediatype', async () => {
|
|
38
|
+
model.mediatype = 'movies';
|
|
39
|
+
model.collections = ['tvnews'];
|
|
29
40
|
const el = await fixture<TileMediatypeIcon>(html`
|
|
30
|
-
<tile-mediatype-icon
|
|
31
|
-
mediatype="movies"
|
|
32
|
-
.collections=${['tvnews']}
|
|
33
|
-
></tile-mediatype-icon>
|
|
41
|
+
<tile-mediatype-icon .model=${model}></tile-mediatype-icon>
|
|
34
42
|
`);
|
|
35
43
|
|
|
36
44
|
const iconDiv = el.shadowRoot?.querySelector('#icon') as HTMLDivElement;
|
|
37
45
|
expect(iconDiv.title).to.equal('TV');
|
|
38
46
|
});
|
|
39
47
|
|
|
40
|
-
it('renders TV Commercial mediatype', async () => {
|
|
48
|
+
it('renders TV Commercial mediatype for TV items with ad ids', async () => {
|
|
49
|
+
model.mediatype = 'movies';
|
|
50
|
+
model.collections = ['tvnews'];
|
|
51
|
+
model.adIds = ['foo'];
|
|
41
52
|
const el = await fixture<TileMediatypeIcon>(html`
|
|
42
|
-
<tile-mediatype-icon
|
|
43
|
-
mediatype="movies"
|
|
44
|
-
.collections=${['tvnews', 'tv_ads']}
|
|
45
|
-
></tile-mediatype-icon>
|
|
53
|
+
<tile-mediatype-icon .model=${model}></tile-mediatype-icon>
|
|
46
54
|
`);
|
|
47
55
|
|
|
48
56
|
const iconDiv = el.shadowRoot?.querySelector('#icon') as HTMLDivElement;
|
|
49
57
|
expect(iconDiv.title).to.equal('TV Commercial');
|
|
50
58
|
});
|
|
51
59
|
|
|
52
|
-
it('renders TV
|
|
60
|
+
it('renders TV Commercial mediatype for TV items in tv_ads collection', async () => {
|
|
61
|
+
model.mediatype = 'movies';
|
|
62
|
+
model.collections = ['tvnews', 'tv_ads'];
|
|
53
63
|
const el = await fixture<TileMediatypeIcon>(html`
|
|
54
|
-
<tile-mediatype-icon
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
64
|
+
<tile-mediatype-icon .model=${model}></tile-mediatype-icon>
|
|
65
|
+
`);
|
|
66
|
+
|
|
67
|
+
const iconDiv = el.shadowRoot?.querySelector('#icon') as HTMLDivElement;
|
|
68
|
+
expect(iconDiv.title).to.equal('TV Commercial');
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('renders TV Fact Check mediatype for TV search results with fact check URLs', async () => {
|
|
72
|
+
model.hitType = 'tv_clip';
|
|
73
|
+
model.hitRequestSource = 'search_query';
|
|
74
|
+
model.mediatype = 'movies';
|
|
75
|
+
model.collections = ['tvnews'];
|
|
76
|
+
model.factChecks = ['https://example.com'];
|
|
77
|
+
const el = await fixture<TileMediatypeIcon>(html`
|
|
78
|
+
<tile-mediatype-icon .model=${model}></tile-mediatype-icon>
|
|
79
|
+
`);
|
|
80
|
+
|
|
81
|
+
const iconDiv = el.shadowRoot?.querySelector('#icon') as HTMLDivElement;
|
|
82
|
+
expect(iconDiv.title).to.equal('TV Fact Check');
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it('renders TV Fact Check mediatype for TV search results in factchecked collection', async () => {
|
|
86
|
+
model.hitType = 'tv_clip';
|
|
87
|
+
model.hitRequestSource = 'search_query';
|
|
88
|
+
model.mediatype = 'movies';
|
|
89
|
+
model.collections = ['tvnews', 'factchecked'];
|
|
90
|
+
const el = await fixture<TileMediatypeIcon>(html`
|
|
91
|
+
<tile-mediatype-icon .model=${model}></tile-mediatype-icon>
|
|
59
92
|
`);
|
|
60
93
|
|
|
61
94
|
const iconDiv = el.shadowRoot?.querySelector('#icon') as HTMLDivElement;
|
|
@@ -63,11 +96,41 @@ describe('Mediatype Icon', () => {
|
|
|
63
96
|
});
|
|
64
97
|
|
|
65
98
|
it('does not use TV Fact Check mediatype for non-search results', async () => {
|
|
99
|
+
model.hitType = 'tv_clip';
|
|
100
|
+
model.hitRequestSource = 'collection_members';
|
|
101
|
+
model.mediatype = 'movies';
|
|
102
|
+
model.collections = ['tvnews'];
|
|
103
|
+
model.factChecks = ['https://example.com'];
|
|
104
|
+
const el = await fixture<TileMediatypeIcon>(html`
|
|
105
|
+
<tile-mediatype-icon .model=${model}></tile-mediatype-icon>
|
|
106
|
+
`);
|
|
107
|
+
|
|
108
|
+
const iconDiv = el.shadowRoot?.querySelector('#icon') as HTMLDivElement;
|
|
109
|
+
expect(iconDiv.title).to.equal('TV');
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it('renders TV Quote mediatype for TV search results that are clips', async () => {
|
|
113
|
+
model.hitType = 'tv_clip';
|
|
114
|
+
model.hitRequestSource = 'search_query';
|
|
115
|
+
model.mediatype = 'movies';
|
|
116
|
+
model.collections = ['tvnews'];
|
|
117
|
+
model.isClip = true;
|
|
118
|
+
const el = await fixture<TileMediatypeIcon>(html`
|
|
119
|
+
<tile-mediatype-icon .model=${model}></tile-mediatype-icon>
|
|
120
|
+
`);
|
|
121
|
+
|
|
122
|
+
const iconDiv = el.shadowRoot?.querySelector('#icon') as HTMLDivElement;
|
|
123
|
+
expect(iconDiv.title).to.equal('TV Quote');
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it('does not use TV Quote mediatype for non-search results', async () => {
|
|
127
|
+
model.hitType = 'tv_clip';
|
|
128
|
+
model.hitRequestSource = 'collection_members';
|
|
129
|
+
model.mediatype = 'movies';
|
|
130
|
+
model.collections = ['tvnews'];
|
|
131
|
+
model.isClip = true;
|
|
66
132
|
const el = await fixture<TileMediatypeIcon>(html`
|
|
67
|
-
<tile-mediatype-icon
|
|
68
|
-
mediatype="movies"
|
|
69
|
-
.collections=${['tvnews', 'factchecked']}
|
|
70
|
-
></tile-mediatype-icon>
|
|
133
|
+
<tile-mediatype-icon .model=${model}></tile-mediatype-icon>
|
|
71
134
|
`);
|
|
72
135
|
|
|
73
136
|
const iconDiv = el.shadowRoot?.querySelector('#icon') as HTMLDivElement;
|
|
@@ -75,11 +138,10 @@ describe('Mediatype Icon', () => {
|
|
|
75
138
|
});
|
|
76
139
|
|
|
77
140
|
it('renders radio mediatype', async () => {
|
|
141
|
+
model.mediatype = 'audio';
|
|
142
|
+
model.collections = ['radio'];
|
|
78
143
|
const el = await fixture<TileMediatypeIcon>(html`
|
|
79
|
-
<tile-mediatype-icon
|
|
80
|
-
mediatype="audio"
|
|
81
|
-
.collections=${['radio']}
|
|
82
|
-
></tile-mediatype-icon>
|
|
144
|
+
<tile-mediatype-icon .model=${model}></tile-mediatype-icon>
|
|
83
145
|
`);
|
|
84
146
|
|
|
85
147
|
const iconDiv = el.shadowRoot?.querySelector('#icon') as HTMLDivElement;
|
|
@@ -87,8 +149,9 @@ describe('Mediatype Icon', () => {
|
|
|
87
149
|
});
|
|
88
150
|
|
|
89
151
|
it('renders no icon if mediatype is unrecognized', async () => {
|
|
152
|
+
model.mediatype = 'foobar' as MediaType;
|
|
90
153
|
const el = await fixture<TileMediatypeIcon>(html`
|
|
91
|
-
<tile-mediatype-icon
|
|
154
|
+
<tile-mediatype-icon .model=${model}></tile-mediatype-icon>
|
|
92
155
|
`);
|
|
93
156
|
|
|
94
157
|
const iconDiv = el.shadowRoot?.querySelector('#icon');
|