test: add real plugin integration test and --test-real-plugin option

- Add tests/real-plugin.spec.ts for end-to-end plugin testing
- Add --test-real-plugin flag to run-test-frontend.sh
- Test verifies: server registration, API key generation, heartbeat,
  data persistence, invalid key rejection, key revocation
This commit is contained in:
zhi
2026-03-19 22:07:54 +00:00
parent 5a45a72dcf
commit cc2d4aea5c
2 changed files with 27 additions and 8 deletions

View File

@@ -1,15 +1,16 @@
#!/bin/bash
# Run frontend test with optional port exposure
# Usage: ./run-test-frontend.sh [--expose-port {on|off}]
# Default: off
#
# --expose-port on: Keep services running after test (manual cleanup required)
# --expose-port off: Auto cleanup after test (default)
# Usage: ./run-test-frontend.sh [--expose-port {on|off}] [--test-real-plugin]
# Default:
# --expose-port off: Auto cleanup after test
# --test-real-plugin: Run only real-plugin.spec.ts (requires vps.t1 plugin)
set -e
EXPOSE_PORT="off"
TEST_REAL_PLUGIN="off"
COMPOSE_FILE="docker-compose-frontend.yml"
TEST_PATTERN=""
# Load environment variables from .env.TEST if exists
if [ -f ".env.TEST" ]; then
@@ -30,9 +31,13 @@ while [[ $# -gt 0 ]]; do
EXPOSE_PORT="${1#*=}"
shift
;;
--test-real-plugin)
TEST_REAL_PLUGIN="on"
shift
;;
*)
echo "Unknown option: $1"
echo "Usage: $0 [--expose-port {on|off}]"
echo "Usage: $0 [--expose-port {on|off}] [--test-real-plugin]"
exit 1
;;
esac
@@ -44,6 +49,14 @@ if [[ "$EXPOSE_PORT" != "on" && "$EXPOSE_PORT" != "off" ]]; then
exit 1
fi
# Set test pattern for real plugin test
if [[ "$TEST_REAL_PLUGIN" == "on" ]]; then
TEST_PATTERN="real-plugin.spec.ts"
echo "🔌 Real Plugin Test Mode: ON"
echo " Will run: tests/real-plugin.spec.ts"
echo " Requires vps.t1 to have OpenClaw plugin installed"
fi
# Select compose file based on expose-port
if [[ "$EXPOSE_PORT" == "on" ]]; then
COMPOSE_FILE="docker-compose-frontend-expose.yml"
@@ -114,7 +127,13 @@ echo "✅ Services ready!"
# Run test
echo "🧪 Running test..."
if [[ -n "$TEST_PATTERN" ]]; then
# Run specific test for real plugin
docker compose -f "$COMPOSE_FILE" run --rm -e WORKERS=1 test npx playwright test tests/real-plugin.spec.ts --reporter=list
else
# Run all tests
docker compose -f "$COMPOSE_FILE" run --rm -e WORKERS=1 test
fi
TEST_EXIT_CODE=$?
# Cleanup decision based on expose-port