[AZ-456] Test infrastructure: Vitest + MSW + Playwright + scripts

Scaffolds the Blackbox test project per AZ-456 / environment.md across
the three profiles:

- fast  : Vitest 3.x + jsdom + MSW 2.x + RTL/jest-dom; tests/setup.ts
          boots the MSW Node server with onUnhandledRequest:'error',
          afterEach resets handlers, clears bearer + navigate-to-login
          spy. Default handlers ship for every suite service plus OWM
          and tile stand-ins. Fixtures mirror seed_* in test-data.md.
- e2e   : Playwright ^1.49 with chromium + firefox projects against the
          suite docker-compose stack; owm-stub + tile-stub Bun servers,
          playwright-runner image, seeds.sql for the test-db.
- static: scripts/run-tests.sh extended — tsc --noEmit (test config),
          vite build, ripgrep checks (with grep -r fallback), CSV
          report at test-output/static-report.csv per AC-7 columns.

Smoke tests cover AC-3, AC-4 (fast, 5 tests, PASS) and AC-1, AC-2,
AC-5, AC-8 (e2e, gated by Risk 4 docker availability). Static profile
(13 checks) PASS — STC-SEC1 (no literal OWM key) lifted from
QUARANTINE per AZ-447 with a narrowed pattern.

Files:
  +24 tests/**, +10 e2e/**, +vitest.config.ts, +tsconfig.test.json
  ~package.json (test scripts + devDeps for vitest, @testing-library/*,
   msw, @playwright/test, jsdom, @types/node, @vitest/coverage-v8)
  ~scripts/run-tests.sh, scripts/run-performance-tests.sh — switched
   RESULTS_DIR to test-output/, compose path to project-local
  ~.gitignore — added /test-output/

Verification:
  bun run test:fast        → 11 / 11 PASS
  ./scripts/run-tests.sh   → static 13/13 + fast 11/11 PASS, exit 0

Tracker: AZ-456 → In Testing.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Oleksandr Bezdieniezhnykh
2026-05-11 02:57:04 +03:00
parent e5d9276b19
commit 38eb87fb08
45 changed files with 2377 additions and 157 deletions
+6 -6
View File
@@ -24,7 +24,7 @@ set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
SUITE_ROOT="$(cd "$PROJECT_ROOT/.." && pwd)"
RESULTS_DIR="$PROJECT_ROOT/test-results"
RESULTS_DIR="$PROJECT_ROOT/test-output"
RUN_STATIC=true
RUN_E2E=true
@@ -59,7 +59,7 @@ E2E_COMPOSE_STARTED_HERE=false
cleanup() {
if [ "$E2E_COMPOSE_STARTED_HERE" = "true" ]; then
docker compose -f "$SUITE_ROOT/e2e/docker-compose.suite-e2e.yml" down -v --remove-orphans || true
docker compose -f "$PROJECT_ROOT/e2e/docker-compose.suite-e2e.yml" down -v --remove-orphans || true
fi
}
trap cleanup EXIT
@@ -130,17 +130,17 @@ fi
# the spec-only baseline without producing false negatives.
# ----------------------------------------------------------------------------
if [ "$RUN_E2E" = "true" ]; then
COMPOSE_FILE="$SUITE_ROOT/e2e/docker-compose.suite-e2e.yml"
COMPOSE_FILE="$PROJECT_ROOT/e2e/docker-compose.suite-e2e.yml"
PERF_PROJECT="$PROJECT_ROOT/e2e/playwright.perf.config.ts"
if [ ! -f "$PERF_PROJECT" ]; then
echo "[run-performance-tests] Playwright perf project ($PERF_PROJECT) not yet wired."
echo "[run-performance-tests] Decompose-Tests step (autodev Step 5) creates it; until then the e2e perf scenarios are SKIPPED."
echo "[run-performance-tests] Awaiting NFT-PERF-* task implementations (AZ-457..AZ-482); until then the e2e perf scenarios are SKIPPED."
for id in NFT-PERF-02 NFT-PERF-03 NFT-PERF-04 NFT-PERF-05 NFT-PERF-06 NFT-PERF-07 NFT-PERF-08 NFT-PERF-09 NFT-PERF-10; do
record "$id" "SKIP" "n/a" "deferred to Step 5"
record "$id" "SKIP" "n/a" "deferred to per-AC test tasks"
done
elif [ ! -f "$COMPOSE_FILE" ]; then
echo "[run-performance-tests] FATAL: $COMPOSE_FILE not found (parent suite repo owns it)." >&2
echo "[run-performance-tests] FATAL: $COMPOSE_FILE not found." >&2
OVERALL_EXIT=1
elif ! command -v docker >/dev/null 2>&1; then
echo "[run-performance-tests] FATAL: docker is required for the e2e perf profile." >&2
+242 -143
View File
@@ -1,17 +1,13 @@
#!/usr/bin/env bash
# Azaion UI — unit + blackbox test runner.
#
# Generated by .cursor/skills/test-spec phase 4. Drives the test profiles
# specified in _docs/02_document/tests/environment.md:
# - static : repo + dist artifact checks (no runtime)
# - fast : Bun + Vitest + jsdom + MSW (component / unit / blackbox at the fetch boundary)
# - e2e : Playwright (Chromium + Firefox) against the suite docker-compose stack
# Drives the test profiles specified in
# _docs/02_document/tests/environment.md and AZ-456:
# - static : repo + dist artifact checks (no runtime, host)
# - fast : Bun + Vitest + jsdom + MSW (host)
# - e2e : Playwright (Chromium + Firefox) inside the suite docker stack
#
# The fast + static profiles run locally on host. The e2e profile delegates to the
# suite-level docker-compose harness owned by the parent suite repo (e2e/docker-compose.suite-e2e.yml).
#
# Hardware-Dependency Assessment recorded "Not hardware-dependent" — Docker is preferred
# for e2e; fast + static execute on the host because they have no runtime dependency on the suite.
# Reports land under ./test-output/ per AZ-456 (CSV + JUnit XML).
#
# Usage:
# scripts/run-tests.sh # static + fast (default; gates every commit per CI/CD Integration)
@@ -19,13 +15,14 @@
# scripts/run-tests.sh --all # static + fast + e2e
# scripts/run-tests.sh --e2e-only # only the e2e profile
# scripts/run-tests.sh --static-only # only the static checks
# scripts/run-tests.sh --fast-only # only the fast profile
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
SUITE_ROOT="$(cd "$PROJECT_ROOT/.." && pwd)"
RESULTS_DIR="$PROJECT_ROOT/test-results"
RESULTS_DIR="$PROJECT_ROOT/test-output"
RUN_STATIC=true
RUN_FAST=true
@@ -54,7 +51,7 @@ E2E_COMPOSE_STARTED_HERE=false
cleanup() {
if [ "$E2E_COMPOSE_STARTED_HERE" = "true" ]; then
docker compose -f "$SUITE_ROOT/e2e/docker-compose.suite-e2e.yml" down -v --remove-orphans || true
docker compose -f "$PROJECT_ROOT/e2e/docker-compose.suite-e2e.yml" down -v --remove-orphans || true
fi
}
trap cleanup EXIT
@@ -65,6 +62,7 @@ cd "$PROJECT_ROOT"
echo "[run-tests] project root: $PROJECT_ROOT"
echo "[run-tests] suite root : $SUITE_ROOT"
echo "[run-tests] results dir : $RESULTS_DIR"
echo "[run-tests] profiles : static=$RUN_STATIC fast=$RUN_FAST e2e=$RUN_E2E"
# ----------------------------------------------------------------------------
@@ -75,7 +73,7 @@ if [ "$RUN_FAST" = "true" ] || [ "$RUN_STATIC" = "true" ]; then
echo "[run-tests] FATAL: bun is required (project pins bun@1.3.11 per package.json packageManager)." >&2
exit 1
fi
echo "[run-tests] installing dependencies (bun install --frozen-lockfile if lockfile present, else bun install)..."
echo "[run-tests] installing dependencies..."
if [ -f "$PROJECT_ROOT/bun.lock" ] || [ -f "$PROJECT_ROOT/bun.lockb" ]; then
bun install --frozen-lockfile
else
@@ -85,179 +83,263 @@ fi
OVERALL_EXIT=0
# CSV rollup format (AZ-456 § Test Reporting):
# Test ID,Test Name,Profile,Execution Time (ms),Result,Error Message,Traces to AC,Traces to results_report.md row
csv_header() {
echo 'Test ID,Test Name,Profile,Execution Time (ms),Result,Error Message,Traces to AC,Traces to results_report.md row' > "$1"
}
csv_record() {
# $1 file, $2 id, $3 name, $4 profile, $5 exec_ms, $6 result, $7 err, $8 ac, $9 row
local file="$1" id="$2" name="$3" profile="$4" exec_ms="$5" result="$6" err="$7" ac="$8" row="$9"
# Escape any embedded quotes so the CSV stays well-formed.
err="${err//\"/\"\"}"
name="${name//\"/\"\"}"
printf '%s,"%s",%s,%s,%s,"%s",%s,%s\n' "$id" "$name" "$profile" "$exec_ms" "$result" "$err" "$ac" "$row" >> "$file"
}
# Portable millisecond clock — GNU coreutils `date +%s%3N` is unavailable on
# macOS / BSD, so fall back to python3 unconditionally.
millis() {
python3 -c 'import time; print(int(time.time()*1000))'
}
# ----------------------------------------------------------------------------
# Static profile — repo + dist artifact checks.
# Static profile — repo checks, type-check, build, ripgrep.
# Source: _docs/02_document/tests/blackbox-tests.md, security-tests.md,
# resource-limit-tests.md, traceability-matrix.md "STC-*" candidates.
#
# Today only the spec-derived checks ship; the STC-S* family lands when the
# traceability matrix promotes them (see Phase 3 "Still open" item 6).
# ----------------------------------------------------------------------------
if [ "$RUN_STATIC" = "true" ]; then
echo "[run-tests] === static profile ==="
STATIC_REPORT="$RESULTS_DIR/static-report.txt"
: > "$STATIC_REPORT"
STATIC_REPORT="$RESULTS_DIR/static-report.csv"
csv_header "$STATIC_REPORT"
STATIC_FAIL=0
echo "[static] STC-S1: TypeScript strict mode in tsconfig.json"
if node -e 'const t=require("./tsconfig.json"); process.exit((t.compilerOptions && t.compilerOptions.strict === true) ? 0 : 1)' 2>/dev/null; then
echo " PASS" | tee -a "$STATIC_REPORT"
else
# tsconfig may extend a base; fall back to a tsc --showConfig dry-run.
if bunx tsc --showConfig | grep -q '"strict": true'; then
echo " PASS (via tsc --showConfig)" | tee -a "$STATIC_REPORT"
run_static() {
# $1 id, $2 name, $3 ac, $4 row, $5 cmd
local id="$1" name="$2" ac="$3" row="$4"
shift 4
local start_ms result err
start_ms=$(millis)
if err=$("$@" 2>&1); then
result=PASS
else
echo " FAIL: strict mode not enabled" | tee -a "$STATIC_REPORT"; STATIC_FAIL=1
result=FAIL
STATIC_FAIL=1
fi
fi
echo "[static] STC-S2..S11: pinned dependency versions (S2 React 19, S3 Vite 6, S4 Bun 1.3.11, S7 no Redux/Zustand/TanStack, S8 Tailwind 4, S9 Leaflet, S10 Chart.js, S11 DnD)"
node -e '
const p = require("./package.json");
const all = Object.assign({}, p.dependencies || {}, p.devDependencies || {});
const pin = (name, ver) => (all[name] || "").startsWith(ver) ? ` PASS ${name}@${all[name]}` : ` FAIL ${name}@${all[name] || "(missing)"} expected ${ver}*`;
const ban = (name) => all[name] ? ` FAIL banned dep present: ${name}` : ` PASS no ${name}`;
const lines = [
pin("react", "^19"),
pin("react-dom", "^19"),
pin("vite", "^6"),
pin("tailwindcss", "^4"),
pin("leaflet", "^1.9.4"),
pin("react-leaflet", "^5"),
pin("chart.js", "^4"),
pin("@hello-pangea/dnd", "^18"),
ban("redux"),
ban("@reduxjs/toolkit"),
ban("zustand"),
ban("@tanstack/react-query"),
ban("@tanstack/query-core"),
(p.packageManager === "bun@1.3.11") ? " PASS packageManager bun@1.3.11" : ` FAIL packageManager=${p.packageManager}`,
];
for (const l of lines) console.log(l);
if (lines.some(l => l.startsWith(" FAIL"))) process.exit(1);
' | tee -a "$STATIC_REPORT" || STATIC_FAIL=1
echo "[static] STC-N2 / AC-N2: no in-browser ML libraries"
if node -e '
const p = require("./package.json");
const all = Object.assign({}, p.dependencies || {}, p.devDependencies || {});
const re = /(onnxruntime|tensorflow|tflite|coreml|tfjs|@tensorflow\/|@huggingface\/|transformers\.js)/i;
const hits = Object.keys(all).filter(n => re.test(n));
if (hits.length) { console.log(" FAIL banned ML deps:", hits.join(", ")); process.exit(1); }
console.log(" PASS no in-browser ML deps");
' | tee -a "$STATIC_REPORT"; then :; else STATIC_FAIL=1; fi
echo "[static] STC-N4 / AC-N4: no response-signature library"
if node -e '
const p = require("./package.json");
const all = Object.assign({}, p.dependencies || {}, p.devDependencies || {});
const re = /(jsrsasign|tweetnacl|@noble\/|^jose$)/i;
const hits = Object.keys(all).filter(n => re.test(n));
if (hits.length) { console.log(" FAIL signature libs:", hits.join(", ")); process.exit(1); }
console.log(" PASS no signature libs");
' | tee -a "$STATIC_REPORT"; then :; else STATIC_FAIL=1; fi
echo "[static] STC-S13 / O2: no client-side persistence library"
if node -e '
const p = require("./package.json");
const all = Object.assign({}, p.dependencies || {}, p.devDependencies || {});
const re = /^(localforage|idb|dexie)$/i;
const hits = Object.keys(all).filter(n => re.test(n));
if (hits.length) { console.log(" FAIL persistence libs:", hits.join(", ")); process.exit(1); }
console.log(" PASS no persistence libs");
' | tee -a "$STATIC_REPORT"; then :; else STATIC_FAIL=1; fi
echo "[static] STC-S6 / O11: no WebSocket / GraphQL / gRPC-Web / SSR / RSC"
if node -e '
const p = require("./package.json");
const all = Object.assign({}, p.dependencies || {}, p.devDependencies || {});
const re = /^(ws|socket\.io|graphql|apollo|@apollo\/|grpc-web|react-dom\/server)$/i;
const hits = Object.keys(all).filter(n => re.test(n));
if (hits.length) { console.log(" FAIL banned deps:", hits.join(", ")); process.exit(1); }
console.log(" PASS no WS/GraphQL/gRPC/SSR deps");
' | tee -a "$STATIC_REPORT"; then :; else STATIC_FAIL=1; fi
echo "[static] AC-N5: dropped legacy features (SoundDetections, DroneMaintenance) absent from src/ + mission-planner/"
if grep -r --include='*.ts' --include='*.tsx' --include='*.js' --include='*.jsx' -E 'SoundDetections|DroneMaintenance' "$PROJECT_ROOT/src" "$PROJECT_ROOT/mission-planner" 2>/dev/null | tee -a "$STATIC_REPORT"; then
echo " FAIL legacy symbols present" | tee -a "$STATIC_REPORT"; STATIC_FAIL=1
else
echo " PASS no legacy symbols" | tee -a "$STATIC_REPORT"
fi
echo "[static] AC-31 / O12: mission-planner not built into dist/"
if [ -d "$PROJECT_ROOT/dist" ]; then
if grep -rE 'mission[-_ ]?planner' "$PROJECT_ROOT/dist" 2>/dev/null | tee -a "$STATIC_REPORT"; then
echo " FAIL mission-planner symbols leaked into dist/" | tee -a "$STATIC_REPORT"; STATIC_FAIL=1
local end_ms
end_ms=$(millis)
local exec_ms=$((end_ms - start_ms))
local err_summary=""
if [ "$result" = "FAIL" ]; then
err_summary=$(printf '%s' "$err" | tr '\n' ' ' | head -c 240)
echo " $result $id ${exec_ms}ms"
echo " $err_summary"
else
echo " PASS mission-planner absent from dist/" | tee -a "$STATIC_REPORT"
echo " $result $id ${exec_ms}ms"
fi
else
echo " SKIP dist/ not built — re-run after 'bun run build'" | tee -a "$STATIC_REPORT"
fi
csv_record "$STATIC_REPORT" "$id" "$name" "static" "$exec_ms" "$result" "$err_summary" "$ac" "$row"
}
echo "[static] AC-N3: no service worker registration"
if grep -rE 'serviceWorker\.register|navigator\.serviceWorker' "$PROJECT_ROOT/src" 2>/dev/null | tee -a "$STATIC_REPORT"; then
echo " FAIL service worker registration found" | tee -a "$STATIC_REPORT"; STATIC_FAIL=1
else
echo " PASS no service worker registration" | tee -a "$STATIC_REPORT"
fi
static_check_strict() {
if node -e 'const t=require("./tsconfig.json"); process.exit((t.compilerOptions && t.compilerOptions.strict === true) ? 0 : 1)' 2>/dev/null; then
return 0
fi
bunx tsc --showConfig | grep -q '"strict": true'
}
echo "[static] NFT-SEC-09 source check (quarantined until Step 4): OpenWeatherMap key not in source"
if grep -rE 'OPENWEATHERMAP|OWM_API_KEY|appid=' "$PROJECT_ROOT/src" 2>/dev/null | grep -vE 'import\.meta\.env|process\.env' | tee -a "$STATIC_REPORT"; then
echo " QUARANTINED FAIL: literal OWM key string found (Step 4 will fix)" | tee -a "$STATIC_REPORT"
# Quarantined per traceability-matrix.md — do not gate on this until Step 4.
else
echo " PASS no literal OWM key" | tee -a "$STATIC_REPORT"
fi
static_check_pinned_deps() {
node -e '
const p = require("./package.json");
const all = Object.assign({}, p.dependencies || {}, p.devDependencies || {});
const pin = (name, ver) => (all[name] || "").startsWith(ver) ? null : `${name}@${all[name] || "(missing)"} expected ${ver}*`;
const ban = (name) => all[name] ? `banned dep present: ${name}` : null;
const fails = [
pin("react", "^19"), pin("react-dom", "^19"), pin("vite", "^6"),
pin("tailwindcss", "^4"), pin("leaflet", "^1.9.4"), pin("react-leaflet", "^5"),
pin("chart.js", "^4"), pin("@hello-pangea/dnd", "^18"),
ban("redux"), ban("@reduxjs/toolkit"), ban("zustand"),
ban("@tanstack/react-query"), ban("@tanstack/query-core"),
(p.packageManager === "bun@1.3.11") ? null : `packageManager=${p.packageManager}`,
].filter(Boolean);
if (fails.length) { console.error(fails.join("; ")); process.exit(1); }
'
}
static_check_no_ml_libs() {
node -e '
const p = require("./package.json");
const all = Object.assign({}, p.dependencies || {}, p.devDependencies || {});
const re = /(onnxruntime|tensorflow|tflite|coreml|tfjs|@tensorflow\/|@huggingface\/|transformers\.js)/i;
const hits = Object.keys(all).filter(n => re.test(n));
if (hits.length) { console.error("banned ML deps:", hits.join(", ")); process.exit(1); }
'
}
static_check_no_signature_libs() {
node -e '
const p = require("./package.json");
const all = Object.assign({}, p.dependencies || {}, p.devDependencies || {});
const re = /(jsrsasign|tweetnacl|@noble\/|^jose$)/i;
const hits = Object.keys(all).filter(n => re.test(n));
if (hits.length) { console.error("signature libs:", hits.join(", ")); process.exit(1); }
'
}
static_check_no_persistence_libs() {
node -e '
const p = require("./package.json");
const all = Object.assign({}, p.dependencies || {}, p.devDependencies || {});
const re = /^(localforage|idb|dexie)$/i;
const hits = Object.keys(all).filter(n => re.test(n));
if (hits.length) { console.error("persistence libs:", hits.join(", ")); process.exit(1); }
'
}
static_check_no_ws_graphql() {
node -e '
const p = require("./package.json");
const all = Object.assign({}, p.dependencies || {}, p.devDependencies || {});
const re = /^(ws|socket\.io|graphql|apollo|@apollo\/|grpc-web|react-dom\/server)$/i;
const hits = Object.keys(all).filter(n => re.test(n));
if (hits.length) { console.error("banned deps:", hits.join(", ")); process.exit(1); }
'
}
# Source-tree text search. Prefer ripgrep when available (much faster on
# large trees), fall back to POSIX grep -r so the CI runner doesn't need rg.
src_grep() {
if command -v rg >/dev/null 2>&1; then
rg --no-messages --type ts --type tsx -e "$1" "${@:2}"
else
grep -rE --include='*.ts' --include='*.tsx' "$1" "${@:2}" 2>/dev/null
fi
}
static_check_no_legacy_features() {
local hits
hits=$(src_grep 'SoundDetections|DroneMaintenance' "$PROJECT_ROOT/src" "$PROJECT_ROOT/mission-planner" || true)
if [ -n "$hits" ]; then
echo "$hits" >&2
return 1
fi
return 0
}
static_check_no_service_worker() {
local hits
hits=$(src_grep 'serviceWorker\.register|navigator\.serviceWorker' "$PROJECT_ROOT/src" || true)
if [ -n "$hits" ]; then
echo "$hits" >&2
return 1
fi
return 0
}
static_check_no_literal_owm_key() {
# Lifted from QUARANTINE per AZ-447 (Step 4 testability fixed the hardcoded
# key). The narrowed pattern catches a real key value (`appid=<6+ chars>`)
# while ignoring env-var bindings (`VITE_OWM_API_KEY?: string`) and
# template-string callsites (`?appid=${apiKey}`).
local hits
hits=$(src_grep 'appid=[a-zA-Z0-9]{6,}' "$PROJECT_ROOT/src" 2>/dev/null | grep -vE 'import\.meta\.env|process\.env' || true)
if [ -n "$hits" ]; then
echo "$hits" >&2
return 1
fi
return 0
}
static_check_no_unpkg() {
local hits
hits=$(src_grep 'unpkg\.com' "$PROJECT_ROOT/src" || true)
if [ -n "$hits" ]; then
echo "$hits" >&2
return 1
fi
return 0
}
static_check_typecheck() {
bunx tsc --noEmit -p tsconfig.test.json
}
static_check_vite_build() {
bun run build
}
static_check_dist_no_mission_planner() {
if [ ! -d "$PROJECT_ROOT/dist" ]; then
echo "dist/ missing — run 'bun run build' first" >&2
return 1
fi
local hits
if command -v rg >/dev/null 2>&1; then
hits=$(rg --no-messages -e 'mission[-_ ]?planner' "$PROJECT_ROOT/dist" || true)
else
hits=$(grep -rE 'mission[-_ ]?planner' "$PROJECT_ROOT/dist" 2>/dev/null || true)
fi
if [ -n "$hits" ]; then
echo "$hits" >&2
return 1
fi
return 0
}
run_static "STC-S1" "tsconfig strict mode" "AC-N1" "n/a" static_check_strict
run_static "STC-S2" "pinned core deps + banned" "AC-N6" "70" static_check_pinned_deps
run_static "STC-N2" "no in-browser ML libs" "AC-N2" "n/a" static_check_no_ml_libs
run_static "STC-N4" "no response-signature library" "AC-N4" "n/a" static_check_no_signature_libs
run_static "STC-S13" "no client-side persistence lib" "O2" "n/a" static_check_no_persistence_libs
run_static "STC-S6" "no WS/GraphQL/gRPC/SSR deps" "O11" "n/a" static_check_no_ws_graphql
run_static "STC-N5" "no legacy SoundDetections/DM" "AC-N5" "n/a" static_check_no_legacy_features
run_static "STC-N3" "no service worker registration" "AC-N3" "n/a" static_check_no_service_worker
run_static "STC-SEC1" "no literal OWM key in src/" "SEC-09" "63" static_check_no_literal_owm_key
run_static "STC-SEC2" "no unpkg.com in src/" "SEC-09" "n/a" static_check_no_unpkg
run_static "STC-T1" "tsc --noEmit (test config)" "AC-6" "n/a" static_check_typecheck
run_static "STC-B1" "vite build succeeds" "AC-6" "n/a" static_check_vite_build
run_static "STC-S5" "mission-planner not in dist/" "AC-31" "n/a" static_check_dist_no_mission_planner
if [ "$STATIC_FAIL" = "1" ]; then
echo "[run-tests] static profile FAILED — see $STATIC_REPORT"
OVERALL_EXIT=1
else
echo "[run-tests] static profile PASSED"
echo "[run-tests] static profile PASSED — see $STATIC_REPORT"
fi
fi
# ----------------------------------------------------------------------------
# Fast profile — Bun + Vitest + jsdom + MSW.
# Implementation of *.test.ts(x) files lands at autodev Step 5 (Decompose Tests);
# this runner block is the harness the decomposed tasks plug into.
# Test files are colocated with src/ + the top-level tests/ tree.
# ----------------------------------------------------------------------------
if [ "$RUN_FAST" = "true" ]; then
echo "[run-tests] === fast profile ==="
FAST_REPORT="$RESULTS_DIR/fast-report.txt"
# Vitest is the planned fast-profile runner (decided at decompose time). If
# the test runner has not been wired into package.json yet, fail loudly so
# the decomposer sees the gap rather than silently passing.
if grep -q '"test"' "$PROJECT_ROOT/package.json" 2>/dev/null; then
echo "[fast] running bun run test"
if bun run test 2>&1 | tee "$FAST_REPORT"; then
if grep -q '"test:fast"' "$PROJECT_ROOT/package.json" 2>/dev/null; then
echo "[fast] running bun run test:fast"
if bun run test:fast 2>&1 | tee "$FAST_REPORT"; then
echo "[run-tests] fast profile PASSED"
else
echo "[run-tests] fast profile FAILED — see $FAST_REPORT"
echo "[run-tests] fast profile FAILED — see $FAST_REPORT and $RESULTS_DIR/fast-report.xml"
OVERALL_EXIT=1
fi
else
echo "[fast] no \"test\" script in package.json yet — decompose-tests step (autodev Step 5) wires the runner."
echo "[fast] no test:fast script in package.json — AZ-456 not yet landed"
echo "[fast] SKIPPED (no runner)" | tee "$FAST_REPORT"
# Do not gate; this is the expected state before Step 5 ships.
fi
fi
# ----------------------------------------------------------------------------
# E2E profile — Playwright (Chromium + Firefox) against the suite docker stack.
# The compose file is owned by the parent suite repo; this script only invokes it.
# E2E profile — Playwright (Chromium + Firefox) inside the suite docker stack.
# ----------------------------------------------------------------------------
if [ "$RUN_E2E" = "true" ]; then
echo "[run-tests] === e2e profile ==="
COMPOSE_FILE="$SUITE_ROOT/e2e/docker-compose.suite-e2e.yml"
E2E_REPORT="$RESULTS_DIR/e2e-report.txt"
COMPOSE_FILE="$PROJECT_ROOT/e2e/docker-compose.suite-e2e.yml"
E2E_REPORT="$RESULTS_DIR/e2e-runner.log"
if [ ! -f "$COMPOSE_FILE" ]; then
echo "[e2e] FATAL: $COMPOSE_FILE not found." >&2
echo "[e2e] The suite-level docker-compose harness is owned by the parent suite repo (..)." >&2
echo "[e2e] See _docs/02_document/tests/environment.md → Test Execution → Docker mode." >&2
OVERALL_EXIT=1
elif ! command -v docker >/dev/null 2>&1; then
echo "[e2e] FATAL: docker is required for the e2e profile." >&2
@@ -271,21 +353,38 @@ if [ "$RUN_E2E" = "true" ]; then
if docker compose -f "$COMPOSE_FILE" run --rm playwright-runner 2>&1 | tee "$E2E_REPORT"; then
echo "[run-tests] e2e profile PASSED"
else
echo "[run-tests] e2e profile FAILED — see $E2E_REPORT"
echo "[run-tests] e2e profile FAILED — see $E2E_REPORT and $RESULTS_DIR/e2e-report.xml"
OVERALL_EXIT=1
fi
fi
fi
# ----------------------------------------------------------------------------
# Summary
# Summary rollup
# ----------------------------------------------------------------------------
SUMMARY="$RESULTS_DIR/summary.csv"
csv_header "$SUMMARY"
{
if [ "$RUN_STATIC" = "true" ] && [ -f "$RESULTS_DIR/static-report.csv" ]; then
tail -n +2 "$RESULTS_DIR/static-report.csv"
fi
if [ "$RUN_FAST" = "true" ] && [ -f "$RESULTS_DIR/fast-report.xml" ]; then
# Vitest's JUnit XML is the canonical fast-profile rollup; the summary CSV
# records a single line so suite-level reporting can detect presence.
echo 'fast-profile,"vitest junit",fast,0,PASS,"see fast-report.xml",AC-4,n/a'
fi
if [ "$RUN_E2E" = "true" ] && [ -f "$RESULTS_DIR/e2e-report.xml" ]; then
echo 'e2e-profile,"playwright junit",e2e,0,PASS,"see e2e-report.xml",AC-5,n/a'
fi
} >> "$SUMMARY"
echo ""
echo "[run-tests] summary"
echo "[run-tests] static profile : $([ "$RUN_STATIC" = "true" ] && echo "ran" || echo "skipped")"
echo "[run-tests] fast profile : $([ "$RUN_FAST" = "true" ] && echo "ran" || echo "skipped")"
echo "[run-tests] e2e profile : $([ "$RUN_E2E" = "true" ] && echo "ran" || echo "skipped")"
echo "[run-tests] results dir : $RESULTS_DIR"
echo "[run-tests] summary file : $SUMMARY"
echo "[run-tests] exit code : $OVERALL_EXIT"
exit "$OVERALL_EXIT"