Skip to content

test(query-devtools/Devtools): add tests for "Bulk Edit Data" mode switch, save, and invalid JSON#10687

Merged
sukvvon merged 1 commit into
mainfrom
test/query-devtools-devtools-data-edit
May 10, 2026
Merged

test(query-devtools/Devtools): add tests for "Bulk Edit Data" mode switch, save, and invalid JSON#10687
sukvvon merged 1 commit into
mainfrom
test/query-devtools-devtools-data-edit

Conversation

@sukvvon
Copy link
Copy Markdown
Collaborator

@sukvvon sukvvon commented May 10, 2026

🎯 Changes

Add tests for the data editor in the query details panel of the Devtools body component.

data edit"Bulk Edit Data" flow:

  • Switches to the data editor when "Bulk Edit Data" is clicked.
  • Saves the edited data to the query cache when the form is submitted with valid JSON.
  • Sets an error state and renders "Invalid Value" when the form is submitted with invalid JSON.

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with `pnpm run test:pr`.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

Summary by CodeRabbit

  • Tests
    • Added comprehensive test coverage for the Devtools bulk data editing functionality, including validation of JSON editor operations and error handling for invalid input.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 10, 2026

📝 Walkthrough

Walkthrough

This 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.

Changes

Data Edit Test Coverage

Layer / File(s) Summary
Test Suite
packages/query-devtools/src/__tests__/Devtools.test.tsx
Adds a describe('data edit') block with three tests: opening the bulk JSON editor from a query row, saving valid edited JSON to update query data, and displaying an "Invalid Value" error when submitting invalid JSON.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 Three tests hop into view,
JSON editors and edits so true,
Valid data flows bright,
Errors caught just right—
The bulk edit suite's all complete! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and specifically describes the main changes: adding tests for the 'Bulk Edit Data' feature covering mode switching, data saving, and invalid JSON handling.
Description check ✅ Passed The description follows the required template structure with all sections completed: Changes section details the test coverage, Checklist items are marked appropriately, and Release Impact correctly indicates this is dev-only with no changeset needed.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/query-devtools-devtools-data-edit

Comment @coderabbitai help to get the list of available commands and usage tips.

@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented May 10, 2026

View your CI Pipeline Execution ↗ for commit 120a0b6

Command Status Duration Result
nx affected --targets=test:sherif,test:knip,tes... ✅ Succeeded 2m 52s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2026-05-10 16:26:03 UTC

@sukvvon sukvvon self-assigned this May 10, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

No changeset entries found. Merging this PR will not cause a version bump for any packages.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/query-devtools/src/__tests__/Devtools.test.tsx (1)

677-689: ⚡ Quick win

Also 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

📥 Commits

Reviewing files that changed from the base of the PR and between 4746ac4 and 120a0b6.

📒 Files selected for processing (1)
  • packages/query-devtools/src/__tests__/Devtools.test.tsx

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 10, 2026

More templates

@tanstack/angular-query-experimental

npm i https://pkg.pr.new/@tanstack/angular-query-experimental@10687

@tanstack/eslint-plugin-query

npm i https://pkg.pr.new/@tanstack/eslint-plugin-query@10687

@tanstack/lit-query

npm i https://pkg.pr.new/@tanstack/lit-query@10687

@tanstack/preact-query

npm i https://pkg.pr.new/@tanstack/preact-query@10687

@tanstack/preact-query-devtools

npm i https://pkg.pr.new/@tanstack/preact-query-devtools@10687

@tanstack/preact-query-persist-client

npm i https://pkg.pr.new/@tanstack/preact-query-persist-client@10687

@tanstack/query-async-storage-persister

npm i https://pkg.pr.new/@tanstack/query-async-storage-persister@10687

@tanstack/query-broadcast-client-experimental

npm i https://pkg.pr.new/@tanstack/query-broadcast-client-experimental@10687

@tanstack/query-core

npm i https://pkg.pr.new/@tanstack/query-core@10687

@tanstack/query-devtools

npm i https://pkg.pr.new/@tanstack/query-devtools@10687

@tanstack/query-persist-client-core

npm i https://pkg.pr.new/@tanstack/query-persist-client-core@10687

@tanstack/query-sync-storage-persister

npm i https://pkg.pr.new/@tanstack/query-sync-storage-persister@10687

@tanstack/react-query

npm i https://pkg.pr.new/@tanstack/react-query@10687

@tanstack/react-query-devtools

npm i https://pkg.pr.new/@tanstack/react-query-devtools@10687

@tanstack/react-query-next-experimental

npm i https://pkg.pr.new/@tanstack/react-query-next-experimental@10687

@tanstack/react-query-persist-client

npm i https://pkg.pr.new/@tanstack/react-query-persist-client@10687

@tanstack/solid-query

npm i https://pkg.pr.new/@tanstack/solid-query@10687

@tanstack/solid-query-devtools

npm i https://pkg.pr.new/@tanstack/solid-query-devtools@10687

@tanstack/solid-query-persist-client

npm i https://pkg.pr.new/@tanstack/solid-query-persist-client@10687

@tanstack/svelte-query

npm i https://pkg.pr.new/@tanstack/svelte-query@10687

@tanstack/svelte-query-devtools

npm i https://pkg.pr.new/@tanstack/svelte-query-devtools@10687

@tanstack/svelte-query-persist-client

npm i https://pkg.pr.new/@tanstack/svelte-query-persist-client@10687

@tanstack/vue-query

npm i https://pkg.pr.new/@tanstack/vue-query@10687

@tanstack/vue-query-devtools

npm i https://pkg.pr.new/@tanstack/vue-query-devtools@10687

commit: 120a0b6

@github-actions
Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
react full 12.1 KB (0%)
react minimal 9.07 KB (0%)

@sukvvon sukvvon merged commit f24d1a3 into main May 10, 2026
10 checks passed
@sukvvon sukvvon deleted the test/query-devtools-devtools-data-edit branch May 10, 2026 16:40
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.

1 participant