refactor(e2e): extract infrastructure into tests/e2e/infra/ module

- Move fixtures.ts, llm-judge.ts, results-db.ts to tests/e2e/infra/
- Deduplicate wdio.conf.js: use createTestFixture() instead of inline copy
- Replace __dirname paths with projectRoot-anchored paths
- Create test-mode-constants.ts (typed env var names, flag registry)
- Create scripts/preflight-check.sh (validates tauri-driver, display, Claude CLI)
- Create scripts/check-test-flags.sh (CI lint for AGOR_TEST flag drift)
- Rewrite tests/e2e/README.md with full documentation
- Update spec imports for moved infra files
This commit is contained in:
Hibryda 2026-03-18 03:06:57 +01:00
parent 538a31f85c
commit e76bc341f2
10 changed files with 235 additions and 191 deletions

50
scripts/check-test-flags.sh Executable file
View file

@ -0,0 +1,50 @@
#!/usr/bin/env bash
# Lint check: verify all AGOR_TEST references are documented.
# Run in CI to catch flag drift between code and documentation.
set -euo pipefail
echo "Checking AGOR_TEST flag references..."
# Known files that should reference AGOR_TEST (from test-mode-constants.ts)
KNOWN_FILES=(
"agor-core/src/config.rs"
"src-tauri/src/commands/misc.rs"
"src-tauri/src/lib.rs"
"src-tauri/src/watcher.rs"
"src-tauri/src/fs_watcher.rs"
"src-tauri/src/telemetry.rs"
"src/App.svelte"
"tests/e2e/wdio.conf.js"
"tests/e2e/infra/fixtures.ts"
"tests/e2e/infra/test-mode-constants.ts"
)
# Find all files referencing AGOR_TEST (excluding node_modules, target, .git)
FOUND=$(grep -rl 'AGOR_TEST' --include='*.rs' --include='*.ts' --include='*.js' --include='*.svelte' \
--exclude-dir=node_modules --exclude-dir=target --exclude-dir=.git . 2>/dev/null | \
sed 's|^\./||' | sort)
UNKNOWN=""
for f in $FOUND; do
MATCH=0
for k in "${KNOWN_FILES[@]}"; do
if [[ "$f" == "$k" ]]; then
MATCH=1
break
fi
done
if [[ $MATCH -eq 0 ]]; then
UNKNOWN="$UNKNOWN $f\n"
fi
done
if [[ -n "$UNKNOWN" ]]; then
echo ""
echo "WARNING: AGOR_TEST referenced in files not in the known registry:"
echo -e "$UNKNOWN"
echo "Update tests/e2e/infra/test-mode-constants.ts and this script."
exit 1
else
echo "All AGOR_TEST references are documented. ✓"
fi

68
scripts/preflight-check.sh Executable file
View file

@ -0,0 +1,68 @@
#!/usr/bin/env bash
# Preflight check for E2E tests — validates system dependencies.
# Run before E2E suite to catch missing tools early.
set -euo pipefail
OK=0
WARN=0
check() {
local name="$1" cmd="$2"
if eval "$cmd" >/dev/null 2>&1; then
echo "$name"
else
echo "$name"
return 1
fi
}
echo "E2E Preflight Check"
echo "==================="
echo ""
echo "Required:"
if ! check "tauri-driver" "command -v tauri-driver"; then
echo " Install: cargo install tauri-driver"
OK=1
fi
if ! check "debug binary" "test -f target/debug/agent-orchestrator"; then
echo " Build: cargo tauri build --debug --no-bundle"
OK=1
fi
# Display server (Linux only)
if [[ "$(uname)" == "Linux" ]]; then
if [[ -n "${DISPLAY:-}" ]] || [[ -n "${WAYLAND_DISPLAY:-}" ]]; then
echo " ✓ display server (DISPLAY=$DISPLAY)"
else
echo " ✗ display server — no DISPLAY or WAYLAND_DISPLAY set"
echo " Use: xvfb-run --auto-servernum npm run test:e2e"
OK=1
fi
fi
echo ""
echo "Optional (LLM judge):"
if command -v claude >/dev/null 2>&1; then
echo " ✓ Claude CLI ($(which claude))"
elif [[ -n "${ANTHROPIC_API_KEY:-}" ]]; then
echo " ✓ ANTHROPIC_API_KEY set"
else
echo " ~ Claude CLI not found, ANTHROPIC_API_KEY not set"
echo " LLM-judged tests will be skipped"
WARN=1
fi
echo ""
if [[ $OK -ne 0 ]]; then
echo "FAILED — missing required dependencies"
exit 1
elif [[ $WARN -ne 0 ]]; then
echo "PASSED with warnings"
else
echo "ALL CHECKS PASSED"
fi