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:
Submodule HarborForge.Backend.Test updated: 5f6a3dffe4...ed21b73a43
@@ -1,15 +1,16 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Run frontend test with optional port exposure
|
# Run frontend test with optional port exposure
|
||||||
# Usage: ./run-test-frontend.sh [--expose-port {on|off}]
|
# Usage: ./run-test-frontend.sh [--expose-port {on|off}] [--test-real-plugin]
|
||||||
# Default: off
|
# Default:
|
||||||
#
|
# --expose-port off: Auto cleanup after test
|
||||||
# --expose-port on: Keep services running after test (manual cleanup required)
|
# --test-real-plugin: Run only real-plugin.spec.ts (requires vps.t1 plugin)
|
||||||
# --expose-port off: Auto cleanup after test (default)
|
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
EXPOSE_PORT="off"
|
EXPOSE_PORT="off"
|
||||||
|
TEST_REAL_PLUGIN="off"
|
||||||
COMPOSE_FILE="docker-compose-frontend.yml"
|
COMPOSE_FILE="docker-compose-frontend.yml"
|
||||||
|
TEST_PATTERN=""
|
||||||
|
|
||||||
# Load environment variables from .env.TEST if exists
|
# Load environment variables from .env.TEST if exists
|
||||||
if [ -f ".env.TEST" ]; then
|
if [ -f ".env.TEST" ]; then
|
||||||
@@ -30,9 +31,13 @@ while [[ $# -gt 0 ]]; do
|
|||||||
EXPOSE_PORT="${1#*=}"
|
EXPOSE_PORT="${1#*=}"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
--test-real-plugin)
|
||||||
|
TEST_REAL_PLUGIN="on"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Unknown option: $1"
|
echo "Unknown option: $1"
|
||||||
echo "Usage: $0 [--expose-port {on|off}]"
|
echo "Usage: $0 [--expose-port {on|off}] [--test-real-plugin]"
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@@ -44,6 +49,14 @@ if [[ "$EXPOSE_PORT" != "on" && "$EXPOSE_PORT" != "off" ]]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
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
|
# Select compose file based on expose-port
|
||||||
if [[ "$EXPOSE_PORT" == "on" ]]; then
|
if [[ "$EXPOSE_PORT" == "on" ]]; then
|
||||||
COMPOSE_FILE="docker-compose-frontend-expose.yml"
|
COMPOSE_FILE="docker-compose-frontend-expose.yml"
|
||||||
@@ -114,7 +127,13 @@ echo "✅ Services ready!"
|
|||||||
|
|
||||||
# Run test
|
# Run test
|
||||||
echo "🧪 Running test..."
|
echo "🧪 Running test..."
|
||||||
docker compose -f "$COMPOSE_FILE" run --rm -e WORKERS=1 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=$?
|
TEST_EXIT_CODE=$?
|
||||||
|
|
||||||
# Cleanup decision based on expose-port
|
# Cleanup decision based on expose-port
|
||||||
|
|||||||
Reference in New Issue
Block a user