Skip to content

Testing & QA Workflow

Standard testing checklist for all applications. Execute these checks before marking features complete.


Pre-Commit Checklist

Type Safety

npx tsc --noEmit
- [ ] No TypeScript errors - [ ] No implicit any types in new code

Browser Console

  • [ ] No console errors
  • [ ] No hydration mismatches
  • [ ] No React warnings (key props, etc.)

Feature Testing

CRUD Operations

For any feature involving data:

  • [ ] Create - New records save to database
  • [ ] Read - Data displays correctly after refresh
  • [ ] Update - Changes persist after save
  • [ ] Delete - Records removed, UI updates

Authentication

  • [ ] Protected routes redirect to login when logged out
  • [ ] API routes return 401 for unauthenticated requests
  • [ ] User can only access their own data (RLS)

Error Handling

  • [ ] Network failures show user-friendly message
  • [ ] Validation errors display clearly
  • [ ] No silent failures (check Network tab)

API Testing

Quick curl tests

# Test auth required
curl -X GET http://localhost:3000/api/trips
# Should return 401

# Test with auth (get token from browser dev tools)
curl -X GET http://localhost:3000/api/trips \
  -H "Cookie: sb-access-token=..."

Status Codes

  • [ ] 200 - Success
  • [ ] 201 - Created
  • [ ] 400 - Bad request (validation)
  • [ ] 401 - Unauthorized
  • [ ] 404 - Not found
  • [ ] 500 - Server error (check logs)

UI Testing

State Management

  • [ ] Loading states show during async operations
  • [ ] Optimistic updates revert on failure
  • [ ] Form state clears after successful submit

Interactions

  • [ ] Buttons disabled during submission
  • [ ] Confirmation dialogs for destructive actions
  • [ ] Keyboard navigation works (forms, modals)

Edge Cases

  • [ ] Empty states (no data)
  • [ ] Long text (truncation/wrapping)
  • [ ] Rapid clicking doesn't cause issues

Database Verification

When in doubt, check the database directly:

# Connect to database
kubectl exec -n supabase -it postgres-0 -- psql -U postgres

# Check data in schema
\dt trip_planner.*
SELECT * FROM trip_planner.trips LIMIT 5;

Testing Workflow

During Development

  1. Make changes
  2. Check browser console
  3. Test happy path manually
  4. Check Network tab for failed requests

Before Commit

  1. Run type check
  2. Test full feature flow
  3. Test error cases
  4. Verify data persists (refresh page)

After Deploy

  1. Verify in production environment
  2. Check logs for errors
  3. Test with real user account

Common Issues

Hydration Errors

  • Server/client rendering mismatch
  • Often caused by: dates, random values, browser-only APIs
  • Fix: Use consistent formatting, check useEffect usage

Silent API Failures

  • Check Network tab in dev tools
  • Look for non-200 status codes
  • Check Supabase logs: kubectl logs -n supabase -l app=postgrest

RLS Blocking Queries

  • Query returns empty but data exists
  • Check RLS policies in Supabase dashboard
  • Verify user ID matches policy conditions

Stale Data After Save

  • API returns success but UI shows old data
  • Check if component re-fetches after mutation
  • May need to invalidate cache or call refresh

Project-Specific Tests

Test Documentation Strategy

We follow a hybrid approach for test documentation:

Universal Standards (this document): - Generic pre-commit checklist (type safety, console errors) - Standard CRUD, auth, error handling patterns - API testing guidelines - UI testing patterns

App-Specific Test Plans (in app repos): - Detailed end-to-end test cases - Feature-specific scenarios with exact steps - Infrastructure verification commands - Database queries for validation - Example: /root/projects/subtitleai/TESTING.md

Where to Store Test Plans

For comprehensive feature test plans (like worker deployment, multi-step flows):

  1. Create TESTING.md in the app repository with detailed test cases
  2. Include in version control - use git commits for versioning (not separate versioned files)
  3. Reference from tower-fleet docs if the testing approach applies to multiple apps
  4. Update after major changes - keep aligned with implementation

For simple feature tests: Add to app's README under a "Testing" section:

## Testing

### Trip Planner Specific
- [ ] Map markers update when locations change
- [ ] AI chat tools execute and reflect in UI
- [ ] Date formatting consistent across timezones

Why this approach: - App-specific details stay with the app code - Universal patterns remain centralized and reusable - Git history tracks when tests were added/modified - Easy to find test plan when reviewing app code