celo-poll/TESTING_GUIDE.md
2025-12-08 16:31:30 +03:00

257 lines
5.2 KiB
Markdown

# Testing Guide
## Manual Testing Checklist
### Mobile Testing (320px - 768px)
- [ ] All pages render correctly
- [ ] Touch targets are 44x44px minimum
- [ ] Text is readable (16px minimum)
- [ ] Buttons are easily tappable
- [ ] Forms are usable
- [ ] Navigation works
- [ ] Images load properly
- [ ] Modals fit screen
### Desktop Testing (1024px+)
- [ ] Layout uses available space
- [ ] Multi-column layouts work
- [ ] Hover states work
- [ ] Keyboard navigation works
- [ ] Tooltips display correctly
### Accessibility Testing
- [ ] All images have alt text
- [ ] All buttons have aria-labels
- [ ] Keyboard navigation works (Tab, Enter, Esc)
- [ ] Focus indicators visible
- [ ] Color contrast meets WCAG AA
- [ ] Screen reader announces content
- [ ] Form labels are associated
- [ ] Error messages are clear
### Performance Testing
- [ ] Pages load in < 3 seconds
- [ ] Images are optimized
- [ ] API responses < 500ms
- [ ] No layout shift (CLS)
- [ ] Smooth scrolling
- [ ] No memory leaks
### Functionality Testing
#### User Features
- [ ] Profile page loads
- [ ] Settings save correctly
- [ ] Stats display accurately
- [ ] Follow/unfollow works
- [ ] Bookmarks work
- [ ] Notifications appear
#### Social Features
- [ ] Comments post successfully
- [ ] Replies work (3 levels)
- [ ] Likes update instantly
- [ ] Mentions link correctly
- [ ] Feed updates
- [ ] Share buttons work
#### Discovery Features
- [ ] Search returns results
- [ ] Filters work
- [ ] Categories display
- [ ] Trending updates
- [ ] Similar polls show
#### Admin Features
- [ ] Dashboard loads
- [ ] Poll management works
- [ ] Moderation queue functions
- [ ] Ban/unban works
- [ ] Reports update
### Browser Testing
- [ ] Chrome/Edge
- [ ] Firefox
- [ ] Safari
- [ ] Mobile Safari
- [ ] Mobile Chrome
### Rate Limiting Testing
```bash
# Test vote rate limit (10/min)
for i in {1..15}; do
curl -X POST http://localhost:3000/api/vote
echo "Request $i"
done
# Test comment rate limit (5/min)
for i in {1..10}; do
curl -X POST http://localhost:3000/api/poll/123/comments
echo "Request $i"
done
```
### Cache Testing
```bash
# Test leaderboard cache (5 min)
curl http://localhost:3000/api/leaderboard
# Wait 1 minute
curl http://localhost:3000/api/leaderboard
# Should be cached
# Test user stats cache (1 min)
curl http://localhost:3000/api/user/123/stats
# Wait 30 seconds
curl http://localhost:3000/api/user/123/stats
# Should be cached
```
## Automated Testing (Future)
### Unit Tests
```typescript
// Example: Test rate limiter
import { rateLimit } from '@/lib/rate-limit'
test('rate limit blocks after limit', async () => {
for (let i = 0; i < 10; i++) {
await rateLimit('test', 10, 60)
}
const result = await rateLimit('test', 10, 60)
expect(result.success).toBe(false)
})
```
### Integration Tests
```typescript
// Example: Test comment creation
test('creates comment successfully', async () => {
const response = await fetch('/api/poll/123/comments', {
method: 'POST',
body: JSON.stringify({ text: 'Test comment' })
})
expect(response.status).toBe(200)
})
```
### E2E Tests
```typescript
// Example: Test user flow
test('user can vote on poll', async () => {
// 1. Navigate to poll
// 2. Select option
// 3. Click vote
// 4. Verify success message
// 5. Check vote recorded
})
```
## Performance Benchmarks
### Target Metrics
- First Contentful Paint (FCP): < 1.8s
- Largest Contentful Paint (LCP): < 2.5s
- Time to Interactive (TTI): < 3.8s
- Cumulative Layout Shift (CLS): < 0.1
- First Input Delay (FID): < 100ms
### API Response Times
- GET requests: < 200ms
- POST requests: < 500ms
- Search queries: < 300ms
- Leaderboard: < 100ms (cached)
### Cache Hit Rates
- Leaderboard: > 80%
- User stats: > 70%
- Platform stats: > 90%
## Bug Reporting Template
```markdown
**Bug Description:**
Brief description of the issue
**Steps to Reproduce:**
1. Go to...
2. Click on...
3. See error
**Expected Behavior:**
What should happen
**Actual Behavior:**
What actually happens
**Environment:**
- Browser: Chrome 120
- Device: iPhone 14
- OS: iOS 17
**Screenshots:**
[Attach if applicable]
**Console Errors:**
[Paste any errors]
```
## Pre-Launch Checklist
### Configuration
- [ ] Environment variables set
- [ ] Admin FIDs configured
- [ ] Redis connected
- [ ] Celo RPC working
- [ ] Protocol wallet set
### Security
- [ ] Rate limiting active
- [ ] Admin routes protected
- [ ] Input validation working
- [ ] XSS prevention
- [ ] CSRF protection
### Performance
- [ ] Caching enabled
- [ ] Images optimized
- [ ] API responses fast
- [ ] No memory leaks
- [ ] Bundle size optimized
### User Experience
- [ ] All pages load
- [ ] All features work
- [ ] Mobile responsive
- [ ] Accessible
- [ ] Error handling
### Monitoring
- [ ] Error tracking setup
- [ ] Analytics configured
- [ ] Performance monitoring
- [ ] Uptime monitoring
- [ ] Alert system
## Post-Launch Monitoring
### Daily Checks
- [ ] Error rate < 1%
- [ ] API response times
- [ ] Cache hit rates
- [ ] User engagement
- [ ] System health
### Weekly Reviews
- [ ] User feedback
- [ ] Performance trends
- [ ] Feature usage
- [ ] Bug reports
- [ ] Growth metrics
### Monthly Analysis
- [ ] Platform metrics
- [ ] User retention
- [ ] Feature adoption
- [ ] Performance optimization
- [ ] Roadmap planning