Skip to content

chore: Optimize table test performance #8051

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 8, 2025
Merged

chore: Optimize table test performance #8051

merged 1 commit into from
Apr 8, 2025

Conversation

devongovett
Copy link
Member

@devongovett devongovett commented Apr 8, 2025

This optimizes the table tests to improve their performance. Before 91s, after 22s.

image

In circleci, test-19 went from 6m 33s on main to 3m 22s on this branch.

Optimizations

  • The version of JSDOM we use has a very slow implementation of window.getComputedStyle (getComputedStyle performance jsdom/jsdom#3234). This is supposedly fixed in newer versions but jest has not upgraded yet. In the meantime, we don't really need a full implementation, so I added a mock that just returns element.style without taking any other stylesheets into consideration. This was the biggest optimization.
  • getByLabelText is also quite slow. This was used to find the select all checkbox. I added a data-testid instead which is much faster.
  • Rendered fewer rows/columns. We set virtualizer to render a 1000x1000 rectangle, which contained hundreds of cells. Reducing this improves performance a lot. Also reduced the size of the collection itself in some cases.
  • Moved the tests in Table.test.js into a separate file which can be reused with TableNestedRows.test.js. Because Table.test.js was imported into TableNestedRows.test.js, those tests actually ran twice before. Sorry for the large diff.

@rspbot
Copy link

rspbot commented Apr 8, 2025

let isReact18 = parseInt(React.version, 10) >= 18;
// getComputedStyle is very slow in our version of jsdom.
// These tests only care about direct inline styles. We can avoid parsing other stylesheets.
window.getComputedStyle = (el) => el.style;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

didn't want to do in a beforeAll using jest.spyOn(window, 'getComputedStyle').mockImplementation(el => el.style)?

@devongovett devongovett added this pull request to the merge queue Apr 8, 2025
Merged via the queue into main with commit 2edef89 Apr 8, 2025
33 checks passed
@devongovett devongovett deleted the table-tests branch April 8, 2025 17:01
ritz078 added a commit to PSPDFKit-labs/react-spectrum that referenced this pull request Apr 10, 2025
* chore: Fix generated code sample for S2 TooltipTrigger docs (adobe#8000)

* Fix generated code sample for S2 TooltipTrigger docs

* review

* inlining

* fix: export SortDescriptor type from S2 (adobe#8030)

* chore: Deprecate UNSTABLE_portalContainer in favor for PortalProvider (adobe#7976)

* Initial refactor to tear out UNSTABLE_portalContainer in favor of the PortalContainer

* yarn.lock update

* switch to deprecating UNSTABLE_portalContainer

* prefer deprecated prop over context to make this a non-breaking change

* add rough docs

* updating copy to include explaination of UNSTABLE

* rename to UNSAFE_PortalProvider

* update copy and split out example

* use styles from RAC examples

---------

Co-authored-by: Robert Snow <[email protected]>

* feat: Add escapeKeyBehavior to GridList/ListBox/Menu/Table/Tree (adobe#7974)

* Add disallowClearAll to Menu/ListBox so Autocomplete in Popover can close without clearing selection

* add support for diallowClearAll to grid/tree/table

* make sure RSP components also surface disallowClearAll

* update api naming to escapeKeyBehavior

* skip 17 tests for build, investigate later

* review comments

* fix: useMove broken by NODE_ENV check (adobe#8046)

* fix: ColorWheel track click (adobe#8049)

* fix: minor typo in CalendarDate docs (adobe#8043)

* fix: minor typo in CalendarDate docs

* fix second example as well

---------

Co-authored-by: Robert Snow <[email protected]>

* fix: Updating collection when items change parents (adobe#8052)

* export Autocomplete from S2 (adobe#8050)

* chore: Optimize table test performance (adobe#8051)

* chore: Update typescript to 5.8 (adobe#7888)

* chore: update typescript to 5.8

* fix all the types for the upgrade

* fix numberfield styles

* fix: Apply touch-action by default in usePress (adobe#8047)

* fix: Apply touch-action by default in usePress

* fix test

---------

Co-authored-by: Daniel Lu <[email protected]>

* fix: set some better flex behaviour (adobe#8048)

* fix: Support React 19 and remove Jest reliance in test utils (adobe#7686)

* attempt to get rid of jest calls in menu util

* update RSP testing docs to directly mention mocks that maybe needed

* bump versions of RTL to 16

* use alternative to calling jest run timers in menu option selection

* fixing types and properly testing long press

* fix lint

* revert to pre testing library bump for clean slate

* fix build and another submenu edge case

now we shouldnt need to call runAllTimers after selectOption

* fix react 16 bug

* update return type of advanceTimer and docs copy

* move some general fixes from selectionMode="replace" branch here

* get rid of unneeded async

* getting rid of extraneous dep

* fix lint

* chore: revert ts update (adobe#8060)

* fix: add static color to s2 notification badge (adobe#8055)

* fix: add static color to s2 notification badge

* make opaque

* updates

* use locale

* fix lint

---------

Co-authored-by: Robert Snow <[email protected]>

* chore: Latest translations (adobe#8036)

* Latest translations

* Translation correction

* Couple of translation corrections

* Remove å from Norwegian string

---------

Co-authored-by: Yihui Liao <[email protected]>

* fix: Relax Parcel version range in public plugins (adobe#8067)

* Disclosure button label size update to match new sizes from Specturm (adobe#8006)

Co-authored-by: Danni <[email protected]>

* chore: audit 3.41 (adobe#8064)

* chore: audit 3.41

* remove deprecation

* chore: audit 3.41 (adobe#8064)

* chore: audit 3.41

* remove deprecation

* chore: Update package dependencies for @react-aria/overlays and @react-aria-components

* Added @react-aria/ssr and updated @react-aria/overlays in @react-aria/overlays package.json
* Added @react-aria/overlays, @react-aria/ssr, and @react-aria/utils in @react-aria-components package.json

* chore: Update import paths and dependencies for @react-aria-nutrient

* Refactored import statements in various components and tests to use @react-aria-nutrient/overlays instead of @react-aria/overlays.
* Removed references to @react-aria/overlays from package.json and yarn.lock.
* Updated documentation links to reflect the new package structure.

* chore: Update import paths in TableTests to use @react-aria-nutrient

* Refactored import statements in TableTests.js to replace @react-aria with @react-aria-nutrient for live-announcer, utils, and focus modules.
* Ensured consistency with recent package structure changes.

* fix: Add missing newline at end of test files

* Ensured proper formatting by adding a newline at the end of Table.test.js and TestTableUtils.test.tsx files to comply with best practices.

---------

Co-authored-by: Daniel Lu <[email protected]>
Co-authored-by: Trevor Howell <[email protected]>
Co-authored-by: Robert Snow <[email protected]>
Co-authored-by: Devon Govett <[email protected]>
Co-authored-by: DarkstarXDD <[email protected]>
Co-authored-by: Robert Snow <[email protected]>
Co-authored-by: Reid Barber <[email protected]>
Co-authored-by: Yihui Liao <[email protected]>
Co-authored-by: Richard Geraghty <[email protected]>
Co-authored-by: Kyle Taborski <[email protected]>
Co-authored-by: Danni <[email protected]>
ritz078 added a commit to PSPDFKit-labs/react-spectrum that referenced this pull request Apr 10, 2025
* chore: Fix generated code sample for S2 TooltipTrigger docs (adobe#8000)

* Fix generated code sample for S2 TooltipTrigger docs

* review

* inlining

* fix: export SortDescriptor type from S2 (adobe#8030)

* chore: Deprecate UNSTABLE_portalContainer in favor for PortalProvider (adobe#7976)

* Initial refactor to tear out UNSTABLE_portalContainer in favor of the PortalContainer

* yarn.lock update

* switch to deprecating UNSTABLE_portalContainer

* prefer deprecated prop over context to make this a non-breaking change

* add rough docs

* updating copy to include explaination of UNSTABLE

* rename to UNSAFE_PortalProvider

* update copy and split out example

* use styles from RAC examples

---------

Co-authored-by: Robert Snow <[email protected]>

* feat: Add escapeKeyBehavior to GridList/ListBox/Menu/Table/Tree (adobe#7974)

* Add disallowClearAll to Menu/ListBox so Autocomplete in Popover can close without clearing selection

* add support for diallowClearAll to grid/tree/table

* make sure RSP components also surface disallowClearAll

* update api naming to escapeKeyBehavior

* skip 17 tests for build, investigate later

* review comments

* fix: useMove broken by NODE_ENV check (adobe#8046)

* fix: ColorWheel track click (adobe#8049)

* fix: minor typo in CalendarDate docs (adobe#8043)

* fix: minor typo in CalendarDate docs

* fix second example as well

---------

Co-authored-by: Robert Snow <[email protected]>

* fix: Updating collection when items change parents (adobe#8052)

* export Autocomplete from S2 (adobe#8050)

* chore: Optimize table test performance (adobe#8051)

* chore: Update typescript to 5.8 (adobe#7888)

* chore: update typescript to 5.8

* fix all the types for the upgrade

* fix numberfield styles

* fix: Apply touch-action by default in usePress (adobe#8047)

* fix: Apply touch-action by default in usePress

* fix test

---------

Co-authored-by: Daniel Lu <[email protected]>

* fix: set some better flex behaviour (adobe#8048)

* fix: Support React 19 and remove Jest reliance in test utils (adobe#7686)

* attempt to get rid of jest calls in menu util

* update RSP testing docs to directly mention mocks that maybe needed

* bump versions of RTL to 16

* use alternative to calling jest run timers in menu option selection

* fixing types and properly testing long press

* fix lint

* revert to pre testing library bump for clean slate

* fix build and another submenu edge case

now we shouldnt need to call runAllTimers after selectOption

* fix react 16 bug

* update return type of advanceTimer and docs copy

* move some general fixes from selectionMode="replace" branch here

* get rid of unneeded async

* getting rid of extraneous dep

* fix lint

* chore: revert ts update (adobe#8060)

* fix: add static color to s2 notification badge (adobe#8055)

* fix: add static color to s2 notification badge

* make opaque

* updates

* use locale

* fix lint

---------

Co-authored-by: Robert Snow <[email protected]>

* chore: Latest translations (adobe#8036)

* Latest translations

* Translation correction

* Couple of translation corrections

* Remove å from Norwegian string

---------

Co-authored-by: Yihui Liao <[email protected]>

* fix: Relax Parcel version range in public plugins (adobe#8067)

* Disclosure button label size update to match new sizes from Specturm (adobe#8006)

Co-authored-by: Danni <[email protected]>

* chore: audit 3.41 (adobe#8064)

* chore: audit 3.41

* remove deprecation

* chore: audit 3.41 (adobe#8064)

* chore: audit 3.41

* remove deprecation

* chore: Update package dependencies for @react-aria/overlays and @react-aria-components

* Added @react-aria/ssr and updated @react-aria/overlays in @react-aria/overlays package.json
* Added @react-aria/overlays, @react-aria/ssr, and @react-aria/utils in @react-aria-components package.json

* chore: Update import paths and dependencies for @react-aria-nutrient

* Refactored import statements in various components and tests to use @react-aria-nutrient/overlays instead of @react-aria/overlays.
* Removed references to @react-aria/overlays from package.json and yarn.lock.
* Updated documentation links to reflect the new package structure.

* chore: Update import paths in TableTests to use @react-aria-nutrient

* Refactored import statements in TableTests.js to replace @react-aria with @react-aria-nutrient for live-announcer, utils, and focus modules.
* Ensured consistency with recent package structure changes.

* fix: Add missing newline at end of test files

* Ensured proper formatting by adding a newline at the end of Table.test.js and TestTableUtils.test.tsx files to comply with best practices.

---------

Co-authored-by: Daniel Lu <[email protected]>
Co-authored-by: Trevor Howell <[email protected]>
Co-authored-by: Robert Snow <[email protected]>
Co-authored-by: Devon Govett <[email protected]>
Co-authored-by: DarkstarXDD <[email protected]>
Co-authored-by: Robert Snow <[email protected]>
Co-authored-by: Reid Barber <[email protected]>
Co-authored-by: Yihui Liao <[email protected]>
Co-authored-by: Richard Geraghty <[email protected]>
Co-authored-by: Kyle Taborski <[email protected]>
Co-authored-by: Danni <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants