@react-aria/test-utils 3.0.0-nightly-db60babaf-241014 → 3.0.0-nightly-e1b72a79f-241016

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.
@@ -76,11 +76,6 @@ class $80a9def682ac1297$export$4c6a9d6ae3b0086 {
76
76
  await (0, $2auAU$testinglibraryreact.fireEvent).click(cell);
77
77
  } else await (0, $5a8bfe1663b8366d$exports.pressElement)(this.user, cell, interactionType);
78
78
  }
79
- // Handle cases where the table may transition in response to the row selection/deselection
80
- await (0, $2auAU$testinglibraryreact.act)(async ()=>{
81
- if (this._advanceTimer == null) throw new Error('No advanceTimers provided for table transition.');
82
- await this._advanceTimer(200);
83
- });
84
79
  };
85
80
  this.toggleSort = async (opts = {})=>{
86
81
  let { index: index, text: text, interactionType: interactionType = this._interactionType } = opts;
@@ -119,9 +114,10 @@ class $80a9def682ac1297$export$4c6a9d6ae3b0086 {
119
114
  }
120
115
  }
121
116
  // Handle cases where the table may transition in response to the row selection/deselection
117
+ if (!this._advanceTimer) throw new Error('No advanceTimers provided for table transition.');
122
118
  await (0, $2auAU$testinglibraryreact.act)(async ()=>{
123
- if (this._advanceTimer == null) throw new Error('No advanceTimers provided for table transition.');
124
- await this._advanceTimer(200);
119
+ var _this__advanceTimer, _this;
120
+ await ((_this__advanceTimer = (_this = this)._advanceTimer) === null || _this__advanceTimer === void 0 ? void 0 : _this__advanceTimer.call(_this, 200));
125
121
  });
126
122
  await (0, $2auAU$testinglibraryreact.waitFor)(()=>{
127
123
  if (document.activeElement !== menuButton) throw new Error(`Expected the document.activeElement to be the table column menu button but got ${document.activeElement}`);
@@ -1 +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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SAAS,CAAC,EAAE;YACpC,IAAI,SAAS,MACX,MAAM,IAAI,CAAC,MAAM;iBACZ,IAAI,QAAQ,MAAM;gBACvB,MAAM,CAAA,GAAA,iCAAK,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,iCAAK,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.main.js.map"}
1
+ {"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAaM,MAAM;IAyNX,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,MAAM;IACpB;IAEA,IAAI,YAAY;QACd,IAAI,QAAQ,IAAI,CAAC,MAAM;QACvB,OAAO,QAAQ,CAAA,GAAA,iCAAK,EAAE,OAAO,cAAc,CAAC,cAAc,EAAE;IAC9D;IAEA,IAAI,UAAU;QACZ,IAAI,iBAAiB,IAAI,CAAC,SAAS,CAAC,EAAE;QACtC,OAAO,iBAAiB,CAAA,GAAA,iCAAK,EAAE,gBAAgB,cAAc,CAAC,kBAAkB,EAAE;IACpF;IAEA,IAAI,OAAO;QACT,IAAI,eAAe,IAAI,CAAC,SAAS,CAAC,EAAE;QACpC,OAAO,eAAe,CAAA,GAAA,iCAAK,EAAE,cAAc,cAAc,CAAC,SAAS,EAAE;IACvE;IAEA,IAAI,eAAe;QACjB,OAAO,IAAI,CAAC,IAAI,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BAEzB;YAEJ;YAGF,OAAO;QACT;QAhNE,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;AA6OF","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\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 if (!this._advanceTimer) {\n throw new Error('No advanceTimers provided for table transition.');\n }\n\n await act(async () => {\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.main.js.map"}
package/dist/table.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import {pressElement as $5d1eca18f92ad0e6$export$6ffa3eb717517feb, triggerLongPress as $5d1eca18f92ad0e6$export$3a22a5a9bc0fd3b} from "./events.mjs";
2
- import {within as $2KUjE$within, fireEvent as $2KUjE$fireEvent, act as $2KUjE$act, waitFor as $2KUjE$waitFor} from "@testing-library/react";
2
+ import {within as $2KUjE$within, fireEvent as $2KUjE$fireEvent, waitFor as $2KUjE$waitFor, act as $2KUjE$act} from "@testing-library/react";
3
3
 
4
4
  /*
5
5
  * Copyright 2024 Adobe. All rights reserved.
@@ -70,11 +70,6 @@ class $6d1e4cf220920c37$export$4c6a9d6ae3b0086 {
70
70
  await (0, $2KUjE$fireEvent).click(cell);
71
71
  } else await (0, $5d1eca18f92ad0e6$export$6ffa3eb717517feb)(this.user, cell, interactionType);
72
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
73
  };
79
74
  this.toggleSort = async (opts = {})=>{
80
75
  let { index: index, text: text, interactionType: interactionType = this._interactionType } = opts;
@@ -113,9 +108,10 @@ class $6d1e4cf220920c37$export$4c6a9d6ae3b0086 {
113
108
  }
114
109
  }
115
110
  // Handle cases where the table may transition in response to the row selection/deselection
111
+ if (!this._advanceTimer) throw new Error('No advanceTimers provided for table transition.');
116
112
  await (0, $2KUjE$act)(async ()=>{
117
- if (this._advanceTimer == null) throw new Error('No advanceTimers provided for table transition.');
118
- await this._advanceTimer(200);
113
+ var _this__advanceTimer, _this;
114
+ await ((_this__advanceTimer = (_this = this)._advanceTimer) === null || _this__advanceTimer === void 0 ? void 0 : _this__advanceTimer.call(_this, 200));
119
115
  });
120
116
  await (0, $2KUjE$waitFor)(()=>{
121
117
  if (document.activeElement !== menuButton) throw new Error(`Expected the document.activeElement to be the table column menu button but got ${document.activeElement}`);
@@ -1,5 +1,5 @@
1
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";
2
+ import {within as $2KUjE$within, fireEvent as $2KUjE$fireEvent, waitFor as $2KUjE$waitFor, act as $2KUjE$act} from "@testing-library/react";
3
3
 
4
4
  /*
5
5
  * Copyright 2024 Adobe. All rights reserved.
@@ -70,11 +70,6 @@ class $6d1e4cf220920c37$export$4c6a9d6ae3b0086 {
70
70
  await (0, $2KUjE$fireEvent).click(cell);
71
71
  } else await (0, $5d1eca18f92ad0e6$export$6ffa3eb717517feb)(this.user, cell, interactionType);
72
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
73
  };
79
74
  this.toggleSort = async (opts = {})=>{
80
75
  let { index: index, text: text, interactionType: interactionType = this._interactionType } = opts;
@@ -113,9 +108,10 @@ class $6d1e4cf220920c37$export$4c6a9d6ae3b0086 {
113
108
  }
114
109
  }
115
110
  // Handle cases where the table may transition in response to the row selection/deselection
111
+ if (!this._advanceTimer) throw new Error('No advanceTimers provided for table transition.');
116
112
  await (0, $2KUjE$act)(async ()=>{
117
- if (this._advanceTimer == null) throw new Error('No advanceTimers provided for table transition.');
118
- await this._advanceTimer(200);
113
+ var _this__advanceTimer, _this;
114
+ await ((_this__advanceTimer = (_this = this)._advanceTimer) === null || _this__advanceTimer === void 0 ? void 0 : _this__advanceTimer.call(_this, 200));
119
115
  });
120
116
  await (0, $2KUjE$waitFor)(()=>{
121
117
  if (document.activeElement !== menuButton) throw new Error(`Expected the document.activeElement to be the table column menu button but got ${document.activeElement}`);
@@ -1 +1 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5C;aAEA,UAAU,CAAC,OAAwC,CAAC,CAAC;YACnD,IAAI,SACF,KAAK,QACL,IAAI,EACL,GAAG;YAEJ,IAAI;YACJ,IAAI,OAAO,IAAI,CAAC,IAAI;YACpB,IAAI,eAAe,IAAI,CAAC,SAAS,CAAC,EAAE;YACpC,IAAI,SAAS,MACX,MAAM,IAAI,CAAC,MAAM;iBACZ,IAAI,QAAQ,MAAM;gBACvB,MAAM,CAAA,GAAA,aAAK,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"}
1
+ {"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAaM,MAAM;IAyNX,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,IAAI,CAAC,SAAS,CAAC,EAAE;QACtC,OAAO,iBAAiB,CAAA,GAAA,aAAK,EAAE,gBAAgB,cAAc,CAAC,kBAAkB,EAAE;IACpF;IAEA,IAAI,OAAO;QACT,IAAI,eAAe,IAAI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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;QAhNE,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;AA6OF","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\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 if (!this._advanceTimer) {\n throw new Error('No advanceTimers provided for table transition.');\n }\n\n await act(async () => {\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"}
@@ -1 +1 @@
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,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;QAAC,eAAe,CAAC,EAAE,QAAQ,CAAC,iBAAiB,CAAC,CAAA;KAAC,mBAgC1J;IAEF,KAAK,sBAcH;IAEF,IAAI,QAAQ,gBAEX;IAED,IAAI,OAAO,gBAEV;IAED,IAAI,OAAO,gBAGV;IAED,OAAO,UAAU;QAAC,OAAO,CAAC,EAAE,WAAW,CAAA;KAAC,KAAQ,WAAW,EAAE,GAAG,KAAK,EAAE,CASrE;IAEF,IAAI,QAAQ,kBAOX;IAED,IAAI,aAAa,gBAGhB;CACF;AC3KD,yBAAiC,SAAQ,QAAQ,EAAE,cAAc;IAC/D,IAAI,EAAE,GAAG,CAAA;CACV;AACD;gBAMc,IAAI,EAAE,eAAe;IAOjC,kBAAkB,SAAU,QAAQ,CAAC,iBAAiB,CAAC,UAErD;IAOF,kBAAkB,UAAgB;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAA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7B,CAAC,SAAS,UAAU,GAAG,cAAc,GACrC,CAAC,SAAS,UAAU,GAAG,cAAc,GACrC,KAAK,CAAC;AAEV,wBAAwB,CAAC,IACvB,CAAC,SAAS,QAAQ,GAAG,aAAa,GAClC,CAAC,SAAS,OAAO,GAAG,YAAY,GAChC,CAAC,SAAS,MAAM,GAAG,WAAW,GAC9B,CAAC,SAAS,UAAU,GAAG,eAAe,GACtC,CAAC,SAAS,UAAU,GAAG,eAAe,GACtC,KAAK,CAAC;AAIR;IACE,IAAI,MAAC;IACL,eAAe,EAAE,QAAQ,CAAC,iBAAiB,CAAC,CAAC;IAC7C,YAAY,EAAE,QAAQ,CAAC,cAAc,CAAC,CAAC;gBAE3B,IAAI,GAAE,QAAa;IAO/B,YAAY,CAAC,CAAC,SAAS,YAAY,EAAE,WAAW,EAAE,CAAC,EAAE,IAAI,EAAE,mBAAmB,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC;CAGjG;ACvDD;;;;;;GAMG;AACH,iCAAuC,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"}
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,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;QAAC,eAAe,CAAC,EAAE,QAAQ,CAAC,iBAAiB,CAAC,CAAA;KAAC,mBAgC1J;IAEF,KAAK,sBAcH;IAEF,IAAI,QAAQ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;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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-aria/test-utils",
3
- "version": "3.0.0-nightly-db60babaf-241014",
3
+ "version": "3.0.0-nightly-e1b72a79f-241016",
4
4
  "description": "Testing utils for react-aria patterns",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
package/src/table.ts CHANGED
@@ -68,15 +68,6 @@ export class TableTester {
68
68
  await pressElement(this.user, cell, interactionType);
69
69
  }
70
70
  }
71
-
72
- // Handle cases where the table may transition in response to the row selection/deselection
73
- await act(async () => {
74
- if (this._advanceTimer == null) {
75
- throw new Error('No advanceTimers provided for table transition.');
76
- }
77
-
78
- await this._advanceTimer(200);
79
- });
80
71
  };
81
72
 
82
73
  toggleSort = async (opts: {index?: number, text?: string, interactionType?: UserOpts['interactionType']} = {}) => {
@@ -145,12 +136,12 @@ export class TableTester {
145
136
  }
146
137
 
147
138
  // Handle cases where the table may transition in response to the row selection/deselection
148
- await act(async () => {
149
- if (this._advanceTimer == null) {
150
- throw new Error('No advanceTimers provided for table transition.');
151
- }
139
+ if (!this._advanceTimer) {
140
+ throw new Error('No advanceTimers provided for table transition.');
141
+ }
152
142
 
153
- await this._advanceTimer(200);
143
+ await act(async () => {
144
+ await this._advanceTimer?.(200);
154
145
  });
155
146
 
156
147
  await waitFor(() => {