Skip to content

test(virtual-core): split index.test.ts into topic files - #1328

Merged
piecyk merged 1 commit into
TanStack:mainfrom
piecyk:test/split-core-tests
Oct 15, 2026
Merged

piecyk merged 1 commit into
TanStack:mainfrom
piecyk:test/split-core-tests

Conversation

@piecyk

@piecyk piecyk commented Oct 15, 2026 •

Copy link
Copy Markdown
Collaborator

🎯 Changes

packages/virtual-core/tests/index.test.ts had grown to ~7000 lines with ~230 flat tests. This PR moves the tests into one file per topic. Test bodies and names are unchanged.

 packages/virtual-core/tests/
-├── index.test.ts            # 6985 lines, everything
+├── index.test.ts            # exports, lanes, setOptions, takeSnapshot
+├── scroll-commands.test.ts  # scrollToIndex/Offset/By, reconcile, cancelScroll, read-backs
+├── measurement.test.ts      # resizeItem, measure(), ResizeObserver cache + batching
+├── range.test.ts            # defaultRangeExtractor, lazy fast path
+├── ios-deferral.test.ts     # iOS deferred corrections, touch phases, Phase 2a/2b, #1250
+├── ios-fling-wait.test.ts   # iOS 27 commands that wait for a fling tail
+├── adjustment.test.ts       # scroll-up jank, self-write direction latch, #1218
+├── anchor-end.test.ts       # anchorTo end, followOnAppend, #1229, #1258
+├── dom-observers.test.ts    # elementScroll/windowScroll, observeElement/WindowOffset
+├── helpers.ts               # helpers used by more than one file
 ├── ios-gesture.test.ts      # (unchanged)
 ├── prepend-hold.test.ts     # (unchanged)
 └── ...
  • Each top-level block (test, helper, section comment) moved whole, by line range.
  • Only 3 helpers are used by more than one file and move to helpers.ts with export: withFakeIOSUserAgent, makeDeferralHarness, makeMockScrollElement. All other helpers stay next to their tests.

Evidence

  • Before: vitest on main → 408 tests, 407 passed, 1 skipped.
    After: vitest on this branch → 408 tests, 407 passed, 1 skipped. The set of (fullName, status) pairs is identical.
  • Every non-blank line of the old file appears exactly once in the new files. The only edit is the export keyword on the 3 shared helpers.
  • A type check that includes tests/ gives the same error count before and after (the existing errors come from loose test mocks; tests/ is not part of test:types).

Merge Danger

Door: two-way

Tests only. A revert restores the single file.

Blast Radius: open-PRs

No published code changes. Open PRs that edit index.test.ts will conflict and need a rebase that moves their new tests into the matching topic file:

✅ 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).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Expanded coverage for virtualized list scrolling, including scroll adjustments, anchoring, end-follow behavior, and scroll commands.
    • Added tests for iOS touch and fling behavior, measurement updates, range extraction, DOM observers, and cleanup.

index.test.ts had grown to ~7000 lines with ~230 flat tests. Move the
tests into one file per topic, without changing any test:

- scroll-commands: scrollToIndex/Offset/By, reconcile, cancelScroll, read-backs
- measurement: resizeItem, measure(), ResizeObserver cache and batching
- range: defaultRangeExtractor and the lazy fast path
- ios-deferral: iOS deferred corrections, touch phases, Phase 2a/2b, TanStack#1250
- ios-fling-wait: iOS 27 commands that wait for a fling tail
- adjustment: scroll-up jank, self-write direction latch, TanStack#1218
- anchor-end: anchorTo end, followOnAppend, TanStack#1229, TanStack#1258
- dom-observers: elementScroll/windowScroll, observeElement/WindowOffset
- index: exports, lanes, setOptions, takeSnapshot

Helpers used by more than one file move to tests/helpers.ts; the others
stay next to their tests. Test bodies and names are unchanged; vitest
reports the same 408 tests before and after.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Oct 15, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 7b77c3e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai

coderabbitai Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0a9c4e94-e7b9-4215-9290-5b346c5c022d
📥 Commits

Reviewing files that changed from the base of the PR and between 77cb05e and 7b77c3e.

📒 Files selected for processing: 10
  • packages/virtual-core/tests/adjustment.test.ts
  • packages/virtual-core/tests/anchor-end.test.ts
  • packages/virtual-core/tests/dom-observers.test.ts
  • packages/virtual-core/tests/helpers.ts
  • packages/virtual-core/tests/index.test.ts
  • packages/virtual-core/tests/ios-deferral.test.ts
  • packages/virtual-core/tests/ios-fling-wait.test.ts
  • packages/virtual-core/tests/measurement.test.ts
  • packages/virtual-core/tests/range.test.ts
  • packages/virtual-core/tests/scroll-commands.test.ts

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

📝 Walkthrough

This pull request adds virtual-core tests for measurement, scroll adjustment and commands, end anchoring, DOM observers, and iOS touch and fling handling.

Changes: Virtualizer behavior coverage

Layer / File(s) Summary
Measurement and range access
packages/virtual-core/tests/measurement.test.ts, packages/virtual-core/tests/range.test.ts
Tests cover measurement cache updates, ResizeObserver behavior, lazy measurements, and range extraction.
DOM scroll observers
packages/virtual-core/tests/dom-observers.test.ts
Tests cover scroll calls and offsets, listener cleanup, and virtualizer scroll-state resets.
Scroll adjustment behavior
packages/virtual-core/tests/adjustment.test.ts
Tests cover adjustment direction, read-backs, notification timing, and measurements of viewport-spanning items.
Scroll command reconciliation
packages/virtual-core/tests/scroll-commands.test.ts
Tests cover command targets, reconciliation and cancellation, end alignment, measurement changes, and scroll-element replacement.
End anchoring and append behavior
packages/virtual-core/tests/anchor-end.test.ts
Tests cover reading-anchor preservation, append following, end-distance calculations, and retries for clamped anchor writes.
iOS scroll deferral and fling handling
packages/virtual-core/tests/helpers.ts, packages/virtual-core/tests/ios-deferral.test.ts, packages/virtual-core/tests/ios-fling-wait.test.ts
Helpers and tests cover deferred corrections, touch and momentum states, queued index commands, fling outcomes, and cleanup.

Priority: ⬇️ Low

Estimated code review effort: 4 (Complex) | ~60 minutes

Change: Other

Merge Risk: ⚪ Minimal · up to 7b77c

This change only reorganizes the virtual-core test suite into topic-based files, with no change to library code or published behavior. It carries no meaningful merge risk.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 72.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 25 functions across 9 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: splitting the monolithic virtual-core test file into topic-specific files.
Description check Passed The description explains the scope, motivation, file organization, validation results, merge impact, checklist, and release impact. The checklist boxes remain unchecked, but the required information i…
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.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

packages/virtual-core/tests/adjustment.test.ts

Parsing error: "parserOptions.project" has been provided for @typescript-eslint/parser.
The file was not found in any of the provided project(s): packages/virtual-core/tests/adjustment.test.ts

packages/virtual-core/tests/anchor-end.test.ts

Parsing error: "parserOptions.project" has been provided for @typescript-eslint/parser.
The file was not found in any of the provided project(s): packages/virtual-core/tests/anchor-end.test.ts

packages/virtual-core/tests/dom-observers.test.ts

Parsing error: "parserOptions.project" has been provided for @typescript-eslint/parser.
The file was not found in any of the provided project(s): packages/virtual-core/tests/dom-observers.test.ts

  • 6 others

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.

@nx-cloud

nx-cloud Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 7b77c3e

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

☁️ Nx Cloud last updated this comment at 2026-10-15 06:47:57 UTC

@pkg-pr-new

pkg-pr-new Bot commented Oct 15, 2026

Copy link
Copy Markdown
More templates

@tanstack/angular-virtual

npm i https://pkg.pr.new/@tanstack/angular-virtual@1328

@tanstack/lit-virtual

npm i https://pkg.pr.new/@tanstack/lit-virtual@1328

@tanstack/marko-virtual

npm i https://pkg.pr.new/@tanstack/marko-virtual@1328

@tanstack/react-virtual

npm i https://pkg.pr.new/@tanstack/react-virtual@1328

@tanstack/solid-virtual

npm i https://pkg.pr.new/@tanstack/solid-virtual@1328

@tanstack/svelte-virtual

npm i https://pkg.pr.new/@tanstack/svelte-virtual@1328

@tanstack/virtual-core

npm i https://pkg.pr.new/@tanstack/virtual-core@1328

@tanstack/vue-virtual

npm i https://pkg.pr.new/@tanstack/vue-virtual@1328

commit: 7b77c3e

@piecyk
piecyk merged commit 16c786a into TanStack:main Oct 15, 2026
10 checks passed
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