Skip to content

test(angular-query-persist-client/withPersistQueryClient): move 'effect' into 'constructor' to follow Angular convention#10538

Merged
sukvvon merged 1 commit intomainfrom
test/angular-query-persist-client-effect-in-constructor
Apr 20, 2026
Merged

test(angular-query-persist-client/withPersistQueryClient): move 'effect' into 'constructor' to follow Angular convention#10538
sukvvon merged 1 commit intomainfrom
test/angular-query-persist-client-effect-in-constructor

Conversation

@sukvvon
Copy link
Copy Markdown
Collaborator

@sukvvon sukvvon commented Apr 20, 2026

🎯 Changes

Refactors the three effect() calls in with-persist-query-client.test.ts from the class-field assignment (_ = effect(...)) pattern into an explicit constructor() body, matching the convention used in our own Angular documentation.

Before

class Page {
  state = injectQuery(() => ({ /* ... */ }))

  _ = effect(() => {
    states.push({ /* ... */ })
  })
}

After

class Page {
  state = injectQuery(() => ({ /* ... */ }))

  constructor() {
    effect(() => {
      states.push({ /* ... */ })
    })
  }
}

Why

The Angular official signals guide explicitly calls out the constructor as the recommended place to register an effect:

"The easiest way to satisfy this requirement is to call effect within a component, directive, or service constructor"
Angular signals guide

The same pattern is already used in our own guide at docs/framework/angular/guides/paginated-queries.md, so moving the tests to match keeps the codebase internally consistent.

This mirrors the same refactor applied to inject-queries.test.ts in #10537.

Verification

  • @tanstack/angular-query-persist-client — 5 tests passed, 1 todo, 0 type errors

✅ 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
    • Improved test implementation patterns in the query persist client test suite to enhance code clarity and maintainability.

…ct' into 'constructor' to follow Angular convention
@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: 2fcb30f0-c162-494a-b46f-cbc2dbdd69b7

📥 Commits

Reviewing files that changed from the base of the PR and between e3ecdc5 and f7f3215.

📒 Files selected for processing (1)
  • packages/angular-query-persist-client/src/__tests__/with-persist-query-client.test.ts

📝 Walkthrough

Walkthrough

The pull request refactors test code in the withPersistQueryClient test suite, replacing the pattern of assigning effect calls to unused variables with explicit constructor definitions that call effect(). The test logic and assertions remain unchanged.

Changes

Cohort / File(s) Summary
Test Component Refactoring
packages/angular-query-persist-client/src/__tests__/with-persist-query-client.test.ts
Updated three test cases (restores cache from persister, should show initialData while restoring, should not refetch after restoring when data is fresh) to move reactive effect initialization from class-field assignments (_ = effect(...)) into explicit constructor() methods. State tracking logic remains unchanged.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐰 Effects in fields? No more, my friend,
Constructors now their home shall be—
A cleaner test, from start to end,
Angular's reactive harmony!
Refactor hops, both small and spry. ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: moving 'effect' into 'constructor' to follow Angular convention in test files.
Description check ✅ Passed The description comprehensively covers changes, motivation, before/after code, reasoning with official Angular guide reference, and all checklist items are completed.
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-persist-client-effect-in-constructor

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 f7f3215

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

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

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

@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@10538

@tanstack/eslint-plugin-query

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

@tanstack/preact-query

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

@tanstack/preact-query-devtools

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

@tanstack/preact-query-persist-client

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: f7f3215

@github-actions
Copy link
Copy Markdown
Contributor

size-limit report 📦

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

@sukvvon sukvvon self-assigned this Apr 20, 2026
@sukvvon sukvvon merged commit 646f04e into main Apr 20, 2026
10 checks passed
@sukvvon sukvvon deleted the test/angular-query-persist-client-effect-in-constructor branch April 20, 2026 17:53
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