#!/usr/bin/env bash
# Nexus 全功能验收（API + 可选 UI）
# 用法:
#   bash scripts/run_full_acceptance.sh
#   bash scripts/run_full_acceptance.sh --with-ui
#   bash scripts/run_full_acceptance.sh --with-unit --json reports/acceptance.json
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
cd "$ROOT"
EXTRA=()
if [[ "${1:-}" == "--with-ui" ]]; then
  shift
  export NEXUS_E2E_BASE="${NEXUS_E2E_BASE:-https://api.synaglobal.vip}"
  export NEXUS_E2E_USER="${NEXUS_E2E_USER:-admin}"
  if [[ -z "${NEXUS_E2E_PASSWORD:-}" && -z "${NEXUS_TEST_ADMIN_PASSWORD:-}" ]]; then
  if command -v ssh >/dev/null 2>&1; then
    export NEXUS_E2E_PASSWORD
    NEXUS_E2E_PASSWORD="$(ssh -o ConnectTimeout=10 nexus 'grep ^NEXUS_TEST_ADMIN_PASSWORD= /www/wwwroot/api.synaglobal.vip/.env | cut -d= -f2-' | tr -d '"' || true)"
    export NEXUS_E2E_PASSWORD
  fi
  fi
  EXTRA+=(--with-ui)
fi
exec python3 scripts/run_nexus_acceptance.py "${EXTRA[@]}" "$@"
