#!/usr/bin/env bash set -euo pipefail BASE_URL="${BASE_URL:-http://127.0.0.1:8085}" ALT_BASE_URL="http://host.containers.internal:8085" detect_base_url() { if curl -fsS --max-time 2 "$BASE_URL/api/health" >/dev/null 2>&1; then echo "$BASE_URL" return fi if curl -fsS --max-time 2 "$ALT_BASE_URL/api/health" >/dev/null 2>&1; then echo "$ALT_BASE_URL" return fi echo "$BASE_URL" } BASE_URL="$(detect_base_url)" echo "Using BASE_URL=$BASE_URL" echo "== Feature test 1: panel 2 controls include Add Selected and no static row Add button ==" grep -q 'id="addSelectedEpisodesBtn"' app/templates/index.html || { echo "Add Selected button missing"; exit 1; } grep -q 'id="refreshEpisodesBtn" class="secondary"' app/templates/index.html || { echo "Refresh Episodes should be secondary"; exit 1; } echo "panel controls validation passed" echo echo "== Feature test 2: episode selection modifiers are implemented ==" grep -q "selectedEpisodeIds: new Set()" app/static/app.js || { echo "selectedEpisodeIds state missing"; exit 1; } grep -q "episodeSelectionAnchorId" app/static/app.js || { echo "episode anchor state missing"; exit 1; } grep -q "event.shiftKey" app/static/app.js || { echo "shift selection handling missing"; exit 1; } grep -q "event.ctrlKey || event.metaKey" app/static/app.js || { echo "ctrl/meta toggle handling missing"; exit 1; } echo "modifier selection validation passed" echo echo "== Feature test 3: Add Selected bulk add flow is wired and clears selection ==" grep -q "async function addSelectedEpisodes()" app/static/app.js || { echo "addSelectedEpisodes function missing"; exit 1; } grep -q "clearEpisodeSelection();" app/static/app.js || { echo "selection clear after add missing"; exit 1; } grep -q "await loadSelectedEpisodes();" app/static/app.js || { echo "selected episodes reload missing"; exit 1; } echo "bulk add flow validation passed" echo echo "All episode selection feature tests passed."