mirror of
https://github.com/azaion/ui.git
synced 2026-06-21 08:01:10 +00:00
[AZ-447] autodev Steps 1-4 baseline: docs, tests, refactor specs
Captures the full output of autodev existing-code Phase A through Step 4 (Code Testability Revision) for the Azaion UI workspace: - Step 1 Document: _docs/02_document/ (FINAL_report, architecture, glossary, components/, modules/, diagrams/, system-flows, module-layout) plus _docs/00_problem/ + _docs/01_solution/ + _docs/legacy/ + _docs/how_to_test + README. - Step 2 Architecture Baseline: architecture_compliance_baseline.md. - Step 3 Test Spec: _docs/02_document/tests/ (environment, test-data, blackbox/performance/resilience/security/ resource-limit tests, traceability-matrix), enum_spec_snapshot, expected_results/results_report.md (98 rows), plus the run-tests.sh + run-performance-tests.sh runners. - Step 4 Code Testability Revision: 01-testability-refactoring/ run dir (list-of-changes C01-C07, deferred_to_refactor, analysis/research_findings + refactoring_roadmap) and the 7 child task specs AZ-448..AZ-454 under _docs/02_tasks/todo/ plus _dependencies_table.md. - _docs/_autodev_state.md pins the cursor at Step 4 / refactor Phase 4 entry so /autodev resumes cleanly. Epic AZ-447 (UI testability gates) tracks the 7 child tasks that will land in subsequent commits. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Executable
+173
@@ -0,0 +1,173 @@
|
||||
#!/usr/bin/env bash
|
||||
# Azaion UI — performance test runner.
|
||||
#
|
||||
# Generated by .cursor/skills/test-spec phase 4. Implements the NFT-PERF-* scenarios
|
||||
# from _docs/02_document/tests/performance-tests.md. Thresholds are sourced from
|
||||
# _docs/00_problem/input_data/expected_results/results_report.md (rows 11, 40, 98 + AC-11 + AC-23).
|
||||
#
|
||||
# Most NFT-PERF-* tests are observable browser timings, not server load tests. The
|
||||
# script therefore runs Playwright-based measurements rather than k6/locust.
|
||||
#
|
||||
# Profile mapping (per environment.md → Test Execution):
|
||||
# - NFT-PERF-01 (bundle ≤ 2 MB gzip) : static — checks dist/ on host
|
||||
# - NFT-PERF-02..09 : fast or e2e — Playwright
|
||||
# - NFT-PERF-10 (FCP ≤ 3 000 ms on /flights) : e2e — Playwright against the suite stack
|
||||
#
|
||||
# Usage:
|
||||
# scripts/run-performance-tests.sh # run all NFT-PERF-* (skips quarantined)
|
||||
# scripts/run-performance-tests.sh --static-only # only NFT-PERF-01 (bundle size)
|
||||
# scripts/run-performance-tests.sh --e2e-only # only NFT-PERF-* that require the stack
|
||||
# scripts/run-performance-tests.sh --bundle-max-bytes 2097152 # override bundle threshold
|
||||
|
||||
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"
|
||||
|
||||
RUN_STATIC=true
|
||||
RUN_E2E=true
|
||||
|
||||
# Thresholds (defaults from results_report.md; overridable via flags).
|
||||
BUNDLE_MAX_BYTES=$((2 * 1024 * 1024)) # AC-11 / NFT-PERF-01 (row 40): 2 MB gzipped initial JS
|
||||
FCP_MAX_MS=3000 # NFT-PERF-10 (row 98): warm-cache FCP on /flights, edge profile
|
||||
AUTH_REFRESH_MAX_MS=200 # NFT-PERF-02 (row 11): refresh round-trip target
|
||||
|
||||
for arg in "$@"; do
|
||||
case "$arg" in
|
||||
--static-only) RUN_STATIC=true; RUN_E2E=false ;;
|
||||
--e2e-only) RUN_STATIC=false; RUN_E2E=true ;;
|
||||
--bundle-max-bytes=*) BUNDLE_MAX_BYTES="${arg#*=}" ;;
|
||||
--bundle-max-bytes) shift; BUNDLE_MAX_BYTES="${1:-$BUNDLE_MAX_BYTES}" ;;
|
||||
--fcp-max-ms=*) FCP_MAX_MS="${arg#*=}" ;;
|
||||
--fcp-max-ms) shift; FCP_MAX_MS="${1:-$FCP_MAX_MS}" ;;
|
||||
--auth-refresh-max-ms=*) AUTH_REFRESH_MAX_MS="${arg#*=}" ;;
|
||||
--auth-refresh-max-ms) shift; AUTH_REFRESH_MAX_MS="${1:-$AUTH_REFRESH_MAX_MS}" ;;
|
||||
-h|--help)
|
||||
sed -n '2,22p' "$0" | sed 's/^# \{0,1\}//'
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "Unknown argument: $arg" >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
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
|
||||
fi
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
mkdir -p "$RESULTS_DIR"
|
||||
|
||||
cd "$PROJECT_ROOT"
|
||||
|
||||
echo "[run-performance-tests] thresholds:"
|
||||
echo " bundle (NFT-PERF-01) : ≤ $BUNDLE_MAX_BYTES bytes gzipped"
|
||||
echo " FCP (NFT-PERF-10) : ≤ $FCP_MAX_MS ms"
|
||||
echo " auth refresh (NFT-PERF-02): ≤ $AUTH_REFRESH_MAX_MS ms"
|
||||
echo " static : $RUN_STATIC"
|
||||
echo " e2e : $RUN_E2E"
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Install deps (matches run-tests.sh).
|
||||
# ----------------------------------------------------------------------------
|
||||
if ! command -v bun >/dev/null 2>&1; then
|
||||
echo "[run-performance-tests] FATAL: bun is required (project pins bun@1.3.11)." >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "[run-performance-tests] installing dependencies..."
|
||||
if [ -f "$PROJECT_ROOT/bun.lock" ] || [ -f "$PROJECT_ROOT/bun.lockb" ]; then
|
||||
bun install --frozen-lockfile
|
||||
else
|
||||
bun install
|
||||
fi
|
||||
|
||||
OVERALL_EXIT=0
|
||||
SUMMARY_FILE="$RESULTS_DIR/performance-summary.txt"
|
||||
: > "$SUMMARY_FILE"
|
||||
|
||||
record() {
|
||||
# $1 = scenario id, $2 = result (PASS|FAIL|SKIP|QUARANTINE), $3 = measured, $4 = threshold
|
||||
printf '%-14s %-12s measured=%-14s threshold=%s\n' "$1" "$2" "$3" "$4" | tee -a "$SUMMARY_FILE"
|
||||
}
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Static perf scenarios.
|
||||
# ----------------------------------------------------------------------------
|
||||
if [ "$RUN_STATIC" = "true" ]; then
|
||||
echo "[run-performance-tests] === NFT-PERF-01 (bundle size) ==="
|
||||
if [ ! -d "$PROJECT_ROOT/dist" ]; then
|
||||
echo "[NFT-PERF-01] dist/ not present — running 'bun run build'..."
|
||||
bun run build
|
||||
fi
|
||||
|
||||
# Sum gzipped sizes of dist/assets/*.js (the initial JS bundle is index-*.js per Vite).
|
||||
BUNDLE_BYTES=$(
|
||||
find "$PROJECT_ROOT/dist/assets" -maxdepth 1 -name '*.js' -print0 2>/dev/null \
|
||||
| xargs -0 -I{} sh -c 'gzip -c "{}" | wc -c' \
|
||||
| awk '{ s += $1 } END { print (s ? s : 0) }'
|
||||
)
|
||||
echo "[NFT-PERF-01] gzipped dist/assets/*.js = $BUNDLE_BYTES bytes"
|
||||
if [ "$BUNDLE_BYTES" -le "$BUNDLE_MAX_BYTES" ]; then
|
||||
record "NFT-PERF-01" "PASS" "${BUNDLE_BYTES}B" "≤ ${BUNDLE_MAX_BYTES}B"
|
||||
else
|
||||
record "NFT-PERF-01" "FAIL" "${BUNDLE_BYTES}B" "≤ ${BUNDLE_MAX_BYTES}B"
|
||||
OVERALL_EXIT=1
|
||||
fi
|
||||
fi
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# E2E perf scenarios (Playwright-based).
|
||||
# The Playwright project lands at autodev Step 5 (Decompose Tests). Until it
|
||||
# ships, NFT-PERF-02..10 are SKIPPED (not FAILED) so this script can run on
|
||||
# the spec-only baseline without producing false negatives.
|
||||
# ----------------------------------------------------------------------------
|
||||
if [ "$RUN_E2E" = "true" ]; then
|
||||
COMPOSE_FILE="$SUITE_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."
|
||||
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"
|
||||
done
|
||||
elif [ ! -f "$COMPOSE_FILE" ]; then
|
||||
echo "[run-performance-tests] FATAL: $COMPOSE_FILE not found (parent suite repo owns it)." >&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
|
||||
OVERALL_EXIT=1
|
||||
else
|
||||
echo "[run-performance-tests] starting compose stack..."
|
||||
docker compose -f "$COMPOSE_FILE" up -d --build
|
||||
E2E_COMPOSE_STARTED_HERE=true
|
||||
|
||||
echo "[run-performance-tests] running Playwright perf project..."
|
||||
if FCP_MAX_MS="$FCP_MAX_MS" AUTH_REFRESH_MAX_MS="$AUTH_REFRESH_MAX_MS" \
|
||||
bunx playwright test --config "$PERF_PROJECT" 2>&1 | tee "$RESULTS_DIR/perf-playwright.txt"; then
|
||||
echo "[run-performance-tests] Playwright perf PASSED"
|
||||
else
|
||||
echo "[run-performance-tests] Playwright perf FAILED — see $RESULTS_DIR/perf-playwright.txt"
|
||||
OVERALL_EXIT=1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Quarantined scenarios (documentary only — never gate today).
|
||||
record "NFT-PERF-03" "QUARANTINE" "—" "Step 8 hardening (SSE refresh rotation)"
|
||||
record "NFT-PERF-08" "QUARANTINE" "—" "Step 4 fix (panel-width persistence)"
|
||||
record "NFT-PERF-09" "QUARANTINE" "—" "Step 4 fix (settings save error surfacing)"
|
||||
|
||||
echo ""
|
||||
echo "[run-performance-tests] summary written to $SUMMARY_FILE"
|
||||
echo "[run-performance-tests] exit code: $OVERALL_EXIT"
|
||||
|
||||
exit "$OVERALL_EXIT"
|
||||
Executable
+291
@@ -0,0 +1,291 @@
|
||||
#!/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
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# Usage:
|
||||
# scripts/run-tests.sh # static + fast (default; gates every commit per CI/CD Integration)
|
||||
# scripts/run-tests.sh --unit-only # alias for default — fast + static, no e2e
|
||||
# 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
|
||||
|
||||
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"
|
||||
|
||||
RUN_STATIC=true
|
||||
RUN_FAST=true
|
||||
RUN_E2E=false
|
||||
|
||||
for arg in "$@"; do
|
||||
case "$arg" in
|
||||
--unit-only) RUN_STATIC=true; RUN_FAST=true; RUN_E2E=false ;;
|
||||
--all) RUN_STATIC=true; RUN_FAST=true; RUN_E2E=true ;;
|
||||
--e2e-only) RUN_STATIC=false; RUN_FAST=false; RUN_E2E=true ;;
|
||||
--static-only) RUN_STATIC=true; RUN_FAST=false; RUN_E2E=false ;;
|
||||
--fast-only) RUN_STATIC=false; RUN_FAST=true; RUN_E2E=false ;;
|
||||
-h|--help)
|
||||
sed -n '2,18p' "$0" | sed 's/^# \{0,1\}//'
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "Unknown argument: $arg" >&2
|
||||
echo "Run with --help for usage." >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
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
|
||||
fi
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
mkdir -p "$RESULTS_DIR"
|
||||
|
||||
cd "$PROJECT_ROOT"
|
||||
|
||||
echo "[run-tests] project root: $PROJECT_ROOT"
|
||||
echo "[run-tests] suite root : $SUITE_ROOT"
|
||||
echo "[run-tests] profiles : static=$RUN_STATIC fast=$RUN_FAST e2e=$RUN_E2E"
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Install dependencies (mandatory — a fresh CI runner has nothing).
|
||||
# ----------------------------------------------------------------------------
|
||||
if [ "$RUN_FAST" = "true" ] || [ "$RUN_STATIC" = "true" ]; then
|
||||
if ! command -v bun >/dev/null 2>&1; 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)..."
|
||||
if [ -f "$PROJECT_ROOT/bun.lock" ] || [ -f "$PROJECT_ROOT/bun.lockb" ]; then
|
||||
bun install --frozen-lockfile
|
||||
else
|
||||
bun install
|
||||
fi
|
||||
fi
|
||||
|
||||
OVERALL_EXIT=0
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Static profile — repo + dist artifact checks.
|
||||
# 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_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"
|
||||
else
|
||||
echo " FAIL: strict mode not enabled" | tee -a "$STATIC_REPORT"; 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
|
||||
else
|
||||
echo " PASS mission-planner absent from dist/" | tee -a "$STATIC_REPORT"
|
||||
fi
|
||||
else
|
||||
echo " SKIP dist/ not built — re-run after 'bun run build'" | tee -a "$STATIC_REPORT"
|
||||
fi
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
if [ "$STATIC_FAIL" = "1" ]; then
|
||||
echo "[run-tests] static profile FAILED — see $STATIC_REPORT"
|
||||
OVERALL_EXIT=1
|
||||
else
|
||||
echo "[run-tests] static profile PASSED"
|
||||
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.
|
||||
# ----------------------------------------------------------------------------
|
||||
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
|
||||
echo "[run-tests] fast profile PASSED"
|
||||
else
|
||||
echo "[run-tests] fast profile FAILED — see $FAST_REPORT"
|
||||
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] 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.
|
||||
# ----------------------------------------------------------------------------
|
||||
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"
|
||||
|
||||
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
|
||||
OVERALL_EXIT=1
|
||||
else
|
||||
echo "[e2e] starting compose stack at $COMPOSE_FILE..."
|
||||
docker compose -f "$COMPOSE_FILE" up -d --build
|
||||
E2E_COMPOSE_STARTED_HERE=true
|
||||
|
||||
echo "[e2e] running playwright-runner..."
|
||||
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"
|
||||
OVERALL_EXIT=1
|
||||
fi
|
||||
fi
|
||||
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] exit code : $OVERALL_EXIT"
|
||||
|
||||
exit "$OVERALL_EXIT"
|
||||
Reference in New Issue
Block a user