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:
72
AGENTS.md
72
AGENTS.md
@@ -102,9 +102,12 @@ These credentials should be used for all automated testing (Magnitude, Playwrigh
|
||||
- ✅ All manual testing with Playwright MCP completed and verified
|
||||
- ✅ All Magnitude tests written and cover all verified functionality
|
||||
- ✅ Database verified for expected state after operations (e.g., deletions actually removed records)
|
||||
- ✅ Run magnitude tests for current feature FIRST: `pnpm test tests/magnitude/your-feature.mag.ts`
|
||||
- ✅ Verify current feature tests pass
|
||||
- ✅ Run ALL magnitude tests: `pnpm test`
|
||||
- ✅ All tests passing
|
||||
- ✅ Verify ENTIRE test suite passes
|
||||
- ✅ No console errors or warnings in production code paths
|
||||
- **CRITICAL**: Do NOT commit until ALL tests pass - feature tests AND full test suite
|
||||
- Only commit after ALL checklist items are complete
|
||||
|
||||
7. **Documentation**:
|
||||
@@ -114,9 +117,76 @@ These credentials should be used for all automated testing (Magnitude, Playwrigh
|
||||
**Testing Resources**:
|
||||
- Playwright Global Setup/Teardown: https://playwright.dev/docs/test-global-setup-teardown
|
||||
- Playwright Test Agents: https://playwright.dev/docs/test-agents
|
||||
- Playwright Docker: https://playwright.dev/docs/docker
|
||||
- Magnitude.run Documentation: https://magnitude.run/docs
|
||||
- Project Test README: `tests/README.md`
|
||||
|
||||
**Playwright Docker Setup**:
|
||||
|
||||
For consistent testing environments across users and CI/CD, use the Playwright Docker image:
|
||||
|
||||
1. **Build the Playwright Docker image**:
|
||||
```bash
|
||||
docker build -f Dockerfile.playwright -t ponderants-playwright .
|
||||
```
|
||||
|
||||
2. **Run Playwright tests in Docker**:
|
||||
```bash
|
||||
docker run --rm \
|
||||
--network=host \
|
||||
-v $(pwd):/home/pwuser/app \
|
||||
-e TEST_BLUESKY_HANDLE \
|
||||
-e TEST_BLUESKY_PASSWORD \
|
||||
ponderants-playwright
|
||||
```
|
||||
|
||||
3. **Benefits**:
|
||||
- Non-root user execution (pwuser) for security
|
||||
- Consistent browser versions across environments
|
||||
- Isolated test environment
|
||||
- Ready for CI/CD integration
|
||||
|
||||
**CI/CD with Gitea Actions**:
|
||||
|
||||
Magnitude tests run automatically on every push and pull request via Gitea Actions:
|
||||
|
||||
1. **Configuration**: `.gitea/workflows/magnitude.yml`
|
||||
|
||||
2. **Workflow steps**:
|
||||
- Checkout code
|
||||
- Setup Node.js and pnpm
|
||||
- Start SurrealDB in Docker
|
||||
- Start Next.js dev server with environment variables
|
||||
- Run Magnitude tests
|
||||
- Upload test results as artifacts
|
||||
|
||||
3. **Required Secrets** (configure in Gitea repository settings):
|
||||
- `ANTHROPIC_API_KEY` - For Magnitude AI vision testing
|
||||
- `TEST_BLUESKY_HANDLE` - Test account handle
|
||||
- `TEST_BLUESKY_PASSWORD` - Test account password
|
||||
- `SURREALDB_USER`, `SURREALDB_PASS`, `SURREALDB_NS`, `SURREALDB_DB`
|
||||
- `ATPROTO_CLIENT_ID`, `ATPROTO_REDIRECT_URI`
|
||||
- `GOOGLE_API_KEY`, `DEEPGRAM_API_KEY`
|
||||
- `SURREAL_JWT_SECRET`
|
||||
|
||||
4. **Test results**: Available as workflow artifacts for 30 days
|
||||
|
||||
**Testing Framework Separation**:
|
||||
|
||||
- **Playwright**: Used for manual testing with Playwright MCP and global auth setup
|
||||
- Location: `tests/playwright/`
|
||||
- Helpers: `tests/playwright/helpers.ts`
|
||||
- Auth setup: `tests/playwright/auth.setup.ts`
|
||||
- Run: `npx playwright test`
|
||||
|
||||
- **Magnitude**: Used for automated end-to-end testing in development and CI/CD
|
||||
- Location: `tests/magnitude/`
|
||||
- Helpers: `tests/magnitude/helpers.ts`
|
||||
- Configuration: `magnitude.config.ts` (uses Claude Sonnet 4.5)
|
||||
- Run: `npx magnitude` or `pnpm test`
|
||||
|
||||
Both frameworks are independent and can be used separately or together depending on the testing need.
|
||||
|
||||
You are an expert-level, full-stack AI coding agent. Your task is to implement
|
||||
the "Ponderants" application. Product Vision: Ponderants is an AI-powered
|
||||
thought partner that interviews a user to capture, structure, and visualize
|
||||
|
||||
Reference in New Issue
Block a user