#!/usr/bin/env bash # Browser smoke validation runner for The Nexus. # Runs provenance checks + Playwright browser tests + screenshot capture. # # Usage: bash bin/browser_smoke.sh # Env: NEXUS_TEST_PORT=9876 (default) set -euo pipefail REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)" cd "$REPO_ROOT" PORT="${NEXUS_TEST_PORT:-9876}" SCREENSHOT_DIR="$REPO_ROOT/test-screenshots" mkdir -p "$SCREENSHOT_DIR" echo "═══════════════════════════════════════════" echo " Nexus Browser Smoke Validation" echo "═══════════════════════════════════════════" # Step 1: Provenance check echo "" echo "[1/4] Provenance check..." if python3 bin/generate_provenance.py --check; then echo " ✓ Provenance verified" else echo " ✗ Provenance mismatch — files have changed since manifest was generated" echo " Run: python3 bin/generate_provenance.py to regenerate" exit 1 fi # Step 2: Static file contract echo "" echo "[2/4] Static file contract..." MISSING=0 for f in index.html app.js style.css portals.json vision.json manifest.json gofai_worker.js; do if [ -f "$f" ]; then echo " ✓ $f" else echo " ✗ $f MISSING" MISSING=1 fi done if [ "$MISSING" -eq 1 ]; then echo " Static file contract FAILED" exit 1 fi # Step 3: Browser tests via pytest + Playwright echo "" echo "[3/4] Browser tests (Playwright)..." NEXUS_TEST_PORT=$PORT python3 -m pytest tests/test_browser_smoke.py \ -v --tb=short -x \ -k "not test_screenshot" \ 2>&1 | tail -30 # Step 4: Screenshot capture echo "" echo "[4/4] Screenshot capture..." NEXUS_TEST_PORT=$PORT python3 -m pytest tests/test_browser_smoke.py \ -v --tb=short \ -k "test_screenshot" \ 2>&1 | tail -15 echo "" echo "═══════════════════════════════════════════" echo " Screenshots saved to: $SCREENSHOT_DIR/" ls -la "$SCREENSHOT_DIR/" 2>/dev/null || echo " (none captured)" echo "═══════════════════════════════════════════" echo " Smoke validation complete."