Skip to content

test(react-grab): cover freeze pause/resume for non-useState hooks - #499

Closed
aidenybai wants to merge 2 commits into
mainfrom
test/freeze-hooks-coverage
Closed

test(react-grab): cover freeze pause/resume for non-useState hooks#499
aidenybai wants to merge 2 commits into
mainfrom
test/freeze-hooks-coverage

Conversation

@aidenybai

@aidenybai aidenybai commented Jun 28, 2026

Copy link
Copy Markdown
Owner

Summary

  • The freeze coverage gap was the real one: freeze-updates.ts (the "inherently fragile" React-internals module) was only exercised via useState, leaving useReducer/useTransition/useSyncExternalStore hook-queue pausing and the entire context-dependency pause/resume block (lines 237–296) at 0%.
  • Adds a FreezeHookHarness to the Vite fixture (useReducer, useTransition, useSyncExternalStore, and a useContext provider/consumer), each bumped by a handler that bypasses useState.
  • Adds freeze-hooks.spec.ts (5 tests) asserting each counter is held frozen during prompt-mode freeze and resumes normal updates after unfreeze.

Scoped to just the freeze specs, freeze-updates.ts moved from 55.67% → 61.94% lines (with the context-dependency paths now executing); higher across the full suite.

Notes

  • The slider-drag and 0% inlined-util "gaps" turned out to be Solid-JSX/sourcemap remapping artifacts (e.g. handleTrackPointerUp shows hits while handleTrackPointerDown shows 0 — impossible in a real drag), so no tests were added there and coverage config was left untouched rather than gamed.

Test plan

  • freeze-hooks.spec.ts — 5/5 pass
  • Full Playwright suite — 754 passed
  • pnpm typecheck clean
  • pnpm lint — 0 warnings / 0 errors

Note

Low Risk
Test-only changes to the e2e app and Playwright specs; no production freeze or runtime logic is modified.

Overview
Adds e2e coverage for react-grab’s page-freeze behavior on React hooks beyond useState, which existing freeze-updates tests did not exercise (including context-dependency pause/resume in freeze-updates.ts).

A new FreezeHookHarness on the Vite fixture exposes counters driven by useReducer, useTransition, useSyncExternalStore, and a context consumer. freeze-hooks.spec.ts (five cases) enters prompt-mode freeze, bumps each counter via synthetic clicks (overlay-safe), asserts values stay fixed while frozen, then checks updates resume after unfreeze; one test asserts all four counters stay frozen in a single freeze cycle.

Reviewed by Cursor Bugbot for commit 198e9c8. Bugbot is set up for automated code reviews on this repo. Configure here.


Summary by cubic

Adds a FreezeHookHarness to the Vite E2E app and 5 tests covering freeze pause/resume for non-useState hooks (useReducer, useTransition, useSyncExternalStore, and context). This exercises hook-queue and context-dependency paths in freeze-updates.ts, raising freeze spec line coverage from 55.67% to 61.94%.

  • Refactors
    • Extracted harness into its own module and wired into the app; relocated the external-store singleton.
    • Stabilized tests with settle waits, synthetic DOM clicks to bypass the overlay, and a guard for missing nodes; narrowed the combined test to assert simultaneity.

Written for commit 198e9c8. Summary will update on new commits.

Review in cubic

Adds a FreezeHookHarness fixture (useReducer, useTransition,
useSyncExternalStore, and a context consumer/provider) plus a
freeze-hooks spec asserting each counter holds frozen during prompt-mode
freeze and resumes normal updates after unfreeze. This drives the
freeze-updates.ts pause/resume paths the useState-only freeze-updates
spec never reached, notably context-dependency pause/resume.
@vercel

vercel Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
react-grab-storybook Ready Ready Preview, Comment Jun 28, 2026 9:36am
react-grab-website Ready Ready Preview, Comment Jun 28, 2026 9:36am

@pkg-pr-new

pkg-pr-new Bot commented Jun 28, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@react-grab/cli@499
npm i https://pkg.pr.new/grab@499
npm i https://pkg.pr.new/react-grab@499

commit: 198e9c8

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Re-trigger cubic

…tle waits

- Move FreezeHookHarness into its own module (mirrors PerfGrid), keeping
  App.tsx a composition root and relocating the external-store singleton.
- Correct the misleading "bypasses useState" comments (transition/context
  counters update via useState) and document the synthetic-click quirk.
- Add settle waits so the freeze-hold assertion can catch a leaked update
  and the post-unfreeze baseline is stable; guard readCount against a
  missing node; narrow the combined test to the simultaneity claim.
@aidenybai

Copy link
Copy Markdown
Owner Author

Superseded by #510, which consolidates all the test-coverage PRs into one. Commits preserved there.

@aidenybai aidenybai closed this Jun 29, 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