test(query-devtools/Devtools): add tests for "Bulk Edit Data" mode switch, save, and invalid JSON#10687
Conversation
…itch, save, and invalid JSON
📝 WalkthroughWalkthroughThis pull request adds a new test suite to validate the "Bulk Edit Data" feature in Query Devtools. Three test cases verify that clicking "Bulk Edit Data" opens the JSON editor, that valid JSON submissions update query data in the QueryClient, and that invalid JSON submissions display an "Invalid Value" error in the UI. ChangesData Edit Test Coverage
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
View your CI Pipeline Execution ↗ for commit 120a0b6
☁️ Nx Cloud last updated this comment at |
🚀 Changeset Version PreviewNo changeset entries found. Merging this PR will not cause a version bump for any packages. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/query-devtools/src/__tests__/Devtools.test.tsx (1)
677-689: ⚡ Quick winAlso assert data is unchanged after invalid JSON submit.
On Line 688, you assert the error state, but not the cache invariant. Adding a cache assertion prevents regressions where invalid input still mutates query data.
Suggested test addition
fireEvent.submit(textarea.closest('form')!) expect(rendered.getByText('Invalid Value')).toBeInTheDocument() + expect(queryClient.getQueryData(['edit-invalid'])).toEqual({ name: 'a' })🤖 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/query-devtools/src/__tests__/Devtools.test.tsx` around lines 677 - 689, The test "should set an error state when the edited data is invalid JSON" currently asserts the error UI but not that the cache was left unchanged; after submitting the invalid JSON (when you call fireEvent.submit on textarea.closest('form') in that test), add an assertion that queryClient.getQueryData(['edit-invalid']) still equals the original object ({ name: 'a' }) to ensure the cache invariant is preserved—use the same query key ['edit-invalid'] and the existing queryClient variable in the test.
🤖 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/query-devtools/src/__tests__/Devtools.test.tsx`:
- Around line 677-689: The test "should set an error state when the edited data
is invalid JSON" currently asserts the error UI but not that the cache was left
unchanged; after submitting the invalid JSON (when you call fireEvent.submit on
textarea.closest('form') in that test), add an assertion that
queryClient.getQueryData(['edit-invalid']) still equals the original object ({
name: 'a' }) to ensure the cache invariant is preserved—use the same query key
['edit-invalid'] and the existing queryClient variable in the test.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 822e4ce9-a11d-42dc-b872-d0b82b02ae19
📒 Files selected for processing (1)
packages/query-devtools/src/__tests__/Devtools.test.tsx
size-limit report 📦
|
🎯 Changes
Add tests for the data editor in the query details panel of the
Devtoolsbody component.data edit—"Bulk Edit Data"flow:"Bulk Edit Data"is clicked."Invalid Value"when the form is submitted with invalid JSON.✅ Checklist
🚀 Release Impact
Summary by CodeRabbit