diff --git a/plugins/ms-ai-architect/tests/run-e2e.sh b/plugins/ms-ai-architect/tests/run-e2e.sh index 98be99d..95b3e7f 100755 --- a/plugins/ms-ai-architect/tests/run-e2e.sh +++ b/plugins/ms-ai-architect/tests/run-e2e.sh @@ -1,6 +1,6 @@ #!/bin/bash # run-e2e.sh — Run E2E regression tests for agent outputs -# Usage: bash tests/run-e2e.sh [--security] [--cost] [--summary] [--ros] [--ai-act] [--playground] [--all] +# Usage: bash tests/run-e2e.sh [--security] [--cost] [--summary] [--ros] [--ai-act] [--playground] [--kb-update] [--all] set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" @@ -17,6 +17,7 @@ RUN_SUMMARY=false RUN_ROS=false RUN_AI_ACT=false RUN_PLAYGROUND=false +RUN_KB_UPDATE=false if [ $# -eq 0 ] || [ "${1:-}" = "--all" ]; then RUN_SECURITY=true @@ -25,6 +26,7 @@ if [ $# -eq 0 ] || [ "${1:-}" = "--all" ]; then RUN_ROS=true RUN_AI_ACT=true RUN_PLAYGROUND=true + RUN_KB_UPDATE=true else while [ $# -gt 0 ]; do case "$1" in @@ -34,8 +36,9 @@ else --ros) RUN_ROS=true ;; --ai-act) RUN_AI_ACT=true ;; --playground) RUN_PLAYGROUND=true ;; + --kb-update) RUN_KB_UPDATE=true ;; *) - echo "Usage: bash tests/run-e2e.sh [--security] [--cost] [--summary] [--ros] [--ai-act] [--playground] [--all]" + echo "Usage: bash tests/run-e2e.sh [--security] [--cost] [--summary] [--ros] [--ai-act] [--playground] [--kb-update] [--all]" exit 1 ;; esac @@ -75,6 +78,10 @@ if $RUN_PLAYGROUND; then bash "$SCRIPT_DIR/test-playground-parsers.sh" || FAILURES=$((FAILURES + 1)) fi +if $RUN_KB_UPDATE; then + bash "$SCRIPT_DIR/test-kb-update.sh" || FAILURES=$((FAILURES + 1)) +fi + echo -e "${CYAN}══════════════════════════════════════════════${NC}" if [ "$FAILURES" -eq 0 ]; then echo -e "${GREEN} All E2E suites passed${NC}" diff --git a/plugins/ms-ai-architect/tests/test-kb-update.sh b/plugins/ms-ai-architect/tests/test-kb-update.sh new file mode 100755 index 0000000..6a20c5c --- /dev/null +++ b/plugins/ms-ai-architect/tests/test-kb-update.sh @@ -0,0 +1,44 @@ +#!/bin/bash +# test-kb-update.sh — Run KB-update node:test suite via the E2E harness. +# Bash 3.2-compatible. Sources lib/e2e-helpers.sh, runs node --test against +# the kb-update glob (Node 25 rejects directory-form arguments to --test), +# and translates the result into the suite's pass/fail counters. +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +PLUGIN_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" + +source "$SCRIPT_DIR/lib/e2e-helpers.sh" + +init_suite "KB Update" + +cd "$PLUGIN_ROOT" + +if ! compgen -G "tests/kb-update/*.test.mjs" >/dev/null 2>&1; then + fail "No test files matched tests/kb-update/*.test.mjs" + print_summary + exit 1 +fi + +TEST_LOG="$(mktemp -t kb-update-suite.XXXXXX)" +trap 'rm -f "$TEST_LOG"' EXIT + +NODE_EXIT=0 +node --test tests/kb-update/*.test.mjs >"$TEST_LOG" 2>&1 || NODE_EXIT=$? + +cat "$TEST_LOG" + +PASS_COUNT="$(awk '/^[^[:alnum:]]*pass[[:space:]]+[0-9]+/ { for (i=1;i<=NF;i++) if ($i=="pass") { print $(i+1); exit } }' "$TEST_LOG")" +FAIL_COUNT="$(awk '/^[^[:alnum:]]*fail[[:space:]]+[0-9]+/ { for (i=1;i<=NF;i++) if ($i=="fail") { print $(i+1); exit } }' "$TEST_LOG")" +TESTS_COUNT="$(awk '/^[^[:alnum:]]*tests[[:space:]]+[0-9]+/ { for (i=1;i<=NF;i++) if ($i=="tests") { print $(i+1); exit } }' "$TEST_LOG")" +PASS_COUNT="${PASS_COUNT:-0}" +FAIL_COUNT="${FAIL_COUNT:-0}" +TESTS_COUNT="${TESTS_COUNT:-0}" + +if [ "$NODE_EXIT" -eq 0 ] && [ "$FAIL_COUNT" -eq 0 ]; then + pass "node --test tests/kb-update/*.test.mjs ($PASS_COUNT/$TESTS_COUNT pass)" +else + fail "node --test failed (pass=$PASS_COUNT, fail=$FAIL_COUNT, tests=$TESTS_COUNT, exit=$NODE_EXIT)" +fi + +print_summary