Files
thrilltrack-explorer/migration/PHASE_14_CLEANUP_TESTING.md

410 lines
9.9 KiB
Markdown

# PHASE 14: Cleanup & Testing
**Status:** ⬜ Not Started
**Estimated Time:** 15-18 hours
**Priority:** CRITICAL
**Depends On:** Phase 13 (Next.js Optimization)
**Blocks:** Production Deployment
---
## 🎯 Goal
Complete removal of all Supabase dependencies, verify 100% functionality in Next.js 15, and ensure production readiness. This is the FINAL phase.
---
## 📋 Tasks
### Task 14.1: Remove Supabase Files & Dependencies (3 hours)
#### Step 1: Delete Supabase Integration Directory
```bash
rm -rf src/integrations/supabase/
```
#### Step 2: Delete Supabase Client Files
```bash
rm src/lib/supabaseClient.ts
rm src/lib/supabaseHelpers.ts
```
#### Step 3: Remove Package Dependency
```bash
bun remove @supabase/supabase-js
bun install # Update lock file
```
#### Step 4: Clean Environment Variables
Edit `.env.local` and `.env.example`:
- [ ] Remove `NEXT_PUBLIC_SUPABASE_URL`
- [ ] Remove `NEXT_PUBLIC_SUPABASE_ANON_KEY`
- [ ] Verify `NEXT_PUBLIC_DJANGO_API_URL` is set correctly
- [ ] Verify all required Next.js env vars present
#### Checklist
- [ ] `src/integrations/supabase/` deleted
- [ ] `src/lib/supabaseClient.ts` deleted
- [ ] `src/lib/supabaseHelpers.ts` deleted
- [ ] `@supabase/supabase-js` removed from `package.json`
- [ ] `package-lock.json` updated
- [ ] Supabase env vars removed
- [ ] Django API URL configured
---
### Task 14.2: Final Verification (2 hours)
Run these commands - ALL MUST RETURN ZERO RESULTS:
```bash
# 1. Check for Supabase imports
grep -r "from '@supabase/supabase-js'" src/ --include="*.ts" --include="*.tsx"
# Expected: No results
# 2. Check for Supabase client imports
grep -r "from '@/lib/supabaseClient'" src/ --include="*.ts" --include="*.tsx"
# Expected: No results
# 3. Check for any supabase usage (excluding comments)
grep -r "supabase\." src/ --include="*.ts" --include="*.tsx" | grep -v "//"
# Expected: No results (or only in comments)
# 4. Check package.json
cat package.json | grep supabase
# Expected: No results
# 5. Check for Supabase types
grep -r "import.*Database.*from.*supabase" src/
# Expected: No results
```
#### Checklist
- [ ] Zero Supabase imports found
- [ ] Zero Supabase usage found
- [ ] Zero Supabase in package.json
- [ ] Zero Supabase types imported
---
### Task 14.3: TypeScript Compilation (1 hour)
```bash
# Run TypeScript compiler with Next.js
bun run type-check
# Or using Next.js lint
bun run lint
```
#### Checklist
- [ ] TypeScript compiles without errors
- [ ] All imports resolve correctly
- [ ] All types are defined
- [ ] No `any` types added (follow TYPESCRIPT_ANY_POLICY.md)
---
### Task 14.4: Next.js Build Test (2 hours)
```bash
# Production build with Turbopack
bun run build
# Verify build output
ls -la .next/
```
#### Checklist
- [ ] Build completes successfully
- [ ] No build errors
- [ ] No build warnings (or acceptable warnings only)
- [ ] `.next/` directory generated correctly
- [ ] Turbopack optimization applied
- [ ] Server components compiled
- [ ] Client components bundled separately
- [ ] Static pages generated (if using ISR/SSG)
- [ ] Build size is reasonable
#### Next.js Specific Checks
- [ ] Server components work in build
- [ ] Client components work in build
- [ ] API routes function
- [ ] Metadata API generates correct tags
- [ ] Image optimization working
- [ ] Font optimization working
---
### Task 14.5: Integration Testing (5 hours)
**Run tests in both development and production modes:**
```bash
# Development mode
bun run dev
# Production mode
bun run build && bun run start
```
Test EVERY major flow:
#### Authentication (30 min)
- [ ] Register new user
- [ ] Login with email/password
- [ ] Login with Google OAuth
- [ ] Login with GitHub OAuth
- [ ] Enable MFA/TOTP
- [ ] Disable MFA/TOTP
- [ ] Logout
- [ ] Password reset
#### Entity CRUD via Sacred Pipeline (1 hour)
- [ ] Submit new park → appears in moderation queue
- [ ] Submit new ride → appears in moderation queue
- [ ] Submit new company → appears in moderation queue
- [ ] Submit new ride model → appears in moderation queue
- [ ] Moderator approves submission → entity appears
- [ ] Edit existing entity → creates submission → approve → changes apply
- [ ] Delete entity → creates submission → approve → entity deleted
#### Reviews & Social (45 min)
- [ ] Write review → creates submission → approve → appears
- [ ] Mark review helpful
- [ ] Add ride credit → creates submission → approve → appears
- [ ] Create top list
- [ ] Add items to top list
- [ ] Reorder top list items
- [ ] Delete top list
#### Media (30 min)
- [ ] Upload photo to park
- [ ] Upload photo to ride
- [ ] Edit photo caption
- [ ] Delete photo
- [ ] Verify CloudFlare URLs
#### Search (30 min)
- [ ] Global search works
- [ ] Park search with filters works
- [ ] Ride search with filters works
- [ ] Company search works
- [ ] Autocomplete suggests
#### Moderation (30 min)
- [ ] View moderation queue
- [ ] Claim submission
- [ ] Lock extends automatically
- [ ] Approve submission
- [ ] Reject submission
- [ ] Selective approve (approve some items, reject others)
- [ ] Lock releases on navigation
#### Admin (30 min)
- [ ] View admin dashboard
- [ ] View moderation stats
- [ ] View pipeline health
- [ ] Manage reports
- [ ] Manage contact submissions
#### Other Features (30 min)
- [ ] Contact form submission
- [ ] Timeline events display
- [ ] Entity history works
- [ ] Version diffs work
- [ ] Profile editing works
- [ ] Settings pages work
---
### Task 14.6: Next.js Specific Testing (2 hours)
#### Server-Side Rendering (SSR)
- [ ] Pages render on server
- [ ] Data fetching works server-side
- [ ] Metadata appears in HTML source
- [ ] No hydration errors
#### Client-Side Navigation
- [ ] App Router navigation works
- [ ] Parallel routes work (if used)
- [ ] Intercepting routes work (if used)
- [ ] Loading states display correctly
#### Performance
- [ ] Turbopack hot reload is fast
- [ ] Production build is optimized
- [ ] Bundle sizes are acceptable
- [ ] Core Web Vitals meet targets:
- [ ] LCP < 2.5s
- [ ] FID < 100ms
- [ ] CLS < 0.1
#### Environment Variables
- [ ] Server-side env vars work
- [ ] Client-side env vars work (NEXT_PUBLIC_*)
- [ ] No secrets exposed to client
---
### Task 14.7: Sacred Pipeline Verification (1 hour)
**CRITICAL:** Verify pipeline integrity
- [ ] Can submit new park → goes to queue
- [ ] Can submit new ride → goes to queue
- [ ] Can submit new company → goes to queue
- [ ] Can edit park → goes to queue
- [ ] Can edit ride → goes to queue
- [ ] Can edit company → goes to queue
- [ ] Can delete park → goes to queue
- [ ] Can delete ride → goes to queue
- [ ] Can delete company → goes to queue
- [ ] Approval creates entity/applies changes
- [ ] Rejection saves reason
- [ ] No way to bypass moderation
- [ ] All changes create versions (pghistory)
---
### Task 14.8: Browser Console Check (30 min)
Open dev tools in browser and check:
- [ ] No errors in console
- [ ] No failed API requests (check Network tab)
- [ ] No 404s
- [ ] No CORS errors
- [ ] No authentication errors
- [ ] All API calls go to Django (not Supabase)
---
### Task 14.9: Final Documentation Update (30 min)
- [ ] Update migration README with completion status
- [ ] Document any known issues
- [ ] Document deployment notes
- [ ] Update main project README if needed
---
## 🎯 Final Success Criteria
### Code Cleanliness
- [ ] Zero Supabase dependencies in code
- [ ] Zero Supabase dependencies in package.json
- [ ] All imports resolve
- [ ] All TypeScript errors fixed
- [ ] Build succeeds without errors
### Functionality
- [ ] Authentication works (all flows)
- [ ] All entity CRUD works via Sacred Pipeline
- [ ] Reviews work
- [ ] Ride credits work
- [ ] Top lists work
- [ ] Photos work
- [ ] Search works
- [ ] Moderation works
- [ ] Admin functions work
- [ ] Contact form works
- [ ] Timeline works
- [ ] History works
### Sacred Pipeline
- [ ] ALL entity changes go through ContentSubmission
- [ ] NO direct database writes possible
- [ ] Moderation queue functional
- [ ] Approval creates versions
- [ ] Rejection saves reason
- [ ] No bypass mechanisms exist
### Performance
- [ ] Pages load quickly
- [ ] Search is responsive
- [ ] No memory leaks
- [ ] API requests are reasonable
---
## 🚀 Deployment
Once ALL success criteria are met:
### 1. Final Commit
```bash
git add .
git commit -m "Complete Supabase→Django + React→Next.js 15 migration - All phases complete"
git push
```
### 2. Deploy to Staging
```bash
# Deploy Django backend to staging
# Deploy frontend to staging (Vercel/etc)
```
### 3. Staging Verification (2-4 hours)
- [ ] Run ALL integration tests again in staging
- [ ] Monitor error logs
- [ ] Check API response times
- [ ] Verify Sacred Pipeline in staging
### 4. Production Deployment
**Only after staging is 100% verified:**
```bash
# Deploy Django backend to production
# Deploy frontend to production
```
### 5. Post-Deployment Monitoring (24 hours)
- [ ] Watch error logs closely
- [ ] Monitor API response times
- [ ] Check Sacred Pipeline is working
- [ ] Verify no Supabase errors
- [ ] Monitor user feedback
---
## 📝 Rollback Plan
If critical issues are found:
1. Immediately rollback frontend deployment
2. Rollback backend deployment if needed
3. Investigate issue
4. Fix in development
5. Re-test thoroughly
6. Re-deploy
---
## 🎉 MIGRATION COMPLETE!
Once Phase 14 is finished and verified:
**✅ Supabase is 100% removed.**
**✅ ThrillWiki runs on Django REST API.**
**✅ Frontend is Next.js 15 + App Router + Turbopack.**
**✅ Sacred Pipeline remains intact.**
**✅ All features work.**
**✅ Package manager is Bun.**
**✅ Environment variables properly configured.**
Celebrate, but monitor closely for 24-48 hours post-deployment.
---
## 🔗 Related Files
- `migration/README.md` - Overview
- `COMPLETE_SUPABASE_REMOVAL_AUDIT_AND_PLAN.md` - Original audit
- All phase documents (01-12) - Implementation guides
---
**Document Version:** 1.0
**Last Updated:** November 9, 2025