# S05: [A] Sprint 0 Refactoring Tasks — UAT

**Milestone:** M019
**Written:** 2026-04-03T23:11:05.685Z

## UAT: S05 — [A] Sprint 0 Refactoring Tasks

### Preconditions
- Frontend built successfully (`cd frontend && npm run build` exits 0)
- Backend running on ub01:8096 with latest code deployed

---

### Test 1: API Module Structure
**Steps:**
1. List files in `frontend/src/api/`: `ls frontend/src/api/*.ts`
2. Confirm `public-client.ts` does NOT exist
3. Confirm these 11 files exist: client.ts, index.ts, search.ts, techniques.ts, creators.ts, topics.ts, stats.ts, reports.ts, admin-pipeline.ts, admin-techniques.ts, auth.ts

**Expected:** 11 files listed, no public-client.ts

### Test 2: No Stale Import References
**Steps:**
1. Run `rg 'public-client' frontend/src/ -g '*.ts' -g '*.tsx'`

**Expected:** Zero matches — all consumers import from barrel `../api` or `../api/index`

### Test 3: Barrel Re-exports All Domains
**Steps:**
1. Open `frontend/src/api/index.ts`
2. Verify it re-exports from all 10 domain modules

**Expected:** 10 `export * from` statements covering all domain modules

### Test 4: Code Splitting — Lazy Imports
**Steps:**
1. Open `frontend/src/App.tsx`
2. Verify these 6 pages use `React.lazy()`: AdminPipeline, AdminTechniquePages, AdminReports, CreatorDashboard, CreatorSettings, About
3. Verify these pages are NOT lazy: Home, SearchResults, TechniquePage, CreatorsBrowse, CreatorDetail, TopicsBrowse, SubTopicPage, Login, Register

**Expected:** Exactly 6 lazy imports, all public and auth pages remain static

### Test 5: Code Splitting — Build Output
**Steps:**
1. Run `cd frontend && npm run build`
2. Count JS files: `ls dist/assets/*.js | wc -l`

**Expected:** 7 JS chunks (1 main bundle + 6 lazy-loaded page chunks)

### Test 6: Suspense Fallback
**Steps:**
1. Open `frontend/src/App.tsx`
2. Verify each lazy-loaded route element is wrapped in `<Suspense fallback={<LoadingFallback />}>`

**Expected:** LoadingFallback component defined, Suspense wraps all lazy route elements

### Test 7: Paginated Topics Endpoint
**Steps:**
1. `curl -s http://ub01:8096/api/v1/topics | python3 -m json.tool | head -5`

**Expected:** Response is `{"items": [...], "total": N}` — NOT a bare array

### Test 8: Paginated Videos Endpoint
**Steps:**
1. `curl -s 'http://ub01:8096/api/v1/videos?offset=0&limit=5' | python3 -m json.tool | head -5`

**Expected:** Response is `{"items": [...], "total": N, "offset": 0, "limit": 5}` — NOT a bare array

### Test 9: Frontend Topics Consumers
**Steps:**
1. Navigate to http://ub01:8096 (Home page)
2. Verify topic categories render in the Topics section
3. Navigate to http://ub01:8096/topics
4. Verify all topic categories render with counts

**Expected:** Both pages display topic data correctly (reading from `.items` of paginated response)

### Edge Cases
- **Test 10:** Navigate directly to an admin page (e.g., /admin/pipeline) — should show loading indicator briefly, then the page content (or login redirect if not authenticated)
- **Test 11:** Navigate between eager and lazy pages rapidly — no white flashes or errors in console
