Skip to content

test(angular-query-experimental/injectQueries): add test for not fetching when 'isRestoring' is true - #10526

Merged
sukvvon merged 2 commits into
mainfrom
test/angular-query-inject-queries-isRestoring
Apr 20, 2026
Merged

test(angular-query-experimental/injectQueries): add test for not fetching when 'isRestoring' is true#10526
sukvvon merged 2 commits into
mainfrom
test/angular-query-inject-queries-isRestoring

Conversation

@sukvvon

@sukvvonsukvvon commented Apr 20, 2026

Copy link
Copy Markdown
Member

🎯 Changes

Add a test verifying that injectQueries does not fetch during the restoring period when isRestoring is true, matching the existing pattern in injectQuery tests.

This covers the isRestoring() ? () => undefined : ... branch in inject-queries.ts.

✅ 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
    • Enhanced test coverage for restoration state: added test setup support for an "is restoring" signal and new tests confirming queries remain pending, do not run their fetch functions, and preserve idle/fetch statuses while restoration is active, preventing premature execution during restore.

@coderabbitai

coderabbitaiBot commented Apr 20, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7c2312cb-d5b5-4ba1-9f3d-b312ddbc795d

📥 Commits

Reviewing files that changed from the base of the PR and between e629c60 and 4b1d9dc.

📒 Files selected for processing (1)
  • packages/angular-query-experimental/src/__tests__/inject-queries.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/angular-query-experimental/src/tests/inject-queries.test.ts

📝 Walkthrough

Walkthrough

Added a test to the Angular Query experimental suite that verifies injectQueries does not start fetches while an isRestoring signal is true; both queries remain pending with fetchStatusidle, data() undefined, and their queryFn mocks are not called.

Changes

Cohort / File(s)Summary
Angular Query Test Suite
packages/angular-query-experimental/src/__tests__/inject-queries.test.ts
Extended test setup to provide isRestoring signal and added a new injectQueries test asserting queries remain pending/idle and queryFns are not executed while restoring.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Possibly related PRs

Poem

🐰 A quiet hop, a test in spring,
Restoring hushes every wing,
Queries wait, no calls to make,
Idle hearts for restoration's sake,
I nibble logs and softly sing.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check nameStatusExplanation
Title check✅ PassedThe title clearly and specifically summarizes the main change: adding a test for the injectQueries function to verify it doesn't fetch when isRestoring is true.
Description check✅ PassedThe description includes all required sections from the template with complete information: clear explanation of changes, fully completed checklist with appropriate items marked, and release impact assessment.
Docstring Coverage✅ PassedNo 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/angular-query-inject-queries-isRestoring

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

@nx-cloud

nx-cloudBot commented Apr 20, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 4b1d9dc

CommandStatusDurationResult
nx affected --targets=test:sherif,test:knip,tes...✅ Succeeded1m 45sView ↗
nx run-many --target=build --exclude=examples/*...✅ Succeeded<1sView ↗

☁️ Nx Cloud last updated this comment at 2026-04-20 11:45:23 UTC

@sukvvonsukvvon self-assigned this Apr 20, 2026
@github-actions

github-actionsBot commented Apr 20, 2026

Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

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

@pkg-pr-new

pkg-pr-newBot commented Apr 20, 2026

Copy link
Copy Markdown
More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/preact-query

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

@tanstack/preact-query-devtools

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

@tanstack/preact-query-persist-client

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: 4b1d9dc

@github-actions

github-actionsBot commented Apr 20, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

PathSize
react full11.99 KB (0%)
react minimal9.02 KB (0%)

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/angular-query-experimental/src/__tests__/inject-queries.test.ts (1)

88-89: Optional: use async/await for side-effectful queryFn mocks for readability.

Non-blocking, but this can make intent a bit clearer when call counts are part of the assertion logic.

♻️ Suggested refactor
- const queryFn1 = vi.fn().mockImplementation(() => sleep(10).then(() => 1))- const queryFn2 = vi.fn().mockImplementation(() => sleep(10).then(() => 2))+ const queryFn1 = vi.fn().mockImplementation(async () => {+ await sleep(10)+ return 1+ })+ const queryFn2 = vi.fn().mockImplementation(async () => {+ await sleep(10)+ return 2+ })

Based on learnings: In TanStack/query test files, when a queryFn contains side effects (e.g., setting flags for test verification), prefer async/await syntax for clarity; when there are no side effects, prefer the .then() pattern for conciseness.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@packages/angular-query-experimental/src/__tests__/inject-queries.test.ts`
around lines 88 - 89, Replace the .then() mock implementations with explicit
async/await functions for readability: update the vi.fn().mockImplementation for
queryFn1 and queryFn2 to use async () => { await sleep(10); return <value>; } so
side-effectful behavior and call counts are clearer (refer to queryFn1,
queryFn2, and sleep).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@packages/angular-query-experimental/src/__tests__/inject-queries.test.ts`:
- Around line 88-89: Replace the .then() mock implementations with explicit
async/await functions for readability: update the vi.fn().mockImplementation for
queryFn1 and queryFn2 to use async () => { await sleep(10); return <value>; } so
side-effectful behavior and call counts are clearer (refer to queryFn1,
queryFn2, and sleep).

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ea124edd-037f-461c-97a2-dd047a20345c

📥 Commits

Reviewing files that changed from the base of the PR and between 599e51d and e629c60.

📒 Files selected for processing (1)
  • packages/angular-query-experimental/src/__tests__/inject-queries.test.ts

…est in 'describe' block for consistency with 'inject-query.test.ts'
@sukvvon
sukvvon merged commit 799952f into mainApr 20, 2026
8 checks passed
@sukvvon
sukvvon deleted the test/angular-query-inject-queries-isRestoring branch April 20, 2026 11:48
Ephem pushed a commit to Ephem/react-query that referenced this pull request Apr 23, 2026
…hing when 'isRestoring' is true (TanStack#10526)
* test(angular-query-experimental/injectQueries): add test for not fetching when 'isRestoring' is true
* test(angular-query-experimental/inject-queries): wrap 'isRestoring' test in 'describe' block for consistency with 'inject-query.test.ts'
Sign up for freeto 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

@sukvvon