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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/dist/combobox.main.js +137 -0
  2. package/dist/combobox.main.js.map +1 -0
  3. package/dist/combobox.mjs +132 -0
  4. package/dist/combobox.module.js +132 -0
  5. package/dist/combobox.module.js.map +1 -0
  6. package/dist/events.main.js +25 -10
  7. package/dist/events.main.js.map +1 -1
  8. package/dist/events.mjs +26 -11
  9. package/dist/events.module.js +25 -10
  10. package/dist/events.module.js.map +1 -1
  11. package/dist/gridlist.main.js +97 -0
  12. package/dist/gridlist.main.js.map +1 -0
  13. package/dist/gridlist.mjs +92 -0
  14. package/dist/gridlist.module.js +92 -0
  15. package/dist/gridlist.module.js.map +1 -0
  16. package/dist/import.mjs +4 -2
  17. package/dist/main.js +10 -18
  18. package/dist/main.js.map +1 -1
  19. package/dist/menu.main.js +176 -0
  20. package/dist/menu.main.js.map +1 -0
  21. package/dist/menu.mjs +171 -0
  22. package/dist/menu.module.js +171 -0
  23. package/dist/menu.module.js.map +1 -0
  24. package/dist/module.js +4 -2
  25. package/dist/module.js.map +1 -1
  26. package/dist/select.main.js +113 -0
  27. package/dist/select.main.js.map +1 -0
  28. package/dist/select.mjs +108 -0
  29. package/dist/select.module.js +108 -0
  30. package/dist/select.module.js.map +1 -0
  31. package/dist/table.main.js +191 -0
  32. package/dist/table.main.js.map +1 -0
  33. package/dist/table.mjs +186 -0
  34. package/dist/table.module.js +186 -0
  35. package/dist/table.module.js.map +1 -0
  36. package/dist/testSetup.main.js +1 -1
  37. package/dist/testSetup.mjs +2 -2
  38. package/dist/testSetup.module.js +1 -1
  39. package/dist/types.d.ts +180 -4
  40. package/dist/types.d.ts.map +1 -1
  41. package/dist/user.main.js +65 -0
  42. package/dist/user.main.js.map +1 -0
  43. package/dist/user.mjs +56 -0
  44. package/dist/user.module.js +56 -0
  45. package/dist/user.module.js.map +1 -0
  46. package/dist/userEventMaps.main.js +15 -15
  47. package/dist/userEventMaps.mjs +16 -16
  48. package/dist/userEventMaps.module.js +15 -15
  49. package/package.json +6 -7
  50. package/src/combobox.ts +188 -0
  51. package/src/events.ts +28 -8
  52. package/src/gridlist.ts +116 -0
  53. package/src/index.ts +6 -3
  54. package/src/menu.ts +246 -0
  55. package/src/select.ts +158 -0
  56. package/src/table.ts +282 -0
  57. package/src/user.ts +73 -0
  58. package/LICENSE +0 -201
@@ -0,0 +1,186 @@
1
+ import {pressElement as $5d1eca18f92ad0e6$export$6ffa3eb717517feb, triggerLongPress as $5d1eca18f92ad0e6$export$3a22a5a9bc0fd3b} from "./events.module.js";
2
+ import {within as $2KUjE$within, fireEvent as $2KUjE$fireEvent, act as $2KUjE$act, waitFor as $2KUjE$waitFor} from "@testing-library/react";
3
+
4
+ /*
5
+ * Copyright 2024 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
+ class $6d1e4cf220920c37$export$4c6a9d6ae3b0086 {
17
+ get table() {
18
+ return this._table;
19
+ }
20
+ get rowGroups() {
21
+ let table = this._table;
22
+ return table ? (0, $2KUjE$within)(table).queryAllByRole('rowgroup') : [];
23
+ }
24
+ get columns() {
25
+ let headerRowGroup = this.rowGroups[0];
26
+ return headerRowGroup ? (0, $2KUjE$within)(headerRowGroup).queryAllByRole('columnheader') : [];
27
+ }
28
+ get rows() {
29
+ let bodyRowGroup = this.rowGroups[1];
30
+ return bodyRowGroup ? (0, $2KUjE$within)(bodyRowGroup).queryAllByRole('row') : [];
31
+ }
32
+ get selectedRows() {
33
+ return this.rows.filter((row)=>row.getAttribute('aria-selected') === 'true');
34
+ }
35
+ get rowHeaders() {
36
+ let table = this.table;
37
+ return table ? (0, $2KUjE$within)(table).queryAllByRole('rowheader') : [];
38
+ }
39
+ get cells() {
40
+ let table = this.table;
41
+ return table ? (0, $2KUjE$within)(table).queryAllByRole('gridcell') : [];
42
+ }
43
+ constructor(opts){
44
+ this.setInteractionType = (type)=>{
45
+ this._interactionType = type;
46
+ };
47
+ this.toggleRowSelection = async (opts = {})=>{
48
+ let { index: index, text: text, needsLongPress: needsLongPress, interactionType: interactionType = this._interactionType } = opts;
49
+ let row = this.findRow({
50
+ index: index,
51
+ text: text
52
+ });
53
+ let rowCheckbox = (0, $2KUjE$within)(row).queryByRole('checkbox');
54
+ if (rowCheckbox) await (0, $5d1eca18f92ad0e6$export$6ffa3eb717517feb)(this.user, rowCheckbox, interactionType);
55
+ else {
56
+ let cell = (0, $2KUjE$within)(row).getAllByRole('gridcell')[0];
57
+ if (needsLongPress && interactionType === 'touch') {
58
+ if (this._advanceTimer == null) throw new Error('No advanceTimers provided for long press.');
59
+ // Note that long press interactions with rows is strictly touch only for grid rows
60
+ await (0, $5d1eca18f92ad0e6$export$3a22a5a9bc0fd3b)({
61
+ element: cell,
62
+ advanceTimer: this._advanceTimer,
63
+ pointerOpts: {
64
+ pointerType: 'touch'
65
+ }
66
+ });
67
+ // TODO: interestingly enough, we need to do a followup click otherwise future row selections may not fire properly?
68
+ // To reproduce, try removing this, forcing toggleRowSelection to hit "needsLongPress ? await triggerLongPress(cell) : await action(cell);" and
69
+ // run Table.test's "should support long press to enter selection mode on touch" test to see what happens
70
+ await (0, $2KUjE$fireEvent).click(cell);
71
+ } else await (0, $5d1eca18f92ad0e6$export$6ffa3eb717517feb)(this.user, cell, interactionType);
72
+ }
73
+ // Handle cases where the table may transition in response to the row selection/deselection
74
+ await (0, $2KUjE$act)(async ()=>{
75
+ if (this._advanceTimer == null) throw new Error('No advanceTimers provided for table transition.');
76
+ await this._advanceTimer(200);
77
+ });
78
+ };
79
+ this.toggleSort = async (opts = {})=>{
80
+ let { index: index, text: text, interactionType: interactionType = this._interactionType } = opts;
81
+ let columnheader;
82
+ if (index != null) columnheader = this.columns[index];
83
+ else if (text != null) {
84
+ columnheader = (0, $2KUjE$within)(this.rowGroups[0]).getByText(text);
85
+ while(columnheader && !/columnheader/.test(columnheader.getAttribute('role')))columnheader = columnheader.parentElement;
86
+ }
87
+ let menuButton = (0, $2KUjE$within)(columnheader).queryByRole('button');
88
+ if (menuButton) {
89
+ let currentSort = columnheader.getAttribute('aria-sort');
90
+ // TODO: Focus management is all kinda of messed up if I just use .focus and Space to open the sort menu. Seems like
91
+ // the focused key doesn't get properly set to the desired column header. Have to do this strange flow where I focus the
92
+ // column header except if the active element is already the menu button within the column header
93
+ if (interactionType === 'keyboard' && document.activeElement !== menuButton) await (0, $5d1eca18f92ad0e6$export$6ffa3eb717517feb)(this.user, columnheader, interactionType);
94
+ else await (0, $5d1eca18f92ad0e6$export$6ffa3eb717517feb)(this.user, menuButton, interactionType);
95
+ await (0, $2KUjE$waitFor)(()=>{
96
+ if (menuButton.getAttribute('aria-controls') == null) throw new Error('No aria-controls found on table column dropdown menu trigger element.');
97
+ else return true;
98
+ });
99
+ let menuId = menuButton.getAttribute('aria-controls');
100
+ await (0, $2KUjE$waitFor)(()=>{
101
+ if (!menuId || document.getElementById(menuId) == null) throw new Error(`Table column header menu with id of ${menuId} not found in document.`);
102
+ else return true;
103
+ });
104
+ if (menuId) {
105
+ let menu = document.getElementById(menuId);
106
+ if (menu) {
107
+ if (currentSort === 'ascending') await (0, $5d1eca18f92ad0e6$export$6ffa3eb717517feb)(this.user, (0, $2KUjE$within)(menu).getAllByRole('menuitem')[1], interactionType);
108
+ else await (0, $5d1eca18f92ad0e6$export$6ffa3eb717517feb)(this.user, (0, $2KUjE$within)(menu).getAllByRole('menuitem')[0], interactionType);
109
+ await (0, $2KUjE$waitFor)(()=>{
110
+ if (document.contains(menu)) throw new Error('Expected table column menu listbox to not be in the document after selecting an option');
111
+ else return true;
112
+ });
113
+ }
114
+ }
115
+ // Handle cases where the table may transition in response to the row selection/deselection
116
+ await (0, $2KUjE$act)(async ()=>{
117
+ if (this._advanceTimer == null) throw new Error('No advanceTimers provided for table transition.');
118
+ await this._advanceTimer(200);
119
+ });
120
+ await (0, $2KUjE$waitFor)(()=>{
121
+ if (document.activeElement !== menuButton) throw new Error(`Expected the document.activeElement to be the table column menu button but got ${document.activeElement}`);
122
+ else return true;
123
+ });
124
+ } else await (0, $5d1eca18f92ad0e6$export$6ffa3eb717517feb)(this.user, columnheader, interactionType);
125
+ };
126
+ // TODO: should there be a util for triggering a row action? Perhaps there should be but it would rely on the user teling us the config of the
127
+ // table. Maybe we could rely on the user knowing to trigger a press/double click? We could have the user pass in "needsDoubleClick"
128
+ // It is also iffy if there is any row selected because then the table is in selectionMode and the below actions will simply toggle row selection
129
+ this.triggerRowAction = async (opts = {})=>{
130
+ let { index: index, text: text, needsDoubleClick: needsDoubleClick, interactionType: interactionType = this._interactionType } = opts;
131
+ let row = this.findRow({
132
+ index: index,
133
+ text: text
134
+ });
135
+ if (row) {
136
+ if (needsDoubleClick) await this.user.dblClick(row);
137
+ else if (interactionType === 'keyboard') {
138
+ (0, $2KUjE$act)(()=>row.focus());
139
+ await this.user.keyboard('[Enter]');
140
+ } else await (0, $5d1eca18f92ad0e6$export$6ffa3eb717517feb)(this.user, row, interactionType);
141
+ }
142
+ };
143
+ // TODO: should there be utils for drag and drop and column resizing? For column resizing, I'm not entirely convinced that users will be doing that in their tests.
144
+ // For DnD, it might be tricky to do for keyboard DnD since we wouldn't know what valid drop zones there are... Similarly, for simulating mouse drag and drop the coordinates depend
145
+ // on the mocks the user sets up for their row height/etc.
146
+ // Additionally, should we also support keyboard navigation/typeahead? Those felt like they could be very easily replicated by the user via user.keyboard already and don't really
147
+ // add much value if we provide that to them
148
+ this.toggleSelectAll = async (opts = {})=>{
149
+ let { interactionType: interactionType = this._interactionType } = opts;
150
+ let checkbox = (0, $2KUjE$within)(this.table).getByLabelText('Select All');
151
+ if (interactionType === 'keyboard') // TODO: using the .focus -> trigger keyboard Enter approach doesn't work for some reason, for now just trigger select all with click.
152
+ await this.user.click(checkbox);
153
+ else await (0, $5d1eca18f92ad0e6$export$6ffa3eb717517feb)(this.user, checkbox, interactionType);
154
+ };
155
+ this.findRow = (opts = {})=>{
156
+ let { index: index, text: text } = opts;
157
+ let row;
158
+ let rows = this.rows;
159
+ let bodyRowGroup = this.rowGroups[1];
160
+ if (index != null) row = rows[index];
161
+ else if (text != null) {
162
+ row = (0, $2KUjE$within)(bodyRowGroup).getByText(text);
163
+ while(row && row.getAttribute('role') !== 'row')row = row.parentElement;
164
+ }
165
+ return row;
166
+ };
167
+ this.findCell = (opts)=>{
168
+ let { text: text } = opts;
169
+ let cell = (0, $2KUjE$within)(this.table).getByText(text);
170
+ if (cell) while(cell && !/gridcell|rowheader|columnheader/.test(cell.getAttribute('role') || '')){
171
+ if (cell.parentElement) cell = cell.parentElement;
172
+ else break;
173
+ }
174
+ return cell;
175
+ };
176
+ let { root: root, user: user, interactionType: interactionType, advanceTimer: advanceTimer } = opts;
177
+ this.user = user;
178
+ this._interactionType = interactionType || 'mouse';
179
+ this._advanceTimer = advanceTimer;
180
+ this._table = root;
181
+ }
182
+ }
183
+
184
+
185
+ export {$6d1e4cf220920c37$export$4c6a9d6ae3b0086 as TableTester};
186
+ //# sourceMappingURL=table.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAaM,MAAM;IAkOX,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,MAAM;IACpB;IAEA,IAAI,YAAY;QACd,IAAI,QAAQ,IAAI,CAAC,MAAM;QACvB,OAAO,QAAQ,CAAA,GAAA,aAAK,EAAE,OAAO,cAAc,CAAC,cAAc,EAAE;IAC9D;IAEA,IAAI,UAAU;QACZ,IAAI,iBAAiB,I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AK,EAAE,cAAc,SAAS,CAAC;gBACrC,MAAO,OAAO,IAAI,YAAY,CAAC,YAAY,MACzC,MAAM,IAAI,aAAa;YAE3B;YAEA,OAAO;QACT;aAEA,WAAW,CAAC;YACV,IAAI,QACF,IAAI,EACL,GAAG;YAEJ,IAAI,OAAO,CAAA,GAAA,aAAK,EAAE,IAAI,CAAC,KAAK,EAAE,SAAS,CAAC;YACxC,IAAI,MACF,MAAO,QAAQ,CAAC,kCAAkC,IAAI,CAAC,KAAK,YAAY,CAAC,WAAW,IAAK;gBACvF,IAAI,KAAK,aAAa,EACpB,OAAO,KAAK,aAAa;qBAEzB;YAEJ;YAGF,OAAO;QACT;QAzNE,IAAI,QAAC,IAAI,QAAE,IAAI,mBAAE,eAAe,gBAAE,YAAY,EAAC,GAAG;QAClD,IAAI,CAAC,IAAI,GAAG;QACZ,IAAI,CAAC,gBAAgB,GAAG,mBAAmB;QAC3C,IAAI,CAAC,aAAa,GAAG;QACrB,IAAI,CAAC,MAAM,GAAG;IAChB;AAsPF","sources":["packages/@react-aria/test-utils/src/table.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, fireEvent, waitFor, within} from '@testing-library/react';\nimport {BaseTesterOpts, UserOpts} from './user';\nimport {pressElement, triggerLongPress} from './events';\nexport interface TableOptions extends UserOpts, BaseTesterOpts {\n user: any,\n advanceTimer: UserOpts['advanceTimer']\n}\n\n// TODO: Previously used logic like https://github.com/testing-library/react-testing-library/blame/c63b873072d62c858959c2a19e68f8e2cc0b11be/src/pure.js#L16\n// but https://github.com/testing-library/dom-testing-library/issues/987#issuecomment-891901804 indicates that it may falsely indicate that fake timers are enabled\n// when they aren't\nexport class TableTester {\n private user;\n private _interactionType: UserOpts['interactionType'];\n private _advanceTimer: UserOpts['advanceTimer'];\n private _table: HTMLElement;\n\n constructor(opts: TableOptions) {\n let {root, user, interactionType, advanceTimer} = opts;\n this.user = user;\n this._interactionType = interactionType || 'mouse';\n this._advanceTimer = advanceTimer;\n this._table = root;\n }\n\n setInteractionType = (type: UserOpts['interactionType']) => {\n this._interactionType = type;\n };\n\n toggleRowSelection = async (opts: {index?: number, text?: string, needsLongPress?: boolean, interactionType?: UserOpts['interactionType']} = {}) => {\n let {\n index,\n text,\n needsLongPress,\n interactionType = this._interactionType\n } = opts;\n\n let row = this.findRow({index, text});\n let rowCheckbox = within(row).queryByRole('checkbox');\n if (rowCheckbox) {\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 // TODO: interestingly enough, we need to do a followup click otherwise future row selections may not fire properly?\n // To reproduce, try removing this, forcing toggleRowSelection to hit \"needsLongPress ? await triggerLongPress(cell) : await action(cell);\" and\n // run Table.test's \"should support long press to enter selection mode on touch\" test to see what happens\n await fireEvent.click(cell);\n } else {\n await pressElement(this.user, cell, interactionType);\n }\n }\n\n // Handle cases where the table may transition in response to the row selection/deselection\n await act(async () => {\n if (this._advanceTimer == null) {\n throw new Error('No advanceTimers provided for table transition.');\n }\n\n await this._advanceTimer(200);\n });\n };\n\n toggleSort = async (opts: {index?: number, text?: string, interactionType?: UserOpts['interactionType']} = {}) => {\n let {\n index,\n text,\n interactionType = this._interactionType\n } = opts;\n\n let columnheader;\n if (index != null) {\n columnheader = this.columns[index];\n } else if (text != null) {\n columnheader = within(this.rowGroups[0]).getByText(text);\n while (columnheader && !/columnheader/.test(columnheader.getAttribute('role'))) {\n columnheader = columnheader.parentElement;\n }\n }\n\n let menuButton = within(columnheader).queryByRole('button');\n if (menuButton) {\n let currentSort = columnheader.getAttribute('aria-sort');\n // TODO: Focus management is all kinda of messed up if I just use .focus and Space to open the sort menu. Seems like\n // the focused key doesn't get properly set to the desired column header. Have to do this strange flow where I focus the\n // column header except if the active element is already the menu button within the column header\n if (interactionType === 'keyboard' && document.activeElement !== menuButton) {\n await pressElement(this.user, columnheader, interactionType);\n } else {\n await pressElement(this.user, menuButton, interactionType);\n }\n\n await waitFor(() => {\n if (menuButton.getAttribute('aria-controls') == null) {\n throw new Error('No aria-controls found on table column dropdown menu trigger element.');\n } else {\n return true;\n }\n });\n\n let menuId = menuButton.getAttribute('aria-controls');\n await waitFor(() => {\n if (!menuId || document.getElementById(menuId) == null) {\n throw new Error(`Table column header menu with id of ${menuId} not found in document.`);\n } else {\n return true;\n }\n });\n\n if (menuId) {\n let menu = document.getElementById(menuId);\n if (menu) {\n if (currentSort === 'ascending') {\n await pressElement(this.user, within(menu).getAllByRole('menuitem')[1], interactionType);\n } else {\n await pressElement(this.user, within(menu).getAllByRole('menuitem')[0], interactionType);\n }\n\n await waitFor(() => {\n if (document.contains(menu)) {\n throw new Error('Expected table column menu listbox to not be in the document after selecting an option');\n } else {\n return true;\n }\n });\n }\n }\n\n // Handle cases where the table may transition in response to the row selection/deselection\n await act(async () => {\n if (this._advanceTimer == null) {\n throw new Error('No advanceTimers provided for table transition.');\n }\n\n await this._advanceTimer(200);\n });\n\n await waitFor(() => {\n if (document.activeElement !== menuButton) {\n throw new Error(`Expected the document.activeElement to be the table column menu button but got ${document.activeElement}`);\n } else {\n return true;\n }\n });\n } else {\n await pressElement(this.user, columnheader, interactionType);\n }\n };\n // TODO: should there be a util for triggering a row action? Perhaps there should be but it would rely on the user teling us the config of the\n // table. Maybe we could rely on the user knowing to trigger a press/double click? We could have the user pass in \"needsDoubleClick\"\n // It is also iffy if there is any row selected because then the table is in selectionMode and the below actions will simply toggle row selection\n triggerRowAction = async (opts: {index?: number, text?: string, needsDoubleClick?: boolean, interactionType?: UserOpts['interactionType']} = {}) => {\n let {\n index,\n text,\n needsDoubleClick,\n interactionType = this._interactionType\n } = opts;\n\n let row = this.findRow({index, text});\n if (row) {\n if (needsDoubleClick) {\n await this.user.dblClick(row);\n } else if (interactionType === 'keyboard') {\n act(() => row.focus());\n await this.user.keyboard('[Enter]');\n } else {\n await pressElement(this.user, row, interactionType);\n }\n }\n };\n\n // TODO: should there be utils for drag and drop and column resizing? For column resizing, I'm not entirely convinced that users will be doing that in their tests.\n // For DnD, it might be tricky to do for keyboard DnD since we wouldn't know what valid drop zones there are... Similarly, for simulating mouse drag and drop the coordinates depend\n // on the mocks the user sets up for their row height/etc.\n // Additionally, should we also support keyboard navigation/typeahead? Those felt like they could be very easily replicated by the user via user.keyboard already and don't really\n // add much value if we provide that to them\n\n toggleSelectAll = async (opts: {interactionType?: UserOpts['interactionType']} = {}) => {\n let {\n interactionType = this._interactionType\n } = opts;\n let checkbox = within(this.table).getByLabelText('Select All');\n if (interactionType === 'keyboard') {\n // TODO: using the .focus -> trigger keyboard Enter approach doesn't work for some reason, for now just trigger select all with click.\n await this.user.click(checkbox);\n } else {\n await pressElement(this.user, checkbox, interactionType);\n }\n };\n\n findRow = (opts: {index?: number, text?: string} = {}) => {\n let {\n index,\n text\n } = opts;\n\n let row;\n let rows = this.rows;\n let bodyRowGroup = this.rowGroups[1];\n if (index != null) {\n row = rows[index];\n } else if (text != null) {\n row = within(bodyRowGroup).getByText(text);\n while (row && row.getAttribute('role') !== 'row') {\n row = row.parentElement;\n }\n }\n\n return row;\n };\n\n findCell = (opts: {text: string}) => {\n let {\n text\n } = opts;\n\n let cell = within(this.table).getByText(text);\n if (cell) {\n while (cell && !/gridcell|rowheader|columnheader/.test(cell.getAttribute('role') || '')) {\n if (cell.parentElement) {\n cell = cell.parentElement;\n } else {\n break;\n }\n }\n }\n\n return cell;\n };\n\n get table() {\n return this._table;\n }\n\n get rowGroups() {\n let table = this._table;\n return table ? within(table).queryAllByRole('rowgroup') : [];\n }\n\n get columns() {\n let headerRowGroup = this.rowGroups[0];\n return headerRowGroup ? within(headerRowGroup).queryAllByRole('columnheader') : [];\n }\n\n get rows() {\n let bodyRowGroup = this.rowGroups[1];\n return bodyRowGroup ? within(bodyRowGroup).queryAllByRole('row') : [];\n }\n\n get selectedRows() {\n return this.rows.filter(row => row.getAttribute('aria-selected') === 'true');\n }\n\n get rowHeaders() {\n let table = this.table;\n return table ? within(table).queryAllByRole('rowheader') : [];\n }\n\n get cells() {\n let table = this.table;\n return table ? within(table).queryAllByRole('gridcell') : [];\n }\n}\n"],"names":[],"version":3,"file":"table.module.js.map"}
@@ -49,7 +49,7 @@ function $b53408e40e8d56d0$export$82f0b04c1d69a901() {
49
49
  $parcel$global.PointerEvent = class FakePointerEvent extends MouseEvent {
50
50
  get pointerType() {
51
51
  var _this__init_pointerType;
52
- return (_this__init_pointerType = this._init.pointerType) !== null && _this__init_pointerType !== void 0 ? _this__init_pointerType : "mouse";
52
+ return (_this__init_pointerType = this._init.pointerType) !== null && _this__init_pointerType !== void 0 ? _this__init_pointerType : 'mouse';
53
53
  }
54
54
  get pointerId() {
55
55
  return this._init.pointerId;
@@ -42,7 +42,7 @@ function $68df97871cfb5e33$export$82f0b04c1d69a901() {
42
42
  $parcel$global.PointerEvent = class FakePointerEvent extends MouseEvent {
43
43
  get pointerType() {
44
44
  var _this__init_pointerType;
45
- return (_this__init_pointerType = this._init.pointerType) !== null && _this__init_pointerType !== void 0 ? _this__init_pointerType : "mouse";
45
+ return (_this__init_pointerType = this._init.pointerType) !== null && _this__init_pointerType !== void 0 ? _this__init_pointerType : 'mouse';
46
46
  }
47
47
  get pointerId() {
48
48
  return this._init.pointerId;
@@ -73,4 +73,4 @@ function $68df97871cfb5e33$export$82f0b04c1d69a901() {
73
73
 
74
74
 
75
75
  export {$68df97871cfb5e33$export$de31e3987c917741 as installMouseEvent, $68df97871cfb5e33$export$82f0b04c1d69a901 as installPointerEvent};
76
- //# sourceMappingURL=testSetup.mjs.map
76
+ //# sourceMappingURL=testSetup.module.js.map
@@ -42,7 +42,7 @@ function $68df97871cfb5e33$export$82f0b04c1d69a901() {
42
42
  $parcel$global.PointerEvent = class FakePointerEvent extends MouseEvent {
43
43
  get pointerType() {
44
44
  var _this__init_pointerType;
45
- return (_this__init_pointerType = this._init.pointerType) !== null && _this__init_pointerType !== void 0 ? _this__init_pointerType : "mouse";
45
+ return (_this__init_pointerType = this._init.pointerType) !== null && _this__init_pointerType !== void 0 ? _this__init_pointerType : 'mouse';
46
46
  }
47
47
  get pointerId() {
48
48
  return this._init.pointerId;
package/dist/types.d.ts CHANGED
@@ -1,11 +1,187 @@
1
1
  import { pointerKey } from "@testing-library/user-event/system/pointer/shared";
2
- export const DEFAULT_LONG_PRESS_TIME = 500;
2
+ interface ComboBoxOptions extends UserOpts, BaseTesterOpts {
3
+ user: any;
4
+ trigger?: HTMLElement;
5
+ }
6
+ declare class ComboBoxTester {
7
+ constructor(opts: ComboBoxOptions);
8
+ setInteractionType: (type: UserOpts["interactionType"]) => void;
9
+ open: (opts?: {
10
+ triggerBehavior?: "focus" | "manual";
11
+ interactionType?: UserOpts["interactionType"];
12
+ }) => Promise<void>;
13
+ selectOption: (opts?: {
14
+ option?: HTMLElement;
15
+ optionText?: string;
16
+ triggerBehavior?: "focus" | "manual";
17
+ interactionType?: UserOpts["interactionType"];
18
+ }) => Promise<void>;
19
+ close: () => Promise<void>;
20
+ get combobox(): HTMLElement;
21
+ get trigger(): HTMLElement;
22
+ get listbox(): HTMLElement;
23
+ options: (opts?: {
24
+ element?: HTMLElement;
25
+ }) => HTMLElement[] | never[];
26
+ get sections(): HTMLElement[];
27
+ get focusedOption(): HTMLElement;
28
+ }
29
+ interface GridListOptions extends UserOpts, BaseTesterOpts {
30
+ user: any;
31
+ }
32
+ declare class GridListTester {
33
+ constructor(opts: GridListOptions);
34
+ setInteractionType: (type: UserOpts["interactionType"]) => void;
35
+ toggleRowSelection: (opts?: {
36
+ index?: number;
37
+ text?: string;
38
+ interactionType?: UserOpts["interactionType"];
39
+ }) => Promise<void>;
40
+ findRow: (opts: {
41
+ index?: number;
42
+ text?: string;
43
+ }) => any;
44
+ triggerRowAction: (opts: {
45
+ index?: number;
46
+ text?: string;
47
+ needsDoubleClick?: boolean;
48
+ interactionType?: UserOpts["interactionType"];
49
+ }) => Promise<void>;
50
+ get gridlist(): HTMLElement;
51
+ get rows(): HTMLElement[];
52
+ get selectedRows(): HTMLElement[];
53
+ cells: (opts?: {
54
+ element?: HTMLElement;
55
+ }) => HTMLElement[];
56
+ }
57
+ interface MenuOptions extends UserOpts, BaseTesterOpts {
58
+ user: any;
59
+ }
60
+ declare class MenuTester {
61
+ constructor(opts: MenuOptions);
62
+ setInteractionType: (type: UserOpts["interactionType"]) => void;
63
+ open: (opts?: {
64
+ needsLongPress?: boolean;
65
+ interactionType?: UserOpts["interactionType"];
66
+ }) => Promise<void>;
67
+ selectOption: (opts: {
68
+ option?: HTMLElement;
69
+ optionText?: string;
70
+ menuSelectionMode?: "single" | "multiple";
71
+ needsLongPress?: boolean;
72
+ closesOnSelect?: boolean;
73
+ interactionType?: UserOpts["interactionType"];
74
+ }) => Promise<void>;
75
+ openSubmenu: (opts: {
76
+ submenuTrigger?: HTMLElement;
77
+ submenuTriggerText?: string;
78
+ needsLongPress?: boolean;
79
+ interactionType?: UserOpts["interactionType"];
80
+ }) => Promise<MenuTester | null>;
81
+ close: () => Promise<void>;
82
+ get trigger(): HTMLElement;
83
+ get menu(): HTMLElement;
84
+ get options(): HTMLElement[] | never[];
85
+ get sections(): HTMLElement[];
86
+ get submenuTriggers(): HTMLElement[];
87
+ }
88
+ interface SelectOptions extends UserOpts, BaseTesterOpts {
89
+ user: any;
90
+ }
91
+ declare class SelectTester {
92
+ constructor(opts: SelectOptions);
93
+ setInteractionType: (type: UserOpts["interactionType"]) => void;
94
+ open: (opts?: {
95
+ interactionType?: UserOpts["interactionType"];
96
+ }) => Promise<void>;
97
+ selectOption: (opts: {
98
+ optionText: string;
99
+ interactionType?: UserOpts["interactionType"];
100
+ }) => Promise<void>;
101
+ close: () => Promise<void>;
102
+ get trigger(): HTMLElement;
103
+ get listbox(): HTMLElement;
104
+ get options(): HTMLElement[];
105
+ get sections(): HTMLElement[];
106
+ }
107
+ interface TableOptions extends UserOpts, BaseTesterOpts {
108
+ user: any;
109
+ advanceTimer: UserOpts['advanceTimer'];
110
+ }
111
+ declare class TableTester {
112
+ constructor(opts: TableOptions);
113
+ setInteractionType: (type: UserOpts["interactionType"]) => void;
114
+ toggleRowSelection: (opts?: {
115
+ index?: number;
116
+ text?: string;
117
+ needsLongPress?: boolean;
118
+ interactionType?: UserOpts["interactionType"];
119
+ }) => Promise<void>;
120
+ toggleSort: (opts?: {
121
+ index?: number;
122
+ text?: string;
123
+ interactionType?: UserOpts["interactionType"];
124
+ }) => Promise<void>;
125
+ triggerRowAction: (opts?: {
126
+ index?: number;
127
+ text?: string;
128
+ needsDoubleClick?: boolean;
129
+ interactionType?: UserOpts["interactionType"];
130
+ }) => Promise<void>;
131
+ toggleSelectAll: (opts?: {
132
+ interactionType?: UserOpts["interactionType"];
133
+ }) => Promise<void>;
134
+ findRow: (opts?: {
135
+ index?: number;
136
+ text?: string;
137
+ }) => any;
138
+ findCell: (opts: {
139
+ text: string;
140
+ }) => HTMLElement;
141
+ get table(): HTMLElement;
142
+ get rowGroups(): HTMLElement[];
143
+ get columns(): HTMLElement[];
144
+ get rows(): HTMLElement[];
145
+ get selectedRows(): HTMLElement[];
146
+ get rowHeaders(): HTMLElement[];
147
+ get cells(): HTMLElement[];
148
+ }
149
+ export interface UserOpts {
150
+ interactionType?: 'mouse' | 'touch' | 'keyboard';
151
+ advanceTimer?: (time?: number) => void | Promise<unknown>;
152
+ }
153
+ interface BaseTesterOpts {
154
+ root: HTMLElement;
155
+ }
156
+ declare let keyToUtil: {
157
+ readonly Select: typeof SelectTester;
158
+ readonly Table: typeof TableTester;
159
+ readonly Menu: typeof MenuTester;
160
+ readonly ComboBox: typeof ComboBoxTester;
161
+ readonly GridList: typeof GridListTester;
162
+ };
163
+ type PatternNames = keyof typeof keyToUtil;
164
+ type ObjectType<T> = T extends 'Select' ? SelectTester : T extends 'Table' ? TableTester : T extends 'Menu' ? MenuTester : T extends 'ComboBox' ? ComboBoxTester : T extends 'GridList' ? GridListTester : never;
165
+ type ObjectOptionsTypes<T> = T extends 'Select' ? SelectOptions : T extends 'Table' ? TableOptions : T extends 'Menu' ? MenuOptions : T extends 'ComboBox' ? ComboBoxOptions : T extends 'GridList' ? GridListOptions : never;
166
+ export class User {
167
+ user: any;
168
+ interactionType: UserOpts['interactionType'];
169
+ advanceTimer: UserOpts['advanceTimer'];
170
+ constructor(opts?: UserOpts);
171
+ createTester<T extends PatternNames>(patternName: T, opts: ObjectOptionsTypes<T>): ObjectType<T>;
172
+ }
3
173
  /**
4
174
  * Simulates a "long press" event on a element.
5
- * @param element - Element to long press.
6
- * @param opts - Options to pass to the simulated event. See https://testing-library.com/docs/dom-testing-library/api-events/#fireevent for more info.
175
+ * @param opts - Options for the long press.
176
+ * @param opts.element - Element to long press.
177
+ * @param opts.advanceTimer - Function that when called advances the timers in your test suite by a specific amount of time(ms).
178
+ * @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.
7
179
  */
8
- export function triggerLongPress(element: HTMLElement, opts?: {}): void;
180
+ export function triggerLongPress(opts: {
181
+ element: HTMLElement;
182
+ advanceTimer: (time?: number) => void | Promise<unknown>;
183
+ pointerOpts?: {};
184
+ }): Promise<void>;
9
185
  /**
10
186
  * Enables reading pageX/pageY from fireEvent.mouse*(..., {pageX: ..., pageY: ...}).
11
187
  */
@@ -1 +1 @@
1
- {"mappings":";AAcA,OAAO,MAAM,6BAA6B,CAAC;AAE3C;;;;GAIG;AACH,iCAAiC,OAAO,EAAE,WAAW,EAAE,IAAI,KAAK,GAAG,IAAI,CAMtE;ACfD;;GAEG;AACH,0CAwBC;AAED,4CAiCC;ACxED,OAAO,IAAI,YAAY,UAAU,EAOL,CAAC","sources":["packages/@react-aria/test-utils/src/packages/@react-aria/test-utils/src/events.ts","packages/@react-aria/test-utils/src/packages/@react-aria/test-utils/src/testSetup.ts","packages/@react-aria/test-utils/src/packages/@react-aria/test-utils/src/userEventMaps.ts","packages/@react-aria/test-utils/src/packages/@react-aria/test-utils/src/index.ts","packages/@react-aria/test-utils/src/index.ts"],"sourcesContent":[null,null,null,null,"/*\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\nexport * from './events';\nexport * from './testSetup';\nexport * from './userEventMaps';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
1
+ {"mappings":";AAeA,yBAAiC,SAAQ,QAAQ,EAAE,cAAc;IAC/D,IAAI,EAAE,GAAG,CAAC;IACV,OAAO,CAAC,EAAE,WAAW,CAAA;CACtB;AAED;gBAMc,IAAI,EAAE,eAAe;IA4BjC,kBAAkB,SAAU,QAAQ,CAAC,iBAAiB,CAAC,UAErD;IAEF,IAAI,UAAgB;QAAC,eAAe,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;QAAC,eAAe,CAAC,EAAE,QAAQ,CAAC,iBAAiB,CAAC,CAAA;KAAC,mBAwCvG;IAEF,YAAY,UAAgB;QAAC,MAAM,CAAC,EAAE,WAAW,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,eAAe,CA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CAAuC,IAAI,EAAE;IAAC,OAAO,EAAE,WAAW,CAAC;IAAC,YAAY,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAAC,WAAW,CAAC,EAAE,EAAE,CAAA;CAAC,iBAQ9I;ACpBD;;GAEG;AACH,0CAwBC;AAED,4CAiCC;ACxED,OAAO,IAAI,YAAY,UAAU,EAOL,CAAC","sources":["packages/@react-aria/test-utils/src/packages/@react-aria/test-utils/src/combobox.ts","packages/@react-aria/test-utils/src/packages/@react-aria/test-utils/src/gridlist.ts","packages/@react-aria/test-utils/src/packages/@react-aria/test-utils/src/menu.ts","packages/@react-aria/test-utils/src/packages/@react-aria/test-utils/src/select.ts","packages/@react-aria/test-utils/src/packages/@react-aria/test-utils/src/table.ts","packages/@react-aria/test-utils/src/packages/@react-aria/test-utils/src/user.ts","packages/@react-aria/test-utils/src/packages/@react-aria/test-utils/src/events.ts","packages/@react-aria/test-utils/src/packages/@react-aria/test-utils/src/testSetup.ts","packages/@react-aria/test-utils/src/packages/@react-aria/test-utils/src/userEventMaps.ts","packages/@react-aria/test-utils/src/packages/@react-aria/test-utils/src/index.ts","packages/@react-aria/test-utils/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,null,"/*\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\nexport {triggerLongPress} from './events';\nexport {installMouseEvent, installPointerEvent} from './testSetup';\nexport {pointerMap} from './userEventMaps';\nexport {User} from './user';\n\nexport type {UserOpts} from './user';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
@@ -0,0 +1,65 @@
1
+ var $15e4b71f2b6c4964$exports = require("./combobox.main.js");
2
+ var $30ee8e379774bea4$exports = require("./gridlist.main.js");
3
+ var $31965f39292c8e99$exports = require("./menu.main.js");
4
+ var $0e568517a25183a7$exports = require("./userEventMaps.main.js");
5
+ var $b97d5a42df7c75b2$exports = require("./select.main.js");
6
+ var $80a9def682ac1297$exports = require("./table.main.js");
7
+ var $iYqJR$testinglibraryuserevent = require("@testing-library/user-event");
8
+
9
+
10
+ function $parcel$interopDefault(a) {
11
+ return a && a.__esModule ? a.default : a;
12
+ }
13
+
14
+ function $parcel$export(e, n, v, s) {
15
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
16
+ }
17
+
18
+ $parcel$export(module.exports, "User", () => $4168d511756883ff$export$1f44aaf2ec115b54);
19
+ /*
20
+ * Copyright 2024 Adobe. All rights reserved.
21
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
22
+ * you may not use this file except in compliance with the License. You may obtain a copy
23
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
24
+ *
25
+ * Unless required by applicable law or agreed to in writing, software distributed under
26
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
27
+ * OF ANY KIND, either express or implied. See the License for the specific language
28
+ * governing permissions and limitations under the License.
29
+ */
30
+
31
+
32
+
33
+
34
+
35
+
36
+ let $4168d511756883ff$var$keyToUtil = {
37
+ 'Select': (0, $b97d5a42df7c75b2$exports.SelectTester),
38
+ 'Table': (0, $80a9def682ac1297$exports.TableTester),
39
+ 'Menu': (0, $31965f39292c8e99$exports.MenuTester),
40
+ 'ComboBox': (0, $15e4b71f2b6c4964$exports.ComboBoxTester),
41
+ 'GridList': (0, $30ee8e379774bea4$exports.GridListTester)
42
+ };
43
+ let $4168d511756883ff$var$defaultAdvanceTimer = async (waitTime)=>await new Promise((resolve)=>setTimeout(resolve, waitTime));
44
+ class $4168d511756883ff$export$1f44aaf2ec115b54 {
45
+ createTester(patternName, opts) {
46
+ return new $4168d511756883ff$var$keyToUtil[patternName]({
47
+ ...opts,
48
+ user: this.user,
49
+ interactionType: this.interactionType,
50
+ advanceTimer: this.advanceTimer
51
+ });
52
+ }
53
+ constructor(opts = {}){
54
+ let { interactionType: interactionType, advanceTimer: advanceTimer } = opts;
55
+ this.user = (0, ($parcel$interopDefault($iYqJR$testinglibraryuserevent))).setup({
56
+ delay: null,
57
+ pointerMap: $0e568517a25183a7$exports.pointerMap
58
+ });
59
+ this.interactionType = interactionType;
60
+ this.advanceTimer = advanceTimer || $4168d511756883ff$var$defaultAdvanceTimer;
61
+ }
62
+ }
63
+
64
+
65
+ //# sourceMappingURL=user.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;AAyBD,IAAI,kCAAY;IAAC,UAAU,CAAA,GAAA,sCAAW;IAAG,SAAS,CAAA,GAAA,qCAAU;IAAG,QAAQ,CAAA,GAAA,oCAAS;IAAG,YAAY,CAAA,GAAA,wCAAa;IAAG,YAAY,CAAA,GAAA,wCAAa;AAAC;AAoBzI,IAAI,4CAAsB,OAAO,WAAiC,MAAM,IAAI,QAAQ,CAAC,UAAY,WAAW,SAAS;AAE9G,MAAM;IAYX,aAAqC,WAAc,EAAE,IAA2B,EAAiB;QAC/F,OAAO,IAAI,AAAC,+BAAU,CAAC,YAAY,CAAC;YAAC,GAAG,IAAI;YAAE,MAAM,IAAI,CAAC,IAAI;YAAE,iBAAiB,IAAI,CAAC,eAAe;YAAE,cAAc,IAAI,CAAC,YAAY;QAAA;IACvI;IATA,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;AAKF","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 {ComboBoxOptions, ComboBoxTester} from './combobox';\nimport {GridListOptions, GridListTester} from './gridlist';\nimport {MenuOptions, MenuTester} from './menu';\nimport {pointerMap} from './';\nimport {SelectOptions, SelectTester} from './select';\nimport {TableOptions, TableTester} from './table';\nimport userEvent from '@testing-library/user-event';\n\n// https://github.com/testing-library/dom-testing-library/issues/939#issuecomment-830771708 is an interesting way of allowing users to configure the timers\n// curent way is like https://testing-library.com/docs/user-event/options/#advancetimers,\nexport interface UserOpts {\n interactionType?: 'mouse' | 'touch' | 'keyboard',\n // If using fake timers user should provide something like (time) => jest.advanceTimersByTime(time))}\n // A real timer user would pass async () => await new Promise((resolve) => setTimeout(resolve, waitTime))\n // Time is in ms.\n advanceTimer?: (time?: number) => void | Promise<unknown>\n}\n\nexport interface BaseTesterOpts {\n // The base element for the given tester (e.g. the table, menu trigger, etc)\n root: HTMLElement\n}\n\nlet keyToUtil = {'Select': SelectTester, 'Table': TableTester, 'Menu': MenuTester, 'ComboBox': ComboBoxTester, 'GridList': GridListTester} as const;\nexport type PatternNames = keyof typeof keyToUtil;\n\n// Conditional type: https://www.typescriptlang.org/docs/handbook/2/conditional-types.html\ntype ObjectType<T> =\n T extends 'Select' ? SelectTester :\n T extends 'Table' ? TableTester :\n T extends 'Menu' ? MenuTester :\n T extends 'ComboBox' ? ComboBoxTester :\n T extends 'GridList' ? GridListTester :\n never;\n\ntype ObjectOptionsTypes<T> =\n T extends 'Select' ? SelectOptions :\n T extends 'Table' ? TableOptions :\n T extends 'Menu' ? MenuOptions :\n T extends 'ComboBox' ? ComboBoxOptions :\n T extends 'GridList' ? GridListOptions :\n never;\n\nlet defaultAdvanceTimer = async (waitTime: number | undefined) => await new Promise((resolve) => setTimeout(resolve, waitTime));\n\nexport class User {\n user;\n interactionType: UserOpts['interactionType'];\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 createTester<T extends PatternNames>(patternName: T, opts: ObjectOptionsTypes<T>): ObjectType<T> {\n return new (keyToUtil)[patternName]({...opts, user: this.user, interactionType: this.interactionType, advanceTimer: this.advanceTimer}) as ObjectType<T>;\n }\n}\n"],"names":[],"version":3,"file":"user.main.js.map"}
package/dist/user.mjs ADDED
@@ -0,0 +1,56 @@
1
+ import {ComboBoxTester as $dab75f394483aa9c$export$f97e14e96d71ab3b} from "./combobox.mjs";
2
+ import {GridListTester as $5ca9e9228f508f75$export$93a85aaed9fabd83} from "./gridlist.mjs";
3
+ import {MenuTester as $74b93f0617179929$export$f73bbc9212ed861e} from "./menu.mjs";
4
+ import {pointerMap as $50ecfb18069ec897$export$7dbde2c4caaa8d35} from "./userEventMaps.mjs";
5
+ import {SelectTester as $4350df3e19e40e36$export$d1859707465446a9} from "./select.mjs";
6
+ import {TableTester as $6d1e4cf220920c37$export$4c6a9d6ae3b0086} from "./table.mjs";
7
+ import $gmkhN$testinglibraryuserevent from "@testing-library/user-event";
8
+
9
+ /*
10
+ * Copyright 2024 Adobe. All rights reserved.
11
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
12
+ * you may not use this file except in compliance with the License. You may obtain a copy
13
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
14
+ *
15
+ * Unless required by applicable law or agreed to in writing, software distributed under
16
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
17
+ * OF ANY KIND, either express or implied. See the License for the specific language
18
+ * governing permissions and limitations under the License.
19
+ */
20
+
21
+
22
+
23
+
24
+
25
+
26
+ let $0d71b4e9cc4df40a$var$keyToUtil = {
27
+ 'Select': (0, $4350df3e19e40e36$export$d1859707465446a9),
28
+ 'Table': (0, $6d1e4cf220920c37$export$4c6a9d6ae3b0086),
29
+ 'Menu': (0, $74b93f0617179929$export$f73bbc9212ed861e),
30
+ 'ComboBox': (0, $dab75f394483aa9c$export$f97e14e96d71ab3b),
31
+ 'GridList': (0, $5ca9e9228f508f75$export$93a85aaed9fabd83)
32
+ };
33
+ let $0d71b4e9cc4df40a$var$defaultAdvanceTimer = async (waitTime)=>await new Promise((resolve)=>setTimeout(resolve, waitTime));
34
+ class $0d71b4e9cc4df40a$export$1f44aaf2ec115b54 {
35
+ createTester(patternName, opts) {
36
+ return new $0d71b4e9cc4df40a$var$keyToUtil[patternName]({
37
+ ...opts,
38
+ user: this.user,
39
+ interactionType: this.interactionType,
40
+ advanceTimer: this.advanceTimer
41
+ });
42
+ }
43
+ constructor(opts = {}){
44
+ let { interactionType: interactionType, advanceTimer: advanceTimer } = opts;
45
+ this.user = (0, $gmkhN$testinglibraryuserevent).setup({
46
+ delay: null,
47
+ pointerMap: $50ecfb18069ec897$export$7dbde2c4caaa8d35
48
+ });
49
+ this.interactionType = interactionType;
50
+ this.advanceTimer = advanceTimer || $0d71b4e9cc4df40a$var$defaultAdvanceTimer;
51
+ }
52
+ }
53
+
54
+
55
+ export {$0d71b4e9cc4df40a$export$1f44aaf2ec115b54 as User};
56
+ //# sourceMappingURL=user.module.js.map