Skip to content

test: NonScalingOverlay + ReactNativeZoomableView test suite (274 tests, 29 suites)#179

Closed
thomasttvo wants to merge 1 commit into
thomas/nonscaling-overlayfrom
thomas/zoomable-tests
Closed

test: NonScalingOverlay + ReactNativeZoomableView test suite (274 tests, 29 suites)#179
thomasttvo wants to merge 1 commit into
thomas/nonscaling-overlayfrom
thomas/zoomable-tests

Conversation

@thomasttvo
Copy link
Copy Markdown
Collaborator

Summary

Adds a Jest + React Testing Library test suite covering NonScalingOverlay, renderOverlay integration, and the full SPECS.md contract for ReactNativeZoomableView. 274 tests across 29 suites, all green locally.

Targets thomas/nonscaling-overlay (PR #178) — when #178 merges to master, this PR's base auto-updates and the tests come along.

Test coverage

  • 14 EC-NSO edge cases from PR Reanimated #151's review (translated from prose into regression tests).
  • 151 SPEC items from SPECS.md (with documented device-only and type-only gaps).
  • PR Reanimated #151 thread regressions: doubleTapZoomToCenter math (#3179084848), spurious-tap on cancel (#3179193006), settle double-fire (#3164939942), pinProps spread (#3107340687 / #3179480336), useLatestWorklet stale closure (#3179033549 / #3238350220), and others.

Suite breakdown

Suite Tests Surface
computeOverlayTransform.test.ts 9 Pure transform-math helper
NonScalingOverlay.test.tsx 9 Overlay component (RTL + reanimated mock)
renderOverlay.test.tsx 6 RNZV.renderOverlay integration
helper/__tests__/* (9 files) 51 Pure math helpers + 4 new extractions
RNZV.{props,imperativeHandle,callbacks}.test.tsx 57 Defaults, methods, callbacks (no gesture)
RNZV.{staticPin,feedback}.test.tsx + useLatestWorklet.test.ts 25 Static pin, debug, hook ref identity
treeShape.test.tsx + StaticPin.styling.test.tsx 17 Tree topology + StaticPin pointerEvents/styling
gestures/* (5 files) 82 Direct gesture-handler invocation via getByGestureTestId('canvas-gesture') (tap, double-tap, long-press, pinch, shift, multi-finger, pan-responder callbacks, intercept)

Test infrastructure (commit e76d21f)

  • Jest 29, @testing-library/react-native@^12.5.0, react-test-renderer@18.3.1, babel-jest, @types/jest.
  • jest.setup.ts wires react-native-reanimated/mock + react-native-gesture-handler/jestSetup.
  • Custom RNGH Gesture.Manual() mock with a withTestId registry (Path 2 from research) so gesture-driven tests can invoke onTouchesDown/Move/Up/Cancelled directly under reanimated/mock.
  • New CI step in .github/workflows/lint.yml: yarn test --ci --runInBand.

Pure-helper extractions (non-behavior-changing)

4 inline expressions in ReactNativeZoomableView.tsx extracted to src/helper/ for unit-testability — math is byte-equivalent to the inline original:

  • calcShiftDelta (from _calcOffsetShiftSinceLastGestureState)
  • applyPinchSensitivity (from _handlePinching resistance math)
  • clampZoom (pinch-frame clamp; publicZoomTo's reject-on-out-of-range was left untouched — different semantics)
  • shouldSkipShift (pan-gate predicate)

SPECS.md changes

  • New section ## NonScalingOverlay contract codifying the prop shape, 5-element transform formula, static-style rules, mount-order rules, and wrapperSize mirror semantics.

Known gaps (documented in phase5-specs-research.md §5)

  • Device-only items: GHRV mount requirement, FP-drift bypass of disablePanOnInitialZoom, native momentum absence, dual-version Reanimated matrix (Elliott's #3691782346).
  • Type-only SPECs covered by tsc --noEmit in CI (no expect-type/tsd dep added).
  • Mock-fidelity caveats: assertions are on JS-thread callback fires rather than intermediate SharedValue trajectories; withTiming/cancelAnimation/runOnUI are no-ops under the mock.

Test plan

  • Reviewer runs yarn test locally and confirms 29 suites / 274 tests pass.
  • CI's Run unit tests step passes on push.
  • Spot-check a few it('SPEC-NNN: …', …) cases to confirm SPEC IDs map to the items in SPECS.md.

🤖 Generated with Claude Code

Empty marker commit so this branch diverges from its base
`thomas/nonscaling-overlay` (which received a revert commit removing
these tests). The substantive test changes are in the 16 commits
prior to this one (e76d21f..563d90a).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@cursor
Copy link
Copy Markdown

cursor Bot commented May 14, 2026

PR Summary

Low Risk
Primarily adds unit/integration tests and Jest infrastructure; the only runtime-impactful changes appear to be small helper extractions for testability, which are low risk but could subtly affect gesture math if not truly equivalent.

Overview
Adds a comprehensive Jest + React Testing Library test suite covering NonScalingOverlay, renderOverlay integration, gesture flows, and the documented SPECS.md contract for ReactNativeZoomableView.

Introduces supporting test infrastructure (Jest config/setup and gesture-handler/reanimated mocking) and extracts a few inline math/predicate helpers into src/helper/ to make the behavior unit-testable without intended runtime behavior changes.

Reviewed by Cursor Bugbot for commit 270d5fc. Configure here.

@thomasttvo
Copy link
Copy Markdown
Collaborator Author

Superseded by PR for thomas/zoomable-tests-v2 — original branch had merge-base issue making the diff empty in GitHub's view. Replacement PR rooted at b8a6df6 so the diff displays correctly.

@thomasttvo thomasttvo closed this May 14, 2026
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