@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.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ACxC;AACF","sources":["packages/@react-aria/test-utils/src/tree.ts"],"sourcesContent":["/*\n * Copyright 2024 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, within} from '@testing-library/react';\nimport {BaseGridRowInteractionOpts, GridRowActionOpts, ToggleGridRowOpts, TreeTesterOpts, UserOpts} from './types';\nimport {getAltKey, getMetaKey, pressElement, triggerLongPress} from './events';\n\ninterface TreeToggleExpansionOpts extends BaseGridRowInteractionOpts {}\ninterface TreeToggleRowOpts extends ToggleGridRowOpts {}\ninterface TreeRowActionOpts extends GridRowActionOpts {}\n\n// TODO: this ended up being pretty much the same as gridlist, refactor so it extends from gridlist\nexport class TreeTester {\n private user;\n private _interactionType: UserOpts['interactionType'];\n private _advanceTimer: UserOpts['advanceTimer'];\n private _tree: HTMLElement;\n\n constructor(opts: TreeTesterOpts) {\n let {root, user, interactionType, advanceTimer} = opts;\n this.user = user;\n this._interactionType = interactionType || 'mouse';\n this._advanceTimer = advanceTimer;\n this._tree = root;\n // TODO: should all helpers do this?\n let tree = within(root).queryByRole('treegrid');\n if (root.getAttribute('role') !== 'treegrid' && tree) {\n this._tree = tree;\n }\n }\n\n /**\n * Set the interaction type used by the tree tester.\n */\n setInteractionType(type: UserOpts['interactionType']): void {\n this._interactionType = type;\n };\n\n /**\n * Returns a row matching the specified index or text content.\n */\n findRow(opts: {rowIndexOrText: number | string}): HTMLElement {\n let {\n rowIndexOrText\n } = opts;\n\n let row;\n if (typeof rowIndexOrText === 'number') {\n row = this.rows[rowIndexOrText];\n } else if (typeof rowIndexOrText === 'string') {\n row = (within(this.tree!).getByText(rowIndexOrText).closest('[role=row]'))! as HTMLElement;\n }\n\n return row;\n }\n\n // TODO: RTL\n private async keyboardNavigateToRow(opts: {row: HTMLElement, selectionOnNav?: 'default' | 'none'}) {\n let {row, selectionOnNav = 'default'} = opts;\n let altKey = getAltKey();\n let rows = this.rows;\n let targetIndex = rows.indexOf(row);\n if (targetIndex === -1) {\n throw new Error('Option provided is not in the tree');\n }\n\n if (document.activeElement !== this._tree && !this._tree.contains(document.activeElement)) {\n act(() => this._tree.focus());\n }\n\n if (document.activeElement === this.tree) {\n await this.user.keyboard(`${selectionOnNav === 'none' ? `[${altKey}>]` : ''}[ArrowDown]${selectionOnNav === 'none' ? `[/${altKey}]` : ''}`);\n } else if (this._tree.contains(document.activeElement) && document.activeElement!.getAttribute('role') !== 'row') {\n do {\n await this.user.keyboard('[ArrowLeft]');\n } while (document.activeElement!.getAttribute('role') !== 'row');\n }\n let currIndex = rows.indexOf(document.activeElement as HTMLElement);\n if (currIndex === -1) {\n throw new Error('ActiveElement is not in the tree');\n }\n let direction = targetIndex > currIndex ? 'down' : 'up';\n\n if (selectionOnNav === 'none') {\n await this.user.keyboard(`[${altKey}>]`);\n }\n for (let i = 0; i < Math.abs(targetIndex - currIndex); i++) {\n await this.user.keyboard(`[${direction === 'down' ? 'ArrowDown' : 'ArrowUp'}]`);\n }\n if (selectionOnNav === 'none') {\n await this.user.keyboard(`[/${altKey}]`);\n }\n };\n\n /**\n * Toggles the selection for the specified tree row. Defaults to using the interaction type set on the tree tester.\n * Note that this will endevor to always add/remove JUST the provided row to the set of selected rows.\n */\n async toggleRowSelection(opts: TreeToggleRowOpts): Promise<void> {\n let {\n row,\n needsLongPress,\n checkboxSelection = true,\n interactionType = this._interactionType,\n selectionBehavior = 'toggle'\n } = opts;\n\n let altKey = getAltKey();\n let metaKey = getMetaKey();\n\n if (typeof row === 'string' || typeof row === 'number') {\n row = this.findRow({rowIndexOrText: row});\n }\n\n if (!row) {\n throw new Error('Target row not found in the tree.');\n }\n\n let rowCheckbox = within(row).queryByRole('checkbox');\n\n // TODO: we early return here because the checkbox can't be keyboard navigated to if the row is disabled usually\n // but we may to check for disabledBehavior (aka if the disable row gets skipped when keyboard navigating or not)\n if (interactionType === 'keyboard' && (rowCheckbox?.getAttribute('disabled') === '' || row?.getAttribute('aria-disabled') === 'true')) {\n return;\n }\n\n // this would be better than the check to do nothing in events.ts\n // also, it'd be good to be able to trigger selection on the row instead of having to go to the checkbox directly\n if (interactionType === 'keyboard' && (!checkboxSelection || !rowCheckbox)) {\n await this.keyboardNavigateToRow({row, selectionOnNav: selectionBehavior === 'replace' ? 'none' : 'default'});\n if (selectionBehavior === 'replace') {\n await this.user.keyboard(`[${altKey}>]`);\n }\n await this.user.keyboard('[Space]');\n if (selectionBehavior === 'replace') {\n await this.user.keyboard(`[/${altKey}]`);\n }\n return;\n }\n if (rowCheckbox && checkboxSelection) {\n await pressElement(this.user, rowCheckbox, interactionType);\n } else {\n let cell = within(row).getAllByRole('gridcell')[0];\n if (needsLongPress && interactionType === 'touch') {\n if (this._advanceTimer == null) {\n throw new Error('No advanceTimers provided for long press.');\n }\n\n // Note that long press interactions with rows is strictly touch only for grid rows\n await triggerLongPress({element: cell, advanceTimer: this._advanceTimer, pointerOpts: {pointerType: 'touch'}});\n } else {\n // TODO add modifiers here? Maybe move into pressElement if we get more cases for different types of modifier keys\n if (selectionBehavior === 'replace' && interactionType !== 'touch') {\n await this.user.keyboard(`[${metaKey}>]`);\n }\n await pressElement(this.user, row, interactionType);\n if (selectionBehavior === 'replace' && interactionType !== 'touch') {\n await this.user.keyboard(`[/${metaKey}]`);\n }\n }\n }\n };\n\n /**\n * Toggles the expansion for the specified tree row. Defaults to using the interaction type set on the tree tester.\n */\n async toggleRowExpansion(opts: TreeToggleExpansionOpts): Promise<void> {\n let {\n row,\n interactionType = this._interactionType\n } = opts;\n if (!this.tree.contains(document.activeElement)) {\n await act(async () => {\n this.tree.focus();\n });\n }\n\n if (typeof row === 'string' || typeof row === 'number') {\n row = this.findRow({rowIndexOrText: row});\n }\n\n if (!row) {\n throw new Error('Target row not found in the tree.');\n } else if (row.getAttribute('aria-expanded') == null) {\n throw new Error('Target row is not expandable.');\n }\n\n if (interactionType === 'mouse' || interactionType === 'touch') {\n let rowExpander = within(row).getAllByRole('button')[0]; // what happens if the button is not first? how can we differentiate?\n await pressElement(this.user, rowExpander, interactionType);\n } else if (interactionType === 'keyboard') {\n if (row?.getAttribute('aria-disabled') === 'true') {\n return;\n }\n\n // TODO: We always Use Option/Ctrl when keyboard navigating so selection isn't changed\n // in selectionmode=\"replace\"/highlight selection when navigating to the row that the user wants\n // to expand. Discuss if this is useful or not\n await this.keyboardNavigateToRow({row});\n if (row.getAttribute('aria-expanded') === 'true') {\n await this.user.keyboard('[ArrowLeft]');\n } else {\n await this.user.keyboard('[ArrowRight]');\n }\n }\n };\n\n /**\n * Triggers the action for the specified tree row. Defaults to using the interaction type set on the tree tester.\n */\n async triggerRowAction(opts: TreeRowActionOpts): Promise<void> {\n let {\n row,\n needsDoubleClick,\n interactionType = this._interactionType\n } = opts;\n\n if (typeof row === 'string' || typeof row === 'number') {\n row = this.findRow({rowIndexOrText: row});\n }\n\n if (!row) {\n throw new Error('Target row not found in the tree.');\n }\n\n if (needsDoubleClick) {\n await this.user.dblClick(row);\n } else if (interactionType === 'keyboard') {\n if (row?.getAttribute('aria-disabled') === 'true') {\n return;\n }\n\n // TODO: same as above, uses the modifier key to make sure we don't modify selection state on row focus\n // as we keyboard navigate to the row we want activate\n await this.keyboardNavigateToRow({row});\n await this.user.keyboard('[Enter]');\n } else {\n await pressElement(this.user, row, interactionType);\n }\n };\n\n /**\n * Returns the tree.\n */\n get tree(): HTMLElement {\n return this._tree;\n }\n\n /**\n * Returns the tree's rows if any.\n */\n get rows(): HTMLElement[] {\n return within(this?.tree).queryAllByRole('row');\n }\n\n /**\n * Returns the tree's selected rows if any.\n */\n get selectedRows(): HTMLElement[] {\n return this.rows.filter(row => row.getAttribute('aria-selected') === 'true');\n }\n\n /**\n * Returns the tree's cells if any. Can be filtered against a specific row if provided via `element`.\n */\n cells(opts: {element?: HTMLElement} = {}): HTMLElement[] {\n let {element = this.tree} = opts;\n return within(element).queryAllByRole('gridcell');\n }\n}\n"],"names":[],"version":3,"file":"tree.js.map"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
var $2c71bb2c1e5033f0$exports = require("./checkboxgroup.cjs");
|
|
2
|
+
var $2cdddd94ee78eafe$exports = require("./combobox.cjs");
|
|
3
|
+
var $cde1dbf8bdfa11d9$exports = require("./dialog.cjs");
|
|
4
|
+
var $31bb3cd1e8c56ca2$exports = require("./gridlist.cjs");
|
|
5
|
+
var $c0f7ae61eac30828$exports = require("./listbox.cjs");
|
|
6
|
+
var $72b6079685b45ac0$exports = require("./menu.cjs");
|
|
7
|
+
var $b3fc8c302673b35d$exports = require("./userEventMaps.cjs");
|
|
8
|
+
var $4308942495e5af40$exports = require("./radiogroup.cjs");
|
|
9
|
+
var $842eb702165f4e83$exports = require("./select.cjs");
|
|
10
|
+
var $b9d4e4f005cd9015$exports = require("./table.cjs");
|
|
11
|
+
var $d225318b7bd4eacf$exports = require("./tabs.cjs");
|
|
12
|
+
var $c7f71a5a893f714a$exports = require("./tree.cjs");
|
|
13
|
+
var $2DbTQ$testinglibraryuserevent = require("@testing-library/user-event");
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
function $parcel$interopDefault(a) {
|
|
17
|
+
return a && a.__esModule ? a.default : a;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function $parcel$export(e, n, v, s) {
|
|
21
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
$parcel$export(module.exports, "User", function () { return $3117e6a7fac3686b$export$1f44aaf2ec115b54; });
|
|
25
|
+
/*
|
|
26
|
+
* Copyright 2024 Adobe. All rights reserved.
|
|
27
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
28
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
29
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
30
|
+
*
|
|
31
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
32
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
33
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
34
|
+
* governing permissions and limitations under the License.
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
let $3117e6a7fac3686b$var$keyToUtil = {
|
|
49
|
+
'CheckboxGroup': (0, $2c71bb2c1e5033f0$exports.CheckboxGroupTester),
|
|
50
|
+
'ComboBox': (0, $2cdddd94ee78eafe$exports.ComboBoxTester),
|
|
51
|
+
'Dialog': (0, $cde1dbf8bdfa11d9$exports.DialogTester),
|
|
52
|
+
'GridList': (0, $31bb3cd1e8c56ca2$exports.GridListTester),
|
|
53
|
+
'ListBox': (0, $c0f7ae61eac30828$exports.ListBoxTester),
|
|
54
|
+
'Menu': (0, $72b6079685b45ac0$exports.MenuTester),
|
|
55
|
+
'RadioGroup': (0, $4308942495e5af40$exports.RadioGroupTester),
|
|
56
|
+
'Select': (0, $842eb702165f4e83$exports.SelectTester),
|
|
57
|
+
'Table': (0, $b9d4e4f005cd9015$exports.TableTester),
|
|
58
|
+
'Tabs': (0, $d225318b7bd4eacf$exports.TabsTester),
|
|
59
|
+
'Tree': (0, $c7f71a5a893f714a$exports.TreeTester)
|
|
60
|
+
};
|
|
61
|
+
let $3117e6a7fac3686b$var$defaultAdvanceTimer = (waitTime)=>new Promise((resolve)=>setTimeout(resolve, waitTime));
|
|
62
|
+
class $3117e6a7fac3686b$export$1f44aaf2ec115b54 {
|
|
63
|
+
constructor(opts = {}){
|
|
64
|
+
let { interactionType: interactionType, advanceTimer: advanceTimer } = opts;
|
|
65
|
+
this.user = (0, ($parcel$interopDefault($2DbTQ$testinglibraryuserevent))).setup({
|
|
66
|
+
delay: null,
|
|
67
|
+
pointerMap: $b3fc8c302673b35d$exports.pointerMap
|
|
68
|
+
});
|
|
69
|
+
this.interactionType = interactionType;
|
|
70
|
+
this.advanceTimer = advanceTimer || $3117e6a7fac3686b$var$defaultAdvanceTimer;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Creates an aria pattern tester, inheriting the options provided to the original user.
|
|
74
|
+
*/ createTester(patternName, opts) {
|
|
75
|
+
return new $3117e6a7fac3686b$var$keyToUtil[patternName]({
|
|
76
|
+
interactionType: this.interactionType,
|
|
77
|
+
advanceTimer: this.advanceTimer,
|
|
78
|
+
...opts,
|
|
79
|
+
user: this.user
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
//# sourceMappingURL=user.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;AA8BD,IAAI,kCAYA;IACF,iBAAiB,CAAA,GAAA,6CAAkB;IACnC,YAAY,CAAA,GAAA,wCAAa;IACzB,UAAU,CAAA,GAAA,sCAAW;IACrB,YAAY,CAAA,GAAA,wCAAa;IACzB,WAAW,CAAA,GAAA,uCAAY;IACvB,QAAQ,CAAA,GAAA,oCAAS;IACjB,cAAc,CAAA,GAAA,0CAAe;IAC7B,UAAU,CAAA,GAAA,sCAAW;IACrB,SAAS,CAAA,GAAA,qCAAU;IACnB,QAAQ,CAAA,GAAA,oCAAS;IACjB,QAAQ,CAAA,GAAA,oCAAS;AACnB;AAgCA,IAAI,4CAAsB,CAAC,WAAiC,IAAI,QAAQ,CAAC,UAAY,WAAW,SAAS;AAElG,MAAM;IAaX,YAAY,OAAiB,CAAC,CAAC,CAAE;QAC/B,IAAI,mBAAC,eAAe,gBAAE,YAAY,EAAC,GAAG;QACtC,IAAI,CAAC,IAAI,GAAG,CAAA,GAAA,wDAAQ,EAAE,KAAK,CAAC;YAAC,OAAO;wBAAM;QAAU;QACpD,IAAI,CAAC,eAAe,GAAG;QACvB,IAAI,CAAC,YAAY,GAAG,gBAAgB;IACtC;IAEA;;GAEC,GACD,aAAqC,WAAc,EAAE,IAAmB,EAAa;QACnF,OAAO,IAAI,AAAC,+BAAU,CAAC,YAAY,CAAC;YAAC,iBAAiB,IAAI,CAAC,eAAe;YAAE,cAAc,IAAI,CAAC,YAAY;YAAE,GAAG,IAAI;YAAE,MAAM,IAAI,CAAC,IAAI;QAAA;IACvI;AACF","sources":["packages/@react-aria/test-utils/src/user.ts"],"sourcesContent":["/*\n * Copyright 2024 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 {CheckboxGroupTester} from './checkboxgroup';\nimport {\n CheckboxGroupTesterOpts,\n ComboBoxTesterOpts,\n DialogTesterOpts,\n GridListTesterOpts,\n ListBoxTesterOpts,\n MenuTesterOpts,\n RadioGroupTesterOpts,\n SelectTesterOpts,\n TableTesterOpts,\n TabsTesterOpts,\n TreeTesterOpts,\n UserOpts\n} from './types';\nimport {ComboBoxTester} from './combobox';\nimport {DialogTester} from './dialog';\nimport {GridListTester} from './gridlist';\nimport {ListBoxTester} from './listbox';\nimport {MenuTester} from './menu';\nimport {pointerMap} from './';\nimport {RadioGroupTester} from './radiogroup';\nimport {SelectTester} from './select';\nimport {TableTester} from './table';\nimport {TabsTester} from './tabs';\nimport {TreeTester} from './tree';\nimport userEvent from '@testing-library/user-event';\n\nlet keyToUtil: {\n 'CheckboxGroup': typeof CheckboxGroupTester,\n 'ComboBox': typeof ComboBoxTester,\n 'Dialog': typeof DialogTester,\n 'GridList': typeof GridListTester,\n 'ListBox': typeof ListBoxTester,\n 'Menu': typeof MenuTester,\n 'RadioGroup': typeof RadioGroupTester,\n 'Select': typeof SelectTester,\n 'Table': typeof TableTester,\n 'Tabs': typeof TabsTester,\n 'Tree': typeof TreeTester\n} = {\n 'CheckboxGroup': CheckboxGroupTester,\n 'ComboBox': ComboBoxTester,\n 'Dialog': DialogTester,\n 'GridList': GridListTester,\n 'ListBox': ListBoxTester,\n 'Menu': MenuTester,\n 'RadioGroup': RadioGroupTester,\n 'Select': SelectTester,\n 'Table': TableTester,\n 'Tabs': TabsTester,\n 'Tree': TreeTester\n} as const;\nexport type PatternNames = keyof typeof keyToUtil;\n\n// Conditional type: https://www.typescriptlang.org/docs/handbook/2/conditional-types.html\ntype Tester<T> =\n T extends 'CheckboxGroup' ? CheckboxGroupTester :\n T extends 'ComboBox' ? ComboBoxTester :\n T extends 'Dialog' ? DialogTester :\n T extends 'GridList' ? GridListTester :\n T extends 'ListBox' ? ListBoxTester :\n T extends 'Menu' ? MenuTester :\n T extends 'RadioGroup' ? RadioGroupTester :\n T extends 'Select' ? SelectTester :\n T extends 'Table' ? TableTester :\n T extends 'Tabs' ? TabsTester :\n T extends 'Tree' ? TreeTester :\n never;\n\ntype TesterOpts<T> =\n T extends 'CheckboxGroup' ? CheckboxGroupTesterOpts :\n T extends 'ComboBox' ? ComboBoxTesterOpts :\n T extends 'Dialog' ? DialogTesterOpts :\n T extends 'GridList' ? GridListTesterOpts :\n T extends 'ListBox' ? ListBoxTesterOpts :\n T extends 'Menu' ? MenuTesterOpts :\n T extends 'RadioGroup' ? RadioGroupTesterOpts :\n T extends 'Select' ? SelectTesterOpts :\n T extends 'Table' ? TableTesterOpts :\n T extends 'Tabs' ? TabsTesterOpts :\n T extends 'Tree' ? TreeTesterOpts :\n never;\n\nlet defaultAdvanceTimer = (waitTime: number | undefined) => new Promise((resolve) => setTimeout(resolve, waitTime));\n\nexport class User {\n private user;\n /**\n * The interaction type (mouse, touch, keyboard) that the test util user will use when interacting with a component. This can be overridden\n * at the aria pattern util level if needed.\n * @default mouse\n */\n interactionType: UserOpts['interactionType'];\n /**\n * A function used by the test utils to advance timers during interactions. Required for certain aria patterns (e.g. table).\n */\n advanceTimer: UserOpts['advanceTimer'];\n\n constructor(opts: UserOpts = {}) {\n let {interactionType, advanceTimer} = opts;\n this.user = userEvent.setup({delay: null, pointerMap});\n this.interactionType = interactionType;\n this.advanceTimer = advanceTimer || defaultAdvanceTimer;\n }\n\n /**\n * Creates an aria pattern tester, inheriting the options provided to the original user.\n */\n createTester<T extends PatternNames>(patternName: T, opts: TesterOpts<T>): Tester<T> {\n return new (keyToUtil)[patternName]({interactionType: this.interactionType, advanceTimer: this.advanceTimer, ...opts, user: this.user}) as Tester<T>;\n }\n}\n"],"names":[],"version":3,"file":"user.cjs.map"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import {CheckboxGroupTester as $e7160b4be83b4967$export$f54f4bde770cc5a6} from "./checkboxgroup.js";
|
|
2
|
+
import {ComboBoxTester as $a2202d8b369e6a8a$export$f97e14e96d71ab3b} from "./combobox.js";
|
|
3
|
+
import {DialogTester as $1bad24930969e309$export$e79328f5295cc2a1} from "./dialog.js";
|
|
4
|
+
import {GridListTester as $ed42840525c46506$export$93a85aaed9fabd83} from "./gridlist.js";
|
|
5
|
+
import {ListBoxTester as $8d2aea0e455eb460$export$54c24f7ee8577f4f} from "./listbox.js";
|
|
6
|
+
import {MenuTester as $460bfe9f038d2630$export$f73bbc9212ed861e} from "./menu.js";
|
|
7
|
+
import {pointerMap as $759f061d800cf446$export$7dbde2c4caaa8d35} from "./userEventMaps.js";
|
|
8
|
+
import {RadioGroupTester as $14dc6ef63d191867$export$d66326e63d27e116} from "./radiogroup.js";
|
|
9
|
+
import {SelectTester as $6acb352063615cf0$export$d1859707465446a9} from "./select.js";
|
|
10
|
+
import {TableTester as $196900c7f8f394b6$export$4c6a9d6ae3b0086} from "./table.js";
|
|
11
|
+
import {TabsTester as $e1a5bc7455cf5719$export$f1539bff3fc7d485} from "./tabs.js";
|
|
12
|
+
import {TreeTester as $d721d67b8ba87a3b$export$4445864b14128396} from "./tree.js";
|
|
13
|
+
import $9gPuy$testinglibraryuserevent from "@testing-library/user-event";
|
|
14
|
+
|
|
15
|
+
/*
|
|
16
|
+
* Copyright 2024 Adobe. All rights reserved.
|
|
17
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
18
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
19
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
20
|
+
*
|
|
21
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
22
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
23
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
24
|
+
* governing permissions and limitations under the License.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
let $4ab48216ddc89c32$var$keyToUtil = {
|
|
39
|
+
'CheckboxGroup': (0, $e7160b4be83b4967$export$f54f4bde770cc5a6),
|
|
40
|
+
'ComboBox': (0, $a2202d8b369e6a8a$export$f97e14e96d71ab3b),
|
|
41
|
+
'Dialog': (0, $1bad24930969e309$export$e79328f5295cc2a1),
|
|
42
|
+
'GridList': (0, $ed42840525c46506$export$93a85aaed9fabd83),
|
|
43
|
+
'ListBox': (0, $8d2aea0e455eb460$export$54c24f7ee8577f4f),
|
|
44
|
+
'Menu': (0, $460bfe9f038d2630$export$f73bbc9212ed861e),
|
|
45
|
+
'RadioGroup': (0, $14dc6ef63d191867$export$d66326e63d27e116),
|
|
46
|
+
'Select': (0, $6acb352063615cf0$export$d1859707465446a9),
|
|
47
|
+
'Table': (0, $196900c7f8f394b6$export$4c6a9d6ae3b0086),
|
|
48
|
+
'Tabs': (0, $e1a5bc7455cf5719$export$f1539bff3fc7d485),
|
|
49
|
+
'Tree': (0, $d721d67b8ba87a3b$export$4445864b14128396)
|
|
50
|
+
};
|
|
51
|
+
let $4ab48216ddc89c32$var$defaultAdvanceTimer = (waitTime)=>new Promise((resolve)=>setTimeout(resolve, waitTime));
|
|
52
|
+
class $4ab48216ddc89c32$export$1f44aaf2ec115b54 {
|
|
53
|
+
constructor(opts = {}){
|
|
54
|
+
let { interactionType: interactionType, advanceTimer: advanceTimer } = opts;
|
|
55
|
+
this.user = (0, $9gPuy$testinglibraryuserevent).setup({
|
|
56
|
+
delay: null,
|
|
57
|
+
pointerMap: $759f061d800cf446$export$7dbde2c4caaa8d35
|
|
58
|
+
});
|
|
59
|
+
this.interactionType = interactionType;
|
|
60
|
+
this.advanceTimer = advanceTimer || $4ab48216ddc89c32$var$defaultAdvanceTimer;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Creates an aria pattern tester, inheriting the options provided to the original user.
|
|
64
|
+
*/ createTester(patternName, opts) {
|
|
65
|
+
return new $4ab48216ddc89c32$var$keyToUtil[patternName]({
|
|
66
|
+
interactionType: this.interactionType,
|
|
67
|
+
advanceTimer: this.advanceTimer,
|
|
68
|
+
...opts,
|
|
69
|
+
user: this.user
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
export {$4ab48216ddc89c32$export$1f44aaf2ec115b54 as User};
|
|
76
|
+
//# sourceMappingURL=user.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;AA8BD,IAAI,kCAYA;IACF,iBAAiB,CAAA,GAAA,yCAAkB;IACnC,YAAY,CAAA,GAAA,yCAAa;IACzB,UAAU,CAAA,GAAA,yCAAW;IACrB,YAAY,CAAA,GAAA,yCAAa;IACzB,WAAW,CAAA,GAAA,yCAAY;IACvB,QAAQ,CAAA,GAAA,yCAAS;IACjB,cAAc,CAAA,GAAA,yCAAe;IAC7B,UAAU,CAAA,GAAA,yCAAW;IACrB,SAAS,CAAA,GAAA,wCAAU;IACnB,QAAQ,CAAA,GAAA,yCAAS;IACjB,QAAQ,CAAA,GAAA,yCAAS;AACnB;AAgCA,IAAI,4CAAsB,CAAC,WAAiC,IAAI,QAAQ,CAAC,UAAY,WAAW,SAAS;AAElG,MAAM;IAaX,YAAY,OAAiB,CAAC,CAAC,CAAE;QAC/B,IAAI,mBAAC,eAAe,gBAAE,YAAY,EAAC,GAAG;QACtC,IAAI,CAAC,IAAI,GAAG,CAAA,GAAA,8BAAQ,EAAE,KAAK,CAAC;YAAC,OAAO;wBAAM;QAAU;QACpD,IAAI,CAAC,eAAe,GAAG;QACvB,IAAI,CAAC,YAAY,GAAG,gBAAgB;IACtC;IAEA;;GAEC,GACD,aAAqC,WAAc,EAAE,IAAmB,EAAa;QACnF,OAAO,IAAI,AAAC,+BAAU,CAAC,YAAY,CAAC;YAAC,iBAAiB,IAAI,CAAC,eAAe;YAAE,cAAc,IAAI,CAAC,YAAY;YAAE,GAAG,IAAI;YAAE,MAAM,IAAI,CAAC,IAAI;QAAA;IACvI;AACF","sources":["packages/@react-aria/test-utils/src/user.ts"],"sourcesContent":["/*\n * Copyright 2024 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 {CheckboxGroupTester} from './checkboxgroup';\nimport {\n CheckboxGroupTesterOpts,\n ComboBoxTesterOpts,\n DialogTesterOpts,\n GridListTesterOpts,\n ListBoxTesterOpts,\n MenuTesterOpts,\n RadioGroupTesterOpts,\n SelectTesterOpts,\n TableTesterOpts,\n TabsTesterOpts,\n TreeTesterOpts,\n UserOpts\n} from './types';\nimport {ComboBoxTester} from './combobox';\nimport {DialogTester} from './dialog';\nimport {GridListTester} from './gridlist';\nimport {ListBoxTester} from './listbox';\nimport {MenuTester} from './menu';\nimport {pointerMap} from './';\nimport {RadioGroupTester} from './radiogroup';\nimport {SelectTester} from './select';\nimport {TableTester} from './table';\nimport {TabsTester} from './tabs';\nimport {TreeTester} from './tree';\nimport userEvent from '@testing-library/user-event';\n\nlet keyToUtil: {\n 'CheckboxGroup': typeof CheckboxGroupTester,\n 'ComboBox': typeof ComboBoxTester,\n 'Dialog': typeof DialogTester,\n 'GridList': typeof GridListTester,\n 'ListBox': typeof ListBoxTester,\n 'Menu': typeof MenuTester,\n 'RadioGroup': typeof RadioGroupTester,\n 'Select': typeof SelectTester,\n 'Table': typeof TableTester,\n 'Tabs': typeof TabsTester,\n 'Tree': typeof TreeTester\n} = {\n 'CheckboxGroup': CheckboxGroupTester,\n 'ComboBox': ComboBoxTester,\n 'Dialog': DialogTester,\n 'GridList': GridListTester,\n 'ListBox': ListBoxTester,\n 'Menu': MenuTester,\n 'RadioGroup': RadioGroupTester,\n 'Select': SelectTester,\n 'Table': TableTester,\n 'Tabs': TabsTester,\n 'Tree': TreeTester\n} as const;\nexport type PatternNames = keyof typeof keyToUtil;\n\n// Conditional type: https://www.typescriptlang.org/docs/handbook/2/conditional-types.html\ntype Tester<T> =\n T extends 'CheckboxGroup' ? CheckboxGroupTester :\n T extends 'ComboBox' ? ComboBoxTester :\n T extends 'Dialog' ? DialogTester :\n T extends 'GridList' ? GridListTester :\n T extends 'ListBox' ? ListBoxTester :\n T extends 'Menu' ? MenuTester :\n T extends 'RadioGroup' ? RadioGroupTester :\n T extends 'Select' ? SelectTester :\n T extends 'Table' ? TableTester :\n T extends 'Tabs' ? TabsTester :\n T extends 'Tree' ? TreeTester :\n never;\n\ntype TesterOpts<T> =\n T extends 'CheckboxGroup' ? CheckboxGroupTesterOpts :\n T extends 'ComboBox' ? ComboBoxTesterOpts :\n T extends 'Dialog' ? DialogTesterOpts :\n T extends 'GridList' ? GridListTesterOpts :\n T extends 'ListBox' ? ListBoxTesterOpts :\n T extends 'Menu' ? MenuTesterOpts :\n T extends 'RadioGroup' ? RadioGroupTesterOpts :\n T extends 'Select' ? SelectTesterOpts :\n T extends 'Table' ? TableTesterOpts :\n T extends 'Tabs' ? TabsTesterOpts :\n T extends 'Tree' ? TreeTesterOpts :\n never;\n\nlet defaultAdvanceTimer = (waitTime: number | undefined) => new Promise((resolve) => setTimeout(resolve, waitTime));\n\nexport class User {\n private user;\n /**\n * The interaction type (mouse, touch, keyboard) that the test util user will use when interacting with a component. This can be overridden\n * at the aria pattern util level if needed.\n * @default mouse\n */\n interactionType: UserOpts['interactionType'];\n /**\n * A function used by the test utils to advance timers during interactions. Required for certain aria patterns (e.g. table).\n */\n advanceTimer: UserOpts['advanceTimer'];\n\n constructor(opts: UserOpts = {}) {\n let {interactionType, advanceTimer} = opts;\n this.user = userEvent.setup({delay: null, pointerMap});\n this.interactionType = interactionType;\n this.advanceTimer = advanceTimer || defaultAdvanceTimer;\n }\n\n /**\n * Creates an aria pattern tester, inheriting the options provided to the original user.\n */\n createTester<T extends PatternNames>(patternName: T, opts: TesterOpts<T>): Tester<T> {\n return new (keyToUtil)[patternName]({interactionType: this.interactionType, advanceTimer: this.advanceTimer, ...opts, user: this.user}) as Tester<T>;\n }\n}\n"],"names":[],"version":3,"file":"user.js.map"}
|
|
@@ -3,8 +3,8 @@ function $parcel$export(e, n, v, s) {
|
|
|
3
3
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
-
$parcel$export(module.exports, "pointerMap", ()
|
|
7
|
-
let $
|
|
6
|
+
$parcel$export(module.exports, "pointerMap", function () { return $b3fc8c302673b35d$export$7dbde2c4caaa8d35; });
|
|
7
|
+
let $b3fc8c302673b35d$export$7dbde2c4caaa8d35 = [
|
|
8
8
|
{
|
|
9
9
|
name: 'MouseLeft',
|
|
10
10
|
pointerType: 'mouse',
|
|
@@ -40,4 +40,4 @@ let $0e568517a25183a7$export$7dbde2c4caaa8d35 = [
|
|
|
40
40
|
];
|
|
41
41
|
|
|
42
42
|
|
|
43
|
-
//# sourceMappingURL=userEventMaps.
|
|
43
|
+
//# sourceMappingURL=userEventMaps.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;AAEO,IAAI,4CAA2B;IACpC;QAAC,MAAM;QAAa,aAAa;QAAS,QAAQ;QAAW,QAAQ;QAAG,OAAO;QAAG,UAAU;IAAG;IAC/F;QAAC,MAAM;QAAc,aAAa;QAAS,QAAQ;IAAW;IAC9D;QAAC,MAAM;QAAe,aAAa;QAAS,QAAQ;IAAW;IAC/D;QAAC,MAAM;QAAU,aAAa;QAAS,QAAQ;QAAG,OAAO;IAAC;IAC1D;QAAC,MAAM;QAAU,aAAa;IAAO;IACrC;QAAC,MAAM;QAAU,aAAa;IAAO;CACtC","sources":["packages/@react-aria/test-utils/src/userEventMaps.ts"],"sourcesContent":["import {pointerKey} from '@testing-library/user-event';\n\nexport let pointerMap: pointerKey[] = [\n {name: 'MouseLeft', pointerType: 'mouse', button: 'primary', height: 1, width: 1, pressure: 0.5},\n {name: 'MouseRight', pointerType: 'mouse', button: 'secondary'},\n {name: 'MouseMiddle', pointerType: 'mouse', button: 'auxiliary'},\n {name: 'TouchA', pointerType: 'touch', height: 1, width: 1},\n {name: 'TouchB', pointerType: 'touch'},\n {name: 'TouchC', pointerType: 'touch'}\n] as unknown as pointerKey[];\n"],"names":[],"version":3,"file":"userEventMaps.
|
|
1
|
+
{"mappings":";;;;;;AAEO,IAAI,4CAA2B;IACpC;QAAC,MAAM;QAAa,aAAa;QAAS,QAAQ;QAAW,QAAQ;QAAG,OAAO;QAAG,UAAU;IAAG;IAC/F;QAAC,MAAM;QAAc,aAAa;QAAS,QAAQ;IAAW;IAC9D;QAAC,MAAM;QAAe,aAAa;QAAS,QAAQ;IAAW;IAC/D;QAAC,MAAM;QAAU,aAAa;QAAS,QAAQ;QAAG,OAAO;IAAC;IAC1D;QAAC,MAAM;QAAU,aAAa;IAAO;IACrC;QAAC,MAAM;QAAU,aAAa;IAAO;CACtC","sources":["packages/@react-aria/test-utils/src/userEventMaps.ts"],"sourcesContent":["import {pointerKey} from '@testing-library/user-event';\n\nexport let pointerMap: pointerKey[] = [\n {name: 'MouseLeft', pointerType: 'mouse', button: 'primary', height: 1, width: 1, pressure: 0.5},\n {name: 'MouseRight', pointerType: 'mouse', button: 'secondary'},\n {name: 'MouseMiddle', pointerType: 'mouse', button: 'auxiliary'},\n {name: 'TouchA', pointerType: 'touch', height: 1, width: 1},\n {name: 'TouchB', pointerType: 'touch'},\n {name: 'TouchC', pointerType: 'touch'}\n] as unknown as pointerKey[];\n"],"names":[],"version":3,"file":"userEventMaps.cjs.map"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
let $
|
|
1
|
+
let $759f061d800cf446$export$7dbde2c4caaa8d35 = [
|
|
2
2
|
{
|
|
3
3
|
name: 'MouseLeft',
|
|
4
4
|
pointerType: 'mouse',
|
|
@@ -34,5 +34,5 @@ let $50ecfb18069ec897$export$7dbde2c4caaa8d35 = [
|
|
|
34
34
|
];
|
|
35
35
|
|
|
36
36
|
|
|
37
|
-
export {$
|
|
38
|
-
//# sourceMappingURL=userEventMaps.
|
|
37
|
+
export {$759f061d800cf446$export$7dbde2c4caaa8d35 as pointerMap};
|
|
38
|
+
//# sourceMappingURL=userEventMaps.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAEO,IAAI,4CAA2B;IACpC;QAAC,MAAM;QAAa,aAAa;QAAS,QAAQ;QAAW,QAAQ;QAAG,OAAO;QAAG,UAAU;IAAG;IAC/F;QAAC,MAAM;QAAc,aAAa;QAAS,QAAQ;IAAW;IAC9D;QAAC,MAAM;QAAe,aAAa;QAAS,QAAQ;IAAW;IAC/D;QAAC,MAAM;QAAU,aAAa;QAAS,QAAQ;QAAG,OAAO;IAAC;IAC1D;QAAC,MAAM;QAAU,aAAa;IAAO;IACrC;QAAC,MAAM;QAAU,aAAa;IAAO;CACtC","sources":["packages/@react-aria/test-utils/src/userEventMaps.ts"],"sourcesContent":["import {pointerKey} from '@testing-library/user-event';\n\nexport let pointerMap: pointerKey[] = [\n {name: 'MouseLeft', pointerType: 'mouse', button: 'primary', height: 1, width: 1, pressure: 0.5},\n {name: 'MouseRight', pointerType: 'mouse', button: 'secondary'},\n {name: 'MouseMiddle', pointerType: 'mouse', button: 'auxiliary'},\n {name: 'TouchA', pointerType: 'touch', height: 1, width: 1},\n {name: 'TouchB', pointerType: 'touch'},\n {name: 'TouchC', pointerType: 'touch'}\n] as unknown as pointerKey[];\n"],"names":[],"version":3,"file":"userEventMaps.
|
|
1
|
+
{"mappings":"AAEO,IAAI,4CAA2B;IACpC;QAAC,MAAM;QAAa,aAAa;QAAS,QAAQ;QAAW,QAAQ;QAAG,OAAO;QAAG,UAAU;IAAG;IAC/F;QAAC,MAAM;QAAc,aAAa;QAAS,QAAQ;IAAW;IAC9D;QAAC,MAAM;QAAe,aAAa;QAAS,QAAQ;IAAW;IAC/D;QAAC,MAAM;QAAU,aAAa;QAAS,QAAQ;QAAG,OAAO;IAAC;IAC1D;QAAC,MAAM;QAAU,aAAa;IAAO;IACrC;QAAC,MAAM;QAAU,aAAa;IAAO;CACtC","sources":["packages/@react-aria/test-utils/src/userEventMaps.ts"],"sourcesContent":["import {pointerKey} from '@testing-library/user-event';\n\nexport let pointerMap: pointerKey[] = [\n {name: 'MouseLeft', pointerType: 'mouse', button: 'primary', height: 1, width: 1, pressure: 0.5},\n {name: 'MouseRight', pointerType: 'mouse', button: 'secondary'},\n {name: 'MouseMiddle', pointerType: 'mouse', button: 'auxiliary'},\n {name: 'TouchA', pointerType: 'touch', height: 1, width: 1},\n {name: 'TouchB', pointerType: 'touch'},\n {name: 'TouchC', pointerType: 'touch'}\n] as unknown as pointerKey[];\n"],"names":[],"version":3,"file":"userEventMaps.js.map"}
|
|
@@ -0,0 +1,45 @@
|
|
|
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 on the tester.
|
|
5
|
+
*/
|
|
6
|
+
interactionType?: UserOpts['interactionType'];
|
|
7
|
+
/**
|
|
8
|
+
* The index, text, or node of the checkbox to toggle selection for.
|
|
9
|
+
*/
|
|
10
|
+
checkbox: number | string | HTMLElement;
|
|
11
|
+
}
|
|
12
|
+
export declare class CheckboxGroupTester {
|
|
13
|
+
private user;
|
|
14
|
+
private _interactionType;
|
|
15
|
+
private _checkboxgroup;
|
|
16
|
+
constructor(opts: CheckboxGroupTesterOpts);
|
|
17
|
+
/**
|
|
18
|
+
* Set the interaction type used by the checkbox group tester.
|
|
19
|
+
*/
|
|
20
|
+
setInteractionType(type: UserOpts['interactionType']): void;
|
|
21
|
+
/**
|
|
22
|
+
* Returns a checkbox matching the specified index or text content.
|
|
23
|
+
*/
|
|
24
|
+
findCheckbox(opts: {
|
|
25
|
+
checkboxIndexOrText: number | string;
|
|
26
|
+
}): HTMLElement;
|
|
27
|
+
private keyboardNavigateToCheckbox;
|
|
28
|
+
/**
|
|
29
|
+
* Toggles the specified checkbox. Defaults to using the interaction type set on the checkbox tester.
|
|
30
|
+
*/
|
|
31
|
+
toggleCheckbox(opts: TriggerCheckboxOptions): Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Returns the checkboxgroup.
|
|
34
|
+
*/
|
|
35
|
+
get checkboxgroup(): HTMLElement;
|
|
36
|
+
/**
|
|
37
|
+
* Returns the checkboxes.
|
|
38
|
+
*/
|
|
39
|
+
get checkboxes(): HTMLElement[];
|
|
40
|
+
/**
|
|
41
|
+
* Returns the currently selected checkboxes in the checkboxgroup if any.
|
|
42
|
+
*/
|
|
43
|
+
get selectedCheckboxes(): HTMLElement[];
|
|
44
|
+
}
|
|
45
|
+
export {};
|
|
@@ -0,0 +1,75 @@
|
|
|
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
|
+
* @default 'manual'
|
|
6
|
+
*/
|
|
7
|
+
triggerBehavior?: 'focus' | 'manual';
|
|
8
|
+
/**
|
|
9
|
+
* What interaction type to use when opening the combobox. Defaults to the interaction type set on the tester.
|
|
10
|
+
*/
|
|
11
|
+
interactionType?: UserOpts['interactionType'];
|
|
12
|
+
}
|
|
13
|
+
interface ComboBoxSelectOpts extends ComboBoxOpenOpts {
|
|
14
|
+
/**
|
|
15
|
+
* The index, text, or node of the option to select. Option nodes can be sourced via `options()`.
|
|
16
|
+
*/
|
|
17
|
+
option: number | string | HTMLElement;
|
|
18
|
+
}
|
|
19
|
+
export declare class ComboBoxTester {
|
|
20
|
+
private user;
|
|
21
|
+
private _interactionType;
|
|
22
|
+
private _combobox;
|
|
23
|
+
private _trigger;
|
|
24
|
+
constructor(opts: ComboBoxTesterOpts);
|
|
25
|
+
/**
|
|
26
|
+
* Set the interaction type used by the combobox tester.
|
|
27
|
+
*/
|
|
28
|
+
setInteractionType(type: UserOpts['interactionType']): void;
|
|
29
|
+
/**
|
|
30
|
+
* Opens the combobox dropdown. Defaults to using the interaction type set on the combobox tester.
|
|
31
|
+
*/
|
|
32
|
+
open(opts?: ComboBoxOpenOpts): Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* Returns an option matching the specified index or text content.
|
|
35
|
+
*/
|
|
36
|
+
findOption(opts: {
|
|
37
|
+
optionIndexOrText: number | string;
|
|
38
|
+
}): HTMLElement;
|
|
39
|
+
/**
|
|
40
|
+
* Selects the desired combobox option. Defaults to using the interaction type set on the combobox tester. If necessary, will open the combobox dropdown beforehand.
|
|
41
|
+
* The desired option can be targeted via the option's node, the option's text, or the option's index.
|
|
42
|
+
*/
|
|
43
|
+
selectOption(opts: ComboBoxSelectOpts): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Closes the combobox dropdown.
|
|
46
|
+
*/
|
|
47
|
+
close(): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Returns the combobox.
|
|
50
|
+
*/
|
|
51
|
+
get combobox(): HTMLElement;
|
|
52
|
+
/**
|
|
53
|
+
* Returns the combobox trigger button.
|
|
54
|
+
*/
|
|
55
|
+
get trigger(): HTMLElement;
|
|
56
|
+
/**
|
|
57
|
+
* Returns the combobox's listbox if present.
|
|
58
|
+
*/
|
|
59
|
+
get listbox(): HTMLElement | null;
|
|
60
|
+
/**
|
|
61
|
+
* Returns the combobox's sections if present.
|
|
62
|
+
*/
|
|
63
|
+
get sections(): HTMLElement[];
|
|
64
|
+
/**
|
|
65
|
+
* Returns the combobox's options if present. Can be filtered to a subsection of the listbox if provided via `element`.
|
|
66
|
+
*/
|
|
67
|
+
options(opts?: {
|
|
68
|
+
element?: HTMLElement;
|
|
69
|
+
}): HTMLElement[];
|
|
70
|
+
/**
|
|
71
|
+
* Returns the currently focused option in the combobox's dropdown if any.
|
|
72
|
+
*/
|
|
73
|
+
get focusedOption(): HTMLElement | null;
|
|
74
|
+
}
|
|
75
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
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 the tester.
|
|
5
|
+
*/
|
|
6
|
+
interactionType?: UserOpts['interactionType'];
|
|
7
|
+
}
|
|
8
|
+
export declare class DialogTester {
|
|
9
|
+
private user;
|
|
10
|
+
private _interactionType;
|
|
11
|
+
private _trigger;
|
|
12
|
+
private _dialog;
|
|
13
|
+
private _overlayType;
|
|
14
|
+
constructor(opts: DialogTesterOpts);
|
|
15
|
+
/**
|
|
16
|
+
* Set the interaction type used by the dialog tester.
|
|
17
|
+
*/
|
|
18
|
+
setInteractionType(type: UserOpts['interactionType']): void;
|
|
19
|
+
/**
|
|
20
|
+
* Opens the dialog. Defaults to using the interaction type set on the dialog tester.
|
|
21
|
+
*/
|
|
22
|
+
open(opts?: DialogOpenOpts): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Closes the dialog via the Escape key.
|
|
25
|
+
*/
|
|
26
|
+
close(): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Returns the dialog's trigger.
|
|
29
|
+
*/
|
|
30
|
+
get trigger(): HTMLElement;
|
|
31
|
+
/**
|
|
32
|
+
* Returns the dialog if present.
|
|
33
|
+
*/
|
|
34
|
+
get dialog(): HTMLElement | null;
|
|
35
|
+
}
|
|
36
|
+
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,51 @@
|
|
|
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 _gridlist;
|
|
11
|
+
constructor(opts: GridListTesterOpts);
|
|
12
|
+
/**
|
|
13
|
+
* Set the interaction type used by the gridlist tester.
|
|
14
|
+
*/
|
|
15
|
+
setInteractionType(type: UserOpts['interactionType']): void;
|
|
16
|
+
/**
|
|
17
|
+
* Returns a row matching the specified index or text content.
|
|
18
|
+
*/
|
|
19
|
+
findRow(opts: {
|
|
20
|
+
rowIndexOrText: number | string;
|
|
21
|
+
}): HTMLElement;
|
|
22
|
+
private keyboardNavigateToRow;
|
|
23
|
+
/**
|
|
24
|
+
* Toggles the selection for the specified gridlist row. Defaults to using the interaction type set on the gridlist tester.
|
|
25
|
+
* Note that this will endevor to always add/remove JUST the provided row to the set of selected rows.
|
|
26
|
+
*/
|
|
27
|
+
toggleRowSelection(opts: GridListToggleRowOpts): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Triggers the action for the specified gridlist row. Defaults to using the interaction type set on the gridlist tester.
|
|
30
|
+
*/
|
|
31
|
+
triggerRowAction(opts: GridListRowActionOpts): Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Returns the gridlist.
|
|
34
|
+
*/
|
|
35
|
+
get gridlist(): HTMLElement;
|
|
36
|
+
/**
|
|
37
|
+
* Returns the gridlist's rows if any.
|
|
38
|
+
*/
|
|
39
|
+
get rows(): HTMLElement[];
|
|
40
|
+
/**
|
|
41
|
+
* Returns the gridlist's selected rows if any.
|
|
42
|
+
*/
|
|
43
|
+
get selectedRows(): HTMLElement[];
|
|
44
|
+
/**
|
|
45
|
+
* Returns the gridlist's cells if any. Can be filtered against a specific row if provided via `element`.
|
|
46
|
+
*/
|
|
47
|
+
cells(opts?: {
|
|
48
|
+
element?: HTMLElement;
|
|
49
|
+
}): HTMLElement[];
|
|
50
|
+
}
|
|
51
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export { triggerLongPress } from './events';
|
|
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,80 @@
|
|
|
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 type set on the tester.
|
|
5
|
+
*/
|
|
6
|
+
interactionType?: UserOpts['interactionType'];
|
|
7
|
+
/**
|
|
8
|
+
* The index, text, or node of the option to toggle selection for.
|
|
9
|
+
*/
|
|
10
|
+
option: number | string | HTMLElement;
|
|
11
|
+
/**
|
|
12
|
+
* Whether the option should be triggered by Space or Enter in keyboard modality.
|
|
13
|
+
* @default 'Enter'
|
|
14
|
+
*/
|
|
15
|
+
keyboardActivation?: 'Space' | 'Enter';
|
|
16
|
+
/**
|
|
17
|
+
* Whether the option needs to be long pressed to be selected. Depends on the listbox's implementation.
|
|
18
|
+
*/
|
|
19
|
+
needsLongPress?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Whether the listbox has a selectionBehavior of "toggle" or "replace" (aka highlight selection). This affects the user operations
|
|
22
|
+
* required to toggle option selection by adding modifier keys during user actions, useful when performing multi-option selection in a "selectionBehavior: 'replace'" listbox.
|
|
23
|
+
* If you would like to still simulate user actions (aka press) without these modifiers keys for a "selectionBehavior: replace" listbox, simply omit this option.
|
|
24
|
+
* See the [RAC Listbox docs](https://react-spectrum.adobe.com/react-aria/ListBox.html#selection-behavior) for more info on this behavior.
|
|
25
|
+
*
|
|
26
|
+
* @default 'toggle'
|
|
27
|
+
*/
|
|
28
|
+
selectionBehavior?: 'toggle' | 'replace';
|
|
29
|
+
}
|
|
30
|
+
interface ListBoxOptionActionOpts extends Omit<ListBoxToggleOptionOpts, 'keyboardActivation' | 'needsLongPress'> {
|
|
31
|
+
/**
|
|
32
|
+
* Whether or not the option needs a double click to trigger the option action. Depends on the listbox's implementation.
|
|
33
|
+
*/
|
|
34
|
+
needsDoubleClick?: boolean;
|
|
35
|
+
}
|
|
36
|
+
export declare class ListBoxTester {
|
|
37
|
+
private user;
|
|
38
|
+
private _interactionType;
|
|
39
|
+
private _advanceTimer;
|
|
40
|
+
private _listbox;
|
|
41
|
+
constructor(opts: ListBoxTesterOpts);
|
|
42
|
+
/**
|
|
43
|
+
* Set the interaction type used by the listbox tester.
|
|
44
|
+
*/
|
|
45
|
+
setInteractionType(type: UserOpts['interactionType']): void;
|
|
46
|
+
/**
|
|
47
|
+
* Returns a option matching the specified index or text content.
|
|
48
|
+
*/
|
|
49
|
+
findOption(opts: {
|
|
50
|
+
optionIndexOrText: number | string;
|
|
51
|
+
}): HTMLElement;
|
|
52
|
+
private keyboardNavigateToOption;
|
|
53
|
+
/**
|
|
54
|
+
* Toggles the selection for the specified listbox option. Defaults to using the interaction type set on the listbox tester.
|
|
55
|
+
*/
|
|
56
|
+
toggleOptionSelection(opts: ListBoxToggleOptionOpts): Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* Triggers the action for the specified listbox option. Defaults to using the interaction type set on the listbox tester.
|
|
59
|
+
*/
|
|
60
|
+
triggerOptionAction(opts: ListBoxOptionActionOpts): Promise<void>;
|
|
61
|
+
/**
|
|
62
|
+
* Returns the listbox.
|
|
63
|
+
*/
|
|
64
|
+
get listbox(): HTMLElement;
|
|
65
|
+
/**
|
|
66
|
+
* Returns the listbox options. Can be filtered to a subsection of the listbox if provided via `element`.
|
|
67
|
+
*/
|
|
68
|
+
options(opts?: {
|
|
69
|
+
element?: HTMLElement;
|
|
70
|
+
}): HTMLElement[];
|
|
71
|
+
/**
|
|
72
|
+
* Returns the listbox's selected options if any.
|
|
73
|
+
*/
|
|
74
|
+
get selectedOptions(): HTMLElement[];
|
|
75
|
+
/**
|
|
76
|
+
* Returns the listbox's sections if any.
|
|
77
|
+
*/
|
|
78
|
+
get sections(): HTMLElement[];
|
|
79
|
+
}
|
|
80
|
+
export {};
|