Repository navigation
test(website): keep one framer-motion mock component per tag - #30681
Conversation
Most frontend test files mock framer-motion with a motion Proxy whose getter calls make(tag) on every read. Each read returns a new React.forwardRef component, so every render gives React a new element type, and React unmounts and remounts that subtree with fresh DOM nodes. A test holding a node from before a re-render then acts on a detached element, which surfaces as a CI-only flake. Wrap the getter in each of the 99 remaining files with a per-file Map so a tag always yields the same component. Each file keeps its own make(), since they strip different props. ChatSidebar.resumeAll is left to its own in-flight fix and is tolerated by the guard in either state. Add a guard that scans website/src and fails, naming the file and line, when a framer-motion mock's motion Proxy getter builds a component per read without caching it. Fixes #30679 Refs #30081
First Principles Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: this changes only tests, removes nothing, and fixes the actual cause (a new component type on every proxy read). A source scan guards the whole tree against the pattern coming back. Notes
[DESIGN-REVIEWED] 4b9ada9 Description read[DESCRIPTION-READ] 5fce57090c92b487c0115cce76e54f2946c965d79b7cc8ec556f496f90723019 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
UX Review (Opus 5.5) — ✅ PASSUX-level review of UX-Verdict: PASS Nothing to check: the diff only changes test files and adds no user-visible control. [UX-REVIEWED] 4b9ada9 Description read[DESCRIPTION-READ] fea42acb907e443dc84caf63db02bf537aed942032d7954513662c1e7d834582 That sha256 names everything this verdict read: the PR description, plus the 3 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
bolichen97
left a comment
There was a problem hiding this comment.
Approving 4b9ada9. I read every file.
- All 100 changed files are under
website/src/test/. In 99 of them theframer-motionmock'smotionProxy getter now caches one component per tag in aMap(byTag) instead of building a new component type on every read, which remounted the subtree and left tests holding detached nodes. I folded the changed lines across the files and checked them: every file makes the same edit, in one of two shapes (multi-line or inlineget). - The new
framerMotionMockStableTags.test.tsscanswebsite/srcand fails, naming the file, when a mock's getter does not cache per tag. It skips its own fixtures andChatSidebar.resumeAll.test.tsx, which #30633 fixes separately. - Test files only, no product code. The new scan uses regex, but it is a test file, so it is out of scope for the no-regex rule.
All checks pass on this head; only numbered Backend test shards and PR Readiness are pending. Auto-merge was already enabled by the author, so I left it as is.
🤖 Kiro Crew Auto-Pipeline [operator: buluoray]:
Problem / Motivation
Goal: Stop 99 frontend test files from remounting their framer-motion subtrees on every render, and fail CI when a new file reintroduces that mock shape.
These files mock
framer-motionwithconst motion = new Proxy({}, { get: (_t, tag: string) => make(tag) }), andmake()returns a newReact.forwardRef(...)on each call (origin/main @ 34e8a26,website/src/test/ChatSidebar.arrowNav.test.tsx:26-37). Eachmotion.divread is a new component type, so every render makes React unmount and remount that subtree with fresh DOM nodes. A test holding a node from before a re-render then acts on a detached element. That already produced the #30081 flake (fixed in one file by #30633) and the earlier #28905 flake (fixed in one file by #29255).Why it matters
Every one of these files can flake the same way whenever a re-render lands between a query and the action that uses its result. On a loaded CI shard that is a matter of timing, so the failures show up as red shards on unrelated PRs, and each one has so far been fixed one file at a time.
Not a goal
make()strips or renders. The files differ there and each keeps its own.website/src/test/ChatSidebar.resumeAll.test.tsx, which test(chat-sidebar): keep one motion component per tag in resume-all mock #30633 owns. test(chat-sidebar): keep one motion component per tag in resume-all mock #30633 can merge before or after this PR: the guard tolerates that file in either state.What changed (motivation → approach → change)
motionProxy getter returns a new component type per read, so React remounts the subtree on every render.Map, so a tag always yields the same component, matching the shape test(chat-sidebar): keep one motion component per tag in resume-all mock #30633 uses and the files that already cached (ChatSidebar.animCap.test.tsx,ChatSidebar.laneScrollMemory.test.tsx). Across all 99 files the only removed lines are the 99 old getter lines; the added lines are theMapdeclaration, a one-line comment, and the cached getter (104 hunks: 93 standard getters, 6 inlinemotion: new Proxy(...)getters, each with theMapdeclared just above itsreturn {).ChatSidebar.slotRenameFocus.test.tsxalready caches inside itsmake(), so it is unchanged.website/src/test/framerMotionMockStableTags.test.tswalkswebsite/src, and for every file mentioningframer-motionfinds eachmotionProxy. It fails withsrc/<file>:<line>unless the getter checks.has(<key>)itself, or delegates to a function defined earlier in the file that does. A first test pins that rule on inline snippets (uncached standard, inline and direct-forwardRefgetters are flagged; a cached getter and a cachingmake()pass).Backwards compatibility
Compatible: only test files change; no production code, config or public API is touched.
Removes nothing: the diff only adds a cache around existing test mocks and a new test.
Tests
website/src/test/framerMotionMockStableTags.test.ts(2 tests): the rule on fixtures, and the whole-tree scan.ChatSidebar.arrowNav.test.tsxturns the scan red withsrc/test/ChatSidebar.arrowNav.test.tsx:39; restoring the file turns it green again.--maxWorkers 4: 100 files passed, 1238 tests passed, 0 failed. The same 99 files on origin/main @ 34e8a26: 99 files and 1236 tests passed, so no test relied on the remounting.arrowNavwent from 160 to 12 andcloseRefusedfrom 57 to 13.hideStatusFilter(2) andmodelFilter(1) were unchanged.renameFailureRecoveryemitted 1 in the batch, but 0 in three solo runs on this branch and three on origin/main, so it is timing-dependent under load.npx tsc -p tsconfig.app.json: 0 errors (it excludes tests). A scratch tsconfig covering the 99 changed test files gave the same 266 pre-existing errors on this branch and on origin/main; the guard file has 0.scripts/check_file_line_cap.py: 0 failures.ChatSidebar.conductorLane.test.tsxgoes from 1750 to 1757 lines; it was already past 1,600 on main.Proof: not provable -- test-only change
Manual verification
N/A — test-only change; the vitest runs and the mutation above cover it.
Screenshots / video
N/A — only test files change, and
pr-policy.ymlexcludeswebsite/src/**/*.test.ts(x)andwebsite/src/test/**from the screenshot watch.Related Issues
Fixes #30679
Refs #30081, #30633, #28905, #29255
#30633 owns
ChatSidebar.resumeAll.test.tsxand should merge first or independently; neither order reds the other.Sibling sweep
Swept: a node scan of every
website/srcfile containingframer-motionformotionProxy getters with no.has(<key>)cache, then a check of each file'smake()for its own cacheSibling: website/src/test/ChatSidebar.resumeAll.test.tsx -- tracked in #30633
Sibling: website/src/test/ChatSidebar.slotRenameFocus.test.tsx -- not affected -- its make() caches one component per tag already
Pattern harvest
Rule candidate: lint
Pattern: a framer-motion mock whose motion Proxy getter builds a new component on every read (now enforced by framerMotionMockStableTags.test.ts)
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.