Skip to content

test(svelte-query): replace hardcoded query keys with 'queryKey()' utility#10415

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

test(svelte-query): replace hardcoded query keys with 'queryKey()' utility#10415
sukvvon merged 1 commit intomainfrom
test/svelte-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 svelte-query test files
  • Applied to runtime tests (.svelte.test.ts) and type tests (.test-d.ts)
  • Files modified: createQuery.svelte.test.ts, createQuery.test-d.ts, createQueries.svelte.test.ts, createQueries.test-d.ts, queryOptions.test-d.ts, infiniteQueryOptions.test-d.ts, mutationOptions.svelte.test.ts, mutationOptions.test-d.ts, useMutationState.svelte.test.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
    • Updated test infrastructure to use standardized query and mutation key generation utilities across test suites for improved consistency and maintainability.

@nx-cloud
Copy link
Copy Markdown

nx-cloud bot commented Apr 7, 2026

View your CI Pipeline Execution ↗ for commit d9206c3

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

☁️ Nx Cloud last updated this comment at 2026-04-07 01:40:33 UTC

@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: 1d93cbd6-0850-4831-853d-4f0d6f8460b1

📥 Commits

Reviewing files that changed from the base of the PR and between f3d3eea and d9206c3.

📒 Files selected for processing (9)
  • packages/svelte-query/tests/createQueries/createQueries.svelte.test.ts
  • packages/svelte-query/tests/createQueries/createQueries.test-d.ts
  • packages/svelte-query/tests/createQuery.svelte.test.ts
  • packages/svelte-query/tests/createQuery.test-d.ts
  • packages/svelte-query/tests/infiniteQueryOptions.test-d.ts
  • packages/svelte-query/tests/mutationOptions/mutationOptions.svelte.test.ts
  • packages/svelte-query/tests/mutationOptions/mutationOptions.test-d.ts
  • packages/svelte-query/tests/queryOptions.test-d.ts
  • packages/svelte-query/tests/useMutationState/useMutationState.svelte.test.ts

📝 Walkthrough

Walkthrough

Query and mutation key generation across nine test files in the svelte-query package is refactored to use queryKey() from @tanstack/query-test-utils instead of hardcoded array literals, ensuring consistent key generation patterns throughout the test suite.

Changes

Cohort / File(s) Summary
createQueries tests
packages/svelte-query/tests/createQueries/createQueries.svelte.test.ts, packages/svelte-query/tests/createQueries/createQueries.test-d.ts
Added queryKey import and replaced hardcoded query key array literals with dynamically generated keys via queryKey() in test cases.
createQuery tests
packages/svelte-query/tests/createQuery.svelte.test.ts, packages/svelte-query/tests/createQuery.test-d.ts
Updated to import queryKey() and replace hardcoded keys with const key = queryKey(). Adjusted composite keys using spread composition (e.g., [...key, count]) when combining generated keys with other values.
infiniteQueryOptions tests
packages/svelte-query/tests/infiniteQueryOptions.test-d.ts
Imported queryKey() and replaced inline ['key'] literals with locally scoped const key = queryKey() in type-level assertions.
mutationOptions tests
packages/svelte-query/tests/mutationOptions/mutationOptions.svelte.test.ts, packages/svelte-query/tests/mutationOptions/mutationOptions.test-d.ts
Added queryKey() import and systematically replaced hardcoded mutationKey array literals with generated keys across callback type inference, variable inference, and filtering scenarios.
queryOptions tests
packages/svelte-query/tests/queryOptions.test-d.ts
Refactored to generate keys via queryKey() and destructure returned tagged queryKeys. Updated downstream operations (QueryClient.getQueryData, setQueryData, QueriesObserver) to use tagged keys instead of original literals.
useMutationState tests
packages/svelte-query/tests/useMutationState/useMutationState.svelte.test.ts
Replaced hardcoded mutation key literals with dynamically generated successKey, errorKey, and mutationKey variables in filter inputs and mutation options.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 Keys were hardcoded, now they hop and play,
Utility functions dance in a structured way,
Nine test files sing in harmonious refrain,
Query and mutation keys—no more in vain,
Consistency blooms across the test terrain! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: replacing hardcoded query keys with the 'queryKey()' utility across svelte-query test files.
Description check ✅ Passed The description follows the template structure with completed 'Changes' section listing affected files, and checklist items addressed with appropriate selections for dev-only changes.
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/svelte-query-replace-hardcoded-keys-with-queryKey

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

@tanstack/eslint-plugin-query

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

@tanstack/preact-query

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

@tanstack/preact-query-devtools

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

@tanstack/preact-query-persist-client

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: d9206c3

@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%)

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