Skip to content

test(lit-query/createInfiniteQueryController): add tests for cancelling the query function when disconnected and for replacing 'skipToken' - #11761

Merged
sukvvon merged 1 commit into
mainfrom
test/lit-query-create-infinite-query-controller-disconnect-and-skip-token
Sep 30, 2026
Merged

sukvvon merged 1 commit into
mainfrom
test/lit-query-create-infinite-query-controller-disconnect-and-skip-token

Conversation

@sukvvon

@sukvvon sukvvon commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

🎯 Changes

Adds two tests to createInfiniteQueryController.test.ts:

  • should cancel the query function when there are no more subscriptions: while the first page is still loading, removing the host aborts the query function's signal.
  • should not fetch when queryFn is skipToken, and fetch once it is replaced: with a function for options, queryFn is skipToken until the reactive postId property is set. The query doesn't fetch before that, then fetches the first page once.

Both render the result in the host and assert it with toHaveTextContent.

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested code changes locally with pnpm run test:pr, or these tests do not apply to this pull request.
  • I have followed the AI contribution policy and fully understand the code in this pull request, including any code generated with AI assistance.

🚀 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
    • Added coverage confirming that removing a subscribed host triggers query cancellation.
    • Added coverage confirming that a skipped infinite query waits to fetch until its query function becomes available.

@sukvvon sukvvon self-assigned this Sep 30, 2026
@nx-cloud

nx-cloud Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 30c7f76

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

☁️ Nx Cloud last updated this comment at 2026-09-30 18:21:29 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

pkg-pr-new Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/lit-query

npm i https://pkg.pr.new/@tanstack/lit-query@11761

@tanstack/preact-query

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

@tanstack/preact-query-devtools

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

@tanstack/preact-query-persist-client

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: 30c7f76

@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
react full 11.73 KB (0%)
react minimal 8.58 KB (0%)

@coderabbitai

coderabbitai Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: TanStack/query/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: db8ddd46-afee-4eda-861b-c4344cd3fdf4

📥 Commits

Reviewing files that changed from the base of the PR and between 14de993 and 30c7f76.

📒 Files selected for processing (1)
  • packages/lit-query/src/__tests__/createInfiniteQueryController.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The change adds two tests for the Lit infinite query controller. One checks abort-listener invocation after host removal. The other checks query execution and rendered page data after postId is set.

Changes

Infinite query controller test coverage

Layer / File(s) Summary
Cancellation and skipToken test cases
packages/lit-query/src/__tests__/createInfiniteQueryController.test.ts
Adds a test that expects host removal to invoke the query’s abort listener. Adds a test that expects the query function to run and rendered pages to update after postId is set. Imports skipToken and Vitest’s Mock type.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Other

Merge Risk: ⚪ Minimal · up to 30c7f

This change adds test coverage for query cancellation on host removal and for activation after a skipToken is replaced. It does not change runtime behavior, and no merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the two test cases added for query cancellation after disconnection and replacing skipToken. It is specific and related to the main changes, although it is somewhat long…
Description check ✅ Passed The description includes the required Changes, Checklist, and Release Impact sections. It explains both tests, records local testing, confirms AI policy compliance, and correctly marks the change as d…
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

…ng the query function when disconnected and for replacing 'skipToken'
@sukvvon
sukvvon force-pushed the test/lit-query-create-infinite-query-controller-disconnect-and-skip-token branch from 14de993 to 30c7f76 Compare September 30, 2026 18:17
@sukvvon
sukvvon merged commit e09f07e into main Sep 30, 2026
9 checks passed
@sukvvon
sukvvon deleted the test/lit-query-create-infinite-query-controller-disconnect-and-skip-token branch September 30, 2026 18:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant