Skip to content

test(query-core/queriesObserver): add test for recalculating combined result when 'combine' function changes#10508

Merged
sukvvon merged 1 commit intomainfrom
test/query-core-queriesObserver-combine
Apr 16, 2026
Merged

test(query-core/queriesObserver): add test for recalculating combined result when 'combine' function changes#10508
sukvvon merged 1 commit intomainfrom
test/query-core-queriesObserver-combine

Conversation

@sukvvon
Copy link
Copy Markdown
Collaborator

@sukvvon sukvvon commented Apr 16, 2026

🎯 Changes

Add a test to verify that QueriesObserver recalculates the combined result when the combine function reference changes, instead of returning the cached result.

This covers the combine !== this.#lastCombine branch in #combineResult.

✅ 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 a test ensuring a single query observer recalculates combined results when the combine function changes. Verifies optimistic results update from the initial to the new combine logic (totals change accordingly), preventing reuse of prior derived values and ensuring correct recomputation behavior. Strengthens coverage for derived-result handling and cache-invalidation scenarios.

@nx-cloud
Copy link
Copy Markdown

nx-cloud bot commented Apr 16, 2026

View your CI Pipeline Execution ↗ for commit f4e9c9b

Command Status Duration Result
nx affected --targets=test:sherif,test:knip,tes... ✅ Succeeded 1m 26s View ↗

☁️ Nx Cloud last updated this comment at 2026-04-16 15:27:30 UTC

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 16, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 087269f7-9399-40a8-b172-1af409b8c991

📥 Commits

Reviewing files that changed from the base of the PR and between 9750ebb and f4e9c9b.

📒 Files selected for processing (1)
  • packages/query-core/src/__tests__/queriesObserver.test.tsx
✅ Files skipped from review due to trivial changes (1)
  • packages/query-core/src/tests/queriesObserver.test.tsx

📝 Walkthrough

Walkthrough

A new test verifies that a single QueriesObserver recomputes the combined optimistic result when the provided combine function changes, rather than reusing a previous combined computation.

Changes

Cohort / File(s) Summary
Test Case Addition
packages/query-core/src/__tests__/queriesObserver.test.tsx
Adds a test that constructs a QueriesObserver, computes getOptimisticResult(queries, combine1) and then computes getOptimisticResult(queries, combine2), asserting the combined result updates to reflect the new combine function.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐇 I hopped to the test with a twitchy whisker,

swapped the combine and watched numbers blister.
Old sums fell away, new totals took flight—
the Observer recomputed by morning light.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The pull request title clearly and concisely describes the main change: adding a test for recalculating combined results when the 'combine' function changes in QueriesObserver.
Description check ✅ Passed The pull request description is complete and well-structured, covering the changes made, the motivation, and addressing all required checklist items appropriately.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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-core-queriesObserver-combine

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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 16, 2026

🚀 Changeset Version Preview

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

@sukvvon sukvvon self-assigned this Apr 16, 2026
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 16, 2026

More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/preact-query

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

@tanstack/preact-query-devtools

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

@tanstack/preact-query-persist-client

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: f4e9c9b

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 16, 2026

size-limit report 📦

Path Size
react full 11.99 KB (0%)
react minimal 9.02 KB (0%)

@sukvvon sukvvon force-pushed the test/query-core-queriesObserver-combine branch from 9750ebb to f4e9c9b Compare April 16, 2026 15:19
@sukvvon sukvvon merged commit dbee9eb into main Apr 16, 2026
11 of 12 checks passed
@sukvvon sukvvon deleted the test/query-core-queriesObserver-combine branch April 16, 2026 15:34
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