Production-ready animations, transitions, backgrounds, and scenes for Remotion
command-menu — verification tests
Pure / deterministic verification for the command-menu component
(registry/remocn-ui/command-menu/). The render path (index.tsx) imports
useRemocnTheme which requires React context and cannot run headlessly — it is
NOT exercised here. This suite covers the pure-testable surface:
filterCommandItems, commandMenuStyleContext, commandMenuStyle presets,
tweenCommandMenuStyle interpolation, the useCommandMenuTransition pure
resolver mirror, and commandMenuConfig controls wiring + snippet codegen.
Animation model — state atom with smooth opt-in
command-menu follows the standard state-atom pattern (STYLE-GUIDE §1):
Snap path (state?: CommandMenuState prop):<CommandMenu> is a frame-free pure renderer. The state prop drives all panel
visuals. Each state maps to a complete resting keyframe via
commandMenuStyle(state, ctx) => CommandMenuStyle. State changes snap.
Smooth path (style?: CommandMenuStyle prop):
Callers opt in to smooth open/close by passing a pre-interpolated
CommandMenuStyle to the style prop. The caller — typically
useCommandMenuTransition — reads useCurrentFrame() via useStateTransition,
applies easings.out to linear progress, and blends the two presets via
tweenCommandMenuStyle(from, to, t). The component remains frame-free.
All fields are numeric (backdropOpacity, panelOpacity, panelScale,
panelTranslateY) — tweenCommandMenuStyle is a straight four-field lerp with
no mixOklch call. All midpoint values are tested exactly.
Filter function (filterCommandItems) is a pure exported utility —
case-insensitive substring match on the visible query prefix — and is tested
directly here.
How to run
bun install
bun test registry/remocn-ui/command-menu/__tests__
What is covered
DEFAULT_DURATION— asserts the constant is 12 frames (longer than the item's 8; the container transitions more slowly).filterCommandItems(items, query, revealCount)— exported pure filter. Asserts: empty query/whitespace-only → all items returned;revealCount=0→ all items (visible prefix is empty); empty items list → empty result; prefix narrows:"profile"→ 1 match,"se"→ 2 matches (Settings + Search docs),"file"→ New File,"new"→ New File; no-match returns empty array; case-insensitivity (uppercase/mixed queries match lowercase labels);revealCountslices the query (revealCount=2 on"settings"uses"se"→ 2 matches; revealCount=8 uses full"settings"→ 1 match); result items are the same object references (no cloning).commandMenuStyleContext(theme)— pure token derivation. Asserts all 8 scalar fields plusitemCtx:panelBg→popover,panelBorder→border,inputFg→popoverForeground,placeholderFg→mutedForeground,mutedFg→mutedForeground,divider→border,caret→foreground,radius→radius.itemCtxis a nestedCommandMenuItemStyleContextwithidleBg→popover. Light/dark themes produce differentpanelBg.commandMenuStyle(state, ctx)presets — every field for every state (2 states × 4 fields = 8 assertions):closed: backdropOpacity=0, panelOpacity=0, panelScale=0.96, panelTranslateY=8opened: backdropOpacity=1, panelOpacity=1, panelScale=1, panelTranslateY=0- All fields distinct between states; all fields numeric for every state.
tweenCommandMenuStyle(a, b, t)— at t=0 all four fields equala; at t=1 all equalb; at t=0.5 exact midpoints: backdropOpacity=0.5, panelOpacity=0.5, panelScale=0.98, panelTranslateY=4; at t=0.25: backdropOpacity=0.25, panelOpacity=0.25, panelScale=0.97, panelTranslateY=6; identity case; reverse direction (opened→closed same midpoints by symmetry).resolveCommandMenuTransition— pure mirror ofuseCommandMenuTransitionlines 49–73 withrawinjected. Key additional contract:easings.outis applied to linear progress before the tween, so mid-window at raw=6/dur=12 gives t=out(0.5)=0.875 → backdropOpacity=0.875 (not 0.5); panelTranslateY=8×(1−0.875)=1; panelScale=0.96+(1−0.96)×0.875. Also asserts: before any step → closed style with both endpointsclosed; at boundary progress=0 → t=out(0)=0 → closed style; past window → fully opened; speed contract (speed=2 halves the raw frame to reach a step).commandMenuConfig.controls— state/query/revealCount/selectedIndex/ highlightedIndex/mode wiring: state is aselectwith options["opened","closed"]and default"opened"; query is atextwith default""; revealCount is anumberwith default 0 and min 0; selectedIndex defaults to −1; highlightedIndex defaults to 0; mode defaults to"light".commandMenuConfig.snippet— import line, structural shape, state always emitted; default omissions (empty query, revealCount=0, selectedIndex=−1, highlightedIndex=−1, mode=light); non-default emissions; all state options round-trip.
Import strategy
../index—filterCommandItems,commandMenuStyle,commandMenuStyleContext,CommandMenuState,CommandMenuEntry../use-command-menu-transition—tweenCommandMenuStyle,DEFAULT_DURATION../config—commandMenuConfig@/lib/remocn-ui—defaultLightTheme,defaultDarkTheme,easings,Steptype
useCommandMenuTransition is NOT imported (it reads useCurrentFrame()). Its
pure body is mirrored as resolveCommandMenuTransition with the frame injected
as raw. bun test resolves tsconfig paths, so the @/lib/remocn-ui alias
works without additional config.
Determinism grep checklist (run manually; must print NOTHING)
command-menu/index.tsx is a pure renderer — must contain none of:
grep -nE "useState|useEffect|useCurrentFrame|onClick|onChange|addEventListener|Date\.now|Math\.random|requestAnimationFrame" \
registry/remocn-ui/command-menu/index.tsx
Expected: no output. Any match is a determinism violation.
use-command-menu-transition.ts intentionally reads useCurrentFrame() via
useStateTransition — correct and expected for the hook file.
Tier-wide sweep:
grep -nE "useState|useEffect|onClick|onChange|addEventListener|Date\.now|Math\.random" \
registry/remocn-ui/command-menu/index.tsx registry/remocn-ui/core/*.ts