0
0
mirror of https://github.com/go-gitea/gitea.git synced 2026-02-23 04:18:07 +01:00
gitea/tools/test-e2e.sh
silverwind f76c0acf59
Rework e2e tests
Remove the Go test harness that compiled test binaries and bootstrapped
a full Gitea server with fixtures. Replace with a bash script that runs
Playwright directly against an already-running Gitea instance.

- Remove Go e2e test files (e2e_test.go, utils_e2e_test.go)
- Add tools/test-e2e.sh that detects server URL, creates e2e user, runs Playwright
- Simplify Makefile to single test-e2e target
- Rewrite playwright.config.ts with chromium-only, no file outputs
- Rewrite tests using semantic Playwright locators (getByLabel, getByRole, getByText)
- Add login/logout utilities in tests/e2e/utils.ts
- Add CI workflow for e2e tests (.github/workflows/pull-e2e-tests.yml)
- Install only chromium in playwright install step

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-18 03:03:15 +01:00

48 lines
1.6 KiB
Bash
Executable File

#!/bin/bash
set -euo pipefail
# Determine the Gitea server URL, either from GITEA_URL env var or from custom/conf/app.ini
if [ -n "${GITEA_URL:-}" ]; then
GITEA_TEST_SERVER_URL="$GITEA_URL"
else
INI_FILE="custom/conf/app.ini"
if [ ! -f "$INI_FILE" ]; then
echo "error: $INI_FILE not found and GITEA_URL not set" >&2
echo "Either start Gitea with a config or set GITEA_URL explicitly:" >&2
echo " GITEA_URL=http://localhost:3000 make test-e2e" >&2
exit 1
fi
ROOT_URL=$(sed -n 's/^ROOT_URL\s*=\s*//p' "$INI_FILE" | tr -d '[:space:]')
if [ -z "$ROOT_URL" ]; then
echo "error: ROOT_URL not found in $INI_FILE" >&2
exit 1
fi
GITEA_TEST_SERVER_URL="$ROOT_URL"
fi
echo "Using Gitea server: $GITEA_TEST_SERVER_URL"
# Verify server is reachable
if ! curl -sf --max-time 5 "$GITEA_TEST_SERVER_URL" > /dev/null 2>&1; then
echo "error: Gitea server at $GITEA_TEST_SERVER_URL is not reachable" >&2
echo "Start Gitea first: ${EXECUTABLE:-./gitea}" >&2
exit 1
fi
# Create e2e test user if it does not already exist
E2E_USER="e2e"
E2E_EMAIL="e2e@test.gitea.io"
E2E_PASSWORD="password"
if ! curl -sf --max-time 5 "$GITEA_TEST_SERVER_URL/api/v1/users/$E2E_USER" > /dev/null 2>&1; then
echo "Creating e2e test user..."
if ${EXECUTABLE:-./gitea} admin user create --username "$E2E_USER" --email "$E2E_EMAIL" --password "$E2E_PASSWORD" --must-change-password=false 2>/dev/null; then
echo "User '$E2E_USER' created"
else
echo "error: failed to create user '$E2E_USER'" >&2
exit 1
fi
fi
export GITEA_TEST_SERVER_URL
exec pnpm exec playwright test "$@"