@internetarchive/collection-browser 2.17.1-alpha-webdev7667.0 → 2.18.1-alpha1

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.
@@ -5,6 +5,7 @@ import { TileModel } from '../src/models';
5
5
  import type { ItemImage } from '../src/tiles/item-image';
6
6
 
7
7
  import '../src/tiles/item-image';
8
+ import { MediaType } from '@internetarchive/field-parsers';
8
9
 
9
10
  const baseImageUrl = 'https://archive.org';
10
11
  const testBookModel: TileModel = new TileModel({});
@@ -131,4 +132,89 @@ describe('ItemImage component', () => {
131
132
  expect(img).to.exist;
132
133
  expect(img?.getAttribute('src')).not.to.exist;
133
134
  });
135
+
136
+ it('should blur image if login required flag set', async () => {
137
+ const model = new TileModel({ identifier: 'foo' });
138
+ model.loginRequired = true;
139
+
140
+ const el = await fixture<ItemImage>(html`
141
+ <item-image
142
+ .isListTile=${false}
143
+ .isCompactTile=${false}
144
+ .model=${model}
145
+ .baseImageUrl=${baseImageUrl}
146
+ >
147
+ </item-image>
148
+ `);
149
+
150
+ const dropShadow = el.shadowRoot?.querySelector('.drop-shadow');
151
+ expect(dropShadow).to.exist;
152
+
153
+ const imgClasses = dropShadow?.querySelector('img')?.classList;
154
+ expect(imgClasses?.contains('blur')).to.be.true;
155
+ });
156
+
157
+ it('should blur image if content warning flag set', async () => {
158
+ const model = new TileModel({ identifier: 'foo' });
159
+ model.contentWarning = true;
160
+
161
+ const el = await fixture<ItemImage>(html`
162
+ <item-image
163
+ .isListTile=${false}
164
+ .isCompactTile=${false}
165
+ .model=${model}
166
+ .baseImageUrl=${baseImageUrl}
167
+ >
168
+ </item-image>
169
+ `);
170
+
171
+ const dropShadow = el.shadowRoot?.querySelector('.drop-shadow');
172
+ expect(dropShadow).to.exist;
173
+
174
+ const imgClasses = dropShadow?.querySelector('img')?.classList;
175
+ expect(imgClasses?.contains('blur')).to.be.true;
176
+ });
177
+
178
+ it('should not blur image if no login required nor content warning', async () => {
179
+ const model = new TileModel({ identifier: 'foo' });
180
+
181
+ const el = await fixture<ItemImage>(html`
182
+ <item-image
183
+ .isListTile=${false}
184
+ .isCompactTile=${false}
185
+ .model=${model}
186
+ .baseImageUrl=${baseImageUrl}
187
+ >
188
+ </item-image>
189
+ `);
190
+
191
+ const dropShadow = el.shadowRoot?.querySelector('.drop-shadow');
192
+ expect(dropShadow).to.exist;
193
+
194
+ const imgClasses = dropShadow?.querySelector('img')?.classList;
195
+ expect(imgClasses?.contains('blur')).to.be.false;
196
+ });
197
+
198
+ it('should not blur image if blurring is suppressed, regardless of content flags', async () => {
199
+ const model = new TileModel({ identifier: 'foo' });
200
+ model.loginRequired = true;
201
+ model.contentWarning = true;
202
+
203
+ const el = await fixture<ItemImage>(html`
204
+ <item-image
205
+ .isListTile=${false}
206
+ .isCompactTile=${false}
207
+ .model=${model}
208
+ .baseImageUrl=${baseImageUrl}
209
+ suppressBlurring
210
+ >
211
+ </item-image>
212
+ `);
213
+
214
+ const dropShadow = el.shadowRoot?.querySelector('.drop-shadow');
215
+ expect(dropShadow).to.exist;
216
+
217
+ const imgClasses = dropShadow?.querySelector('img')?.classList;
218
+ expect(imgClasses?.contains('blur')).to.be.false;
219
+ });
134
220
  });
@@ -291,6 +291,110 @@ export const getMockSuccessWithDateHistogramAggs: () => Result<
291
291
  },
292
292
  });
293
293
 
294
+ export const getMockSuccessArchiveOrgUserResult: () => Result<
295
+ SearchResponse,
296
+ SearchServiceError
297
+ > = () => ({
298
+ success: {
299
+ request: {
300
+ kind: 'hits',
301
+ clientParameters: {
302
+ user_query: 'archive-org-user-loggedin',
303
+ sort: [],
304
+ },
305
+ backendRequests: {
306
+ primary: {
307
+ kind: 'hits',
308
+ finalized_parameters: {
309
+ user_query: 'archive-org-user-loggedin',
310
+ sort: [],
311
+ },
312
+ },
313
+ },
314
+ },
315
+ rawResponse: {},
316
+ sessionContext: {
317
+ is_archive_user: true,
318
+ pps_relevant_user_preferences: {
319
+ display__blur_moderated_content: 'on',
320
+ },
321
+ },
322
+ response: {
323
+ totalResults: 2,
324
+ returnedCount: 2,
325
+ results: [
326
+ new ItemHit({
327
+ fields: {
328
+ identifier: 'foo',
329
+ collection: ['foo', 'loggedin', 'bar'],
330
+ __href__: '/foo',
331
+ },
332
+ }),
333
+ new ItemHit({
334
+ fields: {
335
+ identifier: 'bar',
336
+ collection: ['baz', 'boop'],
337
+ __href__: '/bar',
338
+ },
339
+ }),
340
+ ],
341
+ },
342
+ responseHeader: {
343
+ succeeded: true,
344
+ query_time: 0,
345
+ },
346
+ },
347
+ });
348
+
349
+ export const getMockSuccessArchiveOrgUserNoBlurResult: () => Result<
350
+ SearchResponse,
351
+ SearchServiceError
352
+ > = () => ({
353
+ success: {
354
+ request: {
355
+ kind: 'hits',
356
+ clientParameters: {
357
+ user_query: 'archive-org-user-loggedin-noblur',
358
+ sort: [],
359
+ },
360
+ backendRequests: {
361
+ primary: {
362
+ kind: 'hits',
363
+ finalized_parameters: {
364
+ user_query: 'archive-org-user-loggedin-noblur',
365
+ sort: [],
366
+ },
367
+ },
368
+ },
369
+ },
370
+ rawResponse: {},
371
+ sessionContext: {
372
+ is_archive_user: true,
373
+ pps_relevant_user_preferences: {
374
+ display__blur_moderated_content: 'off',
375
+ },
376
+ },
377
+ response: {
378
+ totalResults: 1,
379
+ returnedCount: 1,
380
+ results: [
381
+ new ItemHit({
382
+ fields: {
383
+ identifier: 'foo',
384
+ collection: ['loggedin'],
385
+ title: 'foo',
386
+ mediatype: 'texts',
387
+ },
388
+ }),
389
+ ],
390
+ },
391
+ responseHeader: {
392
+ succeeded: true,
393
+ query_time: 0,
394
+ },
395
+ },
396
+ });
397
+
294
398
  export const getMockSuccessLoggedInResult: () => Result<
295
399
  SearchResponse,
296
400
  SearchServiceError
@@ -34,6 +34,8 @@ import {
34
34
  getMockSuccessWithWebArchiveHits,
35
35
  getMockSuccessWithManyAggregations,
36
36
  getMockSuccessTvFields,
37
+ getMockSuccessArchiveOrgUserResult,
38
+ getMockSuccessArchiveOrgUserNoBlurResult,
37
39
  } from './mock-search-responses';
38
40
 
39
41
  const responses: Record<
@@ -47,6 +49,8 @@ const responses: Record<
47
49
  loggedin: getMockSuccessLoggedInResult,
48
50
  'no-preview': getMockSuccessNoPreviewResult,
49
51
  'loggedin-no-preview': getMockSuccessLoggedInAndNoPreviewResult,
52
+ 'archive-org-user-loggedin': getMockSuccessArchiveOrgUserResult,
53
+ 'archive-org-user-loggedin-noblur': getMockSuccessArchiveOrgUserNoBlurResult,
50
54
  'first-title': getMockSuccessFirstTitleResult,
51
55
  'first-creator': getMockSuccessFirstCreatorResult,
52
56
  'collection-titles': getMockSuccessWithCollectionTitles,
@@ -120,4 +124,11 @@ export class MockSearchService implements SearchServiceInterface {
120
124
 
121
125
  return result;
122
126
  }
127
+
128
+ async itemDetails(
129
+ _: string,
130
+ ): Promise<Result<SearchResponse, SearchServiceError>> {
131
+ // We don't currently use the itemDetails method in collection-browser
132
+ throw new Error('not implemented');
133
+ }
123
134
  }
@@ -1,30 +1,30 @@
1
- // import { hmrPlugin, presets } from '@open-wc/dev-server-hmr';
2
-
3
- /** Use Hot Module replacement by adding --hmr to the start command */
4
- const hmr = process.argv.includes('--hmr');
5
-
6
- export default /** @type {import('@web/dev-server').DevServerConfig} */ ({
7
- nodeResolve: true,
8
- open: '/',
9
- watch: !hmr,
10
-
11
- /** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
12
- // esbuildTarget: 'auto'
13
-
14
- /** Set appIndex to enable SPA routing */
15
- // appIndex: 'demo/index.html',
16
-
17
- /** Confgure bare import resolve plugin */
18
- // nodeResolve: {
19
- // exportConditions: ['browser', 'development']
20
- // },
21
-
22
- plugins: [
23
- /** Use Hot Module Replacement by uncommenting. Requires @open-wc/dev-server-hmr plugin */
24
- // hmr && hmrPlugin({ exclude: ['**/*/node_modules/**/*'], presets: [presets.litElement] }),
25
- ],
26
-
27
- http2: true,
28
- sslCert: './local.archive.org.cert',
29
- sslKey: './local.archive.org.key',
30
- });
1
+ // import { hmrPlugin, presets } from '@open-wc/dev-server-hmr';
2
+
3
+ /** Use Hot Module replacement by adding --hmr to the start command */
4
+ const hmr = process.argv.includes('--hmr');
5
+
6
+ export default /** @type {import('@web/dev-server').DevServerConfig} */ ({
7
+ nodeResolve: true,
8
+ open: '/',
9
+ watch: !hmr,
10
+
11
+ /** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
12
+ // esbuildTarget: 'auto'
13
+
14
+ /** Set appIndex to enable SPA routing */
15
+ // appIndex: 'demo/index.html',
16
+
17
+ /** Confgure bare import resolve plugin */
18
+ // nodeResolve: {
19
+ // exportConditions: ['browser', 'development']
20
+ // },
21
+
22
+ plugins: [
23
+ /** Use Hot Module Replacement by uncommenting. Requires @open-wc/dev-server-hmr plugin */
24
+ // hmr && hmrPlugin({ exclude: ['**/*/node_modules/**/*'], presets: [presets.litElement] }),
25
+ ],
26
+
27
+ http2: true,
28
+ sslCert: './local.archive.org.cert',
29
+ sslKey: './local.archive.org.key',
30
+ });
@@ -1,41 +1,41 @@
1
- // import { playwrightLauncher } from '@web/test-runner-playwright';
2
-
3
- const filteredLogs = ['Running in dev mode', 'lit-html is in dev mode'];
4
-
5
- export default /** @type {import("@web/test-runner").TestRunnerConfig} */ ({
6
- /** Test files to run */
7
- files: 'dist/test/**/*.test.js',
8
-
9
- /** Resolve bare module imports */
10
- nodeResolve: {
11
- exportConditions: ['browser', 'development'],
12
- },
13
-
14
- /** Filter out lit dev mode logs */
15
- filterBrowserLogs(log) {
16
- for (const arg of log.args) {
17
- if (typeof arg === 'string' && filteredLogs.some(l => arg.includes(l))) {
18
- return false;
19
- }
20
- }
21
- return true;
22
- },
23
-
24
- /** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
25
- // esbuildTarget: 'auto',
26
-
27
- /** Amount of browsers to run concurrently */
28
- // concurrentBrowsers: 2,
29
-
30
- /** Amount of test files per browser to test concurrently */
31
- // concurrency: 1,
32
-
33
- /** Browsers to run tests on */
34
- // browsers: [
35
- // playwrightLauncher({ product: 'chromium' }),
36
- // playwrightLauncher({ product: 'firefox' }),
37
- // playwrightLauncher({ product: 'webkit' }),
38
- // ],
39
-
40
- // See documentation for all available options
41
- });
1
+ // import { playwrightLauncher } from '@web/test-runner-playwright';
2
+
3
+ const filteredLogs = ['Running in dev mode', 'lit-html is in dev mode'];
4
+
5
+ export default /** @type {import("@web/test-runner").TestRunnerConfig} */ ({
6
+ /** Test files to run */
7
+ files: 'dist/test/**/*.test.js',
8
+
9
+ /** Resolve bare module imports */
10
+ nodeResolve: {
11
+ exportConditions: ['browser', 'development'],
12
+ },
13
+
14
+ /** Filter out lit dev mode logs */
15
+ filterBrowserLogs(log) {
16
+ for (const arg of log.args) {
17
+ if (typeof arg === 'string' && filteredLogs.some(l => arg.includes(l))) {
18
+ return false;
19
+ }
20
+ }
21
+ return true;
22
+ },
23
+
24
+ /** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
25
+ // esbuildTarget: 'auto',
26
+
27
+ /** Amount of browsers to run concurrently */
28
+ // concurrentBrowsers: 2,
29
+
30
+ /** Amount of test files per browser to test concurrently */
31
+ // concurrency: 1,
32
+
33
+ /** Browsers to run tests on */
34
+ // browsers: [
35
+ // playwrightLauncher({ product: 'chromium' }),
36
+ // playwrightLauncher({ product: 'firefox' }),
37
+ // playwrightLauncher({ product: 'webkit' }),
38
+ // ],
39
+
40
+ // See documentation for all available options
41
+ });