The existing smoke test only checked TCP port connectivity, which cannot
detect a service that accepts connections but returns errors or serves
the wrong content (exactly how the broken Kiwix slipped through).
Add two new validation layers:
1. validate-http.sh — curls every service's health/UI endpoint and
asserts both the HTTP status code AND meaningful body content (JSON
health fields like "database":"ok", XML markers, page strings). Also
verifies Kiwix has a ZIM actually loaded via its OPDS catalog feed.
2. run-browser-tests.sh — drives a real headless Chromium via the
official Playwright Docker image (no host Node install needed) to
confirm pages render correctly after JavaScript execution and SPA
hydration. Updated playwright-services.spec.ts with correct content
tokens and a waitForFunction step that reliably handles SPA timing.
Both are wired into demo-test.sh (new `http` and `browser` subcommands)
and the full test suite. AGENTS.md and demo/AGENTS.md updated with the
new commands and protocols.
💘 Generated with Crush
Assisted-by: Crush:glm-5.2
43 lines
1.6 KiB
Bash
Executable File
43 lines
1.6 KiB
Bash
Executable File
#!/bin/bash
|
|
# TSYS Developer Support Stack - Browser (Playwright) Validation
|
|
# Purpose: drive a real headless browser against every service to validate that
|
|
# pages render and contain expected content. Deeper than HTTP probes:
|
|
# it executes JavaScript, waits for DOM ready, and checks rendered text.
|
|
#
|
|
# Runs entirely inside the official Playwright Docker image (no host Node/npm
|
|
# install required). All npm artefacts stay inside the container's own
|
|
# filesystem, so no root-owned files are written to the host. Host services are
|
|
# reached via the host network.
|
|
#
|
|
# Usage: ./tests/e2e/run-browser-tests.sh
|
|
# Exit: 0 if all browser checks pass, 1 otherwise.
|
|
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
|
|
PLAYWRIGHT_IMAGE="mcr.microsoft.com/playwright:v1.52.0-noble"
|
|
NETWORK_MODE="${PLAYWRIGHT_NETWORK:-host}"
|
|
|
|
log() { echo "[browser-tests] $*"; }
|
|
|
|
if ! docker info >/dev/null 2>&1; then
|
|
echo "[ERROR] Docker is not running" >&2
|
|
exit 1
|
|
fi
|
|
|
|
log "Ensuring Playwright image is present..."
|
|
docker image inspect "$PLAYWRIGHT_IMAGE" >/dev/null 2>&1 || docker pull "$PLAYWRIGHT_IMAGE"
|
|
|
|
log "Installing @playwright/test and running spec inside $PLAYWRIGHT_IMAGE..."
|
|
# Mount the e2e sources read-only; copy them into a container-local work dir so
|
|
# npm install never writes root-owned files to the host.
|
|
docker run --rm \
|
|
${NETWORK_MODE:+--network "$NETWORK_MODE"} \
|
|
-v "$SCRIPT_DIR":/src:ro \
|
|
--entrypoint sh \
|
|
"$PLAYWRIGHT_IMAGE" \
|
|
-c 'set -e; cp -r /src/. /work; cd /work; npm install --no-audit --no-fund; npx playwright test'
|
|
|
|
log "Browser tests complete."
|