feat: Add comprehensive testing infrastructure
Implements robust testing setup with Playwright global auth, reusable test helpers, Docker support, and CI/CD integration with Gitea Actions. ## Changes ### Playwright Setup - Add global auth setup with storage state reuse (tests/playwright/auth.setup.ts) - Fix auth setup to clear existing state before fresh login - Create reusable performOAuthLogin helper (tests/playwright/helpers.ts) - Configure dotenv loading for environment variables in playwright.config.ts ### Magnitude Configuration - Update to use Claude Sonnet 4.5 (claude-sonnet-4-5-20250514) - Create reusable loginFlow helper (tests/magnitude/helpers.ts) - Fix smoke test to check login page instead of non-existent homepage ### Docker Support - Add Dockerfile.playwright with non-root user (pwuser) for security - Uses official Playwright Docker image (mcr.microsoft.com/playwright:v1.49.1-noble) - Provides consistent testing environment across users and CI/CD ### CI/CD Integration - Add Gitea Actions workflow (.gitea/workflows/magnitude.yml) - Runs Magnitude tests on every push and PR - Starts SurrealDB and Next.js dev server automatically - Uploads test results as artifacts (30-day retention) ### Documentation - Add comprehensive testing setup docs to AGENTS.md: - Playwright Docker setup instructions - CI/CD with Gitea Actions - Testing framework separation (Playwright vs Magnitude) - Required secrets for CI/CD ### Testing Best Practices - Separate Playwright (manual + global auth) from Magnitude (automated E2E) - Reusable helpers reduce code duplication - Both frameworks work independently ## Testing - ✅ Playwright auth setup test passes (5.6s) - ✅ Magnitude smoke test passes - ✅ OAuth flow works correctly with helper function 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
75
.gitea/workflows/magnitude.yml
Normal file
75
.gitea/workflows/magnitude.yml
Normal file
@@ -0,0 +1,75 @@
|
||||
# Gitea Actions workflow for running Magnitude tests
|
||||
name: Magnitude Tests
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main, development]
|
||||
pull_request:
|
||||
branches: [main, development]
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20'
|
||||
|
||||
- name: Install pnpm
|
||||
run: npm install -g pnpm
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
- name: Start SurrealDB
|
||||
run: |
|
||||
docker run -d \
|
||||
--name surrealdb \
|
||||
-p 8000:8000 \
|
||||
-e SURREAL_USER=${{ secrets.SURREALDB_USER }} \
|
||||
-e SURREAL_PASS=${{ secrets.SURREALDB_PASS }} \
|
||||
surrealdb/surrealdb:latest \
|
||||
start --log trace --user ${{ secrets.SURREALDB_USER }} --pass ${{ secrets.SURREALDB_PASS }} memory
|
||||
|
||||
- name: Wait for SurrealDB
|
||||
run: sleep 5
|
||||
|
||||
- name: Start Next.js dev server
|
||||
run: pnpm dev &
|
||||
env:
|
||||
SURREALDB_URL: ws://localhost:8000/rpc
|
||||
SURREALDB_USER: ${{ secrets.SURREALDB_USER }}
|
||||
SURREALDB_PASS: ${{ secrets.SURREALDB_PASS }}
|
||||
SURREALDB_NS: ${{ secrets.SURREALDB_NS }}
|
||||
SURREALDB_DB: ${{ secrets.SURREALDB_DB }}
|
||||
ATPROTO_CLIENT_ID: ${{ secrets.ATPROTO_CLIENT_ID }}
|
||||
ATPROTO_REDIRECT_URI: ${{ secrets.ATPROTO_REDIRECT_URI }}
|
||||
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
|
||||
DEEPGRAM_API_KEY: ${{ secrets.DEEPGRAM_API_KEY }}
|
||||
SURREAL_JWT_SECRET: ${{ secrets.SURREAL_JWT_SECRET }}
|
||||
TEST_BLUESKY_HANDLE: ${{ secrets.TEST_BLUESKY_HANDLE }}
|
||||
TEST_BLUESKY_PASSWORD: ${{ secrets.TEST_BLUESKY_PASSWORD }}
|
||||
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||
|
||||
- name: Wait for Next.js server
|
||||
run: npx wait-on http://localhost:3000 --timeout 120000
|
||||
|
||||
- name: Run Magnitude tests
|
||||
run: npx magnitude
|
||||
env:
|
||||
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||
TEST_BLUESKY_HANDLE: ${{ secrets.TEST_BLUESKY_HANDLE }}
|
||||
TEST_BLUESKY_PASSWORD: ${{ secrets.TEST_BLUESKY_PASSWORD }}
|
||||
|
||||
- name: Upload test results
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: magnitude-results
|
||||
path: test-results/
|
||||
retention-days: 30
|
||||
Reference in New Issue
Block a user