#!/usr/bin/env bash set -euo pipefail ROOT_DIR=$(cd "$(dirname "$0")" && pwd) cd "$ROOT_DIR" LOG=/tmp/playwright_debug.log OUT=/tmp/playwright_run_output.log SIMSHOT=/tmp/sim_postmessage_simulator.png STUDIOSHOT=/tmp/sim_postmessage_studio.png echo "Running Playwright E2E test for studio-panel" echo "Logs: $LOG Output: $OUT" # Ensure node modules exist if [ ! -d node_modules/playwright ]; then echo "Playwright not found in node_modules — installing as devDependency (this may modify package-lock) " npm install --no-audit --no-fund --no-save playwright fi echo "Installing Playwright browsers (may require sudo on some systems)..." npx playwright install --with-deps || true echo "Running test script... (this may take ~15s)" # run and capture output node --experimental-vm-modules scripts/playwright_postmessage_test.mjs > "$OUT" 2>&1 || true # Show summary echo "\n=== Playwright run finished ===\n" if [ -f "$LOG" ]; then echo "Last 200 lines of $LOG:\n" tail -n 200 "$LOG" else echo "$LOG not found" fi if [ -f "$OUT" ]; then echo "\nLast 200 lines of run output ($OUT):\n" tail -n 200 "$OUT" else echo "$OUT not found" fi if [ -f "$SIMSHOT" ]; then echo "Simulator screenshot: $SIMSHOT" else echo "Simulator screenshot not found" fi if [ -f "$STUDIOSHOT" ]; then echo "Studio screenshot: $STUDIOSHOT" else echo "Studio screenshot not found" fi echo "\nIf the test failed, please paste the contents of the two log files above and attach the screenshots listed. You can upload screenshots to an image host and paste URLs, or paste the relevant log sections here."