Skip to content
Source
Sign inSign up
TanStack/virtual

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

Mergedpiecykmerged 1 commit intomain fromrefs/pull/1328/headmerged by piecyk

piecykcommented

🎯 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.
    1. ⚠️ No Changeset found

      Latest commit: 7b77c3e49662b09f8fd157c4b8837296602e9c4a

      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

    2. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      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 77cb05eef131699bcef0f0a5877b60503e54a366 and 7b77c3e49662b09f8fd157c4b8837296602e9c4a.

      📒 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 nameStatusExplanationResolution
      Docstring CoverageWarningDocstring 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 nameStatusExplanation
      Title checkPassedThe title clearly and concisely describes the main change: splitting the monolithic virtual-core test file into topic-specific files.
      Description checkPassedThe 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 checkPassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes checkPassedCheck 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.
    3. nx-cloud[bot](GitHub profile, opens in a new tab)commented

      View your CI Pipeline Execution ↗ for commit 7b77c3e49662b09f8fd157c4b8837296602e9c4a

      CommandStatusDurationResult
      nx affected --targets=test:sherif,test:knip,tes...✅ Succeeded4m 15sView ↗
      nx run-many --target=build --exclude=examples/**✅ Succeeded20sView ↗

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

    4. 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

    5. piecyk merged this16c786a

    6. piecyk closed this

Sign in to join this conversation.