Skip to content

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

Merged
sukvvon merged 2 commits intomainfrom
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 intomainfrom
test/angular-query-inject-queries-isRestoring

Conversation

@sukvvon
Copy link
Copy Markdown
Collaborator

@sukvvon sukvvon commented Apr 20, 2026

🎯 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
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 20, 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: 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 fetchStatus idle, 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 name Status Explanation
Title check ✅ Passed The 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 ✅ Passed The 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 ✅ 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/angular-query-inject-queries-isRestoring

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

@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented Apr 20, 2026

View your CI Pipeline Execution ↗ for commit 4b1d9dc

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

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

@sukvvon sukvvon self-assigned this Apr 20, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 20, 2026

🚀 Changeset Version Preview

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

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 20, 2026

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
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 20, 2026

size-limit report 📦

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

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/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 main Apr 20, 2026
8 checks passed
@sukvvon sukvvon deleted the test/angular-query-inject-queries-isRestoring branch April 20, 2026 11:48
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