@instructure/ui-drilldown 10.19.2-snapshot-2 → 10.19.2-snapshot-4

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 (28) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/package.json +21 -21
  3. package/tsconfig.build.tsbuildinfo +1 -1
  4. package/es/Drilldown/DrilldownGroup/__new-tests__/DrilldownGroup.test.js +0 -696
  5. package/es/Drilldown/DrilldownOption/__new-tests__/DrilldownOption.test.js +0 -708
  6. package/es/Drilldown/DrilldownPage/__new-tests__/DrilldownPage.test.js +0 -353
  7. package/es/Drilldown/DrilldownSeparator/__new-tests__/DrilldownSeparator.test.js +0 -61
  8. package/es/Drilldown/__new-tests__/Drilldown.test.js +0 -1021
  9. package/lib/Drilldown/DrilldownGroup/__new-tests__/DrilldownGroup.test.js +0 -698
  10. package/lib/Drilldown/DrilldownOption/__new-tests__/DrilldownOption.test.js +0 -710
  11. package/lib/Drilldown/DrilldownPage/__new-tests__/DrilldownPage.test.js +0 -355
  12. package/lib/Drilldown/DrilldownSeparator/__new-tests__/DrilldownSeparator.test.js +0 -62
  13. package/lib/Drilldown/__new-tests__/Drilldown.test.js +0 -1022
  14. package/src/Drilldown/DrilldownGroup/__new-tests__/DrilldownGroup.test.tsx +0 -633
  15. package/src/Drilldown/DrilldownOption/__new-tests__/DrilldownOption.test.tsx +0 -774
  16. package/src/Drilldown/DrilldownPage/__new-tests__/DrilldownPage.test.tsx +0 -351
  17. package/src/Drilldown/DrilldownSeparator/__new-tests__/DrilldownSeparator.test.tsx +0 -59
  18. package/src/Drilldown/__new-tests__/Drilldown.test.tsx +0 -1005
  19. package/types/Drilldown/DrilldownGroup/__new-tests__/DrilldownGroup.test.d.ts +0 -2
  20. package/types/Drilldown/DrilldownGroup/__new-tests__/DrilldownGroup.test.d.ts.map +0 -1
  21. package/types/Drilldown/DrilldownOption/__new-tests__/DrilldownOption.test.d.ts +0 -2
  22. package/types/Drilldown/DrilldownOption/__new-tests__/DrilldownOption.test.d.ts.map +0 -1
  23. package/types/Drilldown/DrilldownPage/__new-tests__/DrilldownPage.test.d.ts +0 -2
  24. package/types/Drilldown/DrilldownPage/__new-tests__/DrilldownPage.test.d.ts.map +0 -1
  25. package/types/Drilldown/DrilldownSeparator/__new-tests__/DrilldownSeparator.test.d.ts +0 -2
  26. package/types/Drilldown/DrilldownSeparator/__new-tests__/DrilldownSeparator.test.d.ts.map +0 -1
  27. package/types/Drilldown/__new-tests__/Drilldown.test.d.ts +0 -2
  28. package/types/Drilldown/__new-tests__/Drilldown.test.d.ts.map +0 -1
@@ -1,1022 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- var _react = require("@testing-library/react");
5
- var _vitest = require("vitest");
6
- var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
7
- require("@testing-library/jest-dom");
8
- var _generateA11yTests = require("@instructure/ui-scripts/lib/test/generateA11yTests");
9
- var _runAxeCheck = require("@instructure/ui-axe-check/lib/runAxeCheck.js");
10
- var _IconCheckSolid = require("@instructure/ui-icons/lib/IconCheckSolid.js");
11
- var _index = require("../index");
12
- var _Drilldown16 = _interopRequireDefault(require("../__examples__/Drilldown.examples"));
13
- var _jsxRuntime = require("@emotion/react/jsx-runtime");
14
- var _Drilldown, _Drilldown2, _Drilldown3, _Drilldown4, _Drilldown5, _Drilldown6, _Drilldown7, _Drilldown8, _Drilldown9, _Drilldown$Page, _button, _Drilldown$Page2, _button2, _Drilldown$Page3, _Drilldown$Page4, _button3, _Drilldown$Page5, _button4, _Drilldown$Page6, _Drilldown$Page7, _button5, _Drilldown$Page8, _button6, _Drilldown$Page9, _Drilldown10, _button7, _Drilldown$Page10, _Drilldown11, _button8, _Drilldown$Page11, _button9, _Drilldown$Page12, _button10, _Drilldown$Page13, _Drilldown12, _button11, _Drilldown$Page14, _Drilldown13, _button12, _Drilldown$Page15, _button13, _Drilldown$Page16, _button14, _Drilldown$Page17, _button15, _Drilldown$Page18, _button16, _Drilldown$Page19, _button17, _Drilldown$Page20, _button18, _Drilldown$Page21, _button19, _Drilldown$Page22, _Drilldown14, _Drilldown15;
15
- /*
16
- * The MIT License (MIT)
17
- *
18
- * Copyright (c) 2015 - present Instructure, Inc.
19
- *
20
- * Permission is hereby granted, free of charge, to any person obtaining a copy
21
- * of this software and associated documentation files (the "Software"), to deal
22
- * in the Software without restriction, including without limitation the rights
23
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
24
- * copies of the Software, and to permit persons to whom the Software is
25
- * furnished to do so, subject to the following conditions:
26
- *
27
- * The above copyright notice and this permission notice shall be included in all
28
- * copies or substantial portions of the Software.
29
- *
30
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
31
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
32
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
33
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
34
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
35
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
36
- * SOFTWARE.
37
- */
38
- // eslint-disable-next-line no-restricted-imports
39
- const data = Array(5).fill(0).map((_v, ind) => ({
40
- label: `option ${ind}`,
41
- id: `opt_${ind}`
42
- }));
43
- describe('<Drilldown />', () => {
44
- let consoleWarningMock;
45
- let consoleErrorMock;
46
- beforeEach(() => {
47
- // Mocking console to prevent test output pollution and expect for messages
48
- consoleWarningMock = _vitest.vi.spyOn(console, 'warn').mockImplementation(() => {});
49
- consoleErrorMock = _vitest.vi.spyOn(console, 'error').mockImplementation(() => {});
50
- });
51
- afterEach(() => {
52
- consoleWarningMock.mockRestore();
53
- consoleErrorMock.mockRestore();
54
- });
55
- describe('rootPageId prop', () => {
56
- it('should set the initial page and render it', async () => {
57
- (0, _react.render)(_Drilldown || (_Drilldown = (0, _jsxRuntime.jsxs)(_index.Drilldown, {
58
- rootPageId: "page1",
59
- children: [(0, _jsxRuntime.jsx)(_index.Drilldown.Page, {
60
- id: "page0",
61
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
62
- id: "option01",
63
- children: "Option-01"
64
- })
65
- }), (0, _jsxRuntime.jsx)(_index.Drilldown.Page, {
66
- id: "page1",
67
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
68
- id: "option11",
69
- children: "Option-11"
70
- })
71
- })]
72
- })));
73
- const drilldown = _react.screen.getByRole('menu');
74
- const options = _react.screen.getAllByRole('menuitem');
75
- const rootlessOption = _react.screen.queryByText('Option-01');
76
- expect(drilldown).toBeInTheDocument();
77
- expect(rootlessOption).not.toBeInTheDocument();
78
- expect(options.length).toBe(1);
79
- expect(options[0]).toHaveTextContent('Option-11');
80
- expect(options[0]).toHaveAttribute('id', 'option11');
81
- });
82
- });
83
- describe('children prop', () => {
84
- it('should not allow non-DrilldownPage children', async () => {
85
- (0, _react.render)(_Drilldown2 || (_Drilldown2 = (0, _jsxRuntime.jsx)(_index.Drilldown, {
86
- rootPageId: "page0",
87
- children: (0, _jsxRuntime.jsx)("div", {
88
- id: "testDiv",
89
- children: "DIV-child"
90
- })
91
- })));
92
- const drilldown = _react.screen.queryByRole('menu');
93
- const options = _react.screen.queryAllByRole('menuitem');
94
- const notAllowedChild = _react.screen.queryByText('DIV-child');
95
- expect(drilldown).not.toBeInTheDocument();
96
- expect(options.length).toBe(0);
97
- expect(notAllowedChild).not.toBeInTheDocument();
98
- });
99
- it('should not crash for weird option ids', async () => {
100
- const onSelect = _vitest.vi.fn();
101
- const weirdID = 'some"_weird!@#$%^&*()\\|`id';
102
- (0, _react.render)((0, _jsxRuntime.jsx)(_index.Drilldown, {
103
- rootPageId: "page0",
104
- onSelect: onSelect,
105
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Page, {
106
- id: "page0",
107
- children: data.map(option => (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
108
- id: weirdID + option.id,
109
- value: weirdID + option.id,
110
- "data-testid": weirdID + option.id,
111
- children: option.label
112
- }, weirdID + option.id))
113
- })
114
- }));
115
- const option_1 = _react.screen.getByTestId(weirdID + 'opt_1');
116
- await _userEvent.default.click(option_1);
117
- await (0, _react.waitFor)(() => {
118
- expect(onSelect).toHaveBeenCalled();
119
- });
120
- });
121
- });
122
- describe('id prop', () => {
123
- it('should put id attr on the drilldown', async () => {
124
- (0, _react.render)(_Drilldown3 || (_Drilldown3 = (0, _jsxRuntime.jsx)(_index.Drilldown, {
125
- rootPageId: "page0",
126
- id: "testId",
127
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Page, {
128
- id: "page0",
129
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
130
- id: "option01",
131
- children: "Option"
132
- })
133
- })
134
- })));
135
- const drilldown = _react.screen.getByRole('menu');
136
- expect(drilldown).toBeInTheDocument();
137
- expect(drilldown).toHaveAttribute('id', 'testId');
138
- });
139
- });
140
- describe('label prop', () => {
141
- it('should be added as aria-label', async () => {
142
- (0, _react.render)(_Drilldown4 || (_Drilldown4 = (0, _jsxRuntime.jsx)(_index.Drilldown, {
143
- rootPageId: "page0",
144
- label: "testLabel",
145
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Page, {
146
- id: "page0",
147
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
148
- id: "option01",
149
- children: "Option"
150
- })
151
- })
152
- })));
153
- const drilldown = _react.screen.getByRole('menu');
154
- expect(drilldown).toBeInTheDocument();
155
- expect(drilldown).toHaveAttribute('aria-label', 'testLabel');
156
- });
157
- });
158
- describe('disabled prop', () => {
159
- it('should disable all options', async () => {
160
- (0, _react.render)(_Drilldown5 || (_Drilldown5 = (0, _jsxRuntime.jsx)(_index.Drilldown, {
161
- rootPageId: "page0",
162
- disabled: true,
163
- children: (0, _jsxRuntime.jsxs)(_index.Drilldown.Page, {
164
- id: "page0",
165
- renderActionLabel: "Action",
166
- children: [(0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
167
- id: "option01",
168
- children: "Option"
169
- }), (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
170
- id: "option02",
171
- children: "Option"
172
- }), (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
173
- id: "option03",
174
- children: "Option"
175
- })]
176
- })
177
- })));
178
- const options = _react.screen.getAllByRole('menuitem');
179
- expect(options.length).toBe(4); // header action + 3 options
180
-
181
- options.forEach(option => {
182
- expect(option).toHaveAttribute('aria-disabled', 'true');
183
- });
184
- });
185
- });
186
- describe('as prop', () => {
187
- it('should be "ul" by default', async () => {
188
- const _render = (0, _react.render)(_Drilldown6 || (_Drilldown6 = (0, _jsxRuntime.jsx)(_index.Drilldown, {
189
- rootPageId: "page0",
190
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Page, {
191
- id: "page0",
192
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
193
- id: "option01",
194
- children: "Option"
195
- })
196
- })
197
- }))),
198
- container = _render.container;
199
- const drilldownList = container.querySelector('[class$="-options__list"]');
200
- expect(drilldownList === null || drilldownList === void 0 ? void 0 : drilldownList.tagName).toBe('UL');
201
- });
202
- it('should render as passed element', async () => {
203
- const _render2 = (0, _react.render)(_Drilldown7 || (_Drilldown7 = (0, _jsxRuntime.jsx)(_index.Drilldown, {
204
- rootPageId: "page0",
205
- as: "ol",
206
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Page, {
207
- id: "page0",
208
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
209
- id: "option01",
210
- children: "Option"
211
- })
212
- })
213
- }))),
214
- container = _render2.container;
215
- const drilldownList = container.querySelector('[class$="-options__list"]');
216
- expect(drilldownList === null || drilldownList === void 0 ? void 0 : drilldownList.tagName).toBe('OL');
217
- });
218
- });
219
- describe('role prop', () => {
220
- it('should be "menu" by default', async () => {
221
- const _render3 = (0, _react.render)(_Drilldown8 || (_Drilldown8 = (0, _jsxRuntime.jsx)(_index.Drilldown, {
222
- rootPageId: "page0",
223
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Page, {
224
- id: "page0",
225
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
226
- id: "option01",
227
- children: "Option"
228
- })
229
- })
230
- }))),
231
- container = _render3.container;
232
- const drilldown = container.querySelector('div[id^="Drilldown_"]');
233
- expect(drilldown).toHaveAttribute('role', 'menu');
234
- });
235
- it('should apply passed role', async () => {
236
- const _render4 = (0, _react.render)(_Drilldown9 || (_Drilldown9 = (0, _jsxRuntime.jsx)(_index.Drilldown, {
237
- rootPageId: "page0",
238
- role: "list",
239
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Page, {
240
- id: "page0",
241
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
242
- id: "option01",
243
- children: "Option"
244
- })
245
- })
246
- }))),
247
- container = _render4.container;
248
- const drilldown = container.querySelector('div[id^="Drilldown_"]');
249
- expect(drilldown).toHaveAttribute('role', 'list');
250
- });
251
- });
252
- describe('elementRef prop (and ref static prop)', () => {
253
- it('should give back the drilldown element when there is no trigger', async () => {
254
- const elementRef = _vitest.vi.fn();
255
- (0, _react.render)((0, _jsxRuntime.jsx)(_index.Drilldown, {
256
- rootPageId: "page0",
257
- elementRef: elementRef,
258
- children: _Drilldown$Page || (_Drilldown$Page = (0, _jsxRuntime.jsx)(_index.Drilldown.Page, {
259
- id: "page0",
260
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
261
- id: "option01",
262
- children: "Option"
263
- })
264
- }))
265
- }));
266
- const drilldown = _react.screen.getByRole('menu');
267
- expect(drilldown).toBeInTheDocument();
268
- expect(elementRef).toHaveBeenCalledWith(drilldown);
269
- });
270
- it('should give back the Popover root when drilldown has trigger and is closed', async () => {
271
- const elementRef = _vitest.vi.fn();
272
- const _render5 = (0, _react.render)((0, _jsxRuntime.jsx)(_index.Drilldown, {
273
- rootPageId: "page0",
274
- elementRef: elementRef,
275
- trigger: _button || (_button = (0, _jsxRuntime.jsx)("button", {
276
- children: "Toggle"
277
- })),
278
- children: _Drilldown$Page2 || (_Drilldown$Page2 = (0, _jsxRuntime.jsx)(_index.Drilldown.Page, {
279
- id: "page0",
280
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
281
- id: "option01",
282
- children: "Option"
283
- })
284
- }))
285
- })),
286
- container = _render5.container;
287
- const trigger = _react.screen.getByText('Toggle');
288
- const positionId = trigger.getAttribute('data-position-target');
289
- const drilldownRoot = container.querySelector(`span[data-position="${positionId}"]`);
290
- expect(drilldownRoot).toBeInTheDocument();
291
- expect(elementRef).toHaveBeenCalledWith(drilldownRoot);
292
- });
293
- it('should give back the the Popover root when drilldown has trigger and is open', async () => {
294
- const elementRef = _vitest.vi.fn();
295
- const _render6 = (0, _react.render)((0, _jsxRuntime.jsx)(_index.Drilldown, {
296
- rootPageId: "page0",
297
- elementRef: elementRef,
298
- trigger: _button2 || (_button2 = (0, _jsxRuntime.jsx)("button", {
299
- children: "Toggle"
300
- })),
301
- defaultShow: true,
302
- children: _Drilldown$Page3 || (_Drilldown$Page3 = (0, _jsxRuntime.jsx)(_index.Drilldown.Page, {
303
- id: "page0",
304
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
305
- id: "option01",
306
- children: "Option"
307
- })
308
- }))
309
- })),
310
- container = _render6.container;
311
- const trigger = _react.screen.getByText('Toggle');
312
- const positionId = trigger.getAttribute('data-position-target');
313
- const drilldownRoot = container.querySelector(`span[data-position="${positionId}"]`);
314
- expect(drilldownRoot).toBeInTheDocument();
315
- expect(elementRef).toHaveBeenCalledWith(drilldownRoot);
316
- });
317
- });
318
- describe('drilldownRef prop', () => {
319
- it('should give back the drilldown element when there is no trigger', async () => {
320
- const drilldownRef = _vitest.vi.fn();
321
- (0, _react.render)((0, _jsxRuntime.jsx)(_index.Drilldown, {
322
- rootPageId: "page0",
323
- drilldownRef: drilldownRef,
324
- children: _Drilldown$Page4 || (_Drilldown$Page4 = (0, _jsxRuntime.jsx)(_index.Drilldown.Page, {
325
- id: "page0",
326
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
327
- id: "option01",
328
- children: "Option"
329
- })
330
- }))
331
- }));
332
- const drilldown = _react.screen.getByRole('menu');
333
- expect(drilldownRef).toHaveBeenCalledWith(drilldown);
334
- });
335
- it("shouldn't be called when drilldown has trigger and is closed", async () => {
336
- const drilldownRef = _vitest.vi.fn();
337
- (0, _react.render)((0, _jsxRuntime.jsx)(_index.Drilldown, {
338
- rootPageId: "page0",
339
- drilldownRef: drilldownRef,
340
- trigger: _button3 || (_button3 = (0, _jsxRuntime.jsx)("button", {
341
- children: "Toggle"
342
- })),
343
- children: _Drilldown$Page5 || (_Drilldown$Page5 = (0, _jsxRuntime.jsx)(_index.Drilldown.Page, {
344
- id: "page0",
345
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
346
- id: "option01",
347
- children: "Option"
348
- })
349
- }))
350
- }));
351
- expect(drilldownRef).not.toHaveBeenCalled();
352
- });
353
- it('should give back the drilldown element when drilldown has trigger and is open', async () => {
354
- const drilldownRef = _vitest.vi.fn();
355
- (0, _react.render)((0, _jsxRuntime.jsx)(_index.Drilldown, {
356
- rootPageId: "page0",
357
- drilldownRef: drilldownRef,
358
- trigger: _button4 || (_button4 = (0, _jsxRuntime.jsx)("button", {
359
- children: "Toggle"
360
- })),
361
- defaultShow: true,
362
- children: _Drilldown$Page6 || (_Drilldown$Page6 = (0, _jsxRuntime.jsx)(_index.Drilldown.Page, {
363
- id: "page0",
364
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
365
- id: "option01",
366
- children: "Option"
367
- })
368
- }))
369
- }));
370
- const drilldown = _react.screen.getByRole('menu');
371
- expect(drilldownRef).toHaveBeenCalledWith(drilldown);
372
- });
373
- });
374
- describe('popoverRef prop', () => {
375
- it('should not be called when there is no trigger', async () => {
376
- const popoverRef = _vitest.vi.fn();
377
- (0, _react.render)((0, _jsxRuntime.jsx)(_index.Drilldown, {
378
- rootPageId: "page0",
379
- popoverRef: popoverRef,
380
- children: _Drilldown$Page7 || (_Drilldown$Page7 = (0, _jsxRuntime.jsx)(_index.Drilldown.Page, {
381
- id: "page0",
382
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
383
- id: "option01",
384
- children: "Option"
385
- })
386
- }))
387
- }));
388
- expect(popoverRef).not.toHaveBeenCalled();
389
- });
390
- it('should give back the Popover component when drilldown has trigger and is closed', async () => {
391
- const popoverRef = _vitest.vi.fn();
392
- const _render7 = (0, _react.render)((0, _jsxRuntime.jsx)(_index.Drilldown, {
393
- rootPageId: "page0",
394
- popoverRef: popoverRef,
395
- trigger: _button5 || (_button5 = (0, _jsxRuntime.jsx)("button", {
396
- children: "Toggle"
397
- })),
398
- children: _Drilldown$Page8 || (_Drilldown$Page8 = (0, _jsxRuntime.jsx)(_index.Drilldown.Page, {
399
- id: "page0",
400
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
401
- id: "option01",
402
- children: "Option"
403
- })
404
- }))
405
- })),
406
- container = _render7.container;
407
- const trigger = _react.screen.getByText('Toggle');
408
- const positionId = trigger.getAttribute('data-position-target');
409
- const popoverRoot = container.querySelector(`span[data-position="${positionId}"]`);
410
- expect(popoverRoot).toBeInTheDocument();
411
- expect(popoverRef).toHaveBeenCalled();
412
-
413
- // Popover component's public ref prop
414
- expect(popoverRef.mock.calls[0][0].ref).toBe(popoverRoot);
415
- });
416
- it('should give back the Popover component when drilldown has trigger and is open', async () => {
417
- const popoverRef = _vitest.vi.fn();
418
- const _render8 = (0, _react.render)((0, _jsxRuntime.jsx)(_index.Drilldown, {
419
- rootPageId: "page0",
420
- popoverRef: popoverRef,
421
- trigger: _button6 || (_button6 = (0, _jsxRuntime.jsx)("button", {
422
- children: "Toggle"
423
- })),
424
- defaultShow: true,
425
- children: _Drilldown$Page9 || (_Drilldown$Page9 = (0, _jsxRuntime.jsx)(_index.Drilldown.Page, {
426
- id: "page0",
427
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
428
- id: "option01",
429
- children: "Option"
430
- })
431
- }))
432
- })),
433
- container = _render8.container;
434
- const trigger = _react.screen.getByText('Toggle');
435
- const positionId = trigger.getAttribute('data-position-target');
436
- const popoverRoot = container.querySelector(`span[data-position="${positionId}"]`);
437
- expect(popoverRoot).toBeInTheDocument();
438
- expect(popoverRef).toHaveBeenCalled();
439
-
440
- // Popover component's public ref prop
441
- expect(popoverRef.mock.calls[0][0].ref).toBe(popoverRoot);
442
- });
443
- });
444
- describe('onSelect prop', () => {
445
- it('should fire when option is selected', async () => {
446
- const onSelect = _vitest.vi.fn();
447
- (0, _react.render)((0, _jsxRuntime.jsx)(_index.Drilldown, {
448
- rootPageId: "page0",
449
- onSelect: onSelect,
450
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Page, {
451
- id: "page0",
452
- children: data.map(option => (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
453
- id: option.id,
454
- value: option.id,
455
- "data-testid": option.id,
456
- children: option.label
457
- }, option.id))
458
- })
459
- }));
460
- const option_1 = _react.screen.getByTestId('opt_1');
461
- await _userEvent.default.click(option_1);
462
- await (0, _react.waitFor)(() => {
463
- expect(onSelect).toHaveBeenCalled();
464
- const args = onSelect.mock.calls[0][1];
465
- const event = onSelect.mock.calls[0][0];
466
- expect(args.value).toBe('opt_1');
467
- expect(args.isSelected).toBe(true);
468
- expect(args.selectedOption.props).toHaveProperty('id', 'opt_1');
469
- expect(args.selectedOption.props).toHaveProperty('role', 'menuitem');
470
- expect(args.selectedOption.props).toHaveProperty('value', 'opt_1');
471
- expect(args.drilldown.props).toHaveProperty('role', 'menu');
472
- expect(args.drilldown.hide).toBeInstanceOf(Function);
473
- expect(event.target).toBe(option_1);
474
- });
475
- });
476
- it('should not fire when drilldown is disabled', async () => {
477
- const onSelect = _vitest.vi.fn();
478
- (0, _react.render)((0, _jsxRuntime.jsx)(_index.Drilldown, {
479
- rootPageId: "page0",
480
- onSelect: onSelect,
481
- disabled: true,
482
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Page, {
483
- id: "page0",
484
- children: data.map(option => (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
485
- id: option.id,
486
- "data-testid": option.id,
487
- children: option.label
488
- }, option.id))
489
- })
490
- }));
491
- const option_1 = _react.screen.getByTestId('opt_1');
492
- await _userEvent.default.click(option_1);
493
- await (0, _react.waitFor)(() => {
494
- expect(onSelect).not.toHaveBeenCalled();
495
- });
496
- });
497
- });
498
- describe('with a trigger', () => {
499
- it('should not show content by default', async () => {
500
- (0, _react.render)(_Drilldown10 || (_Drilldown10 = (0, _jsxRuntime.jsx)(_index.Drilldown, {
501
- rootPageId: "page0",
502
- trigger: (0, _jsxRuntime.jsx)("button", {
503
- children: "click me"
504
- }),
505
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Page, {
506
- id: "page0",
507
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
508
- id: "option0",
509
- children: "Option 0"
510
- })
511
- })
512
- })));
513
- const option_0 = _react.screen.queryByText('Option 0');
514
- expect(option_0).not.toBeInTheDocument();
515
- });
516
- it('should render into a mountNode', async () => {
517
- const container = document.createElement('div');
518
- container.setAttribute('data-testid', 'container');
519
- document.body.appendChild(container);
520
- (0, _react.render)((0, _jsxRuntime.jsx)(_index.Drilldown, {
521
- rootPageId: "page0",
522
- mountNode: container,
523
- trigger: _button7 || (_button7 = (0, _jsxRuntime.jsx)("button", {
524
- children: "Options"
525
- })),
526
- children: _Drilldown$Page10 || (_Drilldown$Page10 = (0, _jsxRuntime.jsx)(_index.Drilldown.Page, {
527
- id: "page0",
528
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
529
- id: "option0",
530
- children: "Option 0"
531
- })
532
- }))
533
- }));
534
- const optionsContainer = _react.screen.getByTestId('container');
535
- const trigger = _react.screen.getByRole('button');
536
- expect(optionsContainer).not.toHaveTextContent('Option 0');
537
- await _userEvent.default.click(trigger);
538
- await (0, _react.waitFor)(() => {
539
- const updatedOptionsContainer = _react.screen.getByTestId('container');
540
- expect(updatedOptionsContainer).toHaveTextContent('Option 0');
541
- });
542
- });
543
- it('should have an aria-haspopup attribute', async () => {
544
- (0, _react.render)(_Drilldown11 || (_Drilldown11 = (0, _jsxRuntime.jsx)(_index.Drilldown, {
545
- rootPageId: "page0",
546
- trigger: (0, _jsxRuntime.jsx)("button", {
547
- children: "Options"
548
- }),
549
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Page, {
550
- id: "page0",
551
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
552
- id: "option0",
553
- children: "Option 0"
554
- })
555
- })
556
- })));
557
- const trigger = _react.screen.getByRole('button');
558
- expect(trigger).toHaveAttribute('aria-haspopup');
559
- });
560
- it('should call onToggle when Drilldown is opened', async () => {
561
- const onToggle = _vitest.vi.fn();
562
- (0, _react.render)((0, _jsxRuntime.jsx)(_index.Drilldown, {
563
- rootPageId: "page0",
564
- trigger: _button8 || (_button8 = (0, _jsxRuntime.jsx)("button", {
565
- children: "Options"
566
- })),
567
- onToggle: onToggle,
568
- "data-testid": "drilldown",
569
- children: _Drilldown$Page11 || (_Drilldown$Page11 = (0, _jsxRuntime.jsx)(_index.Drilldown.Page, {
570
- id: "page0",
571
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
572
- id: "option0",
573
- children: "Option 0"
574
- })
575
- }))
576
- }));
577
- const trigger = _react.screen.getByRole('button');
578
- await _userEvent.default.click(trigger);
579
- await (0, _react.waitFor)(() => {
580
- expect(onToggle).toHaveBeenCalled();
581
- const args = onToggle.mock.calls[0][1];
582
- expect(args).toHaveProperty('shown', true);
583
- expect(args).toHaveProperty('pageHistory', ['page0']);
584
- expect(args.goToPage).toBeInstanceOf(Function);
585
- expect(args.goToPreviousPage).toBeInstanceOf(Function);
586
- expect(args.drilldown.props).toHaveProperty('role', 'menu');
587
- expect(args.drilldown.props).toHaveProperty('data-testid', 'drilldown');
588
- });
589
- });
590
- it('should call onToggle when Drilldown is closed', async () => {
591
- const onToggle = _vitest.vi.fn();
592
- (0, _react.render)((0, _jsxRuntime.jsx)(_index.Drilldown, {
593
- rootPageId: "page0",
594
- trigger: _button9 || (_button9 = (0, _jsxRuntime.jsx)("button", {
595
- children: "Options"
596
- })),
597
- onToggle: onToggle,
598
- defaultShow: true,
599
- children: _Drilldown$Page12 || (_Drilldown$Page12 = (0, _jsxRuntime.jsx)(_index.Drilldown.Page, {
600
- id: "page0",
601
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
602
- id: "option0",
603
- children: "Option 0"
604
- })
605
- }))
606
- }));
607
- const trigger = _react.screen.getByRole('button');
608
- await _userEvent.default.click(trigger);
609
- await (0, _react.waitFor)(() => {
610
- expect(onToggle).toHaveBeenCalled();
611
- const args = onToggle.mock.calls[0][1];
612
- expect(args).toHaveProperty('shown', false);
613
- expect(args).toHaveProperty('pageHistory', ['page0']);
614
- expect(args).toHaveProperty('drilldown');
615
- expect(args.goToPage).toBeInstanceOf(Function);
616
- expect(args.goToPreviousPage).toBeInstanceOf(Function);
617
- });
618
- });
619
- });
620
- describe('placement prop', () => {
621
- it('should be passed to Popover', async () => {
622
- let popoverRef = null;
623
- (0, _react.render)((0, _jsxRuntime.jsx)(_index.Drilldown, {
624
- rootPageId: "page0",
625
- trigger: _button10 || (_button10 = (0, _jsxRuntime.jsx)("button", {
626
- children: "Toggle"
627
- })),
628
- defaultShow: true,
629
- popoverRef: e => {
630
- popoverRef = e;
631
- },
632
- placement: 'top start',
633
- children: _Drilldown$Page13 || (_Drilldown$Page13 = (0, _jsxRuntime.jsx)(_index.Drilldown.Page, {
634
- id: "page0",
635
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
636
- id: "option01",
637
- children: "Option"
638
- })
639
- }))
640
- }));
641
- const popoverProps = popoverRef.props;
642
- expect(popoverProps.placement).toBe('top start');
643
- });
644
- });
645
- describe('defaultShow prop', () => {
646
- it('should display Popover on render', async () => {
647
- (0, _react.render)(_Drilldown12 || (_Drilldown12 = (0, _jsxRuntime.jsx)(_index.Drilldown, {
648
- rootPageId: "page0",
649
- trigger: (0, _jsxRuntime.jsx)("button", {
650
- children: "Toggle"
651
- }),
652
- defaultShow: true,
653
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Page, {
654
- id: "page0",
655
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
656
- id: "option01",
657
- children: "Option"
658
- })
659
- })
660
- })));
661
- const popoverContent = _react.screen.getByText('Option');
662
- expect(popoverContent).toBeVisible();
663
- });
664
- });
665
- describe('show prop', () => {
666
- it('should display popover', async () => {
667
- const onToggle = _vitest.vi.fn();
668
- (0, _react.render)((0, _jsxRuntime.jsx)(_index.Drilldown, {
669
- rootPageId: "page0",
670
- trigger: _button11 || (_button11 = (0, _jsxRuntime.jsx)("button", {
671
- children: "Toggle"
672
- })),
673
- show: true,
674
- onToggle: onToggle,
675
- children: _Drilldown$Page14 || (_Drilldown$Page14 = (0, _jsxRuntime.jsx)(_index.Drilldown.Page, {
676
- id: "page0",
677
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
678
- id: "option01",
679
- children: "Option"
680
- })
681
- }))
682
- }));
683
- const popoverContent = _react.screen.getByText('Option');
684
- expect(popoverContent).toBeVisible();
685
- });
686
- it('should give error if onToggle is not provided (controllable)', async () => {
687
- (0, _react.render)(_Drilldown13 || (_Drilldown13 = (0, _jsxRuntime.jsx)(_index.Drilldown, {
688
- rootPageId: "page0",
689
- trigger: (0, _jsxRuntime.jsx)("button", {
690
- children: "Toggle"
691
- }),
692
- show: true,
693
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Page, {
694
- id: "page0",
695
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
696
- id: "option01",
697
- children: "Option"
698
- })
699
- })
700
- })));
701
- const popoverContent = _react.screen.getByText('Option');
702
- expect(popoverContent).toBeVisible();
703
- expect(popoverContent).toBeVisible();
704
- expect(consoleErrorMock).toHaveBeenCalled();
705
- });
706
- });
707
- describe('onFocus prop', () => {
708
- it('should be passed to Popover', async () => {
709
- let popoverRef = null;
710
- const onFocus = _vitest.vi.fn();
711
- (0, _react.render)((0, _jsxRuntime.jsx)(_index.Drilldown, {
712
- rootPageId: "page0",
713
- trigger: _button12 || (_button12 = (0, _jsxRuntime.jsx)("button", {
714
- children: "Toggle"
715
- })),
716
- popoverRef: e => {
717
- popoverRef = e;
718
- },
719
- onFocus: onFocus,
720
- children: _Drilldown$Page15 || (_Drilldown$Page15 = (0, _jsxRuntime.jsx)(_index.Drilldown.Page, {
721
- id: "page0",
722
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
723
- id: "option01",
724
- children: "Option"
725
- })
726
- }))
727
- }));
728
- const popoverProps = popoverRef.props;
729
- expect(popoverProps.onFocus).toEqual(onFocus);
730
- });
731
- });
732
- describe('onMouseOver prop', () => {
733
- it('should be passed to Popover', async () => {
734
- let popoverRef = null;
735
- const onMouseOver = _vitest.vi.fn();
736
- (0, _react.render)((0, _jsxRuntime.jsx)(_index.Drilldown, {
737
- rootPageId: "page0",
738
- trigger: _button13 || (_button13 = (0, _jsxRuntime.jsx)("button", {
739
- children: "Toggle"
740
- })),
741
- popoverRef: e => {
742
- popoverRef = e;
743
- },
744
- onMouseOver: onMouseOver,
745
- children: _Drilldown$Page16 || (_Drilldown$Page16 = (0, _jsxRuntime.jsx)(_index.Drilldown.Page, {
746
- id: "page0",
747
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
748
- id: "option01",
749
- children: "Option"
750
- })
751
- }))
752
- }));
753
- const popoverProps = popoverRef.props;
754
- expect(popoverProps.onMouseOver).toEqual(onMouseOver);
755
- });
756
- });
757
- describe('shouldContainFocus prop', () => {
758
- it('should be passed to Popover', async () => {
759
- let popoverRef = null;
760
- (0, _react.render)((0, _jsxRuntime.jsx)(_index.Drilldown, {
761
- rootPageId: "page0",
762
- trigger: _button14 || (_button14 = (0, _jsxRuntime.jsx)("button", {
763
- children: "Toggle"
764
- })),
765
- popoverRef: e => {
766
- popoverRef = e;
767
- },
768
- shouldContainFocus: true,
769
- children: _Drilldown$Page17 || (_Drilldown$Page17 = (0, _jsxRuntime.jsx)(_index.Drilldown.Page, {
770
- id: "page0",
771
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
772
- id: "option01",
773
- children: "Option"
774
- })
775
- }))
776
- }));
777
- const popoverProps = popoverRef.props;
778
- expect(popoverProps.shouldContainFocus).toEqual(true);
779
- });
780
- });
781
- describe('shouldReturnFocus prop', () => {
782
- it('should be passed to Popover', async () => {
783
- let popoverRef = null;
784
- (0, _react.render)((0, _jsxRuntime.jsx)(_index.Drilldown, {
785
- rootPageId: "page0",
786
- trigger: _button15 || (_button15 = (0, _jsxRuntime.jsx)("button", {
787
- children: "Toggle"
788
- })),
789
- popoverRef: e => {
790
- popoverRef = e;
791
- },
792
- shouldReturnFocus: false,
793
- children: _Drilldown$Page18 || (_Drilldown$Page18 = (0, _jsxRuntime.jsx)(_index.Drilldown.Page, {
794
- id: "page0",
795
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
796
- id: "option01",
797
- children: "Option"
798
- })
799
- }))
800
- }));
801
- const popoverProps = popoverRef.props;
802
- expect(popoverProps.shouldReturnFocus).toEqual(false);
803
- });
804
- });
805
- describe('withArrow prop', () => {
806
- it('should be passed to Popover', async () => {
807
- let popoverRef = null;
808
- (0, _react.render)((0, _jsxRuntime.jsx)(_index.Drilldown, {
809
- rootPageId: "page0",
810
- trigger: _button16 || (_button16 = (0, _jsxRuntime.jsx)("button", {
811
- children: "Toggle"
812
- })),
813
- popoverRef: e => {
814
- popoverRef = e;
815
- },
816
- withArrow: false,
817
- children: _Drilldown$Page19 || (_Drilldown$Page19 = (0, _jsxRuntime.jsx)(_index.Drilldown.Page, {
818
- id: "page0",
819
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
820
- id: "option01",
821
- children: "Option"
822
- })
823
- }))
824
- }));
825
- const popoverProps = popoverRef.props;
826
- expect(popoverProps.withArrow).toEqual(false);
827
- });
828
- });
829
- describe('offsetX prop', () => {
830
- it('should be passed to Popover', async () => {
831
- let popoverRef = null;
832
- (0, _react.render)((0, _jsxRuntime.jsx)(_index.Drilldown, {
833
- rootPageId: "page0",
834
- trigger: _button17 || (_button17 = (0, _jsxRuntime.jsx)("button", {
835
- children: "Toggle"
836
- })),
837
- popoverRef: e => {
838
- popoverRef = e;
839
- },
840
- offsetX: '2rem',
841
- children: _Drilldown$Page20 || (_Drilldown$Page20 = (0, _jsxRuntime.jsx)(_index.Drilldown.Page, {
842
- id: "page0",
843
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
844
- id: "option01",
845
- children: "Option"
846
- })
847
- }))
848
- }));
849
- const popoverProps = popoverRef.props;
850
- expect(popoverProps.offsetX).toEqual('2rem');
851
- });
852
- });
853
- describe('offsetY prop', () => {
854
- it('should be passed to Popover', async () => {
855
- let popoverRef = null;
856
- (0, _react.render)((0, _jsxRuntime.jsx)(_index.Drilldown, {
857
- rootPageId: "page0",
858
- trigger: _button18 || (_button18 = (0, _jsxRuntime.jsx)("button", {
859
- children: "Toggle"
860
- })),
861
- popoverRef: e => {
862
- popoverRef = e;
863
- },
864
- offsetY: '2rem',
865
- children: _Drilldown$Page21 || (_Drilldown$Page21 = (0, _jsxRuntime.jsx)(_index.Drilldown.Page, {
866
- id: "page0",
867
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
868
- id: "option01",
869
- children: "Option"
870
- })
871
- }))
872
- }));
873
- const popoverProps = popoverRef.props;
874
- expect(popoverProps.offsetY).toEqual('2rem');
875
- });
876
- });
877
- describe('positionContainerDisplay prop', () => {
878
- it('should be passed to Popover', async () => {
879
- let popoverRef = null;
880
- (0, _react.render)((0, _jsxRuntime.jsx)(_index.Drilldown, {
881
- rootPageId: "page0",
882
- trigger: _button19 || (_button19 = (0, _jsxRuntime.jsx)("button", {
883
- children: "Toggle"
884
- })),
885
- popoverRef: e => {
886
- popoverRef = e;
887
- },
888
- positionContainerDisplay: "block",
889
- children: _Drilldown$Page22 || (_Drilldown$Page22 = (0, _jsxRuntime.jsx)(_index.Drilldown.Page, {
890
- id: "page0",
891
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
892
- id: "option01",
893
- children: "Option"
894
- })
895
- }))
896
- }));
897
- const popoverProps = popoverRef.props;
898
- expect(popoverProps.positionContainerDisplay).toEqual('block');
899
- });
900
- });
901
- describe('for a11y', () => {
902
- it('should be accessible', async () => {
903
- const _render9 = (0, _react.render)(_Drilldown14 || (_Drilldown14 = (0, _jsxRuntime.jsxs)(_index.Drilldown, {
904
- rootPageId: "page0",
905
- children: [(0, _jsxRuntime.jsxs)(_index.Drilldown.Page, {
906
- id: "page0",
907
- renderTitle: "Page Title",
908
- renderActionLabel: "Action Label",
909
- children: [(0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
910
- id: "item01",
911
- children: "Item1"
912
- }), (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
913
- id: "item02",
914
- subPageId: "page1",
915
- children: "Item2"
916
- }), (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
917
- id: "item03",
918
- description: "This is a description",
919
- children: "Item3"
920
- }), (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
921
- id: "item04",
922
- renderLabelInfo: "After",
923
- children: "Item4"
924
- }), (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
925
- id: "item05",
926
- disabled: true,
927
- children: "Item5"
928
- }), (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
929
- id: "item06",
930
- href: "/",
931
- children: "Item6"
932
- }), (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
933
- id: "item07",
934
- renderBeforeLabel: (0, _jsxRuntime.jsx)(_IconCheckSolid.IconCheckSolid, {}),
935
- children: "Item7"
936
- }), (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
937
- id: "item08",
938
- renderAfterLabel: (0, _jsxRuntime.jsx)(_IconCheckSolid.IconCheckSolid, {}),
939
- children: "Item8"
940
- }), (0, _jsxRuntime.jsx)(_index.Drilldown.Separator, {
941
- id: "sep1"
942
- }), (0, _jsxRuntime.jsxs)(_index.Drilldown.Group, {
943
- id: "group1",
944
- renderGroupTitle: "Multi-select group",
945
- selectableType: "multiple",
946
- children: [(0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
947
- id: "groupItem11",
948
- children: "GroupItem"
949
- }), (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
950
- id: "groupItem12",
951
- children: "GroupItem"
952
- }), (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
953
- id: "groupItem13",
954
- children: "GroupItem"
955
- })]
956
- }), (0, _jsxRuntime.jsxs)(_index.Drilldown.Group, {
957
- id: "group2",
958
- renderGroupTitle: "Single-select group",
959
- selectableType: "single",
960
- children: [(0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
961
- id: "groupItem21",
962
- children: "GroupItem"
963
- }), (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
964
- id: "groupItem22",
965
- children: "GroupItem"
966
- }), (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
967
- id: "groupItem23",
968
- children: "GroupItem"
969
- })]
970
- })]
971
- }), (0, _jsxRuntime.jsx)(_index.Drilldown.Page, {
972
- id: "page1",
973
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
974
- id: "item11",
975
- children: "Item1"
976
- })
977
- })]
978
- }))),
979
- container = _render9.container;
980
-
981
- // axe-check is more strict now, and expects "list" role to have "listitem" children, but we use "role='none'" children. After discussing it with the A11y team, we agreed to ignore this error because the screen readers can read the component perfectly.
982
- // TODO: try to remove this ignore if axe-check is updated and isn't this strict anymore
983
- // https://dequeuniversity.com/rules/axe/4.6/aria-required-children?application=axeAPI
984
- const axeCheck = await (0, _runAxeCheck.runAxeCheck)(container, {
985
- ignores: ['aria-required-children']
986
- });
987
- expect(axeCheck).toBe(true);
988
- });
989
- it('should meet a11y standarts when drilldown is open', async () => {
990
- const _render10 = (0, _react.render)(_Drilldown15 || (_Drilldown15 = (0, _jsxRuntime.jsx)(_index.Drilldown, {
991
- defaultShow: true,
992
- rootPageId: "page0",
993
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Page, {
994
- id: "page0",
995
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
996
- id: "option0",
997
- children: "Option 0"
998
- })
999
- })
1000
- }))),
1001
- container = _render10.container;
1002
- const axeCheck = await (0, _runAxeCheck.runAxeCheck)(container);
1003
- expect(axeCheck).toBe(true);
1004
- });
1005
- });
1006
- describe('with generated examples', () => {
1007
- const generatedComponents = (0, _generateA11yTests.generateA11yTests)(_index.Drilldown, _Drilldown16.default);
1008
- it.each(generatedComponents)('should be accessible with example: $description', async ({
1009
- content
1010
- }) => {
1011
- const _render11 = (0, _react.render)(content),
1012
- container = _render11.container;
1013
- const axeCheck = await (0, _runAxeCheck.runAxeCheck)(container, {
1014
- // axe-check is more strict now, and expects "list" role to have "listitem" children, but we use "role='none'" children. After discussing it with the A11y team, we agreed to ignore this error because the screen readers can read the component perfectly.
1015
- // TODO: try to remove this ignore if axe-check is updated and isn't this strict anymore
1016
- // https://dequeuniversity.com/rules/axe/4.6/aria-required-children?application=axeAPI
1017
- ignores: ['aria-required-children']
1018
- });
1019
- expect(axeCheck).toBe(true);
1020
- });
1021
- });
1022
- });