Skip to content

test(preact-query): replace hardcoded query keys with 'queryKey()' utility#10419

Merged
sukvvon merged 1 commit intomainfrom
test/preact-query-replace-hardcoded-keys-with-queryKey
Apr 7, 2026
Merged

test(preact-query): replace hardcoded query keys with 'queryKey()' utility#10419
sukvvon merged 1 commit intomainfrom
test/preact-query-replace-hardcoded-keys-with-queryKey

Conversation

@sukvvon
Copy link
Copy Markdown
Collaborator

@sukvvon sukvvon commented Apr 7, 2026

🎯 Changes

  • Replace hardcoded query/mutation keys with queryKey() utility from @tanstack/query-test-utils across preact-query test files
  • Applied to runtime tests (.test.tsx) and type tests (.test-d.tsx)

✅ 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
    • Updated test infrastructure to use standardized query key generation utilities across the test suite, improving test consistency and maintainability without affecting end-user functionality.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 7, 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: 9099b0c9-fa3d-4acf-b17e-8db43cf15063

📥 Commits

Reviewing files that changed from the base of the PR and between 4335fce and 25495e6.

📒 Files selected for processing (19)
  • packages/preact-query/src/__tests__/HydrationBoundary.test.tsx
  • packages/preact-query/src/__tests__/infiniteQueryOptions.test-d.tsx
  • packages/preact-query/src/__tests__/infiniteQueryOptions.test.tsx
  • packages/preact-query/src/__tests__/mutationOptions.test-d.tsx
  • packages/preact-query/src/__tests__/mutationOptions.test.tsx
  • packages/preact-query/src/__tests__/queryOptions.test-d.tsx
  • packages/preact-query/src/__tests__/ssr-hydration.test.tsx
  • packages/preact-query/src/__tests__/suspense.test.tsx
  • packages/preact-query/src/__tests__/useInfiniteQuery.test-d.tsx
  • packages/preact-query/src/__tests__/useMutationState.test.tsx
  • packages/preact-query/src/__tests__/usePrefetchInfiniteQuery.test-d.tsx
  • packages/preact-query/src/__tests__/usePrefetchQuery.test-d.tsx
  • packages/preact-query/src/__tests__/useQueries.test-d.tsx
  • packages/preact-query/src/__tests__/useQueries.test.tsx
  • packages/preact-query/src/__tests__/useQuery.test-d.tsx
  • packages/preact-query/src/__tests__/useQuery.test.tsx
  • packages/preact-query/src/__tests__/useSuspenseInfiniteQuery.test-d.tsx
  • packages/preact-query/src/__tests__/useSuspenseQueries.test-d.tsx
  • packages/preact-query/src/__tests__/useSuspenseQuery.test-d.tsx

📝 Walkthrough

Walkthrough

This PR systematically replaces hard-coded query and mutation key array literals (e.g., ['key'], ['string']) with calls to the queryKey() helper from @tanstack/query-test-utils across 18 test files in the preact-query package. Imports, fixture setup, and key references are updated consistently.

Changes

Cohort / File(s) Summary
Type-level tests
infiniteQueryOptions.test-d.tsx, mutationOptions.test-d.tsx, queryOptions.test-d.tsx, useInfiniteQuery.test-d.tsx, usePrefetchInfiniteQuery.test-d.tsx, usePrefetchQuery.test-d.tsx, useQueries.test-d.tsx, useQuery.test-d.tsx, useSuspenseInfiniteQuery.test-d.tsx, useSuspenseQueries.test-d.tsx, useSuspenseQuery.test-d.tsx
Replaced hard-coded queryKey array literals with queryKey() calls from test utils; updated type assertions and variable destructuring accordingly.
Runtime hydration and suspension tests
HydrationBoundary.test.tsx, ssr-hydration.test.tsx, suspense.test.tsx
Introduced shared query-key constants generated by queryKey() at describe scope; replaced inline array literals across prefetching, hydration, and suspension test flows.
Runtime mutation and query option tests
infiniteQueryOptions.test.tsx, mutationOptions.test.tsx, useQuery.test.tsx, useMutationState.test.tsx
Updated mutation and query key references to use queryKey()-generated values; adjusted filter comparisons and key assertions to reference generated constants.
Runtime multi-query tests
useQueries.test.tsx
Changed queryOptions and dynamic query key assignments to use stable queryKey() values instead of inline array literals per render cycle.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Suggested labels

package: preact-query

Poem

🐰 Query keys now dance in the test-light,
No more hard-coded arrays to fight,
The helper returns them fresh and bright,
Each test runs true, each assertion tight,
Preact-query hops to new height!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: replacing hardcoded query keys with a queryKey() utility across test files.
Description check ✅ Passed The description follows the template structure with Changes and Checklist sections completed; however, local test confirmation (pnpm run test:pr) is not checked despite being recommended.

✏️ 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/preact-query-replace-hardcoded-keys-with-queryKey

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

@nx-cloud
Copy link
Copy Markdown

nx-cloud bot commented Apr 7, 2026

View your CI Pipeline Execution ↗ for commit 25495e6

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

☁️ Nx Cloud last updated this comment at 2026-04-07 05:18:02 UTC

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 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 7, 2026

More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/preact-query

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

@tanstack/preact-query-devtools

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

@tanstack/preact-query-persist-client

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: 25495e6

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

size-limit report 📦

Path Size
react full 11.98 KB (0%)
react minimal 9.01 KB (0%)

@sukvvon sukvvon self-assigned this Apr 7, 2026
@sukvvon sukvvon marked this pull request as draft April 7, 2026 05:20
@sukvvon sukvvon marked this pull request as ready for review April 7, 2026 06:38
@sukvvon sukvvon merged commit 389bbca into main Apr 7, 2026
10 checks passed
@sukvvon sukvvon deleted the test/preact-query-replace-hardcoded-keys-with-queryKey branch April 7, 2026 06:38
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