6.8 KiB
Phase 11: Testing & Deployment
Status: ⏳ Todo Progress: 0/15 tasks (0%) Started: - Completed: - Assigned to: -
Overview
Setup testing frameworks (Vitest, Playwright), write tests, create production Docker setup, configure CI/CD pipeline, and deploy to staging/production.
Goal: Fully tested MVP deployed to production with automated CI/CD.
Dependencies
- ✅ All previous phases should be completed
Tasks
Unit Testing Setup
-
Setup Vitest for unit tests
pnpm add -D vitest @vue/test-utils happy-dom- Configure vitest.config.ts
- Add test scripts to package.json:
"test": "vitest" - Create
tests/folder structure
-
Write tests for auth utilities
- Test:
server/utils/pkce.ts- Test PKCE generation (verifier, challenge)
- Test challenge is base64url encoded SHA-256
- Test:
server/utils/jwt.ts- Test JWT validation (mock JWKS)
- Test expired token rejection
- Test invalid issuer/audience rejection
- Test:
-
Write tests for API endpoints
- Test:
/api/products/index.get.ts- Test returns active products only
- Test filtering by category
- Test:
/api/cart/items.post.ts- Test add item to cart
- Test validation (invalid product ID)
- Test:
/api/orders/index.post.ts- Test order creation
- Test requires authentication
- Use:
@nuxt/test-utilsfor API testing
- Test:
E2E Testing Setup
-
Setup Playwright for E2E
pnpm add -D @playwright/test npx playwright install- Configure playwright.config.ts
- Add e2e script:
"test:e2e": "playwright test" - Create
tests/e2e/folder
-
Write E2E test: user registration
- Navigate to /auth
- Click "Register" tab
- Fill registration form
- Submit form
- Verify success message (or redirect to Cidaas)
- Note: May need to mock Cidaas for E2E
-
Write E2E test: complete checkout flow
- Login as user (or create test user)
- Navigate to /produkte
- Click product
- Click "In den Warenkorb"
- Navigate to /warenkorb
- Click "Zur Kasse"
- Fill checkout form
- Mock PayPal payment (or use sandbox)
- Verify order confirmation page
Production Docker Setup
-
Create Dockerfile (production)
- File:
Dockerfile - Multi-stage build (see docs/TECH_STACK.md#dockerfile)
- Build stage: Install deps, build Nuxt
- Production stage: Copy .output, run server
- Optimize for size (alpine, minimal layers)
- File:
-
Create docker-compose.yml (production)
- File:
docker-compose.yml - Services: app, db, redis, worker (BullMQ worker)
- Volumes: postgres_data, redis_data
- Networks: app-network
- Health checks for all services
- Secrets for sensitive data
- See: docs/TECH_STACK.md#docker-compose
- File:
CI/CD Pipeline
-
Configure GitLab CI/CD
- File:
.gitlab-ci.yml - Stages: build, test, deploy-staging, deploy-production
- Build stage:
- Build Docker image
- Push to registry
- Test stage:
- Run unit tests
- Run E2E tests
- Check test coverage
- Deploy-staging stage:
- Deploy to staging automatically on main branch
- Deploy-production stage:
- Manual trigger required
- See: docs/TECH_STACK.md#gitlab-ci
- File:
-
Test production build
pnpm build pnpm preview- Verify build completes without errors
- Verify production server runs
- Test production build locally with Docker:
docker build -t experimenta-app:latest . docker run -p 3000:3000 experimenta-app:latest
Deployment
-
Setup staging environment
- Server: Hetzner VPS or VM (Proxmox)
- Domain: staging.my.experimenta.science
- SSL: Let's Encrypt (automatic)
- Reverse Proxy: Nginx or Traefik
- Docker Compose with staging config
- Environment: STAGING
-
Deploy to staging
- Use GitLab CI/CD or manual deploy
- Verify deployment successful
- Run smoke tests on staging
- Test full user flow on staging
-
Final QA on staging
- Test all features:
- User registration & login
- Product browsing
- Add to cart
- Checkout
- PayPal payment (sandbox)
- Order confirmation
- Order history
- Test on multiple devices/browsers
- Test language switching (DE/EN)
- Test error scenarios
- Test all features:
-
Document deployment process
- Document staging deployment steps
- Document production deployment steps
- Document rollback procedure
- Document database migration process
- Document secrets management
- Document monitoring and logging
-
Deploy to production 🚀
- Server: Hetzner dedicated/VPS
- Domain: my.experimenta.science
- SSL: Let's Encrypt
- Reverse Proxy: Nginx or Traefik
- Docker Compose with production config
- Environment: PRODUCTION
- PayPal: LIVE mode
- X-API: Production endpoint
- Cidaas: Production credentials
- Database backups enabled
Acceptance Criteria
- Vitest is set up and running
- Unit tests cover critical utilities and endpoints
- Playwright is set up and running
- E2E tests cover registration and checkout flows
- Production Dockerfile is optimized and working
- docker-compose.yml for production is complete
- GitLab CI/CD pipeline is configured
- Production build works locally
- Staging environment is set up and accessible
- Deployed to staging successfully
- QA testing on staging passes
- Deployment process is documented
- Deployed to production successfully 🎉
- Production app is accessible and functional
- Monitoring and error tracking are active
Notes
- Test Coverage Goal: 70%+ for critical code paths
- E2E Testing: Focus on happy path for MVP (error scenarios in later phases)
- Docker Production: Use Docker Secrets for sensitive data (not env vars)
- CI/CD: Auto-deploy to staging, manual approval for production
- Monitoring: Setup Sentry or similar for error tracking (optional for MVP)
- Backups: Daily automated database backups with 7-day retention
Blockers
- ⚠️ Production Servers: Need access to production servers
- ⚠️ Production Credentials: Need production credentials for Cidaas, PayPal, X-API
- ⚠️ Domain DNS: Need to point domain to production server
Related Documentation
- docs/TECH_STACK.md: Testing
- docs/TECH_STACK.md: Docker
- docs/TECH_STACK.md: CI/CD
- README.md: Development Setup
Post-Launch
After successful production launch:
- Monitor error rates (Sentry or logs)
- Monitor queue performance (BullBoard)
- Monitor PayPal transaction success rate
- Monitor X-API submission success rate
- Gather user feedback
- Plan Phase 2 features (Educator roles, etc.)
🎉 Congratulations on launching the MVP! 🎉