#!/usr/bin/env bash # Smoke test for M1: builds the Docker image and runs it against example.com, # then verifies all expected output files and report sections exist. set -euo pipefail GREEN='\033[0;32m' RED='\033[0;31m' NC='\033[0m' pass() { echo -e "${GREEN}✓ PASS${NC} $1"; } fail() { echo -e "${RED}✗ FAIL${NC} $1"; FAILED=1; } FAILED=0 OUTPUT_DIR="$(pwd)/output-verify-$$" mkdir -p "$OUTPUT_DIR" cleanup() { rm -rf "$OUTPUT_DIR"; } trap cleanup EXIT cd "$(dirname "$0")/.." echo "Building Docker image (website-evaluator)..." docker build -t website-evaluator . -q echo "Running evaluation against https://example.com..." docker run --rm -v "$OUTPUT_DIR:/output" website-evaluator https://example.com echo "" echo "Checking outputs..." check_file() { local path="$OUTPUT_DIR/$1" if [ -s "$path" ]; then pass "$1 exists and is non-empty" else fail "$1 missing or empty" fi } check_file "report.md" check_file "screenshots/desktop.png" check_file "screenshots/mobile.png" check_file "raw/lighthouse-desktop.json" check_file "raw/lighthouse-mobile.json" check_file "raw/dom.json" check_section() { if grep -q "$1" "$OUTPUT_DIR/report.md" 2>/dev/null; then pass "report.md contains: $1" else fail "report.md missing: $1" fi } check_section "Lighthouse Scores" check_section "Core Web Vitals" check_section "Critical Issues" check_section "Warnings" check_section "Page Structure" check_section "Screenshots" echo "" if [ "$FAILED" = "0" ]; then echo -e "${GREEN}All M1 checks passed.${NC}" exit 0 else echo -e "${RED}Some M1 checks failed. See above for details.${NC}" exit 1 fi