#!/usr/bin/env bash # Runs the browser test of the Mini App: a complete core in test mode # (fake Telegram, fake LNbits, scripted yt-dlp) and headless Chromium # clicking through the built app. # # web/miniapp/e2e/run.sh [screenshot dir] # # Needs Node.js with "npm ci" done in web/miniapp, and a Chromium that # Playwright can start: "npx playwright-core install chromium", or # CHROMIUM_PATH pointing at a Chrome or Chromium binary. set -euo pipefail root="$(cd "$(dirname "$0")/../../.." && pwd)" stage="$(mktemp -d)" shots="${1:-}" log="$stage/core.log" cleanup() { touch "$stage/stop" wait "$core" 2>/dev/null || true rm -rf "$stage" } cd "$root" (cd web/miniapp && npm run build >/dev/null) DLBOT_STAGE_DIR="$stage" go test ./internal/app/ -run '^TestMiniAppStage$' -count=1 -timeout 20m >"$log" 2>&1 & core=$! trap cleanup EXIT for _ in $(seq 1 600); do [ -f "$stage/stage.json" ] && break if ! kill -0 "$core" 2>/dev/null; then echo "the core did not start:" >&2 cat "$log" >&2 exit 1 fi sleep 0.2 done [ -f "$stage/stage.json" ] || { echo "timed out waiting for the core" >&2; cat "$log" >&2; exit 1; } (cd web/miniapp && node e2e/smoke.mjs "$stage" "$shots")