@react-aria/test-utils 1.0.0-nightly.5041 → 1.0.0-rc.0
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/README.md +70 -0
- package/dist/import.mjs +6 -4
- package/dist/main.js +15 -23
- package/dist/main.js.map +1 -1
- package/dist/module.js +6 -4
- package/dist/module.js.map +1 -1
- package/dist/private/act.cjs +33 -0
- package/dist/private/act.cjs.map +1 -0
- package/dist/private/act.js +28 -0
- package/dist/private/act.js.map +1 -0
- package/dist/private/checkboxgroup.cjs +107 -0
- package/dist/private/checkboxgroup.cjs.map +1 -0
- package/dist/private/checkboxgroup.js +102 -0
- package/dist/private/checkboxgroup.js.map +1 -0
- package/dist/private/combobox.cjs +199 -0
- package/dist/private/combobox.cjs.map +1 -0
- package/dist/private/combobox.js +194 -0
- package/dist/private/combobox.js.map +1 -0
- package/dist/private/dialog.cjs +110 -0
- package/dist/private/dialog.cjs.map +1 -0
- package/dist/private/dialog.js +105 -0
- package/dist/private/dialog.js.map +1 -0
- package/dist/private/gridlist.cjs +173 -0
- package/dist/private/gridlist.cjs.map +1 -0
- package/dist/private/gridlist.js +168 -0
- package/dist/private/gridlist.js.map +1 -0
- package/dist/private/listbox.cjs +163 -0
- package/dist/private/listbox.cjs.map +1 -0
- package/dist/private/listbox.js +158 -0
- package/dist/private/listbox.js.map +1 -0
- package/dist/private/menu.cjs +265 -0
- package/dist/private/menu.cjs.map +1 -0
- package/dist/private/menu.js +260 -0
- package/dist/private/menu.js.map +1 -0
- package/dist/private/radiogroup.cjs +122 -0
- package/dist/private/radiogroup.cjs.map +1 -0
- package/dist/private/radiogroup.js +117 -0
- package/dist/private/radiogroup.js.map +1 -0
- package/dist/private/select.cjs +169 -0
- package/dist/private/select.cjs.map +1 -0
- package/dist/private/select.js +164 -0
- package/dist/private/select.js.map +1 -0
- package/dist/private/table.cjs +346 -0
- package/dist/private/table.cjs.map +1 -0
- package/dist/private/table.js +341 -0
- package/dist/private/table.js.map +1 -0
- package/dist/private/tabs.cjs +131 -0
- package/dist/private/tabs.cjs.map +1 -0
- package/dist/private/tabs.js +126 -0
- package/dist/private/tabs.js.map +1 -0
- package/dist/private/testSetup.cjs +87 -0
- package/dist/private/testSetup.cjs.map +1 -0
- package/dist/private/testSetup.js +81 -0
- package/dist/private/testSetup.js.map +1 -0
- package/dist/private/tree.cjs +181 -0
- package/dist/private/tree.cjs.map +1 -0
- package/dist/private/tree.js +176 -0
- 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/private/userEventMaps.cjs.map +1 -0
- package/dist/{userEventMaps.mjs → private/userEventMaps.js} +3 -3
- package/dist/private/userEventMaps.js.map +1 -0
- package/dist/private/utils.cjs +136 -0
- package/dist/private/utils.cjs.map +1 -0
- package/dist/private/utils.js +127 -0
- package/dist/private/utils.js.map +1 -0
- package/dist/types/src/act.d.ts +4 -0
- package/dist/types/src/checkboxgroup.d.ts +47 -0
- package/dist/types/src/combobox.d.ts +87 -0
- package/dist/types/src/dialog.d.ts +37 -0
- package/dist/types/src/events.d.ts +25 -0
- package/dist/types/src/gridlist.d.ts +56 -0
- package/dist/types/src/index.d.ts +16 -0
- package/dist/types/src/listbox.d.ts +91 -0
- package/dist/types/src/menu.d.ts +112 -0
- package/dist/types/src/radiogroup.d.ts +47 -0
- package/dist/types/src/select.d.ts +74 -0
- package/dist/types/src/table.d.ts +120 -0
- package/dist/types/src/tabs.d.ts +59 -0
- package/dist/types/src/testSetup.d.ts +6 -0
- package/dist/types/src/tree.d.ts +62 -0
- package/dist/types/src/types.d.ts +143 -0
- package/dist/types/src/user.d.ts +49 -0
- package/dist/types/src/userEventMaps.d.ts +2 -0
- package/dist/types/src/utils.d.ts +29 -0
- package/package.json +26 -18
- package/src/act.ts +35 -0
- package/src/checkboxgroup.ts +165 -0
- package/src/combobox.ts +307 -0
- package/src/dialog.ts +155 -0
- package/src/gridlist.ts +278 -0
- package/src/index.ts +17 -3
- package/src/listbox.ts +300 -0
- package/src/menu.ts +479 -0
- package/src/radiogroup.ts +179 -0
- package/src/select.ts +273 -0
- package/src/table.ts +589 -0
- package/src/tabs.ts +204 -0
- package/src/testSetup.ts +41 -36
- package/src/tree.ts +290 -0
- package/src/types.ts +171 -0
- package/src/user.ts +153 -0
- package/src/userEventMaps.ts +1 -1
- package/src/utils.ts +155 -0
- package/dist/events.main.js +0 -37
- package/dist/events.main.js.map +0 -1
- package/dist/events.mjs +0 -31
- package/dist/events.module.js +0 -31
- package/dist/events.module.js.map +0 -1
- package/dist/testSetup.main.js +0 -82
- package/dist/testSetup.main.js.map +0 -1
- package/dist/testSetup.mjs +0 -76
- package/dist/testSetup.module.js +0 -76
- package/dist/testSetup.module.js.map +0 -1
- package/dist/types.d.ts +0 -16
- package/dist/types.d.ts.map +0 -1
- package/dist/userEventMaps.main.js.map +0 -1
- package/dist/userEventMaps.module.js +0 -38
- package/dist/userEventMaps.module.js.map +0 -1
- package/src/events.ts +0 -28
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import {act as $1350703ef3ac1acc$export$3ba232387fd5d6dd} from "./act.js";
|
|
2
|
+
import {fireEvent as $3ffHH$fireEvent} from "@testing-library/dom";
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
* Copyright 2023 Adobe. All rights reserved.
|
|
6
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
8
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
11
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
12
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
13
|
+
* governing permissions and limitations under the License.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
const $b4e037a2907521c6$export$4bd1d2d5ba6f5eaf = 500;
|
|
17
|
+
function $b4e037a2907521c6$var$testPlatform(re) {
|
|
18
|
+
return typeof window !== 'undefined' && window.navigator != null ? re.test(window.navigator['userAgentData']?.platform || window.navigator.platform) : false;
|
|
19
|
+
}
|
|
20
|
+
function $b4e037a2907521c6$var$cached(fn) {
|
|
21
|
+
if (process.env.NODE_ENV === 'test') return fn;
|
|
22
|
+
let res = null;
|
|
23
|
+
return ()=>{
|
|
24
|
+
if (res == null) res = fn();
|
|
25
|
+
return res;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
const $b4e037a2907521c6$var$isMac = $b4e037a2907521c6$var$cached(function() {
|
|
29
|
+
return $b4e037a2907521c6$var$testPlatform(/^Mac/i);
|
|
30
|
+
});
|
|
31
|
+
function $b4e037a2907521c6$export$6fc0ccaebd758b9d() {
|
|
32
|
+
return $b4e037a2907521c6$var$isMac() ? 'Alt' : 'ControlLeft';
|
|
33
|
+
}
|
|
34
|
+
function $b4e037a2907521c6$export$7943c508934e27ce() {
|
|
35
|
+
return $b4e037a2907521c6$var$isMac() ? 'MetaLeft' : 'ControlLeft';
|
|
36
|
+
}
|
|
37
|
+
function $b4e037a2907521c6$export$bc3bc4a9206bf789(value) {
|
|
38
|
+
if (typeof HTMLElement !== 'undefined' && value instanceof HTMLElement) return value.cloneNode(false).outerHTML;
|
|
39
|
+
return String(value);
|
|
40
|
+
}
|
|
41
|
+
async function $b4e037a2907521c6$export$3a22a5a9bc0fd3b(opts) {
|
|
42
|
+
let { element: element, advanceTimer: advanceTimer, pointerOpts: pointerOpts = {} } = opts;
|
|
43
|
+
let pointerType = pointerOpts.pointerType ?? 'mouse';
|
|
44
|
+
let shouldFireCompatibilityEvents = false;
|
|
45
|
+
(0, $1350703ef3ac1acc$export$3ba232387fd5d6dd)(()=>{
|
|
46
|
+
shouldFireCompatibilityEvents = (0, $3ffHH$fireEvent).pointerDown(element, {
|
|
47
|
+
pointerType: pointerType,
|
|
48
|
+
...pointerOpts
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
let shouldFocus = true;
|
|
52
|
+
if (shouldFireCompatibilityEvents) {
|
|
53
|
+
if (pointerType === 'touch') (0, $1350703ef3ac1acc$export$3ba232387fd5d6dd)(()=>{
|
|
54
|
+
shouldFocus = shouldFireCompatibilityEvents = (0, $3ffHH$fireEvent).touchStart(element, {
|
|
55
|
+
targetTouches: [
|
|
56
|
+
{
|
|
57
|
+
identifier: pointerOpts.pointerId,
|
|
58
|
+
clientX: pointerOpts.clientX,
|
|
59
|
+
clientY: pointerOpts.clientY
|
|
60
|
+
}
|
|
61
|
+
]
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
else if (pointerType === 'mouse') {
|
|
65
|
+
(0, $1350703ef3ac1acc$export$3ba232387fd5d6dd)(()=>{
|
|
66
|
+
shouldFocus = (0, $3ffHH$fireEvent).mouseDown(element, pointerOpts);
|
|
67
|
+
});
|
|
68
|
+
if (shouldFocus) (0, $1350703ef3ac1acc$export$3ba232387fd5d6dd)(()=>element.focus());
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
await (0, $1350703ef3ac1acc$export$3ba232387fd5d6dd)(async ()=>await advanceTimer($b4e037a2907521c6$export$4bd1d2d5ba6f5eaf));
|
|
72
|
+
(0, $1350703ef3ac1acc$export$3ba232387fd5d6dd)(()=>{
|
|
73
|
+
(0, $3ffHH$fireEvent).pointerUp(element, {
|
|
74
|
+
pointerType: pointerType,
|
|
75
|
+
...pointerOpts
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
if (shouldFireCompatibilityEvents) {
|
|
79
|
+
if (pointerType === 'touch') {
|
|
80
|
+
(0, $1350703ef3ac1acc$export$3ba232387fd5d6dd)(()=>{
|
|
81
|
+
shouldFocus = (0, $3ffHH$fireEvent).touchEnd(element, {
|
|
82
|
+
targetTouches: [
|
|
83
|
+
{
|
|
84
|
+
identifier: pointerOpts.pointerId,
|
|
85
|
+
clientX: pointerOpts.clientX,
|
|
86
|
+
clientY: pointerOpts.clientY
|
|
87
|
+
}
|
|
88
|
+
]
|
|
89
|
+
});
|
|
90
|
+
shouldFocus = (0, $3ffHH$fireEvent).mouseDown(element, pointerOpts);
|
|
91
|
+
});
|
|
92
|
+
if (shouldFocus) (0, $1350703ef3ac1acc$export$3ba232387fd5d6dd)(()=>element.focus());
|
|
93
|
+
(0, $1350703ef3ac1acc$export$3ba232387fd5d6dd)(()=>{
|
|
94
|
+
(0, $3ffHH$fireEvent).mouseUp(element, pointerOpts);
|
|
95
|
+
});
|
|
96
|
+
} else if (pointerType === 'mouse') (0, $1350703ef3ac1acc$export$3ba232387fd5d6dd)(()=>{
|
|
97
|
+
(0, $3ffHH$fireEvent).mouseUp(element, pointerOpts);
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
(0, $1350703ef3ac1acc$export$3ba232387fd5d6dd)(()=>{
|
|
101
|
+
(0, $3ffHH$fireEvent).click(element, {
|
|
102
|
+
detail: 1,
|
|
103
|
+
...pointerOpts
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
async function $b4e037a2907521c6$export$6ffa3eb717517feb(user, element, interactionType) {
|
|
108
|
+
if (interactionType === 'mouse') // Add coords with pressure so this isn't detected as a virtual click
|
|
109
|
+
await user.pointer({
|
|
110
|
+
target: element,
|
|
111
|
+
keys: '[MouseLeft]',
|
|
112
|
+
coords: {
|
|
113
|
+
pressure: 0.5
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
else if (interactionType === 'keyboard') {
|
|
117
|
+
(0, $1350703ef3ac1acc$export$3ba232387fd5d6dd)(()=>element.focus());
|
|
118
|
+
await user.keyboard('[Space]');
|
|
119
|
+
} else if (interactionType === 'touch') await user.pointer({
|
|
120
|
+
target: element,
|
|
121
|
+
keys: '[TouchA]'
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
export {$b4e037a2907521c6$export$4bd1d2d5ba6f5eaf as DEFAULT_LONG_PRESS_TIME, $b4e037a2907521c6$export$6fc0ccaebd758b9d as getAltKey, $b4e037a2907521c6$export$7943c508934e27ce as getMetaKey, $b4e037a2907521c6$export$bc3bc4a9206bf789 as formatTargetNode, $b4e037a2907521c6$export$3a22a5a9bc0fd3b as triggerLongPress, $b4e037a2907521c6$export$6ffa3eb717517feb as pressElement};
|
|
127
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAMM,MAAM,4CAA0B;AACvC,SAAS,mCAAa,EAAU;IAC9B,OAAO,OAAO,WAAW,eAAe,OAAO,SAAS,IAAI,OACxD,GAAG,IAAI,CAAC,OAAO,SAAS,CAAC,gBAAgB,EAAE,YAAY,OAAO,SAAS,CAAC,QAAQ,IAChF;AACN;AAEA,SAAS,6BAAO,EAAiB;IAC/B,IAAI,QAAQ,GAAG,CAAC,QAAQ,KAAK,QAC3B,OAAO;IAGT,IAAI,MAAsB;IAC1B,OAAO;QACL,IAAI,OAAO,MACT,MAAM;QAER,OAAO;IACT;AACF;AAEA,MAAM,8BAAQ,6BAAO;IACnB,OAAO,mCAAa;AACtB;AAEO,SAAS;IACd,OAAO,gCAAU,QAAQ;AAC3B;AAEO,SAAS;IACd,OAAO,gCAAU,aAAa;AAChC;AAEO,SAAS,0CAAiB,KAAoC;IACnE,IAAI,OAAO,gBAAgB,eAAe,iBAAiB,aACzD,OAAO,AAAC,MAAM,SAAS,CAAC,OAAuB,SAAS;IAE1D,OAAO,OAAO;AAChB;AAYO,eAAe,yCAAiB,IAItC;IACC,IAAI,WAAC,OAAO,gBAAE,YAAY,eAAE,cAAc,CAAC,GAAE,GAAG;IAChD,IAAI,cAAc,YAAY,WAAW,IAAI;IAC7C,IAAI,gCAAgC;IACpC,CAAA,GAAA,yCAAE,EAAE;QACF,gCAAgC,CAAA,GAAA,gBAAQ,EAAE,WAAW,CAAC,SAAS;yBAAC;YAAa,GAAG,WAAW;QAAA;IAC7F;IACA,IAAI,cAAc;IAClB,IAAI,+BAA+B;QACjC,IAAI,gBAAgB,SAClB,CAAA,GAAA,yCAAE,EAAE;YACF,cAAc,gCAAgC,CAAA,GAAA,gBAAQ,EAAE,UAAU,CAAC,SAAS;gBAC1E,eAAe;oBACb;wBACE,YAAY,YAAY,SAAS;wBACjC,SAAS,YAAY,OAAO;wBAC5B,SAAS,YAAY,OAAO;oBAC9B;iBACD;YACH;QACF;aACK,IAAI,gBAAgB,SAAS;YAClC,CAAA,GAAA,yCAAE,EAAE;gBACF,cAAc,CAAA,GAAA,gBAAQ,EAAE,SAAS,CAAC,SAAS;YAC7C;YACA,IAAI,aACF,CAAA,GAAA,yCAAE,EAAE,IAAM,QAAQ,KAAK;QAE3B;IACF;IACA,MAAM,CAAA,GAAA,yCAAE,EAAE,UAAY,MAAM,aAAa;IACzC,CAAA,GAAA,yCAAE,EAAE;QACF,CAAA,GAAA,gBAAQ,EAAE,SAAS,CAAC,SAAS;yBAAC;YAAa,GAAG,WAAW;QAAA;IAC3D;IACA,IAAI,+BAA+B;QACjC,IAAI,gBAAgB,SAAS;YAC3B,CAAA,GAAA,yCAAE,EAAE;gBACF,cAAc,CAAA,GAAA,gBAAQ,EAAE,QAAQ,CAAC,SAAS;oBACxC,eAAe;wBACb;4BACE,YAAY,YAAY,SAAS;4BACjC,SAAS,YAAY,OAAO;4BAC5B,SAAS,YAAY,OAAO;wBAC9B;qBACD;gBACH;gBACA,cAAc,CAAA,GAAA,gBAAQ,EAAE,SAAS,CAAC,SAAS;YAC7C;YACA,IAAI,aACF,CAAA,GAAA,yCAAE,EAAE,IAAM,QAAQ,KAAK;YAEzB,CAAA,GAAA,yCAAE,EAAE;gBACF,CAAA,GAAA,gBAAQ,EAAE,OAAO,CAAC,SAAS;YAC7B;QACF,OAAO,IAAI,gBAAgB,SACzB,CAAA,GAAA,yCAAE,EAAE;YACF,CAAA,GAAA,gBAAQ,EAAE,OAAO,CAAC,SAAS;QAC7B;IAEJ;IACA,CAAA,GAAA,yCAAE,EAAE;QACF,CAAA,GAAA,gBAAQ,EAAE,KAAK,CAAC,SAAS;YAAC,QAAQ;YAAG,GAAG,WAAW;QAAA;IACrD;AACF;AAGO,eAAe,0CACpB,IAIC,EACD,OAAoB,EACpB,eAA4C;IAE5C,IAAI,oBAAoB,SACtB,qEAAqE;IACrE,MAAM,KAAK,OAAO,CAAC;QAAC,QAAQ;QAAS,MAAM;QAAe,QAAQ;YAAC,UAAU;QAAG;IAAC;SAC5E,IAAI,oBAAoB,YAAY;QACzC,CAAA,GAAA,yCAAE,EAAE,IAAM,QAAQ,KAAK;QACvB,MAAM,KAAK,QAAQ,CAAC;IACtB,OAAO,IAAI,oBAAoB,SAC7B,MAAM,KAAK,OAAO,CAAC;QAAC,QAAQ;QAAS,MAAM;IAAU;AAEzD","sources":["packages/@react-aria/test-utils/src/utils.ts"],"sourcesContent":["/*\n * Copyright 2023 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {act} from './act';\nimport {fireEvent} from '@testing-library/dom';\nimport {UserOpts} from './types';\n\nexport const DEFAULT_LONG_PRESS_TIME = 500;\nfunction testPlatform(re: RegExp) {\n return typeof window !== 'undefined' && window.navigator != null\n ? re.test(window.navigator['userAgentData']?.platform || window.navigator.platform)\n : false;\n}\n\nfunction cached(fn: () => boolean) {\n if (process.env.NODE_ENV === 'test') {\n return fn;\n }\n\n let res: boolean | null = null;\n return () => {\n if (res == null) {\n res = fn();\n }\n return res;\n };\n}\n\nconst isMac = cached(function () {\n return testPlatform(/^Mac/i);\n});\n\nexport function getAltKey(): 'Alt' | 'ControlLeft' {\n return isMac() ? 'Alt' : 'ControlLeft';\n}\n\nexport function getMetaKey(): 'MetaLeft' | 'ControlLeft' {\n return isMac() ? 'MetaLeft' : 'ControlLeft';\n}\n\nexport function formatTargetNode(value: number | string | HTMLElement): string {\n if (typeof HTMLElement !== 'undefined' && value instanceof HTMLElement) {\n return (value.cloneNode(false) as HTMLElement).outerHTML;\n }\n return String(value);\n}\n\n/**\n * Simulates a \"long press\" event on a element.\n *\n * @param opts - Options for the long press.\n * @param opts.element - Element to long press.\n * @param opts.advanceTimer - Function that when called advances the timers in your test suite by a\n * specific amount of time(ms).\n * @param opts.pointeropts - Options to pass to the simulated event. Defaults to mouse. See\n * https://testing-library.com/docs/dom-testing-library/api-events/#fireevent for more info.\n */\nexport async function triggerLongPress(opts: {\n element: HTMLElement;\n advanceTimer: (time: number) => unknown | Promise<unknown>;\n pointerOpts?: Record<string, any>;\n}): Promise<void> {\n let {element, advanceTimer, pointerOpts = {}} = opts;\n let pointerType = pointerOpts.pointerType ?? 'mouse';\n let shouldFireCompatibilityEvents = false;\n act(() => {\n shouldFireCompatibilityEvents = fireEvent.pointerDown(element, {pointerType, ...pointerOpts});\n });\n let shouldFocus = true;\n if (shouldFireCompatibilityEvents) {\n if (pointerType === 'touch') {\n act(() => {\n shouldFocus = shouldFireCompatibilityEvents = fireEvent.touchStart(element, {\n targetTouches: [\n {\n identifier: pointerOpts.pointerId,\n clientX: pointerOpts.clientX,\n clientY: pointerOpts.clientY\n }\n ]\n });\n });\n } else if (pointerType === 'mouse') {\n act(() => {\n shouldFocus = fireEvent.mouseDown(element, pointerOpts);\n });\n if (shouldFocus) {\n act(() => element.focus());\n }\n }\n }\n await act(async () => await advanceTimer(DEFAULT_LONG_PRESS_TIME));\n act(() => {\n fireEvent.pointerUp(element, {pointerType, ...pointerOpts});\n });\n if (shouldFireCompatibilityEvents) {\n if (pointerType === 'touch') {\n act(() => {\n shouldFocus = fireEvent.touchEnd(element, {\n targetTouches: [\n {\n identifier: pointerOpts.pointerId,\n clientX: pointerOpts.clientX,\n clientY: pointerOpts.clientY\n }\n ]\n });\n shouldFocus = fireEvent.mouseDown(element, pointerOpts);\n });\n if (shouldFocus) {\n act(() => element.focus());\n }\n act(() => {\n fireEvent.mouseUp(element, pointerOpts);\n });\n } else if (pointerType === 'mouse') {\n act(() => {\n fireEvent.mouseUp(element, pointerOpts);\n });\n }\n }\n act(() => {\n fireEvent.click(element, {detail: 1, ...pointerOpts});\n });\n}\n\n// Docs cannot handle the types that userEvent actually declares, so hopefully this sub set is okay\nexport async function pressElement(\n user: {\n click: (element: Element) => Promise<void>;\n keyboard: (keys: string) => Promise<void>;\n pointer: (opts: {target: Element; keys: string; coords?: any}) => Promise<void>;\n },\n element: HTMLElement,\n interactionType: UserOpts['interactionType']\n): Promise<void> {\n if (interactionType === 'mouse') {\n // Add coords with pressure so this isn't detected as a virtual click\n await user.pointer({target: element, keys: '[MouseLeft]', coords: {pressure: 0.5}});\n } else if (interactionType === 'keyboard') {\n act(() => element.focus());\n await user.keyboard('[Space]');\n } else if (interactionType === 'touch') {\n await user.pointer({target: element, keys: '[TouchA]'});\n }\n}\n"],"names":[],"version":3,"file":"utils.js.map"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { CheckboxGroupTesterOpts, UserOpts } from './types';
|
|
2
|
+
interface TriggerCheckboxOptions {
|
|
3
|
+
/**
|
|
4
|
+
* What interaction type to use when triggering a checkbox. Defaults to the interaction type set
|
|
5
|
+
* on the tester.
|
|
6
|
+
*/
|
|
7
|
+
interactionType?: UserOpts['interactionType'];
|
|
8
|
+
/**
|
|
9
|
+
* The index, text, or node of the checkbox to toggle selection for.
|
|
10
|
+
*/
|
|
11
|
+
checkbox: number | string | HTMLElement;
|
|
12
|
+
}
|
|
13
|
+
export declare class CheckboxGroupTester {
|
|
14
|
+
private user;
|
|
15
|
+
private _interactionType;
|
|
16
|
+
private _checkboxgroup;
|
|
17
|
+
constructor(opts: CheckboxGroupTesterOpts);
|
|
18
|
+
/**
|
|
19
|
+
* Set the interaction type used by the checkbox group tester.
|
|
20
|
+
*/
|
|
21
|
+
setInteractionType(type: UserOpts['interactionType']): void;
|
|
22
|
+
/**
|
|
23
|
+
* Returns a checkbox matching the specified index or text content.
|
|
24
|
+
*/
|
|
25
|
+
findCheckbox(opts: {
|
|
26
|
+
indexOrText: number | string;
|
|
27
|
+
}): HTMLElement;
|
|
28
|
+
private keyboardNavigateToCheckbox;
|
|
29
|
+
/**
|
|
30
|
+
* Toggles the specified checkbox. Defaults to using the interaction type set on the checkbox
|
|
31
|
+
* tester.
|
|
32
|
+
*/
|
|
33
|
+
toggleCheckbox(opts: TriggerCheckboxOptions): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Returns the checkboxgroup.
|
|
36
|
+
*/
|
|
37
|
+
getCheckboxGroup(): HTMLElement;
|
|
38
|
+
/**
|
|
39
|
+
* Returns the checkboxes.
|
|
40
|
+
*/
|
|
41
|
+
getCheckboxes(): HTMLElement[];
|
|
42
|
+
/**
|
|
43
|
+
* Returns the currently selected checkboxes in the checkboxgroup if any.
|
|
44
|
+
*/
|
|
45
|
+
getSelectedCheckboxes(): HTMLElement[];
|
|
46
|
+
}
|
|
47
|
+
export {};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { ComboBoxTesterOpts, UserOpts } from './types';
|
|
2
|
+
interface ComboBoxOpenOpts {
|
|
3
|
+
/**
|
|
4
|
+
* Whether the combobox opens on focus or needs to be manually opened via user action.
|
|
5
|
+
*
|
|
6
|
+
* @default 'manual'
|
|
7
|
+
*/
|
|
8
|
+
triggerBehavior?: 'focus' | 'manual';
|
|
9
|
+
/**
|
|
10
|
+
* What interaction type to use when opening the combobox. Defaults to the interaction type set on
|
|
11
|
+
* the tester.
|
|
12
|
+
*/
|
|
13
|
+
interactionType?: UserOpts['interactionType'];
|
|
14
|
+
}
|
|
15
|
+
interface ComboBoxSelectOpts extends ComboBoxOpenOpts {
|
|
16
|
+
/**
|
|
17
|
+
* The index, text, or node of the option to select. Option nodes can be sourced via
|
|
18
|
+
* `getOptions()`.
|
|
19
|
+
*/
|
|
20
|
+
option: number | string | HTMLElement;
|
|
21
|
+
/**
|
|
22
|
+
* Whether or not the combobox closes on selection. Defaults to `true` for single select
|
|
23
|
+
* comboboxes and `false` for multi-select comboboxes.
|
|
24
|
+
*/
|
|
25
|
+
closesOnSelect?: boolean;
|
|
26
|
+
}
|
|
27
|
+
export declare class ComboBoxTester {
|
|
28
|
+
private user;
|
|
29
|
+
private _interactionType;
|
|
30
|
+
private _combobox;
|
|
31
|
+
private _trigger;
|
|
32
|
+
constructor(opts: ComboBoxTesterOpts);
|
|
33
|
+
/**
|
|
34
|
+
* Set the interaction type used by the combobox tester.
|
|
35
|
+
*/
|
|
36
|
+
setInteractionType(type: UserOpts['interactionType']): void;
|
|
37
|
+
/**
|
|
38
|
+
* Opens the combobox dropdown. Defaults to using the interaction type set on the combobox tester.
|
|
39
|
+
*/
|
|
40
|
+
open(opts?: ComboBoxOpenOpts): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Returns an option matching the specified index or text content.
|
|
43
|
+
*/
|
|
44
|
+
findOption(opts: {
|
|
45
|
+
indexOrText: number | string;
|
|
46
|
+
}): HTMLElement;
|
|
47
|
+
private keyboardNavigateToOption;
|
|
48
|
+
/**
|
|
49
|
+
* Toggles the selection of the desired combobox option if possible. Defaults to using the
|
|
50
|
+
* interaction type set on the combobox tester. If necessary, will open the combobox dropdown
|
|
51
|
+
* beforehand. The desired option can be targeted via the option's node, the option's text, or the
|
|
52
|
+
* option's index.
|
|
53
|
+
*/
|
|
54
|
+
toggleOptionSelection(opts: ComboBoxSelectOpts): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* Closes the combobox dropdown.
|
|
57
|
+
*/
|
|
58
|
+
close(): Promise<void>;
|
|
59
|
+
/**
|
|
60
|
+
* Returns the combobox.
|
|
61
|
+
*/
|
|
62
|
+
getCombobox(): HTMLElement;
|
|
63
|
+
/**
|
|
64
|
+
* Returns the combobox trigger button.
|
|
65
|
+
*/
|
|
66
|
+
getTrigger(): HTMLElement;
|
|
67
|
+
/**
|
|
68
|
+
* Returns the combobox's listbox if present.
|
|
69
|
+
*/
|
|
70
|
+
getListbox(): HTMLElement | null;
|
|
71
|
+
/**
|
|
72
|
+
* Returns the combobox's sections if present.
|
|
73
|
+
*/
|
|
74
|
+
getSections(): HTMLElement[];
|
|
75
|
+
/**
|
|
76
|
+
* Returns the combobox's options if present. Can be filtered to a subsection of the listbox if
|
|
77
|
+
* provided via `element`.
|
|
78
|
+
*/
|
|
79
|
+
getOptions(opts?: {
|
|
80
|
+
element?: HTMLElement;
|
|
81
|
+
}): HTMLElement[];
|
|
82
|
+
/**
|
|
83
|
+
* Returns the currently focused option in the combobox's dropdown if any.
|
|
84
|
+
*/
|
|
85
|
+
getFocusedOption(): HTMLElement | null;
|
|
86
|
+
}
|
|
87
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { DialogTesterOpts, UserOpts } from './types';
|
|
2
|
+
interface DialogOpenOpts {
|
|
3
|
+
/**
|
|
4
|
+
* What interaction type to use when opening the dialog. Defaults to the interaction type set on
|
|
5
|
+
* the tester.
|
|
6
|
+
*/
|
|
7
|
+
interactionType?: UserOpts['interactionType'];
|
|
8
|
+
}
|
|
9
|
+
export declare class DialogTester {
|
|
10
|
+
private user;
|
|
11
|
+
private _interactionType;
|
|
12
|
+
private _trigger;
|
|
13
|
+
private _dialog;
|
|
14
|
+
private _overlayType;
|
|
15
|
+
constructor(opts: DialogTesterOpts);
|
|
16
|
+
/**
|
|
17
|
+
* Set the interaction type used by the dialog tester.
|
|
18
|
+
*/
|
|
19
|
+
setInteractionType(type: UserOpts['interactionType']): void;
|
|
20
|
+
/**
|
|
21
|
+
* Opens the dialog. Defaults to using the interaction type set on the dialog tester.
|
|
22
|
+
*/
|
|
23
|
+
open(opts?: DialogOpenOpts): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Closes the dialog via the Escape key.
|
|
26
|
+
*/
|
|
27
|
+
close(): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Returns the dialog's trigger.
|
|
30
|
+
*/
|
|
31
|
+
getTrigger(): HTMLElement;
|
|
32
|
+
/**
|
|
33
|
+
* Returns the dialog if present.
|
|
34
|
+
*/
|
|
35
|
+
getDialog(): HTMLElement | null;
|
|
36
|
+
}
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { UserOpts } from './types';
|
|
2
|
+
export declare const DEFAULT_LONG_PRESS_TIME = 500;
|
|
3
|
+
export declare function getAltKey(): 'Alt' | 'ControlLeft';
|
|
4
|
+
export declare function getMetaKey(): 'MetaLeft' | 'ControlLeft';
|
|
5
|
+
/**
|
|
6
|
+
* Simulates a "long press" event on a element.
|
|
7
|
+
* @param opts - Options for the long press.
|
|
8
|
+
* @param opts.element - Element to long press.
|
|
9
|
+
* @param opts.advanceTimer - Function that when called advances the timers in your test suite by a specific amount of time(ms).
|
|
10
|
+
* @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.
|
|
11
|
+
*/
|
|
12
|
+
export declare function triggerLongPress(opts: {
|
|
13
|
+
element: HTMLElement;
|
|
14
|
+
advanceTimer: (time: number) => unknown | Promise<unknown>;
|
|
15
|
+
pointerOpts?: Record<string, any>;
|
|
16
|
+
}): Promise<void>;
|
|
17
|
+
export declare function pressElement(user: {
|
|
18
|
+
click: (element: Element) => Promise<void>;
|
|
19
|
+
keyboard: (keys: string) => Promise<void>;
|
|
20
|
+
pointer: (opts: {
|
|
21
|
+
target: Element;
|
|
22
|
+
keys: string;
|
|
23
|
+
coords?: any;
|
|
24
|
+
}) => Promise<void>;
|
|
25
|
+
}, element: HTMLElement, interactionType: UserOpts['interactionType']): Promise<void>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { GridListTesterOpts, GridRowActionOpts, ToggleGridRowOpts, UserOpts } from './types';
|
|
2
|
+
interface GridListToggleRowOpts extends ToggleGridRowOpts {
|
|
3
|
+
}
|
|
4
|
+
interface GridListRowActionOpts extends GridRowActionOpts {
|
|
5
|
+
}
|
|
6
|
+
export declare class GridListTester {
|
|
7
|
+
private user;
|
|
8
|
+
private _interactionType;
|
|
9
|
+
private _advanceTimer;
|
|
10
|
+
private _direction;
|
|
11
|
+
private _gridlist;
|
|
12
|
+
private _layout;
|
|
13
|
+
constructor(opts: GridListTesterOpts);
|
|
14
|
+
/**
|
|
15
|
+
* Set the interaction type used by the gridlist 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
|
+
indexOrText: number | string;
|
|
23
|
+
}): HTMLElement;
|
|
24
|
+
private keyboardNavigateToRow;
|
|
25
|
+
/**
|
|
26
|
+
* Toggles the selection for the specified gridlist row. Defaults to using the interaction type
|
|
27
|
+
* set on the gridlist tester. Note that this will endevor to always add/remove JUST the provided
|
|
28
|
+
* row to the set of selected rows.
|
|
29
|
+
*/
|
|
30
|
+
toggleRowSelection(opts: GridListToggleRowOpts): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Triggers the action for the specified gridlist row. Defaults to using the interaction type set
|
|
33
|
+
* on the gridlist tester.
|
|
34
|
+
*/
|
|
35
|
+
triggerRowAction(opts: GridListRowActionOpts): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Returns the gridlist.
|
|
38
|
+
*/
|
|
39
|
+
getGridlist(): HTMLElement;
|
|
40
|
+
/**
|
|
41
|
+
* Returns the gridlist's rows if any.
|
|
42
|
+
*/
|
|
43
|
+
getRows(): HTMLElement[];
|
|
44
|
+
/**
|
|
45
|
+
* Returns the gridlist's selected rows if any.
|
|
46
|
+
*/
|
|
47
|
+
getSelectedRows(): HTMLElement[];
|
|
48
|
+
/**
|
|
49
|
+
* Returns the gridlist's cells if any. Can be filtered against a specific row if provided via
|
|
50
|
+
* `element`.
|
|
51
|
+
*/
|
|
52
|
+
getCells(opts?: {
|
|
53
|
+
element?: HTMLElement;
|
|
54
|
+
}): HTMLElement[];
|
|
55
|
+
}
|
|
56
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export { triggerLongPress } from './utils';
|
|
2
|
+
export { installMouseEvent, installPointerEvent } from './testSetup';
|
|
3
|
+
export { pointerMap } from './userEventMaps';
|
|
4
|
+
export { User } from './user';
|
|
5
|
+
export type { CheckboxGroupTester } from './checkboxgroup';
|
|
6
|
+
export type { ComboBoxTester } from './combobox';
|
|
7
|
+
export type { DialogTester } from './dialog';
|
|
8
|
+
export type { GridListTester } from './gridlist';
|
|
9
|
+
export type { ListBoxTester } from './listbox';
|
|
10
|
+
export type { MenuTester } from './menu';
|
|
11
|
+
export type { RadioGroupTester } from './radiogroup';
|
|
12
|
+
export type { SelectTester } from './select';
|
|
13
|
+
export type { TableTester } from './table';
|
|
14
|
+
export type { TabsTester } from './tabs';
|
|
15
|
+
export type { TreeTester } from './tree';
|
|
16
|
+
export type { UserOpts } from './types';
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { ListBoxTesterOpts, UserOpts } from './types';
|
|
2
|
+
interface ListBoxToggleOptionOpts {
|
|
3
|
+
/**
|
|
4
|
+
* What interaction type to use when toggling selection for an option. Defaults to the interaction
|
|
5
|
+
* type set on the tester.
|
|
6
|
+
*/
|
|
7
|
+
interactionType?: UserOpts['interactionType'];
|
|
8
|
+
/**
|
|
9
|
+
* The index, text, or node of the option to toggle selection for.
|
|
10
|
+
*/
|
|
11
|
+
option: number | string | HTMLElement;
|
|
12
|
+
/**
|
|
13
|
+
* Whether the option should be triggered by Space or Enter in keyboard modality.
|
|
14
|
+
*
|
|
15
|
+
* @default 'Enter'
|
|
16
|
+
*/
|
|
17
|
+
keyboardActivation?: 'Space' | 'Enter';
|
|
18
|
+
/**
|
|
19
|
+
* Whether the option needs to be long pressed to be selected. Depends on the listbox's
|
|
20
|
+
* implementation.
|
|
21
|
+
*/
|
|
22
|
+
needsLongPress?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Whether the listbox has a selectionBehavior of "toggle" or "replace" (aka highlight selection).
|
|
25
|
+
* This affects the user operations required to toggle option selection by adding modifier keys
|
|
26
|
+
* during user actions, useful when performing multi-option selection in a "selectionBehavior:
|
|
27
|
+
* 'replace'" listbox. If you would like to still simulate user actions (aka press) without these
|
|
28
|
+
* modifiers keys for a "selectionBehavior: replace" listbox, simply omit this option. See the
|
|
29
|
+
* [RAC Listbox docs](https://react-spectrum.adobe.com/react-aria/ListBox.html#selection-behavior)
|
|
30
|
+
* for more info on this behavior.
|
|
31
|
+
*
|
|
32
|
+
* @default 'toggle'
|
|
33
|
+
*/
|
|
34
|
+
selectionBehavior?: 'toggle' | 'replace';
|
|
35
|
+
}
|
|
36
|
+
interface ListBoxOptionActionOpts extends Omit<ListBoxToggleOptionOpts, 'keyboardActivation' | 'needsLongPress'> {
|
|
37
|
+
/**
|
|
38
|
+
* Whether or not the option needs a double click to trigger the option action. Depends on the
|
|
39
|
+
* listbox's implementation.
|
|
40
|
+
*/
|
|
41
|
+
needsDoubleClick?: boolean;
|
|
42
|
+
}
|
|
43
|
+
export declare class ListBoxTester {
|
|
44
|
+
private user;
|
|
45
|
+
private _interactionType;
|
|
46
|
+
private _advanceTimer;
|
|
47
|
+
private _listbox;
|
|
48
|
+
private _layout;
|
|
49
|
+
constructor(opts: ListBoxTesterOpts);
|
|
50
|
+
/**
|
|
51
|
+
* Set the interaction type used by the listbox tester.
|
|
52
|
+
*/
|
|
53
|
+
setInteractionType(type: UserOpts['interactionType']): void;
|
|
54
|
+
/**
|
|
55
|
+
* Returns a option matching the specified index or text content.
|
|
56
|
+
*/
|
|
57
|
+
findOption(opts: {
|
|
58
|
+
indexOrText: number | string;
|
|
59
|
+
}): HTMLElement;
|
|
60
|
+
private keyboardNavigateToOption;
|
|
61
|
+
/**
|
|
62
|
+
* Toggles the selection for the specified listbox option. Defaults to using the interaction type
|
|
63
|
+
* set on the listbox tester.
|
|
64
|
+
*/
|
|
65
|
+
toggleOptionSelection(opts: ListBoxToggleOptionOpts): Promise<void>;
|
|
66
|
+
/**
|
|
67
|
+
* Triggers the action for the specified listbox option. Defaults to using the interaction type
|
|
68
|
+
* set on the listbox tester.
|
|
69
|
+
*/
|
|
70
|
+
triggerOptionAction(opts: ListBoxOptionActionOpts): Promise<void>;
|
|
71
|
+
/**
|
|
72
|
+
* Returns the listbox.
|
|
73
|
+
*/
|
|
74
|
+
getListbox(): HTMLElement;
|
|
75
|
+
/**
|
|
76
|
+
* Returns the listbox options. Can be filtered to a subsection of the listbox if provided via
|
|
77
|
+
* `element`.
|
|
78
|
+
*/
|
|
79
|
+
getOptions(opts?: {
|
|
80
|
+
element?: HTMLElement;
|
|
81
|
+
}): HTMLElement[];
|
|
82
|
+
/**
|
|
83
|
+
* Returns the listbox's selected options if any.
|
|
84
|
+
*/
|
|
85
|
+
getSelectedOptions(): HTMLElement[];
|
|
86
|
+
/**
|
|
87
|
+
* Returns the listbox's sections if any.
|
|
88
|
+
*/
|
|
89
|
+
getSections(): HTMLElement[];
|
|
90
|
+
}
|
|
91
|
+
export {};
|
|
@@ -0,0 +1,112 @@
|
|
|
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
|
|
9
|
+
* tester.
|
|
10
|
+
*/
|
|
11
|
+
interactionType?: UserOpts['interactionType'];
|
|
12
|
+
/**
|
|
13
|
+
* Whether to open the menu via ArrowUp or ArrowDown if in keyboard modality.
|
|
14
|
+
*/
|
|
15
|
+
direction?: 'up' | 'down';
|
|
16
|
+
}
|
|
17
|
+
interface MenuSelectOpts extends MenuOpenOpts {
|
|
18
|
+
/**
|
|
19
|
+
* The index, text, or node of the option to select. Option nodes can be sourced via
|
|
20
|
+
* `getOptions()`.
|
|
21
|
+
*/
|
|
22
|
+
option: number | string | HTMLElement;
|
|
23
|
+
/**
|
|
24
|
+
* The menu's selection mode. Will affect whether or not the menu is expected to be closed upon
|
|
25
|
+
* option selection.
|
|
26
|
+
*
|
|
27
|
+
* @default 'single'
|
|
28
|
+
*/
|
|
29
|
+
menuSelectionMode?: 'single' | 'multiple';
|
|
30
|
+
/**
|
|
31
|
+
* Whether or not the menu closes on select. Depends on menu implementation and configuration.
|
|
32
|
+
*
|
|
33
|
+
* @default true
|
|
34
|
+
*/
|
|
35
|
+
closesOnSelect?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Whether the option should be triggered by Space or Enter in keyboard modality.
|
|
38
|
+
*
|
|
39
|
+
* @default 'Enter'
|
|
40
|
+
*/
|
|
41
|
+
keyboardActivation?: 'Space' | 'Enter';
|
|
42
|
+
}
|
|
43
|
+
interface MenuOpenSubmenuOpts extends MenuOpenOpts {
|
|
44
|
+
/**
|
|
45
|
+
* The text or node of the submenu trigger to open. Available submenu trigger nodes can be sourced
|
|
46
|
+
* via `getSubmenuTriggers()`.
|
|
47
|
+
*/
|
|
48
|
+
submenuTrigger: string | HTMLElement;
|
|
49
|
+
}
|
|
50
|
+
export declare class MenuTester {
|
|
51
|
+
private user;
|
|
52
|
+
private _interactionType;
|
|
53
|
+
private _advanceTimer;
|
|
54
|
+
private _trigger;
|
|
55
|
+
private _isSubmenu;
|
|
56
|
+
private _rootMenu;
|
|
57
|
+
constructor(opts: MenuTesterOpts);
|
|
58
|
+
/**
|
|
59
|
+
* Set the interaction type used by the menu tester.
|
|
60
|
+
*/
|
|
61
|
+
setInteractionType(type: UserOpts['interactionType']): void;
|
|
62
|
+
/**
|
|
63
|
+
* Opens the menu. Defaults to using the interaction type set on the menu tester.
|
|
64
|
+
*/
|
|
65
|
+
open(opts?: MenuOpenOpts): Promise<void>;
|
|
66
|
+
/**
|
|
67
|
+
* Returns a option matching the specified index or text content.
|
|
68
|
+
*/
|
|
69
|
+
findOption(opts: {
|
|
70
|
+
indexOrText: number | string;
|
|
71
|
+
}): HTMLElement;
|
|
72
|
+
/**
|
|
73
|
+
* Toggles the selection of the desired menu option if possible. Defaults to using the interaction
|
|
74
|
+
* type set on the menu tester. If necessary, will open the menu dropdown beforehand. The desired
|
|
75
|
+
* option can be targeted via the option's node, the option's text, or the option's index.
|
|
76
|
+
*/
|
|
77
|
+
toggleOptionSelection(opts: MenuSelectOpts): Promise<void>;
|
|
78
|
+
/**
|
|
79
|
+
* Opens the submenu. Defaults to using the interaction type set on the menu tester. The submenu
|
|
80
|
+
* trigger can be targeted via the trigger's node or the trigger's text.
|
|
81
|
+
*/
|
|
82
|
+
openSubmenu(opts: MenuOpenSubmenuOpts): Promise<MenuTester>;
|
|
83
|
+
private keyboardNavigateToOption;
|
|
84
|
+
/**
|
|
85
|
+
* Closes the menu.
|
|
86
|
+
*/
|
|
87
|
+
close(): Promise<void>;
|
|
88
|
+
/**
|
|
89
|
+
* Returns the menu's trigger.
|
|
90
|
+
*/
|
|
91
|
+
getTrigger(): HTMLElement;
|
|
92
|
+
/**
|
|
93
|
+
* Returns the menu if present.
|
|
94
|
+
*/
|
|
95
|
+
getMenu(): HTMLElement | null;
|
|
96
|
+
/**
|
|
97
|
+
* Returns the menu's sections if any.
|
|
98
|
+
*/
|
|
99
|
+
getSections(): HTMLElement[];
|
|
100
|
+
/**
|
|
101
|
+
* Returns the menu's options if present. Can be filtered to a subsection of the menu if provided
|
|
102
|
+
* via `element`.
|
|
103
|
+
*/
|
|
104
|
+
getOptions(opts?: {
|
|
105
|
+
element?: HTMLElement;
|
|
106
|
+
}): HTMLElement[];
|
|
107
|
+
/**
|
|
108
|
+
* Returns the menu's submenu triggers if any.
|
|
109
|
+
*/
|
|
110
|
+
getSubmenuTriggers(): HTMLElement[];
|
|
111
|
+
}
|
|
112
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
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
|
|
5
|
+
* the tester.
|
|
6
|
+
*/
|
|
7
|
+
interactionType?: UserOpts['interactionType'];
|
|
8
|
+
/**
|
|
9
|
+
* The index, text, or node of the radio to toggle selection for.
|
|
10
|
+
*/
|
|
11
|
+
radio: number | string | HTMLElement;
|
|
12
|
+
}
|
|
13
|
+
export declare class RadioGroupTester {
|
|
14
|
+
private user;
|
|
15
|
+
private _interactionType;
|
|
16
|
+
private _radiogroup;
|
|
17
|
+
private _direction;
|
|
18
|
+
constructor(opts: RadioGroupTesterOpts);
|
|
19
|
+
/**
|
|
20
|
+
* Set the interaction type used by the radio tester.
|
|
21
|
+
*/
|
|
22
|
+
setInteractionType(type: UserOpts['interactionType']): void;
|
|
23
|
+
/**
|
|
24
|
+
* Returns a radio matching the specified index or text content.
|
|
25
|
+
*/
|
|
26
|
+
findRadio(opts: {
|
|
27
|
+
indexOrText: number | string;
|
|
28
|
+
}): HTMLElement;
|
|
29
|
+
private keyboardNavigateToRadio;
|
|
30
|
+
/**
|
|
31
|
+
* Triggers the specified radio. Defaults to using the interaction type set on the radio tester.
|
|
32
|
+
*/
|
|
33
|
+
triggerRadio(opts: TriggerRadioOptions): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Returns the radiogroup.
|
|
36
|
+
*/
|
|
37
|
+
getRadioGroup(): HTMLElement;
|
|
38
|
+
/**
|
|
39
|
+
* Returns the radios.
|
|
40
|
+
*/
|
|
41
|
+
getRadios(): HTMLElement[];
|
|
42
|
+
/**
|
|
43
|
+
* Returns the currently selected radio in the radiogroup if any.
|
|
44
|
+
*/
|
|
45
|
+
getSelectedRadio(): HTMLElement | null;
|
|
46
|
+
}
|
|
47
|
+
export {};
|