@internetarchive/collection-browser 4.5.0 → 4.5.1-alpha-webdev8221.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.
Files changed (70) hide show
  1. package/dist/index.js.map +1 -1
  2. package/dist/src/app-root.js +683 -683
  3. package/dist/src/app-root.js.map +1 -1
  4. package/dist/src/collection-browser.d.ts +0 -4
  5. package/dist/src/collection-browser.js +767 -776
  6. package/dist/src/collection-browser.js.map +1 -1
  7. package/dist/src/collection-facets/facet-row.js +143 -143
  8. package/dist/src/collection-facets/facet-row.js.map +1 -1
  9. package/dist/src/collection-facets/facets-template.js +24 -24
  10. package/dist/src/collection-facets/facets-template.js.map +1 -1
  11. package/dist/src/data-source/collection-browser-data-source-interface.d.ts +5 -0
  12. package/dist/src/data-source/collection-browser-data-source-interface.js.map +1 -1
  13. package/dist/src/data-source/collection-browser-data-source.d.ts +1 -1
  14. package/dist/src/data-source/collection-browser-data-source.js +8 -6
  15. package/dist/src/data-source/collection-browser-data-source.js.map +1 -1
  16. package/dist/src/restoration-state-handler.js +2 -4
  17. package/dist/src/restoration-state-handler.js.map +1 -1
  18. package/dist/src/styles/tile-action-styles.js +43 -43
  19. package/dist/src/styles/tile-action-styles.js.map +1 -1
  20. package/dist/src/tiles/base-tile-component.js +11 -11
  21. package/dist/src/tiles/base-tile-component.js.map +1 -1
  22. package/dist/src/tiles/grid/item-tile.js +138 -138
  23. package/dist/src/tiles/grid/item-tile.js.map +1 -1
  24. package/dist/src/tiles/list/tile-list-compact-header.js +62 -62
  25. package/dist/src/tiles/list/tile-list-compact-header.js.map +1 -1
  26. package/dist/src/tiles/list/tile-list-compact.js +123 -123
  27. package/dist/src/tiles/list/tile-list-compact.js.map +1 -1
  28. package/dist/src/tiles/list/tile-list.js +310 -310
  29. package/dist/src/tiles/list/tile-list.js.map +1 -1
  30. package/dist/src/tiles/models.js.map +1 -1
  31. package/dist/src/tiles/tile-dispatcher.js +286 -286
  32. package/dist/src/tiles/tile-dispatcher.js.map +1 -1
  33. package/dist/src/tiles/tile-display-value-provider.js.map +1 -1
  34. package/dist/src/utils/date-filter-field.d.ts +6 -0
  35. package/dist/src/utils/date-filter-field.js +9 -0
  36. package/dist/src/utils/date-filter-field.js.map +1 -0
  37. package/dist/test/collection-browser.test.js +81 -0
  38. package/dist/test/collection-browser.test.js.map +1 -1
  39. package/dist/test/collection-facets/facet-row.test.js +31 -31
  40. package/dist/test/collection-facets/facet-row.test.js.map +1 -1
  41. package/dist/test/tiles/grid/item-tile.test.js +77 -77
  42. package/dist/test/tiles/grid/item-tile.test.js.map +1 -1
  43. package/dist/test/tiles/list/tile-list.test.js +134 -134
  44. package/dist/test/tiles/list/tile-list.test.js.map +1 -1
  45. package/dist/test/tiles/tile-dispatcher.test.js +92 -92
  46. package/dist/test/tiles/tile-dispatcher.test.js.map +1 -1
  47. package/index.ts +29 -29
  48. package/package.json +1 -1
  49. package/src/app-root.ts +1284 -1284
  50. package/src/collection-browser.ts +3165 -3176
  51. package/src/collection-facets/facet-row.ts +309 -309
  52. package/src/collection-facets/facets-template.ts +85 -85
  53. package/src/data-source/collection-browser-data-source-interface.ts +6 -0
  54. package/src/data-source/collection-browser-data-source.ts +16 -7
  55. package/src/restoration-state-handler.ts +5 -5
  56. package/src/styles/tile-action-styles.ts +59 -59
  57. package/src/tiles/base-tile-component.ts +124 -124
  58. package/src/tiles/grid/item-tile.ts +347 -347
  59. package/src/tiles/list/tile-list-compact-header.ts +112 -112
  60. package/src/tiles/list/tile-list-compact.ts +278 -278
  61. package/src/tiles/list/tile-list.ts +718 -718
  62. package/src/tiles/models.ts +21 -21
  63. package/src/tiles/tile-dispatcher.ts +637 -637
  64. package/src/tiles/tile-display-value-provider.ts +133 -133
  65. package/src/utils/date-filter-field.ts +11 -0
  66. package/test/collection-browser.test.ts +132 -0
  67. package/test/collection-facets/facet-row.test.ts +421 -421
  68. package/test/tiles/grid/item-tile.test.ts +520 -520
  69. package/test/tiles/list/tile-list.test.ts +576 -576
  70. package/test/tiles/tile-dispatcher.test.ts +320 -320
@@ -1,320 +1,320 @@
1
- import { aTimeout, expect, fixture } from '@open-wc/testing';
2
- import { html } from 'lit';
3
- import sinon from 'sinon';
4
- import type { TileDispatcher } from '../../src/tiles/tile-dispatcher';
5
-
6
- import '../../src/tiles/tile-dispatcher';
7
- import type { ItemTile } from '../../src/tiles/grid/item-tile';
8
- import { TileHoverPane } from '../../src/tiles/hover/tile-hover-pane';
9
- import type { HoverPaneProperties } from '../../src/tiles/hover/hover-pane-controller';
10
-
11
- describe('Tile Dispatcher', () => {
12
- it('should render item-tile for grid mode by default', async () => {
13
- const el = await fixture<TileDispatcher>(html`
14
- <tile-dispatcher
15
- .tileDisplayMode=${'grid'}
16
- .model=${{ mediatype: 'texts' }}
17
- >
18
- </tile-dispatcher>
19
- `);
20
-
21
- const itemTile = el.shadowRoot?.querySelector('item-tile');
22
- expect(itemTile).to.exist;
23
- });
24
-
25
- it('should render collection-tile for grid mode and collection mediatype', async () => {
26
- const el = await fixture<TileDispatcher>(html`
27
- <tile-dispatcher
28
- .tileDisplayMode=${'grid'}
29
- .model=${{ mediatype: 'collection' }}
30
- >
31
- </tile-dispatcher>
32
- `);
33
-
34
- const collectionTile = el.shadowRoot?.querySelector('collection-tile');
35
- expect(collectionTile).to.exist;
36
- });
37
-
38
- it('should render account-tile for grid mode and account mediatype', async () => {
39
- const el = await fixture<TileDispatcher>(html`
40
- <tile-dispatcher
41
- .tileDisplayMode=${'grid'}
42
- .model=${{ mediatype: 'account' }}
43
- >
44
- </tile-dispatcher>
45
- `);
46
-
47
- const accountTile = el.shadowRoot?.querySelector('account-tile');
48
- expect(accountTile).to.exist;
49
- });
50
-
51
- it('should render search-tile for grid mode and search mediatype', async () => {
52
- const el = await fixture<TileDispatcher>(html`
53
- <tile-dispatcher
54
- .tileDisplayMode=${'grid'}
55
- .model=${{ mediatype: 'search' }}
56
- >
57
- </tile-dispatcher>
58
- `);
59
-
60
- const searchTile = el.shadowRoot?.querySelector('search-tile');
61
- expect(searchTile).to.exist;
62
- });
63
-
64
- it('should render tile-list for extended list mode', async () => {
65
- const el = await fixture<TileDispatcher>(html`
66
- <tile-dispatcher .tileDisplayMode=${'list-detail'} .model=${{}}>
67
- </tile-dispatcher>
68
- `);
69
-
70
- const listTile = el.shadowRoot?.querySelector('tile-list');
71
- expect(listTile).to.exist;
72
- });
73
-
74
- it('should render tile-list-compact for compact list mode', async () => {
75
- const el = await fixture<TileDispatcher>(html`
76
- <tile-dispatcher .tileDisplayMode=${'list-compact'} .model=${{}}>
77
- </tile-dispatcher>
78
- `);
79
-
80
- const compactListTile = el.shadowRoot?.querySelector('tile-list-compact');
81
- expect(compactListTile).to.exist;
82
- });
83
-
84
- it('should open item in new tab when right-clicked in manage mode', async () => {
85
- const oldWindowOpen = window.open;
86
- const spy = sinon.spy();
87
- window.open = spy;
88
-
89
- const el = await fixture<TileDispatcher>(html`
90
- <tile-dispatcher
91
- isManageView
92
- .model=${{ identifier: 'foo', href: '/foo' }}
93
- .baseNavigationUrl=${''}
94
- >
95
- </tile-dispatcher>
96
- `);
97
-
98
- const tileLink = el.shadowRoot?.querySelector(
99
- 'a[href]',
100
- ) as HTMLAnchorElement;
101
- expect(tileLink).to.exist;
102
-
103
- tileLink.dispatchEvent(new Event('contextmenu'));
104
- await el.updateComplete;
105
-
106
- expect(spy.callCount).to.equal(1);
107
- expect(spy.args[0][0]).to.equal('/foo');
108
- expect(spy.args[0][1]).to.equal('_blank');
109
-
110
- window.open = oldWindowOpen;
111
- });
112
-
113
- it('should use model href as link href', async () => {
114
- const el = await fixture<TileDispatcher>(html`
115
- <tile-dispatcher
116
- .model=${{
117
- identifier: 'foo',
118
- href: 'https://web.archive.org/web/20180613065659/http://www.sankei.com/',
119
- }}
120
- .baseNavigationUrl=${''}
121
- ></tile-dispatcher>
122
- `);
123
-
124
- const tileLink = el.shadowRoot?.querySelector(
125
- 'a[href]',
126
- ) as HTMLAnchorElement;
127
- expect(tileLink).to.exist;
128
- expect(tileLink.getAttribute('href')).to.equal(
129
- 'https://web.archive.org/web/20180613065659/http://www.sankei.com/',
130
- );
131
- });
132
-
133
- it('should toggle model checked state when manage check clicked', async () => {
134
- const el = await fixture<TileDispatcher>(html`
135
- <tile-dispatcher
136
- isManageView
137
- .model=${{ identifier: 'foo', href: '/foo' }}
138
- .tileDisplayMode=${'grid'}
139
- ></tile-dispatcher>
140
- `);
141
-
142
- const manageCheck = el.shadowRoot?.querySelector(
143
- '.manage-check > input[type="checkbox"]',
144
- ) as HTMLButtonElement;
145
-
146
- manageCheck.click();
147
- await el.updateComplete;
148
- expect(el.model?.checked).to.be.true;
149
-
150
- manageCheck.click();
151
- await el.updateComplete;
152
- expect(el.model?.checked).to.be.false;
153
- });
154
-
155
- it('should return hover pane props', async () => {
156
- const el = await fixture<TileDispatcher>(html`
157
- <tile-dispatcher .model=${{ identifier: 'foo' }}> </tile-dispatcher>
158
- `);
159
-
160
- expect(el.getHoverPaneProps()).to.satisfy(
161
- (props: HoverPaneProperties) => props?.model?.identifier === 'foo',
162
- );
163
- });
164
-
165
- it('should focus the tile link when requested', async () => {
166
- const el = await fixture<TileDispatcher>(html`
167
- <tile-dispatcher .tileDisplayMode=${'grid'}> </tile-dispatcher>
168
- `);
169
-
170
- const tileLink = el.shadowRoot?.querySelector(
171
- '.tile-link',
172
- ) as HTMLAnchorElement;
173
- expect(tileLink).to.exist;
174
-
175
- const spyFocus = sinon.spy(tileLink, 'focus');
176
- el.acquireFocus();
177
- expect(spyFocus.callCount).to.equal(1);
178
- });
179
-
180
- it('should blur the tile link when requested', async () => {
181
- const el = await fixture<TileDispatcher>(html`
182
- <tile-dispatcher .tileDisplayMode=${'grid'}> </tile-dispatcher>
183
- `);
184
-
185
- const tileLink = el.shadowRoot?.querySelector(
186
- '.tile-link',
187
- ) as HTMLAnchorElement;
188
- expect(tileLink).to.exist;
189
-
190
- const spyBlur = sinon.spy(tileLink, 'blur');
191
- el.releaseFocus();
192
- expect(spyBlur.callCount).to.equal(1);
193
- });
194
-
195
- describe('Hover pane info button behavior', () => {
196
- let oldMatchMedia: typeof window.matchMedia;
197
-
198
- before(() => {
199
- oldMatchMedia = window.matchMedia;
200
- // Pretend that there is no hover-capable input device
201
- window.matchMedia = () => ({ matches: false }) as MediaQueryList;
202
- });
203
-
204
- after(() => {
205
- window.matchMedia = oldMatchMedia;
206
- });
207
-
208
- it('should toggle hover pane when tile info button is pressed', async () => {
209
- const el = await fixture<TileDispatcher>(html`
210
- <tile-dispatcher
211
- .tileDisplayMode=${'grid'}
212
- .model=${{ mediatype: 'texts' }}
213
- .enableHoverPane=${true}
214
- >
215
- </tile-dispatcher>
216
- `);
217
-
218
- const itemTile = el.shadowRoot?.querySelector('item-tile') as ItemTile;
219
- expect(itemTile).to.exist;
220
-
221
- const infoButton = itemTile.shadowRoot?.querySelector(
222
- '.info-button',
223
- ) as HTMLButtonElement;
224
- expect(infoButton).to.exist;
225
-
226
- infoButton.click();
227
- await aTimeout(500);
228
- await el.updateComplete;
229
- expect(el.getHoverPane()).to.be.instanceOf(TileHoverPane);
230
-
231
- infoButton.click();
232
- await aTimeout(500);
233
- await el.updateComplete;
234
- expect(el.getHoverPane()).not.to.exist;
235
- });
236
-
237
- it('should not show info button when hover pane is not enabled', async () => {
238
- const el = await fixture<TileDispatcher>(html`
239
- <tile-dispatcher
240
- .tileDisplayMode=${'grid'}
241
- .model=${{ mediatype: 'texts' }}
242
- .enableHoverPane=${false}
243
- >
244
- </tile-dispatcher>
245
- `);
246
-
247
- const itemTile = el.shadowRoot?.querySelector('item-tile') as ItemTile;
248
- expect(itemTile).to.exist;
249
-
250
- const infoButton = itemTile.shadowRoot?.querySelector('.info-button');
251
- expect(infoButton).to.not.exist;
252
- });
253
- });
254
-
255
- describe('Accessibility', () => {
256
- it('should have proper aria-label on tile link', async () => {
257
- const el = await fixture<TileDispatcher>(html`
258
- <tile-dispatcher
259
- .tileDisplayMode=${'grid'}
260
- .model=${{
261
- title: 'Example Title',
262
- mediatype: 'texts',
263
- }}
264
- >
265
- </tile-dispatcher>
266
- `);
267
-
268
- const tileLink = el.shadowRoot?.querySelector(
269
- '.tile-link',
270
- ) as HTMLAnchorElement;
271
- expect(tileLink).to.exist;
272
- expect(tileLink.getAttribute('aria-label')).to.equal('Example Title');
273
- });
274
-
275
- it('should fallback to untitled aria-label on tile link when no title', async () => {
276
- const el = await fixture<TileDispatcher>(html`
277
- <tile-dispatcher
278
- .tileDisplayMode=${'grid'}
279
- .model=${{
280
- mediatype: 'texts',
281
- }}
282
- >
283
- </tile-dispatcher>
284
- `);
285
-
286
- const tileLink = el.shadowRoot?.querySelector(
287
- '.tile-link',
288
- ) as HTMLAnchorElement;
289
- expect(tileLink).to.exist;
290
- expect(tileLink.getAttribute('aria-label')).to.equal('Untitled item');
291
- });
292
-
293
- it('should have no accessibility violations in grid mode', async () => {
294
- const el = await fixture<TileDispatcher>(html`
295
- <tile-dispatcher
296
- .tileDisplayMode=${'grid'}
297
- .model=${{
298
- title: 'Example Title',
299
- mediatype: 'texts',
300
- }}
301
- >
302
- </tile-dispatcher>
303
- `);
304
-
305
- await expect(el).to.be.accessible();
306
- });
307
-
308
- it('should have no accessibility violations in list mode', async () => {
309
- const el = await fixture<TileDispatcher>(html`
310
- <tile-dispatcher
311
- .tileDisplayMode=${'list-detail'}
312
- .model=${{ mediatype: 'texts' }}
313
- >
314
- </tile-dispatcher>
315
- `);
316
-
317
- await expect(el).to.be.accessible();
318
- });
319
- });
320
- });
1
+ import { aTimeout, expect, fixture } from '@open-wc/testing';
2
+ import { html } from 'lit';
3
+ import sinon from 'sinon';
4
+ import type { TileDispatcher } from '../../src/tiles/tile-dispatcher';
5
+
6
+ import '../../src/tiles/tile-dispatcher';
7
+ import type { ItemTile } from '../../src/tiles/grid/item-tile';
8
+ import { TileHoverPane } from '../../src/tiles/hover/tile-hover-pane';
9
+ import type { HoverPaneProperties } from '../../src/tiles/hover/hover-pane-controller';
10
+
11
+ describe('Tile Dispatcher', () => {
12
+ it('should render item-tile for grid mode by default', async () => {
13
+ const el = await fixture<TileDispatcher>(html`
14
+ <tile-dispatcher
15
+ .tileDisplayMode=${'grid'}
16
+ .model=${{ mediatype: 'texts' }}
17
+ >
18
+ </tile-dispatcher>
19
+ `);
20
+
21
+ const itemTile = el.shadowRoot?.querySelector('item-tile');
22
+ expect(itemTile).to.exist;
23
+ });
24
+
25
+ it('should render collection-tile for grid mode and collection mediatype', async () => {
26
+ const el = await fixture<TileDispatcher>(html`
27
+ <tile-dispatcher
28
+ .tileDisplayMode=${'grid'}
29
+ .model=${{ mediatype: 'collection' }}
30
+ >
31
+ </tile-dispatcher>
32
+ `);
33
+
34
+ const collectionTile = el.shadowRoot?.querySelector('collection-tile');
35
+ expect(collectionTile).to.exist;
36
+ });
37
+
38
+ it('should render account-tile for grid mode and account mediatype', async () => {
39
+ const el = await fixture<TileDispatcher>(html`
40
+ <tile-dispatcher
41
+ .tileDisplayMode=${'grid'}
42
+ .model=${{ mediatype: 'account' }}
43
+ >
44
+ </tile-dispatcher>
45
+ `);
46
+
47
+ const accountTile = el.shadowRoot?.querySelector('account-tile');
48
+ expect(accountTile).to.exist;
49
+ });
50
+
51
+ it('should render search-tile for grid mode and search mediatype', async () => {
52
+ const el = await fixture<TileDispatcher>(html`
53
+ <tile-dispatcher
54
+ .tileDisplayMode=${'grid'}
55
+ .model=${{ mediatype: 'search' }}
56
+ >
57
+ </tile-dispatcher>
58
+ `);
59
+
60
+ const searchTile = el.shadowRoot?.querySelector('search-tile');
61
+ expect(searchTile).to.exist;
62
+ });
63
+
64
+ it('should render tile-list for extended list mode', async () => {
65
+ const el = await fixture<TileDispatcher>(html`
66
+ <tile-dispatcher .tileDisplayMode=${'list-detail'} .model=${{}}>
67
+ </tile-dispatcher>
68
+ `);
69
+
70
+ const listTile = el.shadowRoot?.querySelector('tile-list');
71
+ expect(listTile).to.exist;
72
+ });
73
+
74
+ it('should render tile-list-compact for compact list mode', async () => {
75
+ const el = await fixture<TileDispatcher>(html`
76
+ <tile-dispatcher .tileDisplayMode=${'list-compact'} .model=${{}}>
77
+ </tile-dispatcher>
78
+ `);
79
+
80
+ const compactListTile = el.shadowRoot?.querySelector('tile-list-compact');
81
+ expect(compactListTile).to.exist;
82
+ });
83
+
84
+ it('should open item in new tab when right-clicked in manage mode', async () => {
85
+ const oldWindowOpen = window.open;
86
+ const spy = sinon.spy();
87
+ window.open = spy;
88
+
89
+ const el = await fixture<TileDispatcher>(html`
90
+ <tile-dispatcher
91
+ isManageView
92
+ .model=${{ identifier: 'foo', href: '/foo' }}
93
+ .baseNavigationUrl=${''}
94
+ >
95
+ </tile-dispatcher>
96
+ `);
97
+
98
+ const tileLink = el.shadowRoot?.querySelector(
99
+ 'a[href]',
100
+ ) as HTMLAnchorElement;
101
+ expect(tileLink).to.exist;
102
+
103
+ tileLink.dispatchEvent(new Event('contextmenu'));
104
+ await el.updateComplete;
105
+
106
+ expect(spy.callCount).to.equal(1);
107
+ expect(spy.args[0][0]).to.equal('/foo');
108
+ expect(spy.args[0][1]).to.equal('_blank');
109
+
110
+ window.open = oldWindowOpen;
111
+ });
112
+
113
+ it('should use model href as link href', async () => {
114
+ const el = await fixture<TileDispatcher>(html`
115
+ <tile-dispatcher
116
+ .model=${{
117
+ identifier: 'foo',
118
+ href: 'https://web.archive.org/web/20180613065659/http://www.sankei.com/',
119
+ }}
120
+ .baseNavigationUrl=${''}
121
+ ></tile-dispatcher>
122
+ `);
123
+
124
+ const tileLink = el.shadowRoot?.querySelector(
125
+ 'a[href]',
126
+ ) as HTMLAnchorElement;
127
+ expect(tileLink).to.exist;
128
+ expect(tileLink.getAttribute('href')).to.equal(
129
+ 'https://web.archive.org/web/20180613065659/http://www.sankei.com/',
130
+ );
131
+ });
132
+
133
+ it('should toggle model checked state when manage check clicked', async () => {
134
+ const el = await fixture<TileDispatcher>(html`
135
+ <tile-dispatcher
136
+ isManageView
137
+ .model=${{ identifier: 'foo', href: '/foo' }}
138
+ .tileDisplayMode=${'grid'}
139
+ ></tile-dispatcher>
140
+ `);
141
+
142
+ const manageCheck = el.shadowRoot?.querySelector(
143
+ '.manage-check > input[type="checkbox"]',
144
+ ) as HTMLButtonElement;
145
+
146
+ manageCheck.click();
147
+ await el.updateComplete;
148
+ expect(el.model?.checked).to.be.true;
149
+
150
+ manageCheck.click();
151
+ await el.updateComplete;
152
+ expect(el.model?.checked).to.be.false;
153
+ });
154
+
155
+ it('should return hover pane props', async () => {
156
+ const el = await fixture<TileDispatcher>(html`
157
+ <tile-dispatcher .model=${{ identifier: 'foo' }}> </tile-dispatcher>
158
+ `);
159
+
160
+ expect(el.getHoverPaneProps()).to.satisfy(
161
+ (props: HoverPaneProperties) => props?.model?.identifier === 'foo',
162
+ );
163
+ });
164
+
165
+ it('should focus the tile link when requested', async () => {
166
+ const el = await fixture<TileDispatcher>(html`
167
+ <tile-dispatcher .tileDisplayMode=${'grid'}> </tile-dispatcher>
168
+ `);
169
+
170
+ const tileLink = el.shadowRoot?.querySelector(
171
+ '.tile-link',
172
+ ) as HTMLAnchorElement;
173
+ expect(tileLink).to.exist;
174
+
175
+ const spyFocus = sinon.spy(tileLink, 'focus');
176
+ el.acquireFocus();
177
+ expect(spyFocus.callCount).to.equal(1);
178
+ });
179
+
180
+ it('should blur the tile link when requested', async () => {
181
+ const el = await fixture<TileDispatcher>(html`
182
+ <tile-dispatcher .tileDisplayMode=${'grid'}> </tile-dispatcher>
183
+ `);
184
+
185
+ const tileLink = el.shadowRoot?.querySelector(
186
+ '.tile-link',
187
+ ) as HTMLAnchorElement;
188
+ expect(tileLink).to.exist;
189
+
190
+ const spyBlur = sinon.spy(tileLink, 'blur');
191
+ el.releaseFocus();
192
+ expect(spyBlur.callCount).to.equal(1);
193
+ });
194
+
195
+ describe('Hover pane info button behavior', () => {
196
+ let oldMatchMedia: typeof window.matchMedia;
197
+
198
+ before(() => {
199
+ oldMatchMedia = window.matchMedia;
200
+ // Pretend that there is no hover-capable input device
201
+ window.matchMedia = () => ({ matches: false }) as MediaQueryList;
202
+ });
203
+
204
+ after(() => {
205
+ window.matchMedia = oldMatchMedia;
206
+ });
207
+
208
+ it('should toggle hover pane when tile info button is pressed', async () => {
209
+ const el = await fixture<TileDispatcher>(html`
210
+ <tile-dispatcher
211
+ .tileDisplayMode=${'grid'}
212
+ .model=${{ mediatype: 'texts' }}
213
+ .enableHoverPane=${true}
214
+ >
215
+ </tile-dispatcher>
216
+ `);
217
+
218
+ const itemTile = el.shadowRoot?.querySelector('item-tile') as ItemTile;
219
+ expect(itemTile).to.exist;
220
+
221
+ const infoButton = itemTile.shadowRoot?.querySelector(
222
+ '.info-button',
223
+ ) as HTMLButtonElement;
224
+ expect(infoButton).to.exist;
225
+
226
+ infoButton.click();
227
+ await aTimeout(500);
228
+ await el.updateComplete;
229
+ expect(el.getHoverPane()).to.be.instanceOf(TileHoverPane);
230
+
231
+ infoButton.click();
232
+ await aTimeout(500);
233
+ await el.updateComplete;
234
+ expect(el.getHoverPane()).not.to.exist;
235
+ });
236
+
237
+ it('should not show info button when hover pane is not enabled', async () => {
238
+ const el = await fixture<TileDispatcher>(html`
239
+ <tile-dispatcher
240
+ .tileDisplayMode=${'grid'}
241
+ .model=${{ mediatype: 'texts' }}
242
+ .enableHoverPane=${false}
243
+ >
244
+ </tile-dispatcher>
245
+ `);
246
+
247
+ const itemTile = el.shadowRoot?.querySelector('item-tile') as ItemTile;
248
+ expect(itemTile).to.exist;
249
+
250
+ const infoButton = itemTile.shadowRoot?.querySelector('.info-button');
251
+ expect(infoButton).to.not.exist;
252
+ });
253
+ });
254
+
255
+ describe('Accessibility', () => {
256
+ it('should have proper aria-label on tile link', async () => {
257
+ const el = await fixture<TileDispatcher>(html`
258
+ <tile-dispatcher
259
+ .tileDisplayMode=${'grid'}
260
+ .model=${{
261
+ title: 'Example Title',
262
+ mediatype: 'texts',
263
+ }}
264
+ >
265
+ </tile-dispatcher>
266
+ `);
267
+
268
+ const tileLink = el.shadowRoot?.querySelector(
269
+ '.tile-link',
270
+ ) as HTMLAnchorElement;
271
+ expect(tileLink).to.exist;
272
+ expect(tileLink.getAttribute('aria-label')).to.equal('Example Title');
273
+ });
274
+
275
+ it('should fallback to untitled aria-label on tile link when no title', async () => {
276
+ const el = await fixture<TileDispatcher>(html`
277
+ <tile-dispatcher
278
+ .tileDisplayMode=${'grid'}
279
+ .model=${{
280
+ mediatype: 'texts',
281
+ }}
282
+ >
283
+ </tile-dispatcher>
284
+ `);
285
+
286
+ const tileLink = el.shadowRoot?.querySelector(
287
+ '.tile-link',
288
+ ) as HTMLAnchorElement;
289
+ expect(tileLink).to.exist;
290
+ expect(tileLink.getAttribute('aria-label')).to.equal('Untitled item');
291
+ });
292
+
293
+ it('should have no accessibility violations in grid mode', async () => {
294
+ const el = await fixture<TileDispatcher>(html`
295
+ <tile-dispatcher
296
+ .tileDisplayMode=${'grid'}
297
+ .model=${{
298
+ title: 'Example Title',
299
+ mediatype: 'texts',
300
+ }}
301
+ >
302
+ </tile-dispatcher>
303
+ `);
304
+
305
+ await expect(el).to.be.accessible();
306
+ });
307
+
308
+ it('should have no accessibility violations in list mode', async () => {
309
+ const el = await fixture<TileDispatcher>(html`
310
+ <tile-dispatcher
311
+ .tileDisplayMode=${'list-detail'}
312
+ .model=${{ mediatype: 'texts' }}
313
+ >
314
+ </tile-dispatcher>
315
+ `);
316
+
317
+ await expect(el).to.be.accessible();
318
+ });
319
+ });
320
+ });