#!/usr/bin/env bash set -euo pipefail if [ -z "${BASE_URL:-}" ]; then if curl --silent --fail http://127.0.0.1:8085/api/health >/dev/null 2>&1; then BASE_URL="http://127.0.0.1:8085" elif curl --silent --fail http://host.containers.internal:8085/api/health >/dev/null 2>&1; then BASE_URL="http://host.containers.internal:8085" else echo "ERROR: could not determine BASE_URL. Tried 127.0.0.1 and host.containers.internal." >&2 exit 1 fi fi TMP_DIR="$(mktemp -d)" trap 'rm -rf "$TMP_DIR"' EXIT echo "== Feature test 1: root page renders 4 panels and action controls ==" curl --fail --silent --show-error \ "${BASE_URL}/" \ -o "${TMP_DIR}/index.html" python3 - "${TMP_DIR}/index.html" <<'PY' import sys from pathlib import Path html = Path(sys.argv[1]).read_text(encoding="utf-8") required = [ "1. TV Shows", "2. Episodes", "3. Selected Episodes", "4. Selected Files", "Debug Output", "Filename Preview", "Rename Execute (confirm=true)", ] for needle in required: assert needle in html, f"missing UI text: {needle}" print("UI panel/control validation passed") PY echo echo "== Feature test 2: static assets are served ==" curl --fail --silent --show-error \ "${BASE_URL}/static/styles.css" \ -o "${TMP_DIR}/styles.css" curl --fail --silent --show-error \ "${BASE_URL}/static/app.js" \ -o "${TMP_DIR}/app.js" python3 - "${TMP_DIR}/styles.css" "${TMP_DIR}/app.js" <<'PY' import sys from pathlib import Path css = Path(sys.argv[1]).read_text(encoding="utf-8") js = Path(sys.argv[2]).read_text(encoding="utf-8") assert ".grid" in css, "styles.css missing expected grid styles" assert "session_id" in js, "app.js missing session_id usage" assert "/api/tvdb/search" in js, "app.js missing search endpoint usage" assert "/api/files/discover" in js, "app.js missing discovery endpoint usage" assert "/api/files/folders" in js, "app.js missing folders endpoint usage" print("static assets validation passed") PY echo echo "== Feature test 3: UI references existing backend workflow endpoints ==" python3 - "${TMP_DIR}/app.js" <<'PY' import sys from pathlib import Path js = Path(sys.argv[1]).read_text(encoding="utf-8") required_endpoints = [ "/api/tvdb/search", "/api/tvdb/series/", "/api/session/selected-episodes", "/api/session/selected-files", "/api/files/roots", "/api/files/folders", "/api/files/discover", "/api/session/filename-preview", "/api/session/rename-execute", ] for endpoint in required_endpoints: assert endpoint in js, f"missing endpoint usage in UI: {endpoint}" print("endpoint wiring validation passed") PY echo echo "All UI feature tests passed."