@react-aria/test-utils 1.0.0-beta.0 → 1.0.0-beta.2

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 (49) hide show
  1. package/dist/checkboxgroup.main.js +104 -0
  2. package/dist/checkboxgroup.main.js.map +1 -0
  3. package/dist/checkboxgroup.mjs +99 -0
  4. package/dist/checkboxgroup.module.js +99 -0
  5. package/dist/checkboxgroup.module.js.map +1 -0
  6. package/dist/dialog.main.js +105 -0
  7. package/dist/dialog.main.js.map +1 -0
  8. package/dist/dialog.mjs +100 -0
  9. package/dist/dialog.module.js +100 -0
  10. package/dist/dialog.module.js.map +1 -0
  11. package/dist/main.js.map +1 -1
  12. package/dist/module.js.map +1 -1
  13. package/dist/radiogroup.main.js +123 -0
  14. package/dist/radiogroup.main.js.map +1 -0
  15. package/dist/radiogroup.mjs +118 -0
  16. package/dist/radiogroup.module.js +118 -0
  17. package/dist/radiogroup.module.js.map +1 -0
  18. package/dist/select.main.js +2 -1
  19. package/dist/select.main.js.map +1 -1
  20. package/dist/select.mjs +2 -1
  21. package/dist/select.module.js +2 -1
  22. package/dist/select.module.js.map +1 -1
  23. package/dist/tabs.main.js +5 -3
  24. package/dist/tabs.main.js.map +1 -1
  25. package/dist/tabs.mjs +5 -3
  26. package/dist/tabs.module.js +5 -3
  27. package/dist/tabs.module.js.map +1 -1
  28. package/dist/testSetup.main.js +29 -28
  29. package/dist/testSetup.main.js.map +1 -1
  30. package/dist/testSetup.mjs +30 -29
  31. package/dist/testSetup.module.js +30 -29
  32. package/dist/testSetup.module.js.map +1 -1
  33. package/dist/types.d.ts +142 -13
  34. package/dist/types.d.ts.map +1 -1
  35. package/dist/user.main.js +12 -3
  36. package/dist/user.main.js.map +1 -1
  37. package/dist/user.mjs +12 -3
  38. package/dist/user.module.js +12 -3
  39. package/dist/user.module.js.map +1 -1
  40. package/package.json +2 -2
  41. package/src/checkboxgroup.ts +158 -0
  42. package/src/dialog.ts +143 -0
  43. package/src/index.ts +11 -0
  44. package/src/radiogroup.ts +176 -0
  45. package/src/select.ts +3 -1
  46. package/src/tabs.ts +7 -2
  47. package/src/testSetup.ts +30 -28
  48. package/src/types.ts +21 -0
  49. package/src/user.ts +25 -7
@@ -0,0 +1,158 @@
1
+ /*
2
+ * Copyright 2025 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+
13
+ import {act, within} from '@testing-library/react';
14
+ import {CheckboxGroupTesterOpts, UserOpts} from './types';
15
+ import {pressElement} from './events';
16
+
17
+ interface TriggerCheckboxOptions {
18
+ /**
19
+ * What interaction type to use when triggering a checkbox. Defaults to the interaction type set on the tester.
20
+ */
21
+ interactionType?: UserOpts['interactionType'],
22
+ /**
23
+ * The index, text, or node of the checkbox to toggle selection for.
24
+ */
25
+ checkbox: number | string | HTMLElement
26
+ }
27
+
28
+ export class CheckboxGroupTester {
29
+ private user;
30
+ private _interactionType: UserOpts['interactionType'];
31
+ private _checkboxgroup: HTMLElement;
32
+
33
+
34
+ constructor(opts: CheckboxGroupTesterOpts) {
35
+ let {root, user, interactionType} = opts;
36
+ this.user = user;
37
+ this._interactionType = interactionType || 'mouse';
38
+
39
+ this._checkboxgroup = root;
40
+ let checkboxgroup = within(root).queryAllByRole('group');
41
+ if (checkboxgroup.length > 0) {
42
+ this._checkboxgroup = checkboxgroup[0];
43
+ }
44
+ }
45
+
46
+ /**
47
+ * Set the interaction type used by the checkbox group tester.
48
+ */
49
+ setInteractionType(type: UserOpts['interactionType']): void {
50
+ this._interactionType = type;
51
+ }
52
+
53
+ /**
54
+ * Returns a checkbox matching the specified index or text content.
55
+ */
56
+ findCheckbox(opts: {checkboxIndexOrText: number | string}): HTMLElement {
57
+ let {
58
+ checkboxIndexOrText
59
+ } = opts;
60
+
61
+ let checkbox;
62
+ if (typeof checkboxIndexOrText === 'number') {
63
+ checkbox = this.checkboxes[checkboxIndexOrText];
64
+ } else if (typeof checkboxIndexOrText === 'string') {
65
+ let label = within(this.checkboxgroup).getByText(checkboxIndexOrText);
66
+
67
+ // Label may wrap the checkbox, or the actual label may be a sibling span, or the checkbox div could have the label within it
68
+ if (label) {
69
+ checkbox = within(label).queryByRole('checkbox');
70
+ if (!checkbox) {
71
+ let labelWrapper = label.closest('label');
72
+ if (labelWrapper) {
73
+ checkbox = within(labelWrapper).queryByRole('checkbox');
74
+ } else {
75
+ checkbox = label.closest('[role=checkbox]');
76
+ }
77
+ }
78
+ }
79
+ }
80
+
81
+ return checkbox;
82
+ }
83
+
84
+ private async keyboardNavigateToCheckbox(opts: {checkbox: HTMLElement}) {
85
+ let {checkbox} = opts;
86
+ let checkboxes = this.checkboxes;
87
+ checkboxes = checkboxes.filter(checkbox => !(checkbox.hasAttribute('disabled') || checkbox.getAttribute('aria-disabled') === 'true'));
88
+ if (checkboxes.length === 0) {
89
+ throw new Error('Checkbox group doesnt have any non-disabled checkboxes. Please double check your checkbox group.');
90
+ }
91
+
92
+ let targetIndex = checkboxes.indexOf(checkbox);
93
+ if (targetIndex === -1) {
94
+ throw new Error('Checkbox provided is not in the checkbox group.');
95
+ }
96
+
97
+ if (!this.checkboxgroup.contains(document.activeElement)) {
98
+ act(() => checkboxes[0].focus());
99
+ }
100
+
101
+ let currIndex = checkboxes.indexOf(document.activeElement as HTMLElement);
102
+ if (currIndex === -1) {
103
+ throw new Error('Active element is not in the checkbox group.');
104
+ }
105
+
106
+ for (let i = 0; i < Math.abs(targetIndex - currIndex); i++) {
107
+ await this.user.tab({shift: targetIndex < currIndex});
108
+ }
109
+ };
110
+
111
+ /**
112
+ * Toggles the specified checkbox. Defaults to using the interaction type set on the checkbox tester.
113
+ */
114
+ async toggleCheckbox(opts: TriggerCheckboxOptions): Promise<void> {
115
+ let {
116
+ checkbox,
117
+ interactionType = this._interactionType
118
+ } = opts;
119
+
120
+ if (typeof checkbox === 'string' || typeof checkbox === 'number') {
121
+ checkbox = this.findCheckbox({checkboxIndexOrText: checkbox});
122
+ }
123
+
124
+ if (!checkbox) {
125
+ throw new Error('Target checkbox not found in the checkboxgroup.');
126
+ } else if (checkbox.hasAttribute('disabled')) {
127
+ throw new Error('Target checkbox is disabled.');
128
+ }
129
+
130
+ if (interactionType === 'keyboard') {
131
+ await this.keyboardNavigateToCheckbox({checkbox});
132
+ await this.user.keyboard('[Space]');
133
+ } else {
134
+ await pressElement(this.user, checkbox, interactionType);
135
+ }
136
+ }
137
+
138
+ /**
139
+ * Returns the checkboxgroup.
140
+ */
141
+ get checkboxgroup(): HTMLElement {
142
+ return this._checkboxgroup;
143
+ }
144
+
145
+ /**
146
+ * Returns the checkboxes.
147
+ */
148
+ get checkboxes(): HTMLElement[] {
149
+ return within(this.checkboxgroup).queryAllByRole('checkbox');
150
+ }
151
+
152
+ /**
153
+ * Returns the currently selected checkboxes in the checkboxgroup if any.
154
+ */
155
+ get selectedCheckboxes(): HTMLElement[] {
156
+ return this.checkboxes.filter(checkbox => (checkbox as HTMLInputElement).checked || checkbox.getAttribute('aria-checked') === 'true');
157
+ }
158
+ }
package/src/dialog.ts ADDED
@@ -0,0 +1,143 @@
1
+ /*
2
+ * Copyright 2025 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+
13
+ import {act, waitFor, within} from '@testing-library/react';
14
+ import {DialogTesterOpts, UserOpts} from './types';
15
+
16
+ interface DialogOpenOpts {
17
+ /**
18
+ * What interaction type to use when opening the dialog. Defaults to the interaction type set on the tester.
19
+ */
20
+ interactionType?: UserOpts['interactionType']
21
+ }
22
+
23
+ export class DialogTester {
24
+ private user;
25
+ private _interactionType: UserOpts['interactionType'];
26
+ private _trigger: HTMLElement | undefined;
27
+ private _dialog: HTMLElement | undefined;
28
+ private _overlayType: DialogTesterOpts['overlayType'];
29
+
30
+ constructor(opts: DialogTesterOpts) {
31
+ let {root, user, interactionType, overlayType} = opts;
32
+ this.user = user;
33
+ this._interactionType = interactionType || 'mouse';
34
+ this._overlayType = overlayType || 'modal';
35
+
36
+ // Handle case where element provided is a wrapper of the trigger button
37
+ let trigger = within(root).queryByRole('button');
38
+ if (trigger) {
39
+ this._trigger = trigger;
40
+ } else {
41
+ this._trigger = root;
42
+ }
43
+ }
44
+
45
+ /**
46
+ * Set the interaction type used by the dialog tester.
47
+ */
48
+ setInteractionType(type: UserOpts['interactionType']): void {
49
+ this._interactionType = type;
50
+ }
51
+
52
+ /**
53
+ * Opens the dialog. Defaults to using the interaction type set on the dialog tester.
54
+ */
55
+ async open(opts: DialogOpenOpts = {}): Promise<void> {
56
+ let {
57
+ interactionType = this._interactionType
58
+ } = opts;
59
+ let trigger = this.trigger;
60
+ if (!trigger.hasAttribute('disabled')) {
61
+ if (interactionType === 'mouse') {
62
+ await this.user.click(trigger);
63
+ } else if (interactionType === 'touch') {
64
+ await this.user.pointer({target: trigger, keys: '[TouchA]'});
65
+ } else if (interactionType === 'keyboard') {
66
+ act(() => trigger.focus());
67
+ await this.user.keyboard('[Enter]');
68
+ }
69
+
70
+ if (this._overlayType === 'popover') {
71
+ await waitFor(() => {
72
+ if (trigger.getAttribute('aria-controls') == null) {
73
+ throw new Error('No aria-controls found on dialog trigger element.');
74
+ } else {
75
+ return true;
76
+ }
77
+ });
78
+
79
+ let dialogId = trigger.getAttribute('aria-controls');
80
+ await waitFor(() => {
81
+ if (!dialogId || document.getElementById(dialogId) == null) {
82
+ throw new Error(`Dialog with id of ${dialogId} not found in document.`);
83
+ } else {
84
+ this._dialog = document.getElementById(dialogId)!;
85
+ return true;
86
+ }
87
+ });
88
+ } else {
89
+ let dialog;
90
+ await waitFor(() => {
91
+ dialog = document.querySelector('[role=dialog], [role=alertdialog]');
92
+ if (dialog == null) {
93
+ throw new Error('No dialog of type role="dialog" or role="alertdialog" found after pressing the trigger.');
94
+ } else {
95
+ return true;
96
+ }
97
+ });
98
+
99
+ if (dialog && document.activeElement !== this._trigger && dialog.contains(document.activeElement)) {
100
+ this._dialog = dialog;
101
+ } else {
102
+ throw new Error('New modal dialog doesnt contain the active element OR the active element is still the trigger. Uncertain if the proper modal dialog was found');
103
+ }
104
+ }
105
+ }
106
+ }
107
+
108
+ /**
109
+ * Closes the dialog via the Escape key.
110
+ */
111
+ async close(): Promise<void> {
112
+ let dialog = this._dialog;
113
+ if (dialog) {
114
+ await this.user.keyboard('[Escape]');
115
+ await waitFor(() => {
116
+ if (document.contains(dialog)) {
117
+ throw new Error('Expected the dialog to not be in the document after closing it.');
118
+ } else {
119
+ this._dialog = undefined;
120
+ return true;
121
+ }
122
+ });
123
+ }
124
+ }
125
+
126
+ /**
127
+ * Returns the dialog's trigger.
128
+ */
129
+ get trigger(): HTMLElement {
130
+ if (!this._trigger) {
131
+ throw new Error('No trigger element found for dialog.');
132
+ }
133
+
134
+ return this._trigger;
135
+ }
136
+
137
+ /**
138
+ * Returns the dialog if present.
139
+ */
140
+ get dialog(): HTMLElement | null {
141
+ return this._dialog && document.contains(this._dialog) ? this._dialog : null;
142
+ }
143
+ }
package/src/index.ts CHANGED
@@ -14,5 +14,16 @@ export {triggerLongPress} from './events';
14
14
  export {installMouseEvent, installPointerEvent} from './testSetup';
15
15
  export {pointerMap} from './userEventMaps';
16
16
  export {User} from './user';
17
+ export type {CheckboxGroupTester} from './checkboxgroup';
18
+ export type {ComboBoxTester} from './combobox';
19
+ export type {DialogTester} from './dialog';
20
+ export type {GridListTester} from './gridlist';
21
+ export type {ListBoxTester} from './listbox';
22
+ export type {MenuTester} from './menu';
23
+ export type {RadioGroupTester} from './radiogroup';
24
+ export type {SelectTester} from './select';
25
+ export type {TableTester} from './table';
26
+ export type {TabsTester} from './tabs';
27
+ export type {TreeTester} from './tree';
17
28
 
18
29
  export type {UserOpts} from './types';
@@ -0,0 +1,176 @@
1
+ /*
2
+ * Copyright 2025 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+
13
+ import {act, within} from '@testing-library/react';
14
+ import {Direction, Orientation, RadioGroupTesterOpts, UserOpts} from './types';
15
+ import {pressElement} from './events';
16
+
17
+ interface TriggerRadioOptions {
18
+ /**
19
+ * What interaction type to use when triggering a radio. Defaults to the interaction type set on the tester.
20
+ */
21
+ interactionType?: UserOpts['interactionType'],
22
+ /**
23
+ * The index, text, or node of the radio to toggle selection for.
24
+ */
25
+ radio: number | string | HTMLElement
26
+ }
27
+
28
+ export class RadioGroupTester {
29
+ private user;
30
+ private _interactionType: UserOpts['interactionType'];
31
+ private _radiogroup: HTMLElement;
32
+ private _direction: Direction;
33
+
34
+ constructor(opts: RadioGroupTesterOpts) {
35
+ let {root, user, interactionType, direction} = opts;
36
+ this.user = user;
37
+ this._interactionType = interactionType || 'mouse';
38
+ this._direction = direction || 'ltr';
39
+
40
+ this._radiogroup = root;
41
+ let radiogroup = within(root).queryAllByRole('radiogroup');
42
+ if (radiogroup.length > 0) {
43
+ this._radiogroup = radiogroup[0];
44
+ }
45
+ }
46
+
47
+ /**
48
+ * Set the interaction type used by the radio tester.
49
+ */
50
+ setInteractionType(type: UserOpts['interactionType']): void {
51
+ this._interactionType = type;
52
+ }
53
+
54
+ /**
55
+ * Returns a radio matching the specified index or text content.
56
+ */
57
+ findRadio(opts: {radioIndexOrText: number | string}): HTMLElement {
58
+ let {
59
+ radioIndexOrText
60
+ } = opts;
61
+
62
+ let radio;
63
+ if (typeof radioIndexOrText === 'number') {
64
+ radio = this.radios[radioIndexOrText];
65
+ } else if (typeof radioIndexOrText === 'string') {
66
+ let label = within(this.radiogroup).getByText(radioIndexOrText);
67
+ // Label may wrap the radio, or the actual label may be a sibling span, or the radio div could have the label within it
68
+ if (label) {
69
+ radio = within(label).queryByRole('radio');
70
+ if (!radio) {
71
+ let labelWrapper = label.closest('label');
72
+ if (labelWrapper) {
73
+ radio = within(labelWrapper).queryByRole('radio');
74
+ } else {
75
+ radio = label.closest('[role=radio]');
76
+ }
77
+ }
78
+ }
79
+ }
80
+
81
+ return radio;
82
+ }
83
+
84
+ private async keyboardNavigateToRadio(opts: {radio: HTMLElement, orientation?: Orientation}) {
85
+ let {radio, orientation = 'vertical'} = opts;
86
+ let radios = this.radios;
87
+ radios = radios.filter(radio => !(radio.hasAttribute('disabled') || radio.getAttribute('aria-disabled') === 'true'));
88
+ if (radios.length === 0) {
89
+ throw new Error('Radio group doesnt have any non-disabled radios. Please double check your radio group.');
90
+ }
91
+
92
+ let targetIndex = radios.indexOf(radio);
93
+ if (targetIndex === -1) {
94
+ throw new Error('Radio provided is not in the radio group.');
95
+ }
96
+
97
+ if (!this.radiogroup.contains(document.activeElement)) {
98
+ let selectedRadio = this.selectedRadio;
99
+ if (selectedRadio != null) {
100
+ act(() => selectedRadio.focus());
101
+ } else {
102
+ act(() => radios[0]?.focus());
103
+ }
104
+ }
105
+
106
+ let currIndex = radios.indexOf(document.activeElement as HTMLElement);
107
+ if (currIndex === -1) {
108
+ throw new Error('Active element is not in the radio group.');
109
+ }
110
+
111
+ let arrowUp = 'ArrowUp';
112
+ let arrowDown = 'ArrowDown';
113
+ if (orientation === 'horizontal') {
114
+ if (this._direction === 'ltr') {
115
+ arrowUp = 'ArrowLeft';
116
+ arrowDown = 'ArrowRight';
117
+ } else {
118
+ arrowUp = 'ArrowRight';
119
+ arrowDown = 'ArrowLeft';
120
+ }
121
+ }
122
+
123
+ let movementDirection = targetIndex > currIndex ? 'down' : 'up';
124
+ for (let i = 0; i < Math.abs(targetIndex - currIndex); i++) {
125
+ await this.user.keyboard(`[${movementDirection === 'down' ? arrowDown : arrowUp}]`);
126
+ }
127
+ };
128
+
129
+ /**
130
+ * Triggers the specified radio. Defaults to using the interaction type set on the radio tester.
131
+ */
132
+ async triggerRadio(opts: TriggerRadioOptions): Promise<void> {
133
+ let {
134
+ radio,
135
+ interactionType = this._interactionType
136
+ } = opts;
137
+
138
+ if (typeof radio === 'string' || typeof radio === 'number') {
139
+ radio = this.findRadio({radioIndexOrText: radio});
140
+ }
141
+
142
+ if (!radio) {
143
+ throw new Error('Target radio not found in the radio group.');
144
+ } else if (radio.hasAttribute('disabled')) {
145
+ throw new Error('Target radio is disabled.');
146
+ }
147
+
148
+ if (interactionType === 'keyboard') {
149
+ let radioOrientation = this._radiogroup.getAttribute('aria-orientation') || 'horizontal';
150
+ await this.keyboardNavigateToRadio({radio, orientation: radioOrientation as Orientation});
151
+ } else {
152
+ await pressElement(this.user, radio, interactionType);
153
+ }
154
+ }
155
+
156
+ /**
157
+ * Returns the radiogroup.
158
+ */
159
+ get radiogroup(): HTMLElement {
160
+ return this._radiogroup;
161
+ }
162
+
163
+ /**
164
+ * Returns the radios.
165
+ */
166
+ get radios(): HTMLElement[] {
167
+ return within(this.radiogroup).queryAllByRole('radio');
168
+ }
169
+
170
+ /**
171
+ * Returns the currently selected radio in the radiogroup if any.
172
+ */
173
+ get selectedRadio(): HTMLElement | null {
174
+ return this.radios.find(radio => (radio as HTMLInputElement).checked) || null;
175
+ }
176
+ }
package/src/select.ts CHANGED
@@ -184,6 +184,8 @@ export class SelectTester {
184
184
  throw new Error('Target option not found in the listbox.');
185
185
  }
186
186
 
187
+ let isMultiSelect = listbox.getAttribute('aria-multiselectable') === 'true';
188
+
187
189
  if (interactionType === 'keyboard') {
188
190
  if (option?.getAttribute('aria-disabled') === 'true') {
189
191
  return;
@@ -203,7 +205,7 @@ export class SelectTester {
203
205
  }
204
206
  }
205
207
 
206
- if (option?.getAttribute('href') == null) {
208
+ if (!isMultiSelect && option?.getAttribute('href') == null) {
207
209
  await waitFor(() => {
208
210
  if (document.activeElement !== this._trigger) {
209
211
  throw new Error(`Expected the document.activeElement after selecting an option to be the select component trigger but got ${document.activeElement}`);
package/src/tabs.ts CHANGED
@@ -79,6 +79,11 @@ export class TabsTester {
79
79
  private async keyboardNavigateToTab(opts: {tab: HTMLElement, orientation?: Orientation}) {
80
80
  let {tab, orientation = 'vertical'} = opts;
81
81
  let tabs = this.tabs;
82
+ tabs = tabs.filter(tab => !(tab.hasAttribute('disabled') || tab.getAttribute('aria-disabled') === 'true'));
83
+ if (tabs.length === 0) {
84
+ throw new Error('Tablist doesnt have any non-disabled tabs. Please double check your tabs implementation.');
85
+ }
86
+
82
87
  let targetIndex = tabs.indexOf(tab);
83
88
  if (targetIndex === -1) {
84
89
  throw new Error('Tab provided is not in the tablist');
@@ -89,11 +94,11 @@ export class TabsTester {
89
94
  if (selectedTab != null) {
90
95
  act(() => selectedTab.focus());
91
96
  } else {
92
- act(() => tabs.find(tab => !(tab.hasAttribute('disabled') || tab.getAttribute('aria-disabled') === 'true'))?.focus());
97
+ act(() => tabs[0]?.focus());
93
98
  }
94
99
  }
95
100
 
96
- let currIndex = this.tabs.indexOf(document.activeElement as HTMLElement);
101
+ let currIndex = tabs.indexOf(document.activeElement as HTMLElement);
97
102
  if (currIndex === -1) {
98
103
  throw new Error('ActiveElement is not in the tablist');
99
104
  }
package/src/testSetup.ts CHANGED
@@ -35,35 +35,37 @@ export function installMouseEvent(): void {
35
35
  });
36
36
  }
37
37
 
38
+ export function definePointerEvent(): void {
39
+ // @ts-ignore
40
+ global.PointerEvent = class FakePointerEvent extends MouseEvent {
41
+ _init: {pageX: number, pageY: number, pointerType: string, pointerId: number, width: number, height: number};
42
+ constructor(name, init) {
43
+ super(name, init);
44
+ this._init = init;
45
+ }
46
+ get pointerType() {
47
+ return this._init.pointerType ?? 'mouse';
48
+ }
49
+ get pointerId() {
50
+ return this._init.pointerId;
51
+ }
52
+ get pageX() {
53
+ return this._init.pageX;
54
+ }
55
+ get pageY() {
56
+ return this._init.pageY;
57
+ }
58
+ get width() {
59
+ return this._init.width;
60
+ }
61
+ get height() {
62
+ return this._init.height;
63
+ }
64
+ };
65
+ }
66
+
38
67
  export function installPointerEvent(): void {
39
- beforeAll(() => {
40
- // @ts-ignore
41
- global.PointerEvent = class FakePointerEvent extends MouseEvent {
42
- _init: {pageX: number, pageY: number, pointerType: string, pointerId: number, width: number, height: number};
43
- constructor(name, init) {
44
- super(name, init);
45
- this._init = init;
46
- }
47
- get pointerType() {
48
- return this._init.pointerType ?? 'mouse';
49
- }
50
- get pointerId() {
51
- return this._init.pointerId;
52
- }
53
- get pageX() {
54
- return this._init.pageX;
55
- }
56
- get pageY() {
57
- return this._init.pageY;
58
- }
59
- get width() {
60
- return this._init.width;
61
- }
62
- get height() {
63
- return this._init.height;
64
- }
65
- };
66
- });
68
+ beforeAll(definePointerEvent);
67
69
  afterAll(() => {
68
70
  // @ts-ignore
69
71
  delete global.PointerEvent;
package/src/types.ts CHANGED
@@ -39,6 +39,8 @@ export interface BaseTesterOpts extends UserOpts {
39
39
  root: HTMLElement
40
40
  }
41
41
 
42
+ export interface CheckboxGroupTesterOpts extends BaseTesterOpts {}
43
+
42
44
  export interface ComboBoxTesterOpts extends BaseTesterOpts {
43
45
  /**
44
46
  * 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),
@@ -52,6 +54,17 @@ export interface ComboBoxTesterOpts extends BaseTesterOpts {
52
54
  trigger?: HTMLElement
53
55
  }
54
56
 
57
+ export interface DialogTesterOpts extends BaseTesterOpts {
58
+ /**
59
+ * The trigger element for the dialog.
60
+ */
61
+ root: HTMLElement,
62
+ /**
63
+ * The overlay type of the dialog. Used to inform the tester how to find the dialog.
64
+ */
65
+ overlayType?: 'modal' | 'popover'
66
+ }
67
+
55
68
  export interface GridListTesterOpts extends BaseTesterOpts {}
56
69
 
57
70
  export interface ListBoxTesterOpts extends BaseTesterOpts {
@@ -76,6 +89,14 @@ export interface MenuTesterOpts extends BaseTesterOpts {
76
89
  rootMenu?: HTMLElement
77
90
  }
78
91
 
92
+ export interface RadioGroupTesterOpts extends BaseTesterOpts {
93
+ /**
94
+ * The horizontal layout direction, typically affected by locale.
95
+ * @default 'ltr'
96
+ */
97
+ direction?: Direction
98
+ }
99
+
79
100
  export interface SelectTesterOpts extends BaseTesterOpts {
80
101
  /**
81
102
  * 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),