Skip to content

Commit ef8e761

Browse files
committed
update tests
1 parent 7e6bca2 commit ef8e761

File tree

3 files changed

+121
-13
lines changed

3 files changed

+121
-13
lines changed

PLAYWRIGHT_SETUP.md

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
# Playwright E2E Setup Summary
2+
3+
## ✅ What's Been Configured
4+
5+
### 1. GitHub Actions Workflow (`.github/workflows/playwright.yml`)
6+
- **Triggers:** Push/PR to main/master, manual dispatch
7+
- **Environment:** Ubuntu 22.04, Node.js from package.json, pnpm with caching
8+
- **Process:**
9+
1. Checkout code
10+
2. Setup Node.js and install dependencies (with caching)
11+
3. Install Playwright browsers (chromium only for speed)
12+
4. Build frontend application
13+
5. Start frontend in production mode
14+
6. Wait for health check
15+
7. Run E2E tests
16+
8. Upload reports and artifacts
17+
9. Clean up processes
18+
19+
### 2. Composite Actions
20+
- **`.github/actions/node-setup`** - Existing Node/pnpm setup with caching
21+
- **`.github/actions/e2e-setup`** - New Playwright browser installation
22+
23+
### 3. Turborepo Integration (`turbo.json`)
24+
- Added `e2e` task that depends on build completion
25+
- Configured proper inputs for cache invalidation
26+
27+
### 4. Enhanced Scripts (`package.json`)
28+
- `pnpm e2e` - Run headless tests
29+
- `pnpm e2e:headed` - Run with visible browser
30+
- `pnpm e2e:ui` - Interactive test runner
31+
32+
### 5. Test Verification Script (`scripts/test-e2e-setup.sh`)
33+
- Complete local testing workflow
34+
- Automated setup verification
35+
- Proper cleanup and error handling
36+
37+
## 🚀 How to Use
38+
39+
### Local Development
40+
```bash
41+
# Quick test (after frontend is running)
42+
pnpm e2e
43+
44+
# Full verification including setup
45+
./scripts/test-e2e-setup.sh
46+
47+
# Visual debugging
48+
pnpm e2e:headed
49+
pnpm e2e:ui
50+
```
51+
52+
### CI/CD
53+
- Tests run automatically on pushes and PRs
54+
- Manual trigger available in GitHub Actions tab
55+
- Reports uploaded as artifacts when tests fail
56+
57+
## 🔧 Configuration Details
58+
59+
### Environment Variables (CI)
60+
```yaml
61+
NODE_ENV: test
62+
NEXTAUTH_SECRET: "test-secret-for-ci-only"
63+
NEXT_PUBLIC_EXAMPLE_VARIABLE: "CI Test Variable"
64+
CI: true
65+
```
66+
67+
### Browser Setup
68+
- **CI:** Chromium only (faster, sufficient for most cases)
69+
- **Local:** All browsers available via `playwright install`
70+
71+
### Timeouts & Retries
72+
- **Job timeout:** 60 minutes
73+
- **App startup:** 60 seconds
74+
- **Retries:** 2 in CI, 0 locally
75+
76+
## 📁 Project Structure
77+
```
78+
packages/e2e-frontend/
79+
├── README.md # Detailed E2E documentation
80+
├── playwright.config.ts # Test configuration
81+
├── package.json # E2E-specific scripts
82+
├── *.spec.ts # Test files
83+
├── pages/ # Page Object Models
84+
└── utils/ # Test utilities
85+
86+
.github/
87+
├── workflows/
88+
│ └── playwright.yml # Main E2E workflow
89+
└── actions/
90+
├── node-setup/ # Node/pnpm setup (existing)
91+
└── e2e-setup/ # Playwright setup (new)
92+
```
93+
94+
## 🎯 Next Steps
95+
96+
1. **Test locally:** Run `./scripts/test-e2e-setup.sh`
97+
2. **Push changes:** Commit and push to trigger CI
98+
3. **Monitor results:** Check GitHub Actions tab
99+
4. **Iterate:** Add more tests, adjust configuration as needed
100+
101+
## 🛠️ Troubleshooting
102+
103+
### Common Issues
104+
- **Frontend won't start:** Check build errors, environment variables
105+
- **Tests timeout:** Increase wait time in workflow
106+
- **Flaky tests:** Add proper waits, check for race conditions
107+
- **CI failures:** Check artifacts for detailed reports
108+
109+
### Debug Commands
110+
```bash
111+
# View test report after local run
112+
pnpm --filter e2e-frontend test:report
113+
114+
# Update snapshots after UI changes
115+
pnpm --filter e2e-frontend test:update-snapshots
116+
117+
# Run specific test
118+
pnpm exec playwright test home.spec.ts
119+
```
120+
121+
The setup is production-ready and follows GitHub Actions best practices with proper caching, error handling, and artifact management.

packages/e2e-frontend/multi-device.spec.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,27 +26,20 @@ test.describe('Browser contexts & multiple devices', () => {
2626
}) => {
2727
// Desktop user
2828
const desktop = await createContext(browser, '[email protected]', 'password123', { width: 1280, height: 720 });
29-
await wait(desktop.page);
3029

3130
// Tablet user (e.g., iPad)
3231
const tablet = await createContext(browser, '[email protected]', 'password123', { width: 768, height: 1024 });
33-
await wait(tablet.page);
3432

3533
// Mobile user
3634
const mobile = await createContext(browser, '[email protected]', 'password123', { width: 375, height: 812 });
37-
await wait(mobile.page);
3835

3936
// Screenshots for visual verification
4037
await desktop.page.screenshot({ path: 'reports/screenshots/desktop-logged-in.png' });
4138
await tablet.page.screenshot({ path: 'reports/screenshots/tablet-logged-in.png' });
4239
await mobile.page.screenshot({ path: 'reports/screenshots/mobile-logged-in.png' });
4340

44-
// Close contexts
45-
await wait(desktop.page, 250);
4641
await desktop.context.close();
47-
await wait(tablet.page, 250);
4842
await tablet.context.close();
49-
await wait(mobile.page, 250);
5043
await mobile.context.close();
5144
});
5245
});

packages/e2e-frontend/utils/index.ts

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)