feat(course): audit fixes and twelve extensions (Modules 7b, 12, 13)

Audit pass:
- Frame rule counts frames since the last move, so every step lasts
  exactly movesEvery(score) frames, also right after a speed-up
- clampTime + MAX_GAP_MS: a hidden tab no longer replays the whole gap
- Pong Restart keeps held keys
- Fact corrections (mulberry32 output coverage, Haskell IO, uniform)
- New fixture cases from a mutation analysis

Extensions (all three tracks, shared fixtures, course text):
- Turn queue (Exercise 10.6), persisted high score (10.7),
  replay viewer (10.8), play() end-to-end helper (9.5)
- Optional State (4.7) and optional Module 7b, stack-safe IO
- Module 12, property-based testing with generators, shrinking,
  invariants and a model-based oracle
- Module 13, Conway's Life with a Click event
- JS type checking via jsconfig, JSDoc and types.d.ts
- Maintainer tools: scripts/mutate.mjs, scripts/typecheck-js.sh,
  Playwright end-to-end suite (e2e/, scripts/e2e.sh)

Docs: docs/contract.md is the canonical contract; specs and build log
under docs/superpowers.

Verified: JS 728, Scala 689, F# 691 unit tests; stubs and progression
M01-M13 and M07b; 176 end-to-end tests on Chromium and WebKit.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
Lucas WintherandClaude Fable 5.2 committed 2026-11-11 12:05:29 +01:00
1 parent 876f5aabb1
commit edd57f0148
253 files changed
+21753 -503

No files matched your search

Executable
+70
View File
@@ -0,0 +1,70 @@
#!/usr/bin/env bash
# Usage: scripts/e2e.sh [--tracks js,scala,fsharp] [--base-url <url>] [-- <playwright args>]
# End-to-end tests (e2e/, Playwright) of every track's four pages against the pure JS model. Copies the repo to a temp
# dir, replaces each selected track's src/ with its solutions/, runs build-web.sh for Scala and F#, serves the copy with
# scripts/serve.mjs on a free port, runs the tests against it and cleans up. The exit code is Playwright's.
# --tracks the tracks to test (default: all three)
# --base-url test an already served copy instead (no copy, no build); its <track>/src must hold the code to test
# -- ... passed to `playwright test`, e.g. -- --project=chromium, -- -g "snake", -- --repeat-each=3
# The first run installs @playwright/test into e2e/node_modules (npm, needs the network once). Browsers are never
# downloaded: a missing one is skipped with a message (see e2e/playwright.config.mjs).
set -euo pipefail
repo="$(cd "$(dirname "$0")/.." && pwd)"
tracks="js,scala,fsharp"
base_url=""
pw_args=()
while [ $# -gt 0 ]; do
case "$1" in
--tracks) tracks="${2:?--tracks needs a value}"; shift 2 ;;
--base-url) base_url="${2:?--base-url needs a value}"; shift 2 ;;
--) shift; pw_args=("$@"); break ;;
*) echo "usage: scripts/e2e.sh [--tracks js,scala,fsharp] [--base-url <url>] [-- <playwright args>]" >&2; exit 2 ;;
esac
done
IFS=',' read -r -a selected <<< "$tracks"
for t in "${selected[@]}"; do
case "$t" in js|scala|fsharp) ;; *) echo "unknown track: $t" >&2; exit 2 ;; esac
done
if [ ! -d "$repo/e2e/node_modules/@playwright/test" ]; then
echo "e2e: installing @playwright/test into e2e/node_modules" >&2
(cd "$repo/e2e" && npm ci --no-audit --no-fund) || { echo "e2e: npm ci failed (no network?)" >&2; exit 2; }
fi
tmp=""
server=""
cleanup() {
if [ -n "$server" ]; then kill "$server" 2>/dev/null || true; fi
if [ -n "$tmp" ]; then rm -rf "$tmp"; fi
}
trap cleanup EXIT
if [ -z "$base_url" ]; then
tmp="$(mktemp -d)"
# The copy leaves out builds lying around in the tree (*/web/dist), so a page is only testable once built here.
tar -C "$repo" --exclude=.git --exclude=node_modules --exclude=bin --exclude=obj --exclude=.scala-build \
--exclude=.bsp --exclude=.superpowers --exclude=./e2e --exclude='./*/web/dist' -cf - . | tar -C "$tmp" -xf -
for t in "${selected[@]}"; do
rm -rf "$tmp/$t/src"
cp -r "$tmp/$t/solutions" "$tmp/$t/src"
if [ "$t" != js ]; then
echo "e2e: building the $t pages (build-web.sh)" >&2
(cd "$tmp/$t" && ./build-web.sh > "$tmp/build-$t.log" 2>&1) || { cat "$tmp/build-$t.log" >&2; echo "e2e: $t build failed" >&2; exit 2; }
fi
done
port="$(node -e "const s=require('net').createServer();s.listen(0,'127.0.0.1',()=>{console.log(s.address().port);s.close()})")"
node "$tmp/scripts/serve.mjs" "$port" > "$tmp/serve.log" 2>&1 &
server=$!
base_url="http://127.0.0.1:$port"
for _ in $(seq 1 50); do
if node -e "fetch('$base_url/js/index.html').then(r=>process.exit(r.ok?0:1),()=>process.exit(1))"; then break; fi
sleep 0.1
done
fi
echo "e2e: testing $tracks at $base_url" >&2
set +e
(cd "$repo/e2e" && E2E_BASE_URL="$base_url" E2E_TRACKS="$tracks" npx --no-install playwright test ${pw_args[@]+"${pw_args[@]}"})
status=$?
set -e
exit $status