@react-aria/test-utils 1.0.0-alpha.5 → 1.0.0-alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/combobox.main.js.map +1 -1
- package/dist/combobox.module.js.map +1 -1
- package/dist/events.main.js.map +1 -1
- package/dist/events.module.js.map +1 -1
- package/dist/gridlist.main.js +1 -1
- package/dist/gridlist.main.js.map +1 -1
- package/dist/gridlist.mjs +1 -1
- package/dist/gridlist.module.js +1 -1
- package/dist/gridlist.module.js.map +1 -1
- package/dist/listbox.main.js +2 -3
- package/dist/listbox.main.js.map +1 -1
- package/dist/listbox.mjs +2 -3
- package/dist/listbox.module.js +2 -3
- package/dist/listbox.module.js.map +1 -1
- package/dist/menu.main.js +39 -19
- package/dist/menu.main.js.map +1 -1
- package/dist/menu.mjs +39 -19
- package/dist/menu.module.js +39 -19
- package/dist/menu.module.js.map +1 -1
- package/dist/select.main.js.map +1 -1
- package/dist/select.module.js.map +1 -1
- package/dist/table.main.js.map +1 -1
- package/dist/table.module.js.map +1 -1
- package/dist/tabs.main.js.map +1 -1
- package/dist/tabs.module.js.map +1 -1
- package/dist/testSetup.main.js.map +1 -1
- package/dist/testSetup.module.js.map +1 -1
- package/dist/tree.main.js +1 -1
- package/dist/tree.main.js.map +1 -1
- package/dist/tree.mjs +1 -1
- package/dist/tree.module.js +1 -1
- package/dist/tree.module.js.map +1 -1
- package/dist/types.d.ts +6 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/user.main.js +1 -1
- package/dist/user.main.js.map +1 -1
- package/dist/user.mjs +1 -1
- package/dist/user.module.js +1 -1
- package/dist/user.module.js.map +1 -1
- package/package.json +5 -4
- package/src/combobox.ts +4 -4
- package/src/events.ts +3 -3
- package/src/gridlist.ts +8 -7
- package/src/listbox.ts +7 -13
- package/src/menu.ts +64 -14
- package/src/select.ts +4 -4
- package/src/table.ts +6 -6
- package/src/tabs.ts +2 -2
- package/src/testSetup.ts +2 -2
- package/src/tree.ts +9 -8
- package/src/types.ts +8 -4
- package/src/user.ts +1 -1
package/src/tree.ts
CHANGED
|
@@ -41,7 +41,7 @@ export class TreeTester {
|
|
|
41
41
|
/**
|
|
42
42
|
* Set the interaction type used by the tree tester.
|
|
43
43
|
*/
|
|
44
|
-
setInteractionType(type: UserOpts['interactionType']) {
|
|
44
|
+
setInteractionType(type: UserOpts['interactionType']): void {
|
|
45
45
|
this._interactionType = type;
|
|
46
46
|
};
|
|
47
47
|
|
|
@@ -71,6 +71,11 @@ export class TreeTester {
|
|
|
71
71
|
if (targetIndex === -1) {
|
|
72
72
|
throw new Error('Option provided is not in the tree');
|
|
73
73
|
}
|
|
74
|
+
|
|
75
|
+
if (document.activeElement !== this._tree || !this._tree.contains(document.activeElement)) {
|
|
76
|
+
act(() => this._tree.focus());
|
|
77
|
+
}
|
|
78
|
+
|
|
74
79
|
if (document.activeElement === this.tree) {
|
|
75
80
|
await this.user.keyboard('[ArrowDown]');
|
|
76
81
|
} else if (this._tree.contains(document.activeElement) && document.activeElement!.getAttribute('role') !== 'row') {
|
|
@@ -92,7 +97,7 @@ export class TreeTester {
|
|
|
92
97
|
/**
|
|
93
98
|
* Toggles the selection for the specified tree row. Defaults to using the interaction type set on the tree tester.
|
|
94
99
|
*/
|
|
95
|
-
async toggleRowSelection(opts: TreeToggleRowOpts) {
|
|
100
|
+
async toggleRowSelection(opts: TreeToggleRowOpts): Promise<void> {
|
|
96
101
|
let {
|
|
97
102
|
row,
|
|
98
103
|
needsLongPress,
|
|
@@ -143,7 +148,7 @@ export class TreeTester {
|
|
|
143
148
|
/**
|
|
144
149
|
* Toggles the expansion for the specified tree row. Defaults to using the interaction type set on the tree tester.
|
|
145
150
|
*/
|
|
146
|
-
async toggleRowExpansion(opts: TreeToggleExpansionOpts) {
|
|
151
|
+
async toggleRowExpansion(opts: TreeToggleExpansionOpts): Promise<void> {
|
|
147
152
|
let {
|
|
148
153
|
row,
|
|
149
154
|
interactionType = this._interactionType
|
|
@@ -184,7 +189,7 @@ export class TreeTester {
|
|
|
184
189
|
/**
|
|
185
190
|
* Triggers the action for the specified tree row. Defaults to using the interaction type set on the tree tester.
|
|
186
191
|
*/
|
|
187
|
-
async triggerRowAction(opts: TreeRowActionOpts) {
|
|
192
|
+
async triggerRowAction(opts: TreeRowActionOpts): Promise<void> {
|
|
188
193
|
let {
|
|
189
194
|
row,
|
|
190
195
|
needsDoubleClick,
|
|
@@ -206,10 +211,6 @@ export class TreeTester {
|
|
|
206
211
|
return;
|
|
207
212
|
}
|
|
208
213
|
|
|
209
|
-
if (document.activeElement !== this._tree || !this._tree.contains(document.activeElement)) {
|
|
210
|
-
act(() => this._tree.focus());
|
|
211
|
-
}
|
|
212
|
-
|
|
213
214
|
await this.keyboardNavigateToRow({row});
|
|
214
215
|
await this.user.keyboard('[Enter]');
|
|
215
216
|
} else {
|
package/src/types.ts
CHANGED
|
@@ -22,14 +22,14 @@ export interface UserOpts {
|
|
|
22
22
|
* @default mouse
|
|
23
23
|
*/
|
|
24
24
|
interactionType?: 'mouse' | 'touch' | 'keyboard',
|
|
25
|
-
// If using fake timers user should provide something like (time) => jest.advanceTimersByTime(time))}
|
|
26
|
-
// A real timer user would pass
|
|
25
|
+
// If using fake timers user should provide something like (time) => jest.advanceTimersByTime(time))}.
|
|
26
|
+
// A real timer user would pass (waitTime) => new Promise((resolve) => setTimeout(resolve, waitTime))
|
|
27
27
|
// Time is in ms.
|
|
28
28
|
/**
|
|
29
29
|
* A function used by the test utils to advance timers during interactions. Required for certain aria patterns (e.g. table). This can be overridden
|
|
30
30
|
* at the aria pattern tester level if needed.
|
|
31
31
|
*/
|
|
32
|
-
advanceTimer?: (time
|
|
32
|
+
advanceTimer?: (time: number) => unknown | Promise<unknown>
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
export interface BaseTesterOpts extends UserOpts {
|
|
@@ -69,7 +69,11 @@ export interface MenuTesterOpts extends BaseTesterOpts {
|
|
|
69
69
|
/**
|
|
70
70
|
* Whether the current menu is a submenu.
|
|
71
71
|
*/
|
|
72
|
-
isSubmenu?: boolean
|
|
72
|
+
isSubmenu?: boolean,
|
|
73
|
+
/**
|
|
74
|
+
* The root menu of the menu tree. Only available if the menu is a submenu.
|
|
75
|
+
*/
|
|
76
|
+
rootMenu?: HTMLElement
|
|
73
77
|
}
|
|
74
78
|
|
|
75
79
|
export interface SelectTesterOpts extends BaseTesterOpts {
|
package/src/user.ts
CHANGED
|
@@ -67,7 +67,7 @@ type TesterOpts<T> =
|
|
|
67
67
|
T extends 'Tree' ? TreeTesterOpts :
|
|
68
68
|
never;
|
|
69
69
|
|
|
70
|
-
let defaultAdvanceTimer =
|
|
70
|
+
let defaultAdvanceTimer = (waitTime: number | undefined) => new Promise((resolve) => setTimeout(resolve, waitTime));
|
|
71
71
|
|
|
72
72
|
export class User {
|
|
73
73
|
private user;
|