# Salesforce API v63.0 Parity - Verification Plan

## Goal
Verify all 10 PRD tasks for frontend/backend integration and Salesforce wire-protocol compatibility.

---

## Phase 1: Environment Setup (5 min)
- [ ] Start backend server: `./backend/restart-server.sh`
- [ ] Start frontend: `npm run dev` in frontend/
- [ ] Verify health: `curl http://localhost:3001/health`
- [ ] Login via UI or get auth token

## Phase 2: Backend Gap Implementation (P0)

### Task 7: UI API Missing Endpoints
**Files to modify:**
- `backend/internal/interfaces/rest/ui_api_handler.go`
- `backend/cmd/server/main.go`

**Endpoints to add:**
```go
// HandleRecordDefaultsCreate handles GET /ui-api/record-defaults/create/:objectApiName
// HandleRecordDefaultsClone handles GET /ui-api/record-defaults/clone/:recordId
// HandleListViewInfo handles GET /ui-api/list-info/:objectApiName/:listViewApiName
```

**Route registration:**
```go
uiGroup.GET("/record-defaults/create/:objectApiName", uiAPIHandler.HandleRecordDefaultsCreate)
uiGroup.GET("/record-defaults/clone/:recordId", uiAPIHandler.HandleRecordDefaultsClone)
uiGroup.GET("/list-info/:objectApiName/:listViewApiName", uiAPIHandler.HandleListViewInfo)
```

### Task 10: Workflow Rules Endpoints
**Files to modify:**
- `backend/internal/interfaces/rest/approval_handler.go`
- `backend/cmd/server/main.go`

**Endpoints to add:**
```go
// GetWorkflowRules handles GET /process/rules - List all workflow rules
// GetWorkflowRulesForObject handles GET /process/rules/:sObject - Rules for specific object
```

**Route registration:**
```go
v63.GET("/process/rules", approvalHandler.GetWorkflowRules)
v63.GET("/process/rules/:sObject", approvalHandler.GetWorkflowRulesForObject)
```

---

## Phase 3: Verification Testing (Per Task)

### Task 1: Composite API ✅
```bash
# Test composite batch
curl -X POST http://localhost:3001/services/data/v63.0/composite/batch \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"batchRequests":[{"method":"GET","url":"/services/data/v63.0/sobjects"}]}'

# Frontend tests
cd frontend && npm test -- composite.test.ts
```

### Task 2: sObject Collections ✅
```bash
# Test bulk create
curl -X POST http://localhost:3001/services/data/v63.0/composite/sobjects \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"records":[{"attributes":{"type":"Account"},"Name":"Test1"}]}'

# Frontend tests
cd frontend && npm test -- data.test.ts
```

### Task 3: Limits API ✅
```bash
# Test limits endpoint
curl http://localhost:3001/services/data/v63.0/limits \
  -H "Authorization: Bearer $TOKEN"

# Expected: JSON with DailyApiRequests, DataStorageMB, etc.

# Frontend tests
cd frontend && npm test -- limits.test.ts
```

### Task 4: Reports API
```bash
# Test report describe
curl http://localhost:3001/services/data/v63.0/analytics/reports/00O000000001234/describe \
  -H "Authorization: Bearer $TOKEN"

# Test report execution
curl -X POST http://localhost:3001/services/data/v63.0/analytics/reports/00O000000001234 \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{}'

# Frontend tests
cd frontend && npm test -- analytics.test.ts
```

### Task 5: Connect API
```bash
# Test user files
curl http://localhost:3001/services/data/v63.0/connect/files/users/me \
  -H "Authorization: Bearer $TOKEN"

# Test followers
curl http://localhost:3001/services/data/v63.0/chatter/users/me/followers \
  -H "Authorization: Bearer $TOKEN"

# Frontend tests
cd frontend && npm test -- chatter.test.ts
```

### Task 6: Actions API
```bash
# Test list all actions
curl http://localhost:3001/services/data/v63.0/actions \
  -H "Authorization: Bearer $TOKEN"

# Test standard actions
curl http://localhost:3001/services/data/v63.0/actions/standard \
  -H "Authorization: Bearer $TOKEN"

# Frontend tests
cd frontend && npm test -- actions.test.ts
```

### Task 7: UI API Extensions
```bash
# Test object info (existing)
curl http://localhost:3001/services/data/v63.0/ui-api/object-info/Account \
  -H "Authorization: Bearer $TOKEN"

# Test record defaults (after implementation)
curl http://localhost:3001/services/data/v63.0/ui-api/record-defaults/create/Account \
  -H "Authorization: Bearer $TOKEN"

# Frontend tests
cd frontend && npm test -- ui.test.ts
```

### Task 8: QueryAll
```bash
# Test queryAll for deleted records
curl "http://localhost:3001/services/data/v63.0/queryAll?q=SELECT+Id,Name,IsDeleted+FROM+Account" \
  -H "Authorization: Bearer $TOKEN"

# Verify IsDeleted records included
```

### Task 9: Describe Global
```bash
# Test describe global
curl http://localhost:3001/services/data/v63.0/sobjects \
  -H "Authorization: Bearer $TOKEN"

# Verify childRelationships in object describe
curl http://localhost:3001/services/data/v63.0/sobjects/Account/describe \
  -H "Authorization: Bearer $TOKEN" | jq '.childRelationships'
```

### Task 10: Workflow Rules
```bash
# Test workflow rules (after implementation)
curl http://localhost:3001/services/data/v63.0/process/rules \
  -H "Authorization: Bearer $TOKEN"

# Test object-specific rules
curl http://localhost:3001/services/data/v63.0/process/rules/Account \
  -H "Authorization: Bearer $TOKEN"
```

---

## Phase 4: Wire Format Compliance

### PascalCase Verification
For each endpoint, verify JSON uses PascalCase:
- ✅ `Id` not `id`
- ✅ `Name` not `name`
- ✅ `attributes.type` structure present

### Error Format Verification
```json
[{
  "errorCode": "INVALID_FIELD",
  "message": "Field 'xyz' not found",
  "fields": ["xyz"]
}]
```

---

## Phase 5: Frontend Test Suite

```bash
# Run all API tests
cd frontend && npm test -- --testPathPattern='infrastructure/api'

# Expected: All tests pass
# - composite.test.ts: 9 tests
# - data.test.ts: 23 tests
# - limits.test.ts: 8 tests
# - analytics.test.ts: 10 tests
# - chatter.test.ts: 9 tests
# - actions.test.ts: 9 tests
# - ui.test.ts: 11 tests
```

---

## Done When
- [ ] All 5 missing backend endpoints implemented
- [ ] All 10 tasks have passing frontend tests
- [ ] curl verification successful for each endpoint
- [ ] Wire format compliance confirmed (PascalCase)
- [ ] No 404 or 500 errors in integration testing
