Skip to content

test(deps): make suite pass on React 19 / MUI 9 / chai 6#56

Merged
leecalcote merged 3 commits intomasterfrom
chore/tests
May 4, 2026
Merged

test(deps): make suite pass on React 19 / MUI 9 / chai 6#56
leecalcote merged 3 commits intomasterfrom
chore/tests

Conversation

@leecalcote
Copy link
Copy Markdown
Member

Summary

  • Restore the React 17/18-shaped test surface that enzyme + react-shallow-renderer + the cfaester adapter still expect, layered on top of the upgraded React 19 runtime — __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED stub, hook-call → shallow-renderer dispatcher routing, fiber-walking findDOMNode, native-event-based Simulate (with input value-tracker reset + checkbox-via-click), and an Object.freeze skip for React elements so we can null _owner at creation.
  • Migrate two components whose APIs broke in the dep bump: TablePagination to MUI v9's slotProps.actions.{previousButton,nextButton} / slotProps.select, and TableToolbar from the dropped <ReactToPrint> / <PrintContextConsumer> pair to a useReactToPrint hook wrapper.
  • Override react-is to ^19.2.5 so the adapter's element check recognizes React 19's react.transitional.element symbol, and externalize runtime deps in rollup.config.js so peerDeps and @babel/runtime-corejs3/* subpaths stop tripping rollup's "Unresolved dependencies" warning.

Result: npm test → 234 passing, 0 failing. rollup -c → no unresolved-dependency warnings.

Test plan

  • npm test — full mocha suite passes (234 tests)
  • npx rollup -c — clean build, no "Unresolved dependencies" warning
  • CI green on this branch

The dep upgrade left the test stack split between two React eras: enzyme +
react-shallow-renderer + the cfaester adapter were built for the React 17/18
internals, while React 19 ships a different shared-internals shape, removed
findDOMNode and Simulate, and freezes elements with a fiber back-reference
that breaks circular-graph assertions.

Reconstruct the legacy surface from inside the test setup, migrate the two
components whose APIs broke, and externalize runtime deps in rollup so the
bundle stops warning about subpath imports it shouldn't be inlining.

- test/setup-mocha-env.js: stub `__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED`,
  route React.use* through the shallow renderer's dispatcher, polyfill
  findDOMNode by walking the fiber tree, rebuild Simulate as native event
  dispatch (with input-tracker reset and checkbox-via-click handling), and
  skip Object.freeze for React elements so `_owner` can be cleared at
  creation time.
- src/components/TablePagination.js: migrate `backIconButtonProps`/`nextIconButtonProps`/`SelectProps`
  to MUI v9's `slotProps.actions.{previousButton,nextButton}` / `slotProps.select`.
- src/components/TableToolbar.js: replace the dropped `<ReactToPrint>` /
  `<PrintContextConsumer>` pair with a `useReactToPrint` hook wrapper.
- rollup.config.js: derive externals from package.json so peerDeps and
  `@babel/runtime-corejs3/*` subpaths don't trigger "Unresolved dependencies".
- package.json: pin react-is to ^19.2.5 via overrides so the adapter's
  isElement check recognizes React 19's `react.transitional.element` symbol.

Signed-off-by: Lee Calcote <lee.calcote@layer5.io>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the repository to keep the existing Mocha + Enzyme test suite and build tooling working after upgrading to React 19, MUI v9, and Chai 6. This primarily does so by restoring legacy React test surfaces expected by the Enzyme React 18 adapter, and by adjusting a couple of component integrations for the newer MUI / react-to-print APIs.

Changes:

  • Extend test/setup-mocha-env.js with React 19 compatibility shims (internals stub, hook dispatch routing, Simulate, and findDOMNode polyfills) and adjust jsdom globals for Chai 6.
  • Update TableToolbar printing implementation to use useReactToPrint instead of the removed ReactToPrint/PrintContextConsumer components.
  • Update TablePagination to MUI v9 slotProps and adjust Rollup externals + npm overrides (react-is).

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
test/setup-mocha-env.js Adds React 19/Chai 6 shims for Enzyme + shallow rendering and DOM event simulation.
src/components/TableToolbar.js Migrates printing to useReactToPrint hook via a small wrapper component.
src/components/TablePagination.js Migrates MUI TablePagination props to the v9 slotProps API.
rollup.config.js Externalizes dependencies/peerDependencies (including subpath imports) to remove unresolved-dep warnings.
package.json Adds an npm overrides pin for react-is to align React 19 element symbol handling.
package-lock.json Lockfile updates reflecting dependency/override resolution changes.

Comment thread test/setup-mocha-env.js Outdated
Comment thread test/setup-mocha-env.js
- findDOMNode: walk the BFS queue with an index pointer instead of array shift
  so traversal stays O(n) on larger fiber trees.
- Simulate: map doubleClick -> dblclick (the actual DOM type) and route it
  through MouseEvent so onDoubleClick handlers fire.

Signed-off-by: Lee Calcote <lee.calcote@layer5.io>
@leecalcote
Copy link
Copy Markdown
Member Author

@copilot please re-review the latest changes.

@leecalcote leecalcote merged commit da5d7f4 into master May 4, 2026
1 check passed
@leecalcote leecalcote deleted the chore/tests branch May 4, 2026 03:26
Copilot stopped work on behalf of leecalcote due to an error May 4, 2026 03:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants