test(preact-query-devtools/PreactQueryDevtools): add tests for forwarding option changes after mount#11020
Conversation
|
View your CI Pipeline Execution ↗ for commit 89e038f
☁️ Nx Cloud last updated this comment at |
📝 WalkthroughWalkthroughThis PR adds five new test cases to PreactQueryDevtools.test.tsx that verify prop updates after component mount are propagated to the underlying TanstackQueryDevtools instance, checking that rerendering with new buttonPosition, position, initialIsOpen, errorTypes, and theme values triggers the corresponding setter methods. ChangesDevtools Prop Rerender Test Coverage
Estimated code review effort: 1 (Trivial) | ~5 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
🚀 Changeset Version PreviewNo changeset entries found. Merging this PR will not cause a version bump for any packages. |
…ding option changes after mount
89e038f to
09ab6fc
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/preact-query-devtools/src/__tests__/PreactQueryDevtools.test.tsx (1)
185-263: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider parameterizing these near-identical tests.
All five tests follow the same render → mockClear → rerender → assert pattern, differing only in prop name, values, and mock. A
test.eachtable could reduce duplication while keeping the same coverage. Purely optional since the current form is clear and readable.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/preact-query-devtools/src/__tests__/PreactQueryDevtools.test.tsx` around lines 185 - 263, The five tests in PreactQueryDevtools.test.tsx are duplicating the same render, mockClear, rerender, and assertion flow for different props. Refactor the repeated cases around PreactQueryDevtools into a single parameterized test using test.each, with a table covering buttonPosition, position, initialIsOpen, errorTypes, and theme, while still asserting the corresponding setter mock receives the updated value after rerender.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@packages/preact-query-devtools/src/__tests__/PreactQueryDevtools.test.tsx`:
- Around line 185-263: The five tests in PreactQueryDevtools.test.tsx are
duplicating the same render, mockClear, rerender, and assertion flow for
different props. Refactor the repeated cases around PreactQueryDevtools into a
single parameterized test using test.each, with a table covering buttonPosition,
position, initialIsOpen, errorTypes, and theme, while still asserting the
corresponding setter mock receives the updated value after rerender.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: f54ea7bc-555d-43f1-bacb-6bd9a77b8103
📒 Files selected for processing (1)
packages/preact-query-devtools/src/__tests__/PreactQueryDevtools.test.tsx
size-limit report 📦
|
🎯 Changes
Adds regression tests verifying that
PreactQueryDevtoolsforwards option changes to the underlying devtools instance after mount, not just on the initial render.The existing tests only cover the initial forwarding of options. Each option is wired through its own
useEffectwith a dependency array (e.g.[position, devtools]), so if a dependency is accidentally dropped, the option would silently stop being re-forwarded on update — a case the initial-render tests cannot catch.The new tests use
rerenderto change each prop after mount and assert the corresponding setter is called again:buttonPositionpositioninitialIsOpenerrorTypestheme✅ Checklist
pnpm run test:pr.🚀 Release Impact
Summary by CodeRabbit