Files
rename-mvp/feature_tests_ui.sh
T
2026-03-08 09:45:56 +01:00

95 lines
2.9 KiB
Bash
Executable File

#!/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",
"Select Files",
"Rename",
]
for needle in required:
assert needle in html, f"missing UI text: {needle}"
for removed in ["Debug Output", "Filename Preview", "Mapping Preview"]:
assert removed not in html, f"unexpected legacy UI text present: {removed}"
print("UI panel/control validation passed")
PY
echo
echo "== Feature test 2: debug page and static assets are served =="
curl --fail --silent --show-error \
"${BASE_URL}/debug.html" \
-o "${TMP_DIR}/debug.html"
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}/debug.html" "${TMP_DIR}/styles.css" "${TMP_DIR}/app.js" <<'PY'
import sys
from pathlib import Path
debug_html = Path(sys.argv[1]).read_text(encoding="utf-8")
css = Path(sys.argv[2]).read_text(encoding="utf-8")
js = Path(sys.argv[3]).read_text(encoding="utf-8")
assert "Rename MVP Debug" in debug_html, "debug.html missing expected title/text"
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/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."