@react-aria/test-utils 1.0.0-alpha.3 → 1.0.0-alpha.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 (64) hide show
  1. package/dist/combobox.main.js +116 -82
  2. package/dist/combobox.main.js.map +1 -1
  3. package/dist/combobox.mjs +117 -83
  4. package/dist/combobox.module.js +117 -83
  5. package/dist/combobox.module.js.map +1 -1
  6. package/dist/events.main.js.map +1 -1
  7. package/dist/events.module.js.map +1 -1
  8. package/dist/gridlist.main.js +102 -59
  9. package/dist/gridlist.main.js.map +1 -1
  10. package/dist/gridlist.mjs +103 -60
  11. package/dist/gridlist.module.js +103 -60
  12. package/dist/gridlist.module.js.map +1 -1
  13. package/dist/listbox.main.js +135 -0
  14. package/dist/listbox.main.js.map +1 -0
  15. package/dist/listbox.mjs +130 -0
  16. package/dist/listbox.module.js +130 -0
  17. package/dist/listbox.module.js.map +1 -0
  18. package/dist/main.js.map +1 -1
  19. package/dist/menu.main.js +195 -161
  20. package/dist/menu.main.js.map +1 -1
  21. package/dist/menu.mjs +196 -162
  22. package/dist/menu.module.js +196 -162
  23. package/dist/menu.module.js.map +1 -1
  24. package/dist/module.js.map +1 -1
  25. package/dist/select.main.js +116 -70
  26. package/dist/select.main.js.map +1 -1
  27. package/dist/select.mjs +117 -71
  28. package/dist/select.module.js +117 -71
  29. package/dist/select.module.js.map +1 -1
  30. package/dist/table.main.js +170 -139
  31. package/dist/table.main.js.map +1 -1
  32. package/dist/table.mjs +171 -140
  33. package/dist/table.module.js +171 -140
  34. package/dist/table.module.js.map +1 -1
  35. package/dist/tabs.main.js +133 -0
  36. package/dist/tabs.main.js.map +1 -0
  37. package/dist/tabs.mjs +128 -0
  38. package/dist/tabs.module.js +128 -0
  39. package/dist/tabs.module.js.map +1 -0
  40. package/dist/tree.main.js +165 -0
  41. package/dist/tree.main.js.map +1 -0
  42. package/dist/tree.mjs +160 -0
  43. package/dist/tree.module.js +160 -0
  44. package/dist/tree.module.js.map +1 -0
  45. package/dist/types.d.ts +607 -145
  46. package/dist/types.d.ts.map +1 -1
  47. package/dist/user.main.js +15 -4
  48. package/dist/user.main.js.map +1 -1
  49. package/dist/user.mjs +15 -4
  50. package/dist/user.module.js +15 -4
  51. package/dist/user.module.js.map +1 -1
  52. package/package.json +2 -3
  53. package/src/combobox.ts +105 -36
  54. package/src/events.ts +1 -1
  55. package/src/gridlist.ts +146 -59
  56. package/src/index.ts +1 -1
  57. package/src/listbox.ts +226 -0
  58. package/src/menu.ts +152 -62
  59. package/src/select.ts +137 -44
  60. package/src/table.ts +129 -64
  61. package/src/tabs.ts +198 -0
  62. package/src/tree.ts +248 -0
  63. package/src/types.ts +133 -0
  64. package/src/user.ts +62 -37
package/dist/types.d.ts CHANGED
@@ -1,163 +1,630 @@
1
1
  import { pointerKey } from "@testing-library/user-event/system/pointer/shared";
2
- interface ComboBoxOptions extends UserOpts, BaseTesterOpts {
2
+ type Direction = 'ltr' | 'rtl';
3
+ export interface UserOpts {
4
+ /**
5
+ * The interaction type (mouse, touch, keyboard) that the test util user will use when interacting with a component. This can be overridden
6
+ * at the aria pattern tester level if needed.
7
+ * @default mouse
8
+ */
9
+ interactionType?: 'mouse' | 'touch' | 'keyboard';
10
+ /**
11
+ * A function used by the test utils to advance timers during interactions. Required for certain aria patterns (e.g. table). This can be overridden
12
+ * at the aria pattern tester level if needed.
13
+ */
14
+ advanceTimer?: (time?: number) => void | Promise<unknown>;
15
+ }
16
+ interface BaseTesterOpts extends UserOpts {
17
+ /** @private */
3
18
  user?: any;
19
+ /** The base element for the given tester (e.g. the table, menu trigger button, etc). */
20
+ root: HTMLElement;
21
+ }
22
+ interface ComboBoxTesterOpts extends BaseTesterOpts {
23
+ /**
24
+ * The base element for the combobox. If provided the wrapping element around the target combobox (as is the the case with a ref provided to RSP ComboBox),
25
+ * will automatically search for the combobox element within.
26
+ */
27
+ root: HTMLElement;
28
+ /**
29
+ * The node of the combobox trigger button if any. If not provided, we will try to automatically use any button
30
+ * within the `root` provided or that the `root` serves as the trigger.
31
+ */
4
32
  trigger?: HTMLElement;
5
33
  }
34
+ interface GridListTesterOpts extends BaseTesterOpts {
35
+ }
36
+ interface ListBoxTesterOpts extends BaseTesterOpts {
37
+ /**
38
+ * A function used by the test utils to advance timers during interactions.
39
+ */
40
+ advanceTimer?: UserOpts['advanceTimer'];
41
+ }
42
+ interface MenuTesterOpts extends BaseTesterOpts {
43
+ /**
44
+ * The trigger element for the menu.
45
+ */
46
+ root: HTMLElement;
47
+ /**
48
+ * Whether the current menu is a submenu.
49
+ */
50
+ isSubmenu?: boolean;
51
+ }
52
+ interface SelectTesterOpts extends BaseTesterOpts {
53
+ /**
54
+ * The trigger element for the select. If provided the wrapping element around the target select (as is the case with a ref provided to RSP Select),
55
+ * will automatically search for the select's trigger element within.
56
+ */
57
+ root: HTMLElement;
58
+ }
59
+ interface TableTesterOpts extends BaseTesterOpts {
60
+ /**
61
+ * A function used by the test utils to advance timers during interactions.
62
+ */
63
+ advanceTimer?: UserOpts['advanceTimer'];
64
+ }
65
+ interface TabsTesterOpts extends BaseTesterOpts {
66
+ /**
67
+ * The horizontal layout direction, typically affected by locale.
68
+ * @default 'ltr'
69
+ */
70
+ direction?: Direction;
71
+ }
72
+ interface TreeTesterOpts extends BaseTesterOpts {
73
+ /**
74
+ * A function used by the test utils to advance timers during interactions.
75
+ */
76
+ advanceTimer?: UserOpts['advanceTimer'];
77
+ }
78
+ interface BaseGridRowInteractionOpts {
79
+ /**
80
+ * The index, text, or node of the row to target.
81
+ */
82
+ row: number | string | HTMLElement;
83
+ /**
84
+ * What interaction type to use when interacting with the row. Defaults to the interaction type set on the tester.
85
+ */
86
+ interactionType?: UserOpts['interactionType'];
87
+ }
88
+ interface ToggleGridRowOpts extends BaseGridRowInteractionOpts {
89
+ /**
90
+ * Whether the row needs to be long pressed to be selected. Depends on the components implementation.
91
+ */
92
+ needsLongPress?: boolean;
93
+ /**
94
+ * Whether the checkbox should be used to select the row. If false, will attempt to select the row via press.
95
+ * @default 'true'
96
+ */
97
+ checkboxSelection?: boolean;
98
+ }
99
+ interface GridRowActionOpts extends BaseGridRowInteractionOpts {
100
+ /**
101
+ * Whether or not the row needs a double click to trigger the row action. Depends on the components implementation.
102
+ */
103
+ needsDoubleClick?: boolean;
104
+ }
105
+ /**
106
+ * Simulates a "long press" event on a element.
107
+ * @param opts - Options for the long press.
108
+ * @param opts.element - Element to long press.
109
+ * @param opts.advanceTimer - Function that when called advances the timers in your test suite by a specific amount of time(ms).
110
+ * @param opts.pointeropts - Options to pass to the simulated event. Defaults to mouse. See https://testing-library.com/docs/dom-testing-library/api-events/#fireevent for more info.
111
+ */
112
+ export function triggerLongPress(opts: {
113
+ element: HTMLElement;
114
+ advanceTimer: (time?: number) => void | Promise<unknown>;
115
+ pointerOpts?: {};
116
+ }): Promise<void>;
117
+ /**
118
+ * Enables reading pageX/pageY from fireEvent.mouse*(..., {pageX: ..., pageY: ...}).
119
+ */
120
+ export function installMouseEvent(): void;
121
+ export function installPointerEvent(): void;
122
+ export let pointerMap: pointerKey[];
123
+ interface ComboBoxOpenOpts {
124
+ /**
125
+ * Whether the combobox opens on focus or needs to be manually opened via user action.
126
+ * @default 'manual'
127
+ */
128
+ triggerBehavior?: 'focus' | 'manual';
129
+ /**
130
+ * What interaction type to use when opening the combobox. Defaults to the interaction type set on the tester.
131
+ */
132
+ interactionType?: UserOpts['interactionType'];
133
+ }
134
+ interface ComboBoxSelectOpts extends ComboBoxOpenOpts {
135
+ /**
136
+ * The index, text, or node of the option to select. Option nodes can be sourced via `options()`.
137
+ */
138
+ option: number | string | HTMLElement;
139
+ }
6
140
  declare class ComboBoxTester {
7
- constructor(opts: ComboBoxOptions);
8
- setInteractionType: (type: UserOpts["interactionType"]) => void;
9
- open: (opts?: {
10
- triggerBehavior?: "focus" | "manual";
11
- interactionType?: UserOpts["interactionType"];
12
- }) => Promise<void>;
13
- selectOption: (opts?: {
14
- option?: HTMLElement;
15
- optionText?: string;
16
- triggerBehavior?: "focus" | "manual";
17
- interactionType?: UserOpts["interactionType"];
18
- }) => Promise<void>;
19
- close: () => Promise<void>;
141
+ constructor(opts: ComboBoxTesterOpts);
142
+ /**
143
+ * Set the interaction type used by the combobox tester.
144
+ */
145
+ setInteractionType(type: UserOpts['interactionType']): void;
146
+ /**
147
+ * Opens the combobox dropdown. Defaults to using the interaction type set on the combobox tester.
148
+ */
149
+ open(opts?: ComboBoxOpenOpts): Promise<void>;
150
+ /**
151
+ * Returns an option matching the specified index or text content.
152
+ */
153
+ findOption(opts: {
154
+ optionIndexOrText: number | string;
155
+ }): HTMLElement;
156
+ /**
157
+ * Selects the desired combobox option. Defaults to using the interaction type set on the combobox tester. If necessary, will open the combobox dropdown beforehand.
158
+ * The desired option can be targeted via the option's node, the option's text, or the option's index.
159
+ */
160
+ selectOption(opts: ComboBoxSelectOpts): Promise<void>;
161
+ /**
162
+ * Closes the combobox dropdown.
163
+ */
164
+ close(): Promise<void>;
165
+ /**
166
+ * Returns the combobox.
167
+ */
20
168
  get combobox(): HTMLElement;
21
- get trigger(): HTMLElement | undefined;
22
- get listbox(): HTMLElement | undefined;
23
- options: (opts?: {
24
- element?: HTMLElement;
25
- }) => HTMLElement[] | never[];
169
+ /**
170
+ * Returns the combobox trigger button.
171
+ */
172
+ get trigger(): HTMLElement;
173
+ /**
174
+ * Returns the combobox's listbox if present.
175
+ */
176
+ get listbox(): HTMLElement | null;
177
+ /**
178
+ * Returns the combobox's sections if present.
179
+ */
26
180
  get sections(): HTMLElement[];
27
- get focusedOption(): HTMLElement | null | undefined;
181
+ /**
182
+ * Returns the combobox's options if present. Can be filtered to a subsection of the listbox if provided via `element`.
183
+ */
184
+ options(opts?: {
185
+ element?: HTMLElement;
186
+ }): HTMLElement[];
187
+ /**
188
+ * Returns the currently focused option in the combobox's dropdown if any.
189
+ */
190
+ get focusedOption(): HTMLElement | null;
28
191
  }
29
- interface GridListOptions extends UserOpts, BaseTesterOpts {
30
- user?: any;
192
+ interface GridListToggleRowOpts extends ToggleGridRowOpts {
193
+ }
194
+ interface GridListRowActionOpts extends GridRowActionOpts {
31
195
  }
32
196
  declare class GridListTester {
33
- constructor(opts: GridListOptions);
34
- setInteractionType: (type: UserOpts["interactionType"]) => void;
35
- toggleRowSelection: (opts?: {
36
- index?: number;
37
- text?: string;
38
- interactionType?: UserOpts["interactionType"];
39
- }) => Promise<void>;
40
- findRow: (opts: {
41
- index?: number;
42
- text?: string;
43
- }) => any;
44
- triggerRowAction: (opts: {
45
- index?: number;
46
- text?: string;
47
- needsDoubleClick?: boolean;
48
- interactionType?: UserOpts["interactionType"];
49
- }) => Promise<void>;
197
+ constructor(opts: GridListTesterOpts);
198
+ /**
199
+ * Set the interaction type used by the gridlist tester.
200
+ */
201
+ setInteractionType(type: UserOpts['interactionType']): void;
202
+ /**
203
+ * Returns a row matching the specified index or text content.
204
+ */
205
+ findRow(opts: {
206
+ rowIndexOrText: number | string;
207
+ }): HTMLElement;
208
+ /**
209
+ * Toggles the selection for the specified gridlist row. Defaults to using the interaction type set on the gridlist tester.
210
+ */
211
+ toggleRowSelection(opts: GridListToggleRowOpts): Promise<void>;
212
+ /**
213
+ * Triggers the action for the specified gridlist row. Defaults to using the interaction type set on the gridlist tester.
214
+ */
215
+ triggerRowAction(opts: GridListRowActionOpts): Promise<void>;
216
+ /**
217
+ * Returns the gridlist.
218
+ */
50
219
  get gridlist(): HTMLElement;
220
+ /**
221
+ * Returns the gridlist's rows if any.
222
+ */
51
223
  get rows(): HTMLElement[];
224
+ /**
225
+ * Returns the gridlist's selected rows if any.
226
+ */
52
227
  get selectedRows(): HTMLElement[];
53
- cells: (opts?: {
228
+ /**
229
+ * Returns the gridlist's cells if any. Can be filtered against a specific row if provided via `element`.
230
+ */
231
+ cells(opts?: {
54
232
  element?: HTMLElement;
55
- }) => HTMLElement[];
233
+ }): HTMLElement[];
56
234
  }
57
- interface MenuOptions extends UserOpts, BaseTesterOpts {
58
- user?: any;
59
- isSubmenu?: boolean;
235
+ interface ListBoxToggleOptionOpts {
236
+ /**
237
+ * What interaction type to use when toggling selection for an option. Defaults to the interaction type set on the tester.
238
+ */
239
+ interactionType?: UserOpts['interactionType'];
240
+ /**
241
+ * The index, text, or node of the option to toggle selection for.
242
+ */
243
+ option: number | string | HTMLElement;
244
+ /**
245
+ * Whether the option should be triggered by Space or Enter in keyboard modality.
246
+ * @default 'Enter'
247
+ */
248
+ keyboardActivation?: 'Space' | 'Enter';
249
+ /**
250
+ * Whether the option needs to be long pressed to be selected. Depends on the listbox's implementation.
251
+ */
252
+ needsLongPress?: boolean;
253
+ }
254
+ interface ListBoxOptionActionOpts extends Omit<ListBoxToggleOptionOpts, 'keyboardActivation' | 'needsLongPress'> {
255
+ /**
256
+ * Whether or not the option needs a double click to trigger the option action. Depends on the listbox's implementation.
257
+ */
258
+ needsDoubleClick?: boolean;
259
+ }
260
+ declare class ListBoxTester {
261
+ constructor(opts: ListBoxTesterOpts);
262
+ /**
263
+ * Set the interaction type used by the listbox tester.
264
+ */
265
+ setInteractionType(type: UserOpts['interactionType']): void;
266
+ /**
267
+ * Returns a option matching the specified index or text content.
268
+ */
269
+ findOption(opts: {
270
+ optionIndexOrText: number | string;
271
+ }): HTMLElement;
272
+ /**
273
+ * Toggles the selection for the specified listbox option. Defaults to using the interaction type set on the listbox tester.
274
+ */
275
+ toggleOptionSelection(opts: ListBoxToggleOptionOpts): Promise<void>;
276
+ /**
277
+ * Triggers the action for the specified listbox option. Defaults to using the interaction type set on the listbox tester.
278
+ */
279
+ triggerOptionAction(opts: ListBoxOptionActionOpts): Promise<void>;
280
+ /**
281
+ * Returns the listbox.
282
+ */
283
+ get listbox(): HTMLElement;
284
+ /**
285
+ * Returns the listbox options. Can be filtered to a subsection of the listbox if provided via `element`.
286
+ */
287
+ options(opts?: {
288
+ element?: HTMLElement;
289
+ }): HTMLElement[];
290
+ /**
291
+ * Returns the listbox's selected options if any.
292
+ */
293
+ get selectedOptions(): HTMLElement[];
294
+ /**
295
+ * Returns the listbox's sections if any.
296
+ */
297
+ get sections(): HTMLElement[];
298
+ }
299
+ interface MenuOpenOpts {
300
+ /**
301
+ * Whether the menu needs to be long pressed to open.
302
+ */
303
+ needsLongPress?: boolean;
304
+ /**
305
+ * What interaction type to use when opening the menu. Defaults to the interaction type set on the tester.
306
+ */
307
+ interactionType?: UserOpts['interactionType'];
308
+ /**
309
+ * Whether to open the menu via ArrowUp or ArrowDown if in keyboard modality.
310
+ */
311
+ direction?: 'up' | 'down';
312
+ }
313
+ interface MenuSelectOpts extends MenuOpenOpts {
314
+ /**
315
+ * The index, text, or node of the option to select. Option nodes can be sourced via `options()`.
316
+ */
317
+ option: number | string | HTMLElement;
318
+ /**
319
+ * The menu's selection mode. Will affect whether or not the menu is expected to be closed upon option selection.
320
+ * @default 'single'
321
+ */
322
+ menuSelectionMode?: 'single' | 'multiple';
323
+ /**
324
+ * Whether or not the menu closes on select. Depends on menu implementation and configuration.
325
+ * @default true
326
+ */
327
+ closesOnSelect?: boolean;
328
+ /**
329
+ * Whether the option should be triggered by Space or Enter in keyboard modality.
330
+ * @default 'Enter'
331
+ */
332
+ keyboardActivation?: 'Space' | 'Enter';
333
+ }
334
+ interface MenuOpenSubmenuOpts extends MenuOpenOpts {
335
+ /**
336
+ * The text or node of the submenu trigger to open. Available submenu trigger nodes can be sourced via `submenuTriggers`.
337
+ */
338
+ submenuTrigger: string | HTMLElement;
60
339
  }
61
340
  declare class MenuTester {
62
- constructor(opts: MenuOptions);
63
- setInteractionType: (type: UserOpts["interactionType"]) => void;
64
- open: (opts?: {
65
- needsLongPress?: boolean;
66
- interactionType?: UserOpts["interactionType"];
67
- direction?: "up" | "down";
68
- }) => Promise<void>;
69
- selectOption: (opts: {
70
- option?: HTMLElement;
71
- optionText?: string;
72
- menuSelectionMode?: "single" | "multiple";
73
- needsLongPress?: boolean;
74
- closesOnSelect?: boolean;
75
- interactionType?: UserOpts["interactionType"];
76
- keyboardActivation?: "Space" | "Enter";
77
- }) => Promise<void>;
78
- openSubmenu: (opts: {
79
- submenuTrigger?: HTMLElement;
80
- submenuTriggerText?: string;
81
- needsLongPress?: boolean;
82
- interactionType?: UserOpts["interactionType"];
83
- }) => Promise<MenuTester | null>;
84
- keyboardNavigateToOption: (opts: {
85
- option: HTMLElement;
86
- }) => Promise<void>;
87
- close: () => Promise<void>;
341
+ constructor(opts: MenuTesterOpts);
342
+ /**
343
+ * Set the interaction type used by the menu tester.
344
+ */
345
+ setInteractionType(type: UserOpts['interactionType']): void;
346
+ /**
347
+ * Opens the menu. Defaults to using the interaction type set on the menu tester.
348
+ */
349
+ open(opts?: MenuOpenOpts): Promise<void>;
350
+ /**
351
+ * Returns a option matching the specified index or text content.
352
+ */
353
+ findOption(opts: {
354
+ optionIndexOrText: number | string;
355
+ }): HTMLElement;
356
+ /**
357
+ * Selects the desired menu option. Defaults to using the interaction type set on the menu tester. If necessary, will open the menu dropdown beforehand.
358
+ * The desired option can be targeted via the option's node, the option's text, or the option's index.
359
+ */
360
+ selectOption(opts: MenuSelectOpts): Promise<void>;
361
+ /**
362
+ * Opens the submenu. Defaults to using the interaction type set on the menu tester. The submenu trigger can be targeted via the trigger's node or the trigger's text.
363
+ */
364
+ openSubmenu(opts: MenuOpenSubmenuOpts): Promise<MenuTester | null>;
365
+ /**
366
+ * Closes the menu.
367
+ */
368
+ close(): Promise<void>;
369
+ /**
370
+ * Returns the menu's trigger.
371
+ */
88
372
  get trigger(): HTMLElement;
89
- get menu(): HTMLElement | null | undefined;
90
- get options(): HTMLElement[];
373
+ /**
374
+ * Returns the menu if present.
375
+ */
376
+ get menu(): HTMLElement | null;
377
+ /**
378
+ * Returns the menu's sections if any.
379
+ */
91
380
  get sections(): HTMLElement[];
381
+ /**
382
+ * Returns the menu's options if present. Can be filtered to a subsection of the menu if provided via `element`.
383
+ */
384
+ options(opts?: {
385
+ element?: HTMLElement;
386
+ }): HTMLElement[];
387
+ /**
388
+ * Returns the menu's submenu triggers if any.
389
+ */
92
390
  get submenuTriggers(): HTMLElement[];
93
391
  }
94
- interface SelectOptions extends UserOpts, BaseTesterOpts {
95
- user?: any;
392
+ interface SelectOpenOpts {
393
+ /**
394
+ * What interaction type to use when opening the select. Defaults to the interaction type set on the tester.
395
+ */
396
+ interactionType?: UserOpts['interactionType'];
397
+ }
398
+ interface SelectTriggerOptionOpts extends SelectOpenOpts {
399
+ /**
400
+ * The index, text, or node of the option to select. Option nodes can be sourced via `options()`.
401
+ */
402
+ option: number | string | HTMLElement;
96
403
  }
97
404
  declare class SelectTester {
98
- constructor(opts: SelectOptions);
99
- setInteractionType: (type: UserOpts["interactionType"]) => void;
100
- open: (opts?: {
101
- interactionType?: UserOpts["interactionType"];
102
- }) => Promise<void>;
103
- selectOption: (opts: {
104
- optionText: string;
105
- interactionType?: UserOpts["interactionType"];
106
- }) => Promise<void>;
107
- close: () => Promise<void>;
405
+ constructor(opts: SelectTesterOpts);
406
+ /**
407
+ * Set the interaction type used by the select tester.
408
+ */
409
+ setInteractionType(type: UserOpts['interactionType']): void;
410
+ /**
411
+ * Opens the select. Defaults to using the interaction type set on the select tester.
412
+ */
413
+ open(opts?: SelectOpenOpts): Promise<void>;
414
+ /**
415
+ * Closes the select.
416
+ */
417
+ close(): Promise<void>;
418
+ /**
419
+ * Returns a option matching the specified index or text content.
420
+ */
421
+ findOption(opts: {
422
+ optionIndexOrText: number | string;
423
+ }): HTMLElement;
424
+ /**
425
+ * Selects the desired select option. Defaults to using the interaction type set on the select tester. If necessary, will open the select dropdown beforehand.
426
+ * The desired option can be targeted via the option's node, the option's text, or the option's index.
427
+ */
428
+ selectOption(opts: SelectTriggerOptionOpts): Promise<void>;
429
+ /**
430
+ * Returns the select's options if present. Can be filtered to a subsection of the listbox if provided via `element`.
431
+ */
432
+ options(opts?: {
433
+ element?: HTMLElement;
434
+ }): HTMLElement[];
435
+ /**
436
+ * Returns the select's trigger.
437
+ */
108
438
  get trigger(): HTMLElement;
109
- get listbox(): HTMLElement | null | undefined;
110
- get options(): HTMLElement[];
439
+ /**
440
+ * Returns the select's listbox if present.
441
+ */
442
+ get listbox(): HTMLElement | null;
443
+ /**
444
+ * Returns the select's sections if present.
445
+ */
111
446
  get sections(): HTMLElement[];
112
447
  }
113
- interface TableOptions extends UserOpts, BaseTesterOpts {
114
- user?: any;
115
- advanceTimer: UserOpts['advanceTimer'];
448
+ interface TableToggleRowOpts extends ToggleGridRowOpts {
449
+ }
450
+ interface TableToggleSortOpts {
451
+ /**
452
+ * The index, text, or node of the column to toggle selection for.
453
+ */
454
+ column: number | string | HTMLElement;
455
+ /**
456
+ * What interaction type to use when sorting the column. Defaults to the interaction type set on the tester.
457
+ */
458
+ interactionType?: UserOpts['interactionType'];
459
+ }
460
+ interface TableRowActionOpts extends GridRowActionOpts {
116
461
  }
117
462
  declare class TableTester {
118
- constructor(opts: TableOptions);
119
- setInteractionType: (type: UserOpts["interactionType"]) => void;
120
- toggleRowSelection: (opts?: {
121
- index?: number;
122
- text?: string;
123
- needsLongPress?: boolean;
124
- interactionType?: UserOpts["interactionType"];
125
- }) => Promise<void>;
126
- toggleSort: (opts?: {
127
- index?: number;
128
- text?: string;
129
- interactionType?: UserOpts["interactionType"];
130
- }) => Promise<void>;
131
- triggerRowAction: (opts?: {
132
- index?: number;
133
- text?: string;
134
- needsDoubleClick?: boolean;
135
- interactionType?: UserOpts["interactionType"];
136
- }) => Promise<void>;
137
- toggleSelectAll: (opts?: {
138
- interactionType?: UserOpts["interactionType"];
139
- }) => Promise<void>;
140
- findRow: (opts?: {
141
- index?: number;
142
- text?: string;
143
- }) => any;
144
- findCell: (opts: {
463
+ constructor(opts: TableTesterOpts);
464
+ /**
465
+ * Set the interaction type used by the table tester.
466
+ */
467
+ setInteractionType(type: UserOpts['interactionType']): void;
468
+ /**
469
+ * Toggles the selection for the specified table row. Defaults to using the interaction type set on the table tester.
470
+ */
471
+ toggleRowSelection(opts: TableToggleRowOpts): Promise<void>;
472
+ /**
473
+ * Toggles the sort order for the specified table column. Defaults to using the interaction type set on the table tester.
474
+ */
475
+ toggleSort(opts: TableToggleSortOpts): Promise<void>;
476
+ /**
477
+ * Triggers the action for the specified table row. Defaults to using the interaction type set on the table tester.
478
+ */
479
+ triggerRowAction(opts: TableRowActionOpts): Promise<void>;
480
+ /**
481
+ * Toggle selection for all rows in the table. Defaults to using the interaction type set on the table tester.
482
+ */
483
+ toggleSelectAll(opts?: {
484
+ interactionType?: UserOpts['interactionType'];
485
+ }): Promise<void>;
486
+ /**
487
+ * Returns a row matching the specified index or text content.
488
+ */
489
+ findRow(opts: {
490
+ rowIndexOrText: number | string;
491
+ }): HTMLElement;
492
+ /**
493
+ * Returns a cell matching the specified text content.
494
+ */
495
+ findCell(opts: {
145
496
  text: string;
146
- }) => HTMLElement;
497
+ }): HTMLElement;
498
+ /**
499
+ * Returns the table.
500
+ */
147
501
  get table(): HTMLElement;
502
+ /**
503
+ * Returns the row groups within the table.
504
+ */
148
505
  get rowGroups(): HTMLElement[];
506
+ /**
507
+ * Returns the columns within the table.
508
+ */
149
509
  get columns(): HTMLElement[];
510
+ /**
511
+ * Returns the rows within the table if any.
512
+ */
150
513
  get rows(): HTMLElement[];
514
+ /**
515
+ * Returns the currently selected rows within the table if any.
516
+ */
151
517
  get selectedRows(): HTMLElement[];
518
+ /**
519
+ * Returns the row headers within the table if any.
520
+ */
152
521
  get rowHeaders(): HTMLElement[];
153
- get cells(): HTMLElement[];
522
+ /**
523
+ * Returns the cells within the table if any. Can be filtered against a specific row if provided via `element`.
524
+ */
525
+ cells(opts?: {
526
+ element?: HTMLElement;
527
+ }): HTMLElement[];
154
528
  }
155
- export interface UserOpts {
156
- interactionType?: 'mouse' | 'touch' | 'keyboard';
157
- advanceTimer?: (time?: number) => void | Promise<unknown>;
529
+ interface TriggerTabOptions {
530
+ /**
531
+ * What interaction type to use when triggering a tab. Defaults to the interaction type set on the tester.
532
+ */
533
+ interactionType?: UserOpts['interactionType'];
534
+ /**
535
+ * The index, text, or node of the tab to toggle selection for.
536
+ */
537
+ tab: number | string | HTMLElement;
538
+ /**
539
+ * Whether the tab needs to be activated manually rather than on focus.
540
+ */
541
+ manualActivation?: boolean;
158
542
  }
159
- interface BaseTesterOpts {
160
- root: HTMLElement;
543
+ declare class TabsTester {
544
+ constructor(opts: TabsTesterOpts);
545
+ /**
546
+ * Set the interaction type used by the tabs tester.
547
+ */
548
+ setInteractionType(type: UserOpts['interactionType']): void;
549
+ /**
550
+ * Returns a tab matching the specified index or text content.
551
+ */
552
+ findTab(opts: {
553
+ tabIndexOrText: number | string;
554
+ }): HTMLElement;
555
+ /**
556
+ * Triggers the specified tab. Defaults to using the interaction type set on the tabs tester.
557
+ */
558
+ triggerTab(opts: TriggerTabOptions): Promise<void>;
559
+ /**
560
+ * Returns the tablist.
561
+ */
562
+ get tablist(): HTMLElement;
563
+ /**
564
+ * Returns the tabpanels.
565
+ */
566
+ get tabpanels(): HTMLElement[];
567
+ /**
568
+ * Returns the tabs in the tablist.
569
+ */
570
+ get tabs(): HTMLElement[];
571
+ /**
572
+ * Returns the currently selected tab in the tablist if any.
573
+ */
574
+ get selectedTab(): HTMLElement | null;
575
+ /**
576
+ * Returns the currently active tabpanel if any.
577
+ */
578
+ get activeTabpanel(): HTMLElement | null;
579
+ }
580
+ interface TreeToggleExpansionOpts extends BaseGridRowInteractionOpts {
581
+ }
582
+ interface TreeToggleRowOpts extends ToggleGridRowOpts {
583
+ }
584
+ interface TreeRowActionOpts extends GridRowActionOpts {
585
+ }
586
+ declare class TreeTester {
587
+ constructor(opts: TreeTesterOpts);
588
+ /**
589
+ * Set the interaction type used by the tree tester.
590
+ */
591
+ setInteractionType(type: UserOpts['interactionType']): void;
592
+ /**
593
+ * Returns a row matching the specified index or text content.
594
+ */
595
+ findRow(opts: {
596
+ rowIndexOrText: number | string;
597
+ }): HTMLElement;
598
+ /**
599
+ * Toggles the selection for the specified tree row. Defaults to using the interaction type set on the tree tester.
600
+ */
601
+ toggleRowSelection(opts: TreeToggleRowOpts): Promise<void>;
602
+ /**
603
+ * Toggles the expansion for the specified tree row. Defaults to using the interaction type set on the tree tester.
604
+ */
605
+ toggleRowExpansion(opts: TreeToggleExpansionOpts): Promise<void>;
606
+ /**
607
+ * Triggers the action for the specified tree row. Defaults to using the interaction type set on the tree tester.
608
+ */
609
+ triggerRowAction(opts: TreeRowActionOpts): Promise<void>;
610
+ /**
611
+ * Returns the tree.
612
+ */
613
+ get tree(): HTMLElement;
614
+ /**
615
+ * Returns the tree's rows if any.
616
+ */
617
+ get rows(): HTMLElement[];
618
+ /**
619
+ * Returns the tree's selected rows if any.
620
+ */
621
+ get selectedRows(): HTMLElement[];
622
+ /**
623
+ * Returns the tree's cells if any. Can be filtered against a specific row if provided via `element`.
624
+ */
625
+ cells(opts?: {
626
+ element?: HTMLElement;
627
+ }): HTMLElement[];
161
628
  }
162
629
  declare let keyToUtil: {
163
630
  readonly Select: typeof SelectTester;
@@ -165,34 +632,29 @@ declare let keyToUtil: {
165
632
  readonly Menu: typeof MenuTester;
166
633
  readonly ComboBox: typeof ComboBoxTester;
167
634
  readonly GridList: typeof GridListTester;
635
+ readonly ListBox: typeof ListBoxTester;
636
+ readonly Tabs: typeof TabsTester;
637
+ readonly Tree: typeof TreeTester;
168
638
  };
169
639
  type PatternNames = keyof typeof keyToUtil;
170
- type ObjectType<T> = T extends 'Select' ? SelectTester : T extends 'Table' ? TableTester : T extends 'Menu' ? MenuTester : T extends 'ComboBox' ? ComboBoxTester : T extends 'GridList' ? GridListTester : never;
171
- type ObjectOptionsTypes<T> = T extends 'Select' ? SelectOptions : T extends 'Table' ? TableOptions : T extends 'Menu' ? MenuOptions : T extends 'ComboBox' ? ComboBoxOptions : T extends 'GridList' ? GridListOptions : never;
640
+ type Tester<T> = T extends 'ComboBox' ? ComboBoxTester : T extends 'GridList' ? GridListTester : T extends 'ListBox' ? ListBoxTester : T extends 'Menu' ? MenuTester : T extends 'Select' ? SelectTester : T extends 'Table' ? TableTester : T extends 'Tabs' ? TabsTester : T extends 'Tree' ? TreeTester : never;
641
+ type TesterOpts<T> = T extends 'ComboBox' ? ComboBoxTesterOpts : T extends 'GridList' ? GridListTesterOpts : T extends 'ListBox' ? ListBoxTesterOpts : T extends 'Menu' ? MenuTesterOpts : T extends 'Select' ? SelectTesterOpts : T extends 'Table' ? TableTesterOpts : T extends 'Tabs' ? TabsTesterOpts : T extends 'Tree' ? TreeTesterOpts : never;
172
642
  export class User {
173
- user: any;
643
+ /**
644
+ * The interaction type (mouse, touch, keyboard) that the test util user will use when interacting with a component. This can be overridden
645
+ * at the aria pattern util level if needed.
646
+ * @default mouse
647
+ */
174
648
  interactionType: UserOpts['interactionType'];
649
+ /**
650
+ * A function used by the test utils to advance timers during interactions. Required for certain aria patterns (e.g. table).
651
+ */
175
652
  advanceTimer: UserOpts['advanceTimer'];
176
653
  constructor(opts?: UserOpts);
177
- createTester<T extends PatternNames>(patternName: T, opts: ObjectOptionsTypes<T>): ObjectType<T>;
654
+ /**
655
+ * Creates an aria pattern tester, inheriting the options provided to the original user.
656
+ */
657
+ createTester<T extends PatternNames>(patternName: T, opts: TesterOpts<T>): Tester<T>;
178
658
  }
179
- /**
180
- * Simulates a "long press" event on a element.
181
- * @param opts - Options for the long press.
182
- * @param opts.element - Element to long press.
183
- * @param opts.advanceTimer - Function that when called advances the timers in your test suite by a specific amount of time(ms).
184
- * @param opts.pointeropts - Options to pass to the simulated event. Defaults to mouse. See https://testing-library.com/docs/dom-testing-library/api-events/#fireevent for more info.
185
- */
186
- export function triggerLongPress(opts: {
187
- element: HTMLElement;
188
- advanceTimer: (time?: number) => void | Promise<unknown>;
189
- pointerOpts?: {};
190
- }): Promise<void>;
191
- /**
192
- * Enables reading pageX/pageY from fireEvent.mouse*(..., {pageX: ..., pageY: ...}).
193
- */
194
- export function installMouseEvent(): void;
195
- export function installPointerEvent(): void;
196
- export let pointerMap: pointerKey[];
197
659
 
198
660
  //# sourceMappingURL=types.d.ts.map