Improve the UI and tests
This commit is contained in:
@@ -39,37 +39,87 @@ npx playwright install
|
||||
|
||||
## 🎯 Running Tests
|
||||
|
||||
### Run all tests (headless)
|
||||
### Testing Against Local Dev Server (Default)
|
||||
|
||||
These commands test against the Vite dev server running on `localhost:5173`:
|
||||
|
||||
#### Run all tests (headless)
|
||||
```bash
|
||||
npm run test:e2e
|
||||
```
|
||||
|
||||
### Run tests with UI (interactive mode)
|
||||
#### Run tests with UI (interactive mode)
|
||||
```bash
|
||||
npm run test:e2e:ui
|
||||
```
|
||||
|
||||
### Run tests in headed mode (see browser)
|
||||
#### Run tests in headed mode (see browser)
|
||||
```bash
|
||||
npm run test:e2e:headed
|
||||
```
|
||||
|
||||
### Run tests in debug mode (step through tests)
|
||||
#### Run tests in debug mode (step through tests)
|
||||
```bash
|
||||
npm run test:e2e:debug
|
||||
```
|
||||
|
||||
### Run specific test file
|
||||
### Testing Against Local Kubernetes/Tilt Environment
|
||||
|
||||
These commands test against your Tilt-managed Kubernetes cluster on `localhost`:
|
||||
|
||||
#### Prerequisites
|
||||
- Tilt must be running: `tilt up`
|
||||
- Frontend service must be accessible at `http://localhost` (via ingress)
|
||||
- All services should be healthy (check with `tilt status` or the Tilt UI)
|
||||
|
||||
#### Run all tests against K8s (headless)
|
||||
```bash
|
||||
npm run test:e2e:k8s
|
||||
```
|
||||
|
||||
#### Run tests with UI (interactive mode)
|
||||
```bash
|
||||
npm run test:e2e:k8s:ui
|
||||
```
|
||||
|
||||
#### Run tests in headed mode (see browser)
|
||||
```bash
|
||||
npm run test:e2e:k8s:headed
|
||||
```
|
||||
|
||||
#### Run tests in debug mode
|
||||
```bash
|
||||
npm run test:e2e:k8s:debug
|
||||
```
|
||||
|
||||
#### Record tests against K8s environment
|
||||
```bash
|
||||
npm run test:e2e:k8s:codegen
|
||||
```
|
||||
|
||||
#### Custom base URL
|
||||
If your K8s ingress uses a different URL (e.g., `bakery-ia.local`):
|
||||
```bash
|
||||
PLAYWRIGHT_BASE_URL=http://bakery-ia.local npm run test:e2e:k8s
|
||||
```
|
||||
|
||||
### General Test Commands
|
||||
|
||||
#### Run specific test file
|
||||
```bash
|
||||
npx playwright test tests/auth/login.spec.ts
|
||||
# Or against K8s:
|
||||
npx playwright test --config=playwright.k8s.config.ts tests/auth/login.spec.ts
|
||||
```
|
||||
|
||||
### Run tests matching a pattern
|
||||
#### Run tests matching a pattern
|
||||
```bash
|
||||
npx playwright test --grep "login"
|
||||
# Or against K8s:
|
||||
npx playwright test --config=playwright.k8s.config.ts --grep "login"
|
||||
```
|
||||
|
||||
### View test report
|
||||
#### View test report
|
||||
```bash
|
||||
npm run test:e2e:report
|
||||
```
|
||||
@@ -289,13 +339,15 @@ Current test coverage:
|
||||
## 🚨 Common Issues
|
||||
|
||||
### Tests fail with "timeout exceeded"
|
||||
- Check if dev server is running
|
||||
- Increase timeout in `playwright.config.ts`
|
||||
- Check if dev server is running (for regular tests)
|
||||
- For K8s tests: Verify Tilt is running and services are healthy
|
||||
- Increase timeout in `playwright.config.ts` or `playwright.k8s.config.ts`
|
||||
- Check network speed
|
||||
|
||||
### Authentication fails
|
||||
- Verify test credentials are correct
|
||||
- Check if test user exists in database
|
||||
- For K8s tests: Ensure the database is seeded with test data
|
||||
- Clear `.auth/user.json` and re-run
|
||||
|
||||
### "Element not found"
|
||||
@@ -308,6 +360,44 @@ Current test coverage:
|
||||
- Ensure database is seeded with test data
|
||||
- Check for timing issues (add explicit waits)
|
||||
|
||||
### K8s-Specific Issues
|
||||
|
||||
#### Cannot connect to http://localhost
|
||||
```bash
|
||||
# Check if ingress is running
|
||||
kubectl get ingress -n bakery-ia
|
||||
|
||||
# Verify services are up
|
||||
tilt status
|
||||
|
||||
# Check if you can access the frontend manually
|
||||
curl http://localhost
|
||||
```
|
||||
|
||||
#### Ingress returns 404 or 503
|
||||
- Verify all Tilt resources are healthy in the Tilt UI
|
||||
- Check frontend pod logs: `kubectl logs -n bakery-ia -l app=frontend`
|
||||
- Restart Tilt: `tilt down && tilt up`
|
||||
|
||||
#### Tests are slower in K8s than dev server
|
||||
- This is expected due to ingress routing overhead
|
||||
- The K8s config has increased `navigationTimeout` to 30 seconds
|
||||
- Consider running fewer browsers in parallel for K8s tests
|
||||
|
||||
#### Authentication state doesn't work
|
||||
- Test credentials must match what's seeded in K8s database
|
||||
- Check orchestrator logs for auth issues: `kubectl logs -n bakery-ia -l app=orchestrator`
|
||||
- Delete `.auth/user.json` and re-run setup
|
||||
|
||||
#### Using custom ingress host (e.g., bakery-ia.local)
|
||||
```bash
|
||||
# Add to /etc/hosts
|
||||
echo "127.0.0.1 bakery-ia.local" | sudo tee -a /etc/hosts
|
||||
|
||||
# Run tests with custom URL
|
||||
PLAYWRIGHT_BASE_URL=http://bakery-ia.local npm run test:e2e:k8s
|
||||
```
|
||||
|
||||
## 📚 Resources
|
||||
|
||||
- [Playwright Documentation](https://playwright.dev)
|
||||
|
||||
Reference in New Issue
Block a user