Skip to content

test(e2e): add real-browser suite for sprite animation + keyboard-driven movement - #539

Open
stormmuller wants to merge 1 commit into
devfrom
claude/animation-e2e-test-kxjrnv
Open

test(e2e): add real-browser suite for sprite animation + keyboard-driven movement#539
stormmuller wants to merge 1 commit into
devfrom
claude/animation-e2e-test-kxjrnv

Conversation

@stormmuller

Copy link
Copy Markdown
Member

Summary

  • Adds e2e/fixtures/scenes/character-animation.ts + e2e/specs/character-animation.spec.ts: a real-browser Playwright suite exercising the sprite animation system end-to-end. It slices the adventurer sprite sheet (copied into e2e/fixtures/ to keep /e2e dependent only on /src) into idle and run AnimationClips, drives left/right movement via a keyboard-bound Axis1dAction, and asserts on both ECS state (clip handle, animationFrameIndex, FlipEcsComponent.flipX, position) and actual rendered canvas pixels (a centroid-tracking measurement that stays robust to the run clip's swinging limbs, and a recentered-patch pixel diff that ties rendered output directly to animationFrameIndex advancing).
  • Adds a matching documentation-site/src/pages/demos/sprite-animation/ demo, wired into the "Demos" nav dropdown, showing the same idle/run/flip pattern driven by A/D keys.
  • Fixes two gaps in the Sprite Animations guide (documentation-site/docs/docs/animations/sprite-animations.md) found while building the above:
    • Its createImageSprite() call used a stale positional signature (new Vector2(32, 32) as a 4th argument) instead of the current options-object API ({ frameDimensions: new Vector2(32, 32) }).
    • Its example never set SpriteEcsComponent.uvScale, which createImageSprite's frameDimensions option does not set automatically (it only sizes the sprite's world-space quad) - the example rendered the entire sprite sheet squashed into one frame's quad instead of a single cropped frame. Added the missing sprite.uvScale = spriteSheet.frames[0][0].dimensions.clone(); step (matching the existing pattern in the space-shooter demo's explosion sprite) plus an explicit troubleshooting note.

No /src changes - this is test and documentation-site work, so no CHANGELOG entry per AGENTS.md's excluded-types list.

Test plan

  • npx tsc --noEmit --project e2e/tsconfig.json - passes
  • npx eslint e2e/fixtures/scenes/character-animation.ts e2e/specs/character-animation.spec.ts - passes
  • npx playwright test --config e2e/playwright.config.ts -g "character animation" - 5/5 pass, run 3x for flakiness, and verified the frame-advance assertion actually fails when createSpriteAnimationEcsSystem is disabled
  • Root npm run check-types, npm test (1067 tests), npm run lint, npm run cspell, npm run check-exports - all pass
  • documentation-site: npm run typecheck and npm run build - both pass
  • Manually loaded /demos/sprite-animation in a browser and confirmed idle/run/flip render correctly with A/D input

Generated by Claude Code

…ven movement

Adds a character-animation scene/spec exercising the sprite animation
system end-to-end: the adventurer sprite sheet sliced into idle/run
AnimationClips, keyboard-driven left/right movement via an Axis1dAction,
clip switching, and sprite flipping, asserting against both ECS state and
actual rendered/centroid-tracked canvas pixels.

Also adds a matching documentation-site demo showcasing the same pattern,
and fixes two documentation gaps found while building both: an outdated
createImageSprite() call signature in the Sprite Animations guide, and a
missing step (manually setting SpriteEcsComponent.uvScale from the sprite
sheet's frame dimensions) that the guide's example omitted entirely.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XAiYXVHjozy4yBLTLgTKfo
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.

2 participants