Skip to content

test({react,preact}-query/usePrefetchInfiniteQuery): inline single-use helpers and adopt the 'pageParam' mock convention#11079

Merged
sukvvon merged 1 commit into
mainfrom
test/inline-helpers-pageparam-convention
Jul 18, 2026
Merged

test({react,preact}-query/usePrefetchInfiniteQuery): inline single-use helpers and adopt the 'pageParam' mock convention#11079
sukvvon merged 1 commit into
mainfrom
test/inline-helpers-pageparam-convention

Conversation

@sukvvon

@sukvvon sukvvon commented Jul 18, 2026

Copy link
Copy Markdown
Member

🎯 Changes

Inlines the createFallback factory (called only twice) directly at each call site, and rewrites generateInfiniteQueryOptions — a stateful closure-based page mock — to use the pageParam-driven queryFn/getNextPageParam convention already used by useInfiniteQuery.test.tsx, removing the shared helper entirely. Applies to both react-query and preact-query.

The should not create an endless loop when using inside a suspense boundary test's getNextPageParam always reports another page available (never returns undefined), preserving the original's perpetual-hasNextPage semantics that make toHaveBeenCalledTimes(3) a meaningful guard against runaway auto-advancing. The other two tests terminate pagination at 3 pages, matching their originals.

✅ 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
    • Simplified infinite-query test scenarios with inline pagination options.
    • Updated page rendering assertions to reflect the current string-based page data format.
    • Improved mock query setup and cleanup across standard and suspense-related test cases.

…e helpers and adopt the 'pageParam' mock convention
@nx-cloud

nx-cloud Bot commented Jul 18, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit da1f81d

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

☁️ Nx Cloud last updated this comment at 2026-07-18 12:39:00 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.

@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e6415e8c-9d73-498f-9493-7131657d5a65

📥 Commits

Reviewing files that changed from the base of the PR and between 10770f0 and da1f81d.

📒 Files selected for processing (2)
  • packages/preact-query/src/__tests__/usePrefetchInfiniteQuery.test.tsx
  • packages/react-query/src/__tests__/usePrefetchInfiniteQuery.test.tsx

📝 Walkthrough

Walkthrough

The Preact and React usePrefetchInfiniteQuery tests replace shared object-page helpers with inline query options that return string pages. Assertions render pages directly, mock cleanup is simplified, and suspense loop coverage retains updated pagination behavior.

Changes

Infinite query test refactor

Layer / File(s) Summary
Preact inline query options
packages/preact-query/src/__tests__/usePrefetchInfiniteQuery.test.tsx
Tests define string-page query functions and pagination inline, render pages directly, simplify mock handling, and update the suspense loop guard.
React inline query options
packages/react-query/src/__tests__/usePrefetchInfiniteQuery.test.tsx
Tests replace shared helpers with inline string-page options, use initialPageParam: 0, simplify mock cleanup, and render pages directly.

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

Possibly related PRs

  • TanStack/query#11078: Refactors overlapping usePrefetchInfiniteQuery tests to use inline query and page-rendering logic.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the test-only refactor and the switch to pageParam-driven mocks.
Description check ✅ Passed The description follows the template and covers changes, checklist items, and release impact.
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
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/inline-helpers-pageparam-convention

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

@sukvvon sukvvon self-assigned this Jul 18, 2026
@pkg-pr-new

pkg-pr-new Bot commented Jul 18, 2026

Copy link
Copy Markdown
More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/lit-query

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

@tanstack/preact-query

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

@tanstack/preact-query-devtools

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

@tanstack/preact-query-persist-client

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: da1f81d

@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
react full 12.13 KB (0%)
react minimal 9.08 KB (0%)

@sukvvon
sukvvon merged commit 99690d1 into main Jul 18, 2026
9 checks passed
@sukvvon
sukvvon deleted the test/inline-helpers-pageparam-convention branch July 18, 2026 12:43
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