test(studio): characterization suites for resize commit and razor history#2201
Conversation
853b5b0 to
af9f377
Compare
ff02d68 to
3c08ade
Compare
af9f377 to
fc4382f
Compare
3c08ade to
ae82816
Compare
miga-heygen
left a comment
There was a problem hiding this comment.
Reviewed as part of the 25-PR NLE overhaul stack. Full stack review on #2205 (the keystone). No blockers on this PR. — Miga
vanceingalls
left a comment
There was a problem hiding this comment.
🟠 Request changes — useRazorSplit.history.test.tsx is genuine characterization and lands 🟢; anchoredResizeReleaseShift.test.ts is 2/3 aspirational math theater that cannot regress on real code changes.
useRazorSplit.history.test.tsx — 🟢 legit characterization.
Both branches (plain HTML + GSAP rewrite) mount the real useRazorSplit hook, exercise handleRazorSplit under act, and assert (i) the split reached disk via the mocked fetch layer that faithfully mirrors /api/projects/:id/file-mutations/split-element/ and /api/projects/:id/gsap-mutations/, (ii) snapshot().undoLabel === "Split timeline clip", (iii) an undo via undoViaDisk restores the exact pre-split bytes. If the production hook drops the history entry, uses a different label, or fails to route through the persistent edit history store, the test fails. Faithful.
Two small callouts, non-blocking:
- The GSAP-branch fixture (
SPLIT_GSAP, line 271-275) writestl.set("#clip1-split",{x:0},2)— a static synthetic timeline. The server-mirror mock at line 297-306 hardcodes the response toSPLIT_GSAPregardless of what the hook actually asks for. This pins the "endpoint gets called + response gets applied" contract, not "the server produces this exact rewrite given this input" (which is a studio-server concern, correctly out of scope here). expected: finalContent(line 356) uses the fixture as the equality target — meaning the test pins that studio's fetch pipeline round-trips the server response to disk verbatim. Legit contract for a client-side hook test.
anchoredResizeReleaseShift.test.ts — 🟠 aspirational, does not pin production behavior.
Tests 1 (line 97 "the per-frame center anchor converges") and 2 (line 139 "the center stays fixed for every corner at any rotation") both simulate an N-frame anchor loop using a test-file-local helper accumulateResizeAnchor (line 50-60). That helper doesn't wrap or import any production symbol — it re-implements the fix's math inline. The tests then assert that this local math converges.
I grepped the repo for the fix's key state (lastResizeAnchor, accumulateResizeAnchor) at this PR's head SHA — zero hits in production code. The docstring at lines 39-41 says "Fix (useDomEditOverlayGestures pointermove, resize branch, fa4f39168)" — that SHA doesn't resolve in the repo history, and useDomEditOverlayGestures.ts at this SHA has no resize-branch anchor accumulator (grep shows only one line 384 unrelated).
Consequence: these two tests will pass whether the production resize gesture converges, oscillates, or is deleted entirely — because they never call into it. As a regression tripwire for the "later glue-swap PRs must keep these green" claim in the PR body, tests 1 and 2 are false safety. Two possible fixes:
- Preferred. Import the actual production accumulator from
useDomEditOverlayGesturesand drive the loop through it — even if that means factoring the per-frame anchor step out to a namedcomputeNextResizeAnchor(prev, fixedStart, centerNow)helper that the gesture hook calls. That's the "leaf helper" pattern this stack uses everywhere else (see #2192). - If the production fix hasn't landed yet in this stack: delete tests 1 and 2 from this PR and re-add them in the same PR that lands
lastResizeAnchoron the hook, so they're tied to real code from the start. Landing aspirational tests ahead of the production fix creates the exact false-safety window the PR body's "regression tripwires" framing is designed to prevent.
Test 3 (line 182 "net translate after persist+reload equals the committed anchor offset (non-GSAP)") does import real production symbols (applyStudioBoxSize, applyStudioPathOffset, readStudioBoxSize, reapplyPositionEditsAfterSeek, createManualOffsetDragMember, applyManualOffsetDragCommit, buildBoxSizePatches, buildPathOffsetPatches), asserts the committed anchor offset survives the persist→reload chain end-to-end, and would fail if any of those functions drifts. Keep test 3 as-is.
Ask. Either (a) rewire tests 1+2 to drive the loop through the production accumulator this PR body says exists, or (b) drop tests 1+2 and land them alongside the fix in a later PR. Either is fine — the current state ships fabric that looks like characterization but isn't.
R1 by Via
ae82816 to
bd0c221
Compare
fc4382f to
8e77fb1
Compare
|
Fixed — you were right that tests 1–2 proved nothing about production: the accumulate math only lands with the gesture code in #2211, so a test-local helper here was false safety. Taken your option composite: tests 1–2 are removed from this PR (test 3, which imports the real persist symbols, stays), and #2211 now extracts the per-frame anchor step into a named production helper ( |
8e77fb1 to
ba28195
Compare
bd0c221 to
b372711
Compare
ba28195 to
ab2e3db
Compare
b372711 to
267d84c
Compare
…tory What: two test-only suites pinning CURRENT behavior before the NLE swap: anchoredResizeReleaseShift.test.ts (manual-offset resize release commits) and useRazorSplit.history.test.tsx (razor split undo/redo history). Why: regression tripwires — the later glue-swap PRs must keep these green. How: test files only; they import existing main modules unchanged and pass against them as-is. Test plan: bunx vitest run on both suites; fallow audit clean.
ab2e3db to
b88fb09
Compare
267d84c to
34fba38
Compare

What
two test-only suites pinning CURRENT behavior before the NLE swap: anchoredResizeReleaseShift.test.ts (manual-offset resize release commits) and useRazorSplit.history.test.tsx (razor split undo/redo history).
Why
regression tripwires — the later glue-swap PRs must keep these green.
How
test files only; they import existing main modules unchanged and pass against them as-is.
Test plan
bunx vitest run on both suites; fallow audit clean.
Stack position 10/25 — studio NLE overhaul (CapCut-parity timeline + canvas). Graphite manages bases; merge from #2192 upward. Temporary
TEMP(studio-dnd)fallow entries (unwired-component windows) are all removed by #2213 (app-shell swap), whose tree is byte-identical to the fully-verified integration branch.