Add Playwright UI tests and before/after screenshots to CI
Lint / UI screenshots (before/after) (push) Skipped
Lint / JS (eslint) (push) Successful in 16s
Lint / PHP (phpcs PSR-12) (push) Successful in 30s
Lint / PHP requirements (version + extensions) (push) Successful in 50s
Lint / UI (playwright) (push) Successful in 3m29s
Lint / Deploy (push) Skipped
Lint / Notify on failure (push) Skipped
Security / PHP Security (semgrep) (push) Successful in 2m59s
Lint / JS (eslint) (pull_request) Successful in 16s
Lint / PHP (phpcs PSR-12) (pull_request) Successful in 33s
Lint / PHP requirements (version + extensions) (pull_request) Successful in 32s
Lint / UI (playwright) (pull_request) Successful in 2m23s
Lint / Deploy (pull_request) Skipped
Lint / Notify on failure (pull_request) Skipped
Security / PHP Security (semgrep) (pull_request) Successful in 1m32s
Lint / UI screenshots (before/after) (pull_request) Successful in 4m14s
Lint / UI screenshots (before/after) (push) Skipped
Lint / JS (eslint) (push) Successful in 16s
Lint / PHP (phpcs PSR-12) (push) Successful in 30s
Lint / PHP requirements (version + extensions) (push) Successful in 50s
Lint / UI (playwright) (push) Successful in 3m29s
Lint / Deploy (push) Skipped
Lint / Notify on failure (push) Skipped
Security / PHP Security (semgrep) (push) Successful in 2m59s
Lint / JS (eslint) (pull_request) Successful in 16s
Lint / PHP (phpcs PSR-12) (pull_request) Successful in 33s
Lint / PHP requirements (version + extensions) (pull_request) Successful in 32s
Lint / UI (playwright) (pull_request) Successful in 2m23s
Lint / Deploy (pull_request) Skipped
Lint / Notify on failure (pull_request) Skipped
Security / PHP Security (semgrep) (pull_request) Successful in 1m32s
Lint / UI screenshots (before/after) (pull_request) Successful in 4m14s
New UI (playwright) job: PHP and MariaDB inside the Playwright image, a seeded instance (tests/ui/stack.sh, synthetic data only) and 21 tests: every main page loads with no page errors, console errors or failed requests, description and comment markdown render safely (#114), and pages fit a phone screen. Deploys now wait for it. New UI screenshots (before/after) job: for PRs that change assets/ or views/, runs the base branch and the PR side by side with the same data and uploads one side-by-side PNG per page and view (dark, light, phone). Modelled on Pulse's ui and ui-screenshots jobs. Fixes found while building it: - migrate.php split statements on semicolons inside -- comments, so 001 and 003 failed on a fresh database. - API endpoints applied rate limiting before loading config, so RATE_LIMIT_DEFAULT/RATE_LIMIT_API from .env and TRUSTED_PROXIES were ignored there: every user behind the proxy shared one per-IP bucket. The limiter now loads config itself; the per-IP limits are configurable (RATE_LIMIT_IP, RATE_LIMIT_IP_API) with unchanged defaults. - The avatar error fallback was registered in the footer, after the header avatar, so a fast 404 left a broken image instead of initials. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
bdc6028572
commit
f1decca31f
22 files changed
+777
-8
No files matched your search
Executable
+72
@@ -0,0 +1,72 @@
|
||||
#!/bin/bash
|
||||
# Starts one Tinker Tickets instance for the UI tests on a fresh database:
|
||||
#
|
||||
# tests/ui/stack.sh <checkout-dir> <port> <db-name>
|
||||
#
|
||||
# Creates the database, writes the checkout's .env (throwaway values only),
|
||||
# applies the checkout's migrations, loads the synthetic seed
|
||||
# data and serves the checkout with PHP's built-in server. The seed and router
|
||||
# always come from this script's directory, so the same data goes into the
|
||||
# base branch's checkout for before/after screenshots.
|
||||
#
|
||||
# Needs a MariaDB on 127.0.0.1 with a 'tinker_ui' user (tests/ui/setup.sh in
|
||||
# CI) and root access to it over the local socket. Logs go to
|
||||
# <checkout>/.ui-stack/server.log.
|
||||
set -euo pipefail
|
||||
CHECKOUT=$(cd "${1:?checkout dir}" && pwd)
|
||||
PORT=${2:?port}
|
||||
DB=${3:?database name}
|
||||
HERE=$(cd "$(dirname "$0")" && pwd)
|
||||
|
||||
case "$DB" in
|
||||
tinker_ui*) ;;
|
||||
*) echo "refusing: database name must start with tinker_ui" >&2; exit 2 ;;
|
||||
esac
|
||||
|
||||
mariadb -e "DROP DATABASE IF EXISTS \`$DB\`; CREATE DATABASE \`$DB\`;
|
||||
GRANT ALL ON \`$DB\`.* TO 'tinker_ui'@'127.0.0.1';"
|
||||
|
||||
if [ -e "$CHECKOUT/.env" ] && ! grep -q "^; tinker-ui-stack" "$CHECKOUT/.env"; then
|
||||
echo "refusing: $CHECKOUT/.env exists and was not written by this script" >&2
|
||||
exit 2
|
||||
fi
|
||||
cat > "$CHECKOUT/.env" <<EOF
|
||||
; tinker-ui-stack: throwaway UI test settings, safe to delete
|
||||
DB_HOST=127.0.0.1
|
||||
DB_USER=tinker_ui
|
||||
DB_PASS=ci-only
|
||||
DB_NAME=$DB
|
||||
LDAP_ENABLED=false
|
||||
TIMEZONE=UTC
|
||||
; One client IP makes every request in a test run; the default limits would
|
||||
; turn later pages into 429s.
|
||||
RATE_LIMIT_DEFAULT=100000
|
||||
RATE_LIMIT_API=100000
|
||||
RATE_LIMIT_IP=100000
|
||||
RATE_LIMIT_IP_API=100000
|
||||
EOF
|
||||
|
||||
# This branch's migration runner, run from inside the checkout so it reads
|
||||
# that checkout's config and migrations: a base branch with an older runner
|
||||
# (before the comment fix) still gets its schema.
|
||||
cp "$HERE/../../migrations/migrate.php" "$CHECKOUT/migrations/.ui-migrate.php"
|
||||
php "$CHECKOUT/migrations/.ui-migrate.php"
|
||||
rm -f "$CHECKOUT/migrations/.ui-migrate.php"
|
||||
DB_NAME=$DB php "$HERE/seed.php"
|
||||
|
||||
mkdir -p "$CHECKOUT/.ui-stack"
|
||||
(cd "$CHECKOUT" && setsid php -S "127.0.0.1:$PORT" -t . "$HERE/router.php" \
|
||||
> "$CHECKOUT/.ui-stack/server.log" 2>&1 &)
|
||||
|
||||
for _ in $(seq 1 30); do
|
||||
code=$(curl -s -o /dev/null -w '%{http_code}' -H 'Remote-User: ci.tester' -H 'Remote-Name: CI Tester' \
|
||||
-H 'Remote-Email: ci@example.invalid' -H 'Remote-Groups: admin' "http://127.0.0.1:$PORT/" || true)
|
||||
if [ "$code" = 200 ]; then
|
||||
echo "Tinker Tickets ($CHECKOUT) on http://127.0.0.1:$PORT, database $DB"
|
||||
exit 0
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
echo "::error::Tinker Tickets did not answer on port $PORT (last HTTP ${code:-none})"
|
||||
tail -n 50 "$CHECKOUT/.ui-stack/server.log" || true
|
||||
exit 1
|
||||
Reference in new issue
Block a user