@react-aria/test-utils 1.0.0-beta.2 → 1.0.0-beta.3
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/import.mjs +5 -5
- package/dist/main.js +9 -9
- package/dist/module.js +5 -5
- package/dist/{checkboxgroup.main.js → private/checkboxgroup.cjs} +19 -19
- package/dist/private/checkboxgroup.cjs.map +1 -0
- package/dist/{checkboxgroup.mjs → private/checkboxgroup.js} +19 -19
- package/dist/private/checkboxgroup.js.map +1 -0
- package/dist/{combobox.main.js → private/combobox.cjs} +35 -35
- package/dist/private/combobox.cjs.map +1 -0
- package/dist/{combobox.mjs → private/combobox.js} +35 -35
- package/dist/private/combobox.js.map +1 -0
- package/dist/{dialog.main.js → private/dialog.cjs} +19 -19
- package/dist/private/dialog.cjs.map +1 -0
- package/dist/{dialog.mjs → private/dialog.js} +19 -19
- package/dist/private/dialog.js.map +1 -0
- package/dist/{events.main.js → private/events.cjs} +32 -34
- package/dist/private/events.cjs.map +1 -0
- package/dist/{events.mjs → private/events.js} +29 -31
- package/dist/private/events.js.map +1 -0
- package/dist/{gridlist.main.js → private/gridlist.cjs} +27 -28
- package/dist/private/gridlist.cjs.map +1 -0
- package/dist/{gridlist.mjs → private/gridlist.js} +27 -28
- package/dist/private/gridlist.js.map +1 -0
- package/dist/{listbox.main.js → private/listbox.cjs} +24 -24
- package/dist/private/listbox.cjs.map +1 -0
- package/dist/{listbox.mjs → private/listbox.js} +24 -24
- package/dist/private/listbox.js.map +1 -0
- package/dist/{menu.main.js → private/menu.cjs} +46 -48
- package/dist/private/menu.cjs.map +1 -0
- package/dist/{menu.mjs → private/menu.js} +46 -48
- package/dist/private/menu.js.map +1 -0
- package/dist/{radiogroup.main.js → private/radiogroup.cjs} +21 -24
- package/dist/private/radiogroup.cjs.map +1 -0
- package/dist/{radiogroup.mjs → private/radiogroup.js} +21 -24
- package/dist/private/radiogroup.js.map +1 -0
- package/dist/{select.main.js → private/select.cjs} +31 -29
- package/dist/private/select.cjs.map +1 -0
- package/dist/{select.module.js → private/select.js} +31 -29
- package/dist/private/select.js.map +1 -0
- package/dist/{table.main.js → private/table.cjs} +82 -57
- package/dist/private/table.cjs.map +1 -0
- package/dist/{table.module.js → private/table.js} +82 -57
- package/dist/private/table.js.map +1 -0
- package/dist/{tabs.main.js → private/tabs.cjs} +21 -25
- package/dist/private/tabs.cjs.map +1 -0
- package/dist/{tabs.mjs → private/tabs.js} +21 -25
- package/dist/private/tabs.js.map +1 -0
- package/dist/{testSetup.main.js → private/testSetup.cjs} +27 -19
- package/dist/private/testSetup.cjs.map +1 -0
- package/dist/{testSetup.module.js → private/testSetup.js} +26 -18
- package/dist/private/testSetup.js.map +1 -0
- package/dist/{tree.main.js → private/tree.cjs} +34 -35
- package/dist/private/tree.cjs.map +1 -0
- package/dist/{tree.mjs → private/tree.js} +34 -35
- package/dist/private/tree.js.map +1 -0
- package/dist/private/user.cjs +85 -0
- package/dist/private/user.cjs.map +1 -0
- package/dist/private/user.js +76 -0
- package/dist/private/user.js.map +1 -0
- package/dist/{userEventMaps.main.js → private/userEventMaps.cjs} +3 -3
- package/dist/{userEventMaps.main.js.map → private/userEventMaps.cjs.map} +1 -1
- package/dist/{userEventMaps.mjs → private/userEventMaps.js} +3 -3
- package/dist/{userEventMaps.module.js.map → private/userEventMaps.js.map} +1 -1
- package/dist/types/src/checkboxgroup.d.ts +45 -0
- package/dist/types/src/combobox.d.ts +75 -0
- package/dist/types/src/dialog.d.ts +36 -0
- package/dist/types/src/events.d.ts +25 -0
- package/dist/types/src/gridlist.d.ts +51 -0
- package/dist/types/src/index.d.ts +16 -0
- package/dist/types/src/listbox.d.ts +80 -0
- package/dist/types/src/menu.d.ts +102 -0
- package/dist/types/src/radiogroup.d.ts +46 -0
- package/dist/types/src/select.d.ts +67 -0
- package/dist/types/src/table.d.ts +104 -0
- package/dist/types/src/tabs.d.ts +58 -0
- package/dist/types/src/testSetup.d.ts +6 -0
- package/dist/types/src/tree.d.ts +57 -0
- package/dist/types/src/types.d.ts +136 -0
- package/dist/types/src/user.d.ts +47 -0
- package/dist/types/src/userEventMaps.d.ts +2 -0
- package/package.json +7 -7
- package/src/select.ts +10 -2
- package/src/table.ts +46 -1
- package/dist/checkboxgroup.main.js.map +0 -1
- package/dist/checkboxgroup.module.js +0 -99
- package/dist/checkboxgroup.module.js.map +0 -1
- package/dist/combobox.main.js.map +0 -1
- package/dist/combobox.module.js +0 -167
- package/dist/combobox.module.js.map +0 -1
- package/dist/dialog.main.js.map +0 -1
- package/dist/dialog.module.js +0 -100
- package/dist/dialog.module.js.map +0 -1
- package/dist/events.main.js.map +0 -1
- package/dist/events.module.js +0 -112
- package/dist/events.module.js.map +0 -1
- package/dist/gridlist.main.js.map +0 -1
- package/dist/gridlist.module.js +0 -149
- package/dist/gridlist.module.js.map +0 -1
- package/dist/listbox.main.js.map +0 -1
- package/dist/listbox.module.js +0 -138
- package/dist/listbox.module.js.map +0 -1
- package/dist/menu.main.js.map +0 -1
- package/dist/menu.module.js +0 -269
- package/dist/menu.module.js.map +0 -1
- package/dist/radiogroup.main.js.map +0 -1
- package/dist/radiogroup.module.js +0 -118
- package/dist/radiogroup.module.js.map +0 -1
- package/dist/select.main.js.map +0 -1
- package/dist/select.mjs +0 -158
- package/dist/select.module.js.map +0 -1
- package/dist/table.main.js.map +0 -1
- package/dist/table.mjs +0 -290
- package/dist/table.module.js.map +0 -1
- package/dist/tabs.main.js.map +0 -1
- package/dist/tabs.module.js +0 -130
- package/dist/tabs.module.js.map +0 -1
- package/dist/testSetup.main.js.map +0 -1
- package/dist/testSetup.mjs +0 -73
- package/dist/testSetup.module.js.map +0 -1
- package/dist/tree.main.js.map +0 -1
- package/dist/tree.module.js +0 -179
- package/dist/tree.module.js.map +0 -1
- package/dist/types.d.ts +0 -823
- package/dist/types.d.ts.map +0 -1
- package/dist/user.main.js +0 -85
- package/dist/user.main.js.map +0 -1
- package/dist/user.mjs +0 -76
- package/dist/user.module.js +0 -76
- package/dist/user.module.js.map +0 -1
- package/dist/userEventMaps.module.js +0 -38
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { MenuTesterOpts, UserOpts } from './types';
|
|
2
|
+
interface MenuOpenOpts {
|
|
3
|
+
/**
|
|
4
|
+
* Whether the menu needs to be long pressed to open.
|
|
5
|
+
*/
|
|
6
|
+
needsLongPress?: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* What interaction type to use when opening the menu. Defaults to the interaction type set on the tester.
|
|
9
|
+
*/
|
|
10
|
+
interactionType?: UserOpts['interactionType'];
|
|
11
|
+
/**
|
|
12
|
+
* Whether to open the menu via ArrowUp or ArrowDown if in keyboard modality.
|
|
13
|
+
*/
|
|
14
|
+
direction?: 'up' | 'down';
|
|
15
|
+
}
|
|
16
|
+
interface MenuSelectOpts extends MenuOpenOpts {
|
|
17
|
+
/**
|
|
18
|
+
* The index, text, or node of the option to select. Option nodes can be sourced via `options()`.
|
|
19
|
+
*/
|
|
20
|
+
option: number | string | HTMLElement;
|
|
21
|
+
/**
|
|
22
|
+
* The menu's selection mode. Will affect whether or not the menu is expected to be closed upon option selection.
|
|
23
|
+
* @default 'single'
|
|
24
|
+
*/
|
|
25
|
+
menuSelectionMode?: 'single' | 'multiple';
|
|
26
|
+
/**
|
|
27
|
+
* Whether or not the menu closes on select. Depends on menu implementation and configuration.
|
|
28
|
+
* @default true
|
|
29
|
+
*/
|
|
30
|
+
closesOnSelect?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Whether the option should be triggered by Space or Enter in keyboard modality.
|
|
33
|
+
* @default 'Enter'
|
|
34
|
+
*/
|
|
35
|
+
keyboardActivation?: 'Space' | 'Enter';
|
|
36
|
+
}
|
|
37
|
+
interface MenuOpenSubmenuOpts extends MenuOpenOpts {
|
|
38
|
+
/**
|
|
39
|
+
* The text or node of the submenu trigger to open. Available submenu trigger nodes can be sourced via `submenuTriggers`.
|
|
40
|
+
*/
|
|
41
|
+
submenuTrigger: string | HTMLElement;
|
|
42
|
+
}
|
|
43
|
+
export declare class MenuTester {
|
|
44
|
+
private user;
|
|
45
|
+
private _interactionType;
|
|
46
|
+
private _advanceTimer;
|
|
47
|
+
private _trigger;
|
|
48
|
+
private _isSubmenu;
|
|
49
|
+
private _rootMenu;
|
|
50
|
+
constructor(opts: MenuTesterOpts);
|
|
51
|
+
/**
|
|
52
|
+
* Set the interaction type used by the menu tester.
|
|
53
|
+
*/
|
|
54
|
+
setInteractionType(type: UserOpts['interactionType']): void;
|
|
55
|
+
/**
|
|
56
|
+
* Opens the menu. Defaults to using the interaction type set on the menu tester.
|
|
57
|
+
*/
|
|
58
|
+
open(opts?: MenuOpenOpts): Promise<void>;
|
|
59
|
+
/**
|
|
60
|
+
* Returns a option matching the specified index or text content.
|
|
61
|
+
*/
|
|
62
|
+
findOption(opts: {
|
|
63
|
+
optionIndexOrText: number | string;
|
|
64
|
+
}): HTMLElement;
|
|
65
|
+
/**
|
|
66
|
+
* Selects the desired menu option. Defaults to using the interaction type set on the menu tester. If necessary, will open the menu dropdown beforehand.
|
|
67
|
+
* The desired option can be targeted via the option's node, the option's text, or the option's index.
|
|
68
|
+
*/
|
|
69
|
+
selectOption(opts: MenuSelectOpts): Promise<void>;
|
|
70
|
+
/**
|
|
71
|
+
* 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.
|
|
72
|
+
*/
|
|
73
|
+
openSubmenu(opts: MenuOpenSubmenuOpts): Promise<MenuTester | null>;
|
|
74
|
+
private keyboardNavigateToOption;
|
|
75
|
+
/**
|
|
76
|
+
* Closes the menu.
|
|
77
|
+
*/
|
|
78
|
+
close(): Promise<void>;
|
|
79
|
+
/**
|
|
80
|
+
* Returns the menu's trigger.
|
|
81
|
+
*/
|
|
82
|
+
get trigger(): HTMLElement;
|
|
83
|
+
/**
|
|
84
|
+
* Returns the menu if present.
|
|
85
|
+
*/
|
|
86
|
+
get menu(): HTMLElement | null;
|
|
87
|
+
/**
|
|
88
|
+
* Returns the menu's sections if any.
|
|
89
|
+
*/
|
|
90
|
+
get sections(): HTMLElement[];
|
|
91
|
+
/**
|
|
92
|
+
* Returns the menu's options if present. Can be filtered to a subsection of the menu if provided via `element`.
|
|
93
|
+
*/
|
|
94
|
+
options(opts?: {
|
|
95
|
+
element?: HTMLElement;
|
|
96
|
+
}): HTMLElement[];
|
|
97
|
+
/**
|
|
98
|
+
* Returns the menu's submenu triggers if any.
|
|
99
|
+
*/
|
|
100
|
+
get submenuTriggers(): HTMLElement[];
|
|
101
|
+
}
|
|
102
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { RadioGroupTesterOpts, UserOpts } from './types';
|
|
2
|
+
interface TriggerRadioOptions {
|
|
3
|
+
/**
|
|
4
|
+
* What interaction type to use when triggering a radio. Defaults to the interaction type set on the tester.
|
|
5
|
+
*/
|
|
6
|
+
interactionType?: UserOpts['interactionType'];
|
|
7
|
+
/**
|
|
8
|
+
* The index, text, or node of the radio to toggle selection for.
|
|
9
|
+
*/
|
|
10
|
+
radio: number | string | HTMLElement;
|
|
11
|
+
}
|
|
12
|
+
export declare class RadioGroupTester {
|
|
13
|
+
private user;
|
|
14
|
+
private _interactionType;
|
|
15
|
+
private _radiogroup;
|
|
16
|
+
private _direction;
|
|
17
|
+
constructor(opts: RadioGroupTesterOpts);
|
|
18
|
+
/**
|
|
19
|
+
* Set the interaction type used by the radio tester.
|
|
20
|
+
*/
|
|
21
|
+
setInteractionType(type: UserOpts['interactionType']): void;
|
|
22
|
+
/**
|
|
23
|
+
* Returns a radio matching the specified index or text content.
|
|
24
|
+
*/
|
|
25
|
+
findRadio(opts: {
|
|
26
|
+
radioIndexOrText: number | string;
|
|
27
|
+
}): HTMLElement;
|
|
28
|
+
private keyboardNavigateToRadio;
|
|
29
|
+
/**
|
|
30
|
+
* Triggers the specified radio. Defaults to using the interaction type set on the radio tester.
|
|
31
|
+
*/
|
|
32
|
+
triggerRadio(opts: TriggerRadioOptions): Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* Returns the radiogroup.
|
|
35
|
+
*/
|
|
36
|
+
get radiogroup(): HTMLElement;
|
|
37
|
+
/**
|
|
38
|
+
* Returns the radios.
|
|
39
|
+
*/
|
|
40
|
+
get radios(): HTMLElement[];
|
|
41
|
+
/**
|
|
42
|
+
* Returns the currently selected radio in the radiogroup if any.
|
|
43
|
+
*/
|
|
44
|
+
get selectedRadio(): HTMLElement | null;
|
|
45
|
+
}
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { SelectTesterOpts, UserOpts } from './types';
|
|
2
|
+
interface SelectOpenOpts {
|
|
3
|
+
/**
|
|
4
|
+
* What interaction type to use when opening the select. Defaults to the interaction type set on the tester.
|
|
5
|
+
*/
|
|
6
|
+
interactionType?: UserOpts['interactionType'];
|
|
7
|
+
}
|
|
8
|
+
interface SelectTriggerOptionOpts extends SelectOpenOpts {
|
|
9
|
+
/**
|
|
10
|
+
* The index, text, or node of the option to select. Option nodes can be sourced via `options()`.
|
|
11
|
+
*/
|
|
12
|
+
option: number | string | HTMLElement;
|
|
13
|
+
/**
|
|
14
|
+
* Whether or not the select closes on selection. Depends on select implementation and configuration.
|
|
15
|
+
* @default true
|
|
16
|
+
*/
|
|
17
|
+
closesOnSelect?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export declare class SelectTester {
|
|
20
|
+
private user;
|
|
21
|
+
private _interactionType;
|
|
22
|
+
private _trigger;
|
|
23
|
+
constructor(opts: SelectTesterOpts);
|
|
24
|
+
/**
|
|
25
|
+
* Set the interaction type used by the select tester.
|
|
26
|
+
*/
|
|
27
|
+
setInteractionType(type: UserOpts['interactionType']): void;
|
|
28
|
+
/**
|
|
29
|
+
* Opens the select. Defaults to using the interaction type set on the select tester.
|
|
30
|
+
*/
|
|
31
|
+
open(opts?: SelectOpenOpts): Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Closes the select.
|
|
34
|
+
*/
|
|
35
|
+
close(): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Returns a option matching the specified index or text content.
|
|
38
|
+
*/
|
|
39
|
+
findOption(opts: {
|
|
40
|
+
optionIndexOrText: number | string;
|
|
41
|
+
}): HTMLElement;
|
|
42
|
+
private keyboardNavigateToOption;
|
|
43
|
+
/**
|
|
44
|
+
* Selects the desired select option. Defaults to using the interaction type set on the select tester. If necessary, will open the select dropdown beforehand.
|
|
45
|
+
* The desired option can be targeted via the option's node, the option's text, or the option's index.
|
|
46
|
+
*/
|
|
47
|
+
selectOption(opts: SelectTriggerOptionOpts): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Returns the select's options if present. Can be filtered to a subsection of the listbox if provided via `element`.
|
|
50
|
+
*/
|
|
51
|
+
options(opts?: {
|
|
52
|
+
element?: HTMLElement;
|
|
53
|
+
}): HTMLElement[];
|
|
54
|
+
/**
|
|
55
|
+
* Returns the select's trigger.
|
|
56
|
+
*/
|
|
57
|
+
get trigger(): HTMLElement;
|
|
58
|
+
/**
|
|
59
|
+
* Returns the select's listbox if present.
|
|
60
|
+
*/
|
|
61
|
+
get listbox(): HTMLElement | null;
|
|
62
|
+
/**
|
|
63
|
+
* Returns the select's sections if present.
|
|
64
|
+
*/
|
|
65
|
+
get sections(): HTMLElement[];
|
|
66
|
+
}
|
|
67
|
+
export {};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { BaseGridRowInteractionOpts, GridRowActionOpts, TableTesterOpts, ToggleGridRowOpts, UserOpts } from './types';
|
|
2
|
+
interface TableToggleRowOpts extends ToggleGridRowOpts {
|
|
3
|
+
}
|
|
4
|
+
interface TableToggleExpansionOpts extends BaseGridRowInteractionOpts {
|
|
5
|
+
}
|
|
6
|
+
interface TableToggleSortOpts {
|
|
7
|
+
/**
|
|
8
|
+
* The index, text, or node of the column to toggle selection for.
|
|
9
|
+
*/
|
|
10
|
+
column: number | string | HTMLElement;
|
|
11
|
+
/**
|
|
12
|
+
* What interaction type to use when sorting the column. Defaults to the interaction type set on the tester.
|
|
13
|
+
*/
|
|
14
|
+
interactionType?: UserOpts['interactionType'];
|
|
15
|
+
}
|
|
16
|
+
interface TableColumnHeaderActionOpts extends TableToggleSortOpts {
|
|
17
|
+
/**
|
|
18
|
+
* The index of the column header action to trigger.
|
|
19
|
+
*/
|
|
20
|
+
action: number;
|
|
21
|
+
}
|
|
22
|
+
interface TableRowActionOpts extends GridRowActionOpts {
|
|
23
|
+
}
|
|
24
|
+
export declare class TableTester {
|
|
25
|
+
private user;
|
|
26
|
+
private _interactionType;
|
|
27
|
+
private _advanceTimer;
|
|
28
|
+
private _table;
|
|
29
|
+
constructor(opts: TableTesterOpts);
|
|
30
|
+
/**
|
|
31
|
+
* Set the interaction type used by the table tester.
|
|
32
|
+
*/
|
|
33
|
+
setInteractionType(type: UserOpts['interactionType']): void;
|
|
34
|
+
private keyboardNavigateToRow;
|
|
35
|
+
/**
|
|
36
|
+
* Toggles the selection for the specified table row. Defaults to using the interaction type set on the table tester.
|
|
37
|
+
*/
|
|
38
|
+
toggleRowSelection(opts: TableToggleRowOpts): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Toggles the expansion for the specified tree row. Defaults to using the interaction type set on the tree tester.
|
|
41
|
+
*/
|
|
42
|
+
toggleRowExpansion(opts: TableToggleExpansionOpts): Promise<void>;
|
|
43
|
+
/**
|
|
44
|
+
* Toggles the sort order for the specified table column. Defaults to using the interaction type set on the table tester.
|
|
45
|
+
*/
|
|
46
|
+
toggleSort(opts: TableToggleSortOpts): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Triggers an action for the specified table column menu. Defaults to using the interaction type set on the table tester.
|
|
49
|
+
*/
|
|
50
|
+
triggerColumnHeaderAction(opts: TableColumnHeaderActionOpts): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Triggers the action for the specified table row. Defaults to using the interaction type set on the table tester.
|
|
53
|
+
*/
|
|
54
|
+
triggerRowAction(opts: TableRowActionOpts): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* Toggle selection for all rows in the table. Defaults to using the interaction type set on the table tester.
|
|
57
|
+
*/
|
|
58
|
+
toggleSelectAll(opts?: {
|
|
59
|
+
interactionType?: UserOpts['interactionType'];
|
|
60
|
+
}): Promise<void>;
|
|
61
|
+
/**
|
|
62
|
+
* Returns a row matching the specified index or text content.
|
|
63
|
+
*/
|
|
64
|
+
findRow(opts: {
|
|
65
|
+
rowIndexOrText: number | string;
|
|
66
|
+
}): HTMLElement;
|
|
67
|
+
/**
|
|
68
|
+
* Returns a cell matching the specified text content.
|
|
69
|
+
*/
|
|
70
|
+
findCell(opts: {
|
|
71
|
+
text: string;
|
|
72
|
+
}): HTMLElement;
|
|
73
|
+
/**
|
|
74
|
+
* Returns the table.
|
|
75
|
+
*/
|
|
76
|
+
get table(): HTMLElement;
|
|
77
|
+
/**
|
|
78
|
+
* Returns the row groups within the table.
|
|
79
|
+
*/
|
|
80
|
+
get rowGroups(): HTMLElement[];
|
|
81
|
+
/**
|
|
82
|
+
* Returns the columns within the table.
|
|
83
|
+
*/
|
|
84
|
+
get columns(): HTMLElement[];
|
|
85
|
+
/**
|
|
86
|
+
* Returns the rows within the table if any.
|
|
87
|
+
*/
|
|
88
|
+
get rows(): HTMLElement[];
|
|
89
|
+
/**
|
|
90
|
+
* Returns the currently selected rows within the table if any.
|
|
91
|
+
*/
|
|
92
|
+
get selectedRows(): HTMLElement[];
|
|
93
|
+
/**
|
|
94
|
+
* Returns the row headers within the table if any.
|
|
95
|
+
*/
|
|
96
|
+
get rowHeaders(): HTMLElement[];
|
|
97
|
+
/**
|
|
98
|
+
* Returns the cells within the table if any. Can be filtered against a specific row if provided via `element`.
|
|
99
|
+
*/
|
|
100
|
+
cells(opts?: {
|
|
101
|
+
element?: HTMLElement;
|
|
102
|
+
}): HTMLElement[];
|
|
103
|
+
}
|
|
104
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { TabsTesterOpts, UserOpts } from './types';
|
|
2
|
+
interface TriggerTabOptions {
|
|
3
|
+
/**
|
|
4
|
+
* What interaction type to use when triggering a tab. Defaults to the interaction type set on the tester.
|
|
5
|
+
*/
|
|
6
|
+
interactionType?: UserOpts['interactionType'];
|
|
7
|
+
/**
|
|
8
|
+
* The index, text, or node of the tab to toggle selection for.
|
|
9
|
+
*/
|
|
10
|
+
tab: number | string | HTMLElement;
|
|
11
|
+
/**
|
|
12
|
+
* Whether the tab needs to be activated manually rather than on focus.
|
|
13
|
+
*/
|
|
14
|
+
manualActivation?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare class TabsTester {
|
|
17
|
+
private user;
|
|
18
|
+
private _interactionType;
|
|
19
|
+
private _tablist;
|
|
20
|
+
private _direction;
|
|
21
|
+
constructor(opts: TabsTesterOpts);
|
|
22
|
+
/**
|
|
23
|
+
* Set the interaction type used by the tabs tester.
|
|
24
|
+
*/
|
|
25
|
+
setInteractionType(type: UserOpts['interactionType']): void;
|
|
26
|
+
/**
|
|
27
|
+
* Returns a tab matching the specified index or text content.
|
|
28
|
+
*/
|
|
29
|
+
findTab(opts: {
|
|
30
|
+
tabIndexOrText: number | string;
|
|
31
|
+
}): HTMLElement;
|
|
32
|
+
private keyboardNavigateToTab;
|
|
33
|
+
/**
|
|
34
|
+
* Triggers the specified tab. Defaults to using the interaction type set on the tabs tester.
|
|
35
|
+
*/
|
|
36
|
+
triggerTab(opts: TriggerTabOptions): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Returns the tablist.
|
|
39
|
+
*/
|
|
40
|
+
get tablist(): HTMLElement;
|
|
41
|
+
/**
|
|
42
|
+
* Returns the tabpanels.
|
|
43
|
+
*/
|
|
44
|
+
get tabpanels(): HTMLElement[];
|
|
45
|
+
/**
|
|
46
|
+
* Returns the tabs in the tablist.
|
|
47
|
+
*/
|
|
48
|
+
get tabs(): HTMLElement[];
|
|
49
|
+
/**
|
|
50
|
+
* Returns the currently selected tab in the tablist if any.
|
|
51
|
+
*/
|
|
52
|
+
get selectedTab(): HTMLElement | null;
|
|
53
|
+
/**
|
|
54
|
+
* Returns the currently active tabpanel if any.
|
|
55
|
+
*/
|
|
56
|
+
get activeTabpanel(): HTMLElement | null;
|
|
57
|
+
}
|
|
58
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { BaseGridRowInteractionOpts, GridRowActionOpts, ToggleGridRowOpts, TreeTesterOpts, UserOpts } from './types';
|
|
2
|
+
interface TreeToggleExpansionOpts extends BaseGridRowInteractionOpts {
|
|
3
|
+
}
|
|
4
|
+
interface TreeToggleRowOpts extends ToggleGridRowOpts {
|
|
5
|
+
}
|
|
6
|
+
interface TreeRowActionOpts extends GridRowActionOpts {
|
|
7
|
+
}
|
|
8
|
+
export declare class TreeTester {
|
|
9
|
+
private user;
|
|
10
|
+
private _interactionType;
|
|
11
|
+
private _advanceTimer;
|
|
12
|
+
private _tree;
|
|
13
|
+
constructor(opts: TreeTesterOpts);
|
|
14
|
+
/**
|
|
15
|
+
* Set the interaction type used by the tree tester.
|
|
16
|
+
*/
|
|
17
|
+
setInteractionType(type: UserOpts['interactionType']): void;
|
|
18
|
+
/**
|
|
19
|
+
* Returns a row matching the specified index or text content.
|
|
20
|
+
*/
|
|
21
|
+
findRow(opts: {
|
|
22
|
+
rowIndexOrText: number | string;
|
|
23
|
+
}): HTMLElement;
|
|
24
|
+
private keyboardNavigateToRow;
|
|
25
|
+
/**
|
|
26
|
+
* Toggles the selection for the specified tree row. Defaults to using the interaction type set on the tree tester.
|
|
27
|
+
* Note that this will endevor to always add/remove JUST the provided row to the set of selected rows.
|
|
28
|
+
*/
|
|
29
|
+
toggleRowSelection(opts: TreeToggleRowOpts): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Toggles the expansion for the specified tree row. Defaults to using the interaction type set on the tree tester.
|
|
32
|
+
*/
|
|
33
|
+
toggleRowExpansion(opts: TreeToggleExpansionOpts): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Triggers the action for the specified tree row. Defaults to using the interaction type set on the tree tester.
|
|
36
|
+
*/
|
|
37
|
+
triggerRowAction(opts: TreeRowActionOpts): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Returns the tree.
|
|
40
|
+
*/
|
|
41
|
+
get tree(): HTMLElement;
|
|
42
|
+
/**
|
|
43
|
+
* Returns the tree's rows if any.
|
|
44
|
+
*/
|
|
45
|
+
get rows(): HTMLElement[];
|
|
46
|
+
/**
|
|
47
|
+
* Returns the tree's selected rows if any.
|
|
48
|
+
*/
|
|
49
|
+
get selectedRows(): HTMLElement[];
|
|
50
|
+
/**
|
|
51
|
+
* Returns the tree's cells if any. Can be filtered against a specific row if provided via `element`.
|
|
52
|
+
*/
|
|
53
|
+
cells(opts?: {
|
|
54
|
+
element?: HTMLElement;
|
|
55
|
+
}): HTMLElement[];
|
|
56
|
+
}
|
|
57
|
+
export {};
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
export type Orientation = 'horizontal' | 'vertical';
|
|
2
|
+
export 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) => unknown | Promise<unknown>;
|
|
15
|
+
}
|
|
16
|
+
export interface BaseTesterOpts extends UserOpts {
|
|
17
|
+
/** @private */
|
|
18
|
+
user?: any;
|
|
19
|
+
/** The base element for the given tester (e.g. the table, menu trigger button, etc). */
|
|
20
|
+
root: HTMLElement;
|
|
21
|
+
}
|
|
22
|
+
export interface CheckboxGroupTesterOpts extends BaseTesterOpts {
|
|
23
|
+
}
|
|
24
|
+
export interface ComboBoxTesterOpts extends BaseTesterOpts {
|
|
25
|
+
/**
|
|
26
|
+
* 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),
|
|
27
|
+
* will automatically search for the combobox element within.
|
|
28
|
+
*/
|
|
29
|
+
root: HTMLElement;
|
|
30
|
+
/**
|
|
31
|
+
* The node of the combobox trigger button if any. If not provided, we will try to automatically use any button
|
|
32
|
+
* within the `root` provided or that the `root` serves as the trigger.
|
|
33
|
+
*/
|
|
34
|
+
trigger?: HTMLElement;
|
|
35
|
+
}
|
|
36
|
+
export interface DialogTesterOpts extends BaseTesterOpts {
|
|
37
|
+
/**
|
|
38
|
+
* The trigger element for the dialog.
|
|
39
|
+
*/
|
|
40
|
+
root: HTMLElement;
|
|
41
|
+
/**
|
|
42
|
+
* The overlay type of the dialog. Used to inform the tester how to find the dialog.
|
|
43
|
+
*/
|
|
44
|
+
overlayType?: 'modal' | 'popover';
|
|
45
|
+
}
|
|
46
|
+
export interface GridListTesterOpts extends BaseTesterOpts {
|
|
47
|
+
}
|
|
48
|
+
export interface ListBoxTesterOpts extends BaseTesterOpts {
|
|
49
|
+
/**
|
|
50
|
+
* A function used by the test utils to advance timers during interactions.
|
|
51
|
+
*/
|
|
52
|
+
advanceTimer?: UserOpts['advanceTimer'];
|
|
53
|
+
}
|
|
54
|
+
export interface MenuTesterOpts extends BaseTesterOpts {
|
|
55
|
+
/**
|
|
56
|
+
* The trigger element for the menu.
|
|
57
|
+
*/
|
|
58
|
+
root: HTMLElement;
|
|
59
|
+
/**
|
|
60
|
+
* Whether the current menu is a submenu.
|
|
61
|
+
*/
|
|
62
|
+
isSubmenu?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* The root menu of the menu tree. Only available if the menu is a submenu.
|
|
65
|
+
*/
|
|
66
|
+
rootMenu?: HTMLElement;
|
|
67
|
+
}
|
|
68
|
+
export interface RadioGroupTesterOpts extends BaseTesterOpts {
|
|
69
|
+
/**
|
|
70
|
+
* The horizontal layout direction, typically affected by locale.
|
|
71
|
+
* @default 'ltr'
|
|
72
|
+
*/
|
|
73
|
+
direction?: Direction;
|
|
74
|
+
}
|
|
75
|
+
export interface SelectTesterOpts extends BaseTesterOpts {
|
|
76
|
+
/**
|
|
77
|
+
* 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),
|
|
78
|
+
* will automatically search for the select's trigger element within.
|
|
79
|
+
*/
|
|
80
|
+
root: HTMLElement;
|
|
81
|
+
}
|
|
82
|
+
export interface TableTesterOpts extends BaseTesterOpts {
|
|
83
|
+
/**
|
|
84
|
+
* A function used by the test utils to advance timers during interactions.
|
|
85
|
+
*/
|
|
86
|
+
advanceTimer?: UserOpts['advanceTimer'];
|
|
87
|
+
}
|
|
88
|
+
export interface TabsTesterOpts extends BaseTesterOpts {
|
|
89
|
+
/**
|
|
90
|
+
* The horizontal layout direction, typically affected by locale.
|
|
91
|
+
* @default 'ltr'
|
|
92
|
+
*/
|
|
93
|
+
direction?: Direction;
|
|
94
|
+
}
|
|
95
|
+
export interface TreeTesterOpts extends BaseTesterOpts {
|
|
96
|
+
/**
|
|
97
|
+
* A function used by the test utils to advance timers during interactions.
|
|
98
|
+
*/
|
|
99
|
+
advanceTimer?: UserOpts['advanceTimer'];
|
|
100
|
+
}
|
|
101
|
+
export interface BaseGridRowInteractionOpts {
|
|
102
|
+
/**
|
|
103
|
+
* The index, text, or node of the row to target.
|
|
104
|
+
*/
|
|
105
|
+
row: number | string | HTMLElement;
|
|
106
|
+
/**
|
|
107
|
+
* What interaction type to use when interacting with the row. Defaults to the interaction type set on the tester.
|
|
108
|
+
*/
|
|
109
|
+
interactionType?: UserOpts['interactionType'];
|
|
110
|
+
}
|
|
111
|
+
export interface ToggleGridRowOpts extends BaseGridRowInteractionOpts {
|
|
112
|
+
/**
|
|
113
|
+
* Whether the row needs to be long pressed to be selected. Depends on the components implementation.
|
|
114
|
+
*/
|
|
115
|
+
needsLongPress?: boolean;
|
|
116
|
+
/**
|
|
117
|
+
* Whether the checkbox should be used to select the row. If false, will attempt to select the row via press.
|
|
118
|
+
* @default 'true'
|
|
119
|
+
*/
|
|
120
|
+
checkboxSelection?: boolean;
|
|
121
|
+
/**
|
|
122
|
+
* Whether the grid has a selectionBehavior of "toggle" or "replace" (aka highlight selection). This affects the user operations
|
|
123
|
+
* required to toggle row selection by adding modifier keys during user actions, useful when performing multi-row selection in a "selectionBehavior: 'replace'" grid.
|
|
124
|
+
* If you would like to still simulate user actions (aka press) without these modifiers keys for a "selectionBehavior: replace" grid, simply omit this option.
|
|
125
|
+
* See the "Selection Behavior" section of the appropriate React Aria Component docs for more information (e.g. https://react-spectrum.adobe.com/react-aria/Tree.html#selection-behavior).
|
|
126
|
+
*
|
|
127
|
+
* @default 'toggle'
|
|
128
|
+
*/
|
|
129
|
+
selectionBehavior?: 'toggle' | 'replace';
|
|
130
|
+
}
|
|
131
|
+
export interface GridRowActionOpts extends BaseGridRowInteractionOpts {
|
|
132
|
+
/**
|
|
133
|
+
* Whether or not the row needs a double click to trigger the row action. Depends on the components implementation.
|
|
134
|
+
*/
|
|
135
|
+
needsDoubleClick?: boolean;
|
|
136
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { CheckboxGroupTester } from './checkboxgroup';
|
|
2
|
+
import { CheckboxGroupTesterOpts, ComboBoxTesterOpts, DialogTesterOpts, GridListTesterOpts, ListBoxTesterOpts, MenuTesterOpts, RadioGroupTesterOpts, SelectTesterOpts, TableTesterOpts, TabsTesterOpts, TreeTesterOpts, UserOpts } from './types';
|
|
3
|
+
import { ComboBoxTester } from './combobox';
|
|
4
|
+
import { DialogTester } from './dialog';
|
|
5
|
+
import { GridListTester } from './gridlist';
|
|
6
|
+
import { ListBoxTester } from './listbox';
|
|
7
|
+
import { MenuTester } from './menu';
|
|
8
|
+
import { RadioGroupTester } from './radiogroup';
|
|
9
|
+
import { SelectTester } from './select';
|
|
10
|
+
import { TableTester } from './table';
|
|
11
|
+
import { TabsTester } from './tabs';
|
|
12
|
+
import { TreeTester } from './tree';
|
|
13
|
+
declare let keyToUtil: {
|
|
14
|
+
'CheckboxGroup': typeof CheckboxGroupTester;
|
|
15
|
+
'ComboBox': typeof ComboBoxTester;
|
|
16
|
+
'Dialog': typeof DialogTester;
|
|
17
|
+
'GridList': typeof GridListTester;
|
|
18
|
+
'ListBox': typeof ListBoxTester;
|
|
19
|
+
'Menu': typeof MenuTester;
|
|
20
|
+
'RadioGroup': typeof RadioGroupTester;
|
|
21
|
+
'Select': typeof SelectTester;
|
|
22
|
+
'Table': typeof TableTester;
|
|
23
|
+
'Tabs': typeof TabsTester;
|
|
24
|
+
'Tree': typeof TreeTester;
|
|
25
|
+
};
|
|
26
|
+
export type PatternNames = keyof typeof keyToUtil;
|
|
27
|
+
type Tester<T> = T extends 'CheckboxGroup' ? CheckboxGroupTester : T extends 'ComboBox' ? ComboBoxTester : T extends 'Dialog' ? DialogTester : T extends 'GridList' ? GridListTester : T extends 'ListBox' ? ListBoxTester : T extends 'Menu' ? MenuTester : T extends 'RadioGroup' ? RadioGroupTester : T extends 'Select' ? SelectTester : T extends 'Table' ? TableTester : T extends 'Tabs' ? TabsTester : T extends 'Tree' ? TreeTester : never;
|
|
28
|
+
type TesterOpts<T> = T extends 'CheckboxGroup' ? CheckboxGroupTesterOpts : T extends 'ComboBox' ? ComboBoxTesterOpts : T extends 'Dialog' ? DialogTesterOpts : T extends 'GridList' ? GridListTesterOpts : T extends 'ListBox' ? ListBoxTesterOpts : T extends 'Menu' ? MenuTesterOpts : T extends 'RadioGroup' ? RadioGroupTesterOpts : T extends 'Select' ? SelectTesterOpts : T extends 'Table' ? TableTesterOpts : T extends 'Tabs' ? TabsTesterOpts : T extends 'Tree' ? TreeTesterOpts : never;
|
|
29
|
+
export declare class User {
|
|
30
|
+
private user;
|
|
31
|
+
/**
|
|
32
|
+
* The interaction type (mouse, touch, keyboard) that the test util user will use when interacting with a component. This can be overridden
|
|
33
|
+
* at the aria pattern util level if needed.
|
|
34
|
+
* @default mouse
|
|
35
|
+
*/
|
|
36
|
+
interactionType: UserOpts['interactionType'];
|
|
37
|
+
/**
|
|
38
|
+
* A function used by the test utils to advance timers during interactions. Required for certain aria patterns (e.g. table).
|
|
39
|
+
*/
|
|
40
|
+
advanceTimer: UserOpts['advanceTimer'];
|
|
41
|
+
constructor(opts?: UserOpts);
|
|
42
|
+
/**
|
|
43
|
+
* Creates an aria pattern tester, inheriting the options provided to the original user.
|
|
44
|
+
*/
|
|
45
|
+
createTester<T extends PatternNames>(patternName: T, opts: TesterOpts<T>): Tester<T>;
|
|
46
|
+
}
|
|
47
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-aria/test-utils",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.3",
|
|
4
4
|
"description": "Testing utils for react-aria patterns",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
7
7
|
"module": "dist/module.js",
|
|
8
8
|
"exports": {
|
|
9
9
|
"source": "./src/index.ts",
|
|
10
|
-
"types":
|
|
11
|
-
"./dist/types.d.ts",
|
|
12
|
-
"./src/index.ts"
|
|
13
|
-
],
|
|
10
|
+
"types": "./dist/types/src/index.d.ts",
|
|
14
11
|
"import": "./dist/import.mjs",
|
|
15
12
|
"require": "./dist/main.js"
|
|
16
13
|
},
|
|
17
|
-
"types": "dist/types.d.ts",
|
|
14
|
+
"types": "./dist/types/src/index.d.ts",
|
|
18
15
|
"source": "src/index.ts",
|
|
19
16
|
"files": [
|
|
20
17
|
"dist",
|
|
@@ -37,5 +34,8 @@
|
|
|
37
34
|
"publishConfig": {
|
|
38
35
|
"access": "public"
|
|
39
36
|
},
|
|
40
|
-
"
|
|
37
|
+
"targets": {
|
|
38
|
+
"types": false
|
|
39
|
+
},
|
|
40
|
+
"gitHead": "a6999bdf494a2e9c0381a5881908328bdd22ddae"
|
|
41
41
|
}
|