diff --git a/AGENTS.md b/AGENTS.md index b0cbba4..18d269b 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -123,28 +123,40 @@ These credentials should be used for all automated testing (Magnitude, Playwrigh **Playwright Docker Setup**: -For consistent testing environments across users and CI/CD, use the Playwright Docker image: +Playwright is integrated into docker-compose for consistent testing environments: -1. **Build the Playwright Docker image**: +1. **Run Playwright tests with docker-compose**: ```bash - docker build -f Dockerfile.playwright -t ponderants-playwright . + # Start database services + docker compose up -d + + # Start Next.js dev server + pnpm dev + + # Run Playwright tests in Docker (in another terminal) + docker compose run --rm playwright ``` -2. **Run Playwright tests in Docker**: +2. **Alternative: Use the 'test' profile**: ```bash - docker run --rm \ - --network=host \ - -v $(pwd):/home/pwuser/app \ - -e TEST_BLUESKY_HANDLE \ - -e TEST_BLUESKY_PASSWORD \ - ponderants-playwright + # Start all services including Playwright + docker compose --profile test up + + # Or run tests one-off without keeping services up + docker compose --profile test run --rm playwright ``` 3. **Benefits**: - Non-root user execution (pwuser) for security - Consistent browser versions across environments - - Isolated test environment - - Ready for CI/CD integration + - Integrated with existing docker-compose setup + - Uses host networking to access dev server on localhost:3000 + - Node modules volume prevents permission issues + +4. **Configuration**: + - Environment variables loaded from .env file + - Uses `network_mode: host` to access dev server + - Runs with `profiles: [test]` to keep it optional **CI/CD with Gitea Actions**: diff --git a/docker-compose.yml b/docker-compose.yml index 5130b92..aac2777 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -32,3 +32,26 @@ services: - "8080:8080" depends_on: - surrealdb + + playwright: + image: mcr.microsoft.com/playwright:v1.49.1-noble + working_dir: /home/pwuser/app + user: pwuser + network_mode: host + volumes: + - .:/home/pwuser/app + - /home/pwuser/app/node_modules + environment: + - TEST_BLUESKY_HANDLE=${TEST_BLUESKY_HANDLE} + - TEST_BLUESKY_PASSWORD=${TEST_BLUESKY_PASSWORD} + - PLAYWRIGHT_BASE_URL=${PLAYWRIGHT_BASE_URL:-http://localhost:3000} + command: > + sh -c " + npm install -g pnpm && + pnpm install --frozen-lockfile && + npx playwright test + " + depends_on: + - surrealdb + profiles: + - test