Skip to content

test(craft): Playwright integration tests for craft lab variants#73621

Draft
stephenliang wants to merge 4 commits into
stephen/craft-wire-appsfrom
stephen/craft-playwright-tests
Draft

test(craft): Playwright integration tests for craft lab variants#73621
stephenliang wants to merge 4 commits into
stephen/craft-wire-appsfrom
stephen/craft-playwright-tests

Conversation

@stephenliang

Copy link
Copy Markdown
Member

Summary

  • Add CraftLab POM extending LegacyBlocklyLab with craft-specific helpers (game canvas, API execution, state queries)
  • Smoke tests for all 4 variants: simple, aquatic, agent, designer — verify Phaser renders and lab chrome loads
  • 57 scenario-level tests marked test.todo for incremental implementation (matching the vitest integration test inventory)

Context

Fourth of 4 stacked PRs for the craft-lab migration. Stacked on #73619.

Replaces the vitest integration tests that were it.todo in #73618 — those tests required a real browser (Phaser Canvas/WebGL) which jsdom can't provide.

Test plan

  • npx playwright test tests/levels/craft.spec.ts — 4 smoke tests pass, 57 todos reported
  • Smoke tests verify: game canvas visible, run button present, Blockly workspace loaded

🤖 Generated with Claude Code

stephenliang and others added 4 commits July 1, 2026 14:14
Add POM (CraftLab) extending LegacyBlocklyLab with craft-specific
helpers: game canvas locator, API execution via page.evaluate,
player position and success state queries.

Spec covers all 4 variants with load-and-render smoke tests;
remaining 57 scenario-level tests are marked test.todo for
incremental implementation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… data

Port all 57 original Karma/tape integration tests to Playwright using a
demo-shell pattern: a Vite-served harness page loads Phaser UMD + the
GameController directly, and page.evaluate() drives the game API.

- Add integration-harness.html/.ts that expose runLevel() via
  window.__craftTest (stubs Math.random for determinism)
- Add servePhaserUmd() Vite plugin to serve phaser-ce from hoisted
  node_modules via createRequire (no copied file)
- Rewrite craft-lab.ts page object to standalone gotoCraftHarness() and
  isCraftDevServerUp() functions
- 56 tests across 5 describe blocks (Adventurer 17, Agent 10, Aquatic 12,
  Designer 13, Functionality 4), all passing in 2.3 minutes
- Designer tests use slowMotion step=0.5 to avoid timeout racing under
  Phaser's forceSetTimeOut game loop

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…nterfaces

Define CraftApi, CraftLevelModel, CraftEvent, CraftPositionClass, and
CraftTestHarness interfaces for the browser-side test harness API. All
page.evaluate() callbacks now use typed parameters instead of any.

The integration-harness.ts uses a minimal GameControllerInstance interface
for the untyped JS GameController class, with unknown for its dynamic
properties and a window global typed through cast-to-unknown.

168/168 tests pass (56 tests x 3 browsers).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move Playwright integration tests from e2e-tests (for true end-to-end
tests against studio.code.org) to the craft package's own e2e/ directory,
matching the pattern established by oceans-lab.

- Add playwright.config.ts with webServer block that auto-starts yarn dev
- Add test:ui / test:ui:ci scripts to package.json
- Add playwright catalog dependency
- Use baseURL + page.goto() instead of standalone gotoCraftHarness
- Import from 'playwright/test' (workspace convention)
- Delete craft-lab.ts page helper (inlined into spec)
- 168/168 tests pass (56 x 3 browsers, 2.6 min)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@stephenliang stephenliang marked this pull request as draft July 2, 2026 21:46
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