8.4 KiB
QUICK START - ENCOUNTER EDIT MODE TESTING
Pre-Test Checklist
- You have valid encounter IDs to test with
- Browser DevTools are ready (F12 or Cmd+Opt+I)
- Network tab can be monitored
- You have update permissions (RBAC configured)
- API is running and accessible
Running TEST 1: Load Edit Page (5 min)
Setup
- Open browser DevTools → Console tab
- Navigate to:
http://localhost:3000/outpatient/encounter/123/edit(replace 123 with valid ID)
Expected Flow
1. Page loads with spinner
2. Console shows: 📥 [EDIT MODE] Loading encounter detail: {id: 123}
3. After 1-2 seconds, data loads
4. Console shows: ✅ [EDIT MODE] Encounter detail loaded and form mapped successfully
5. Form fields auto-populate with encounter data
Verify
- Patient name visible in form
- Doctor/Specialist selected
- Date in YYYY-MM-DD format
- Payment type shown (jkn, spm, etc.)
- If JKN payment: Card number and SEP number visible
- No console errors (❌ should not appear)
- No red validation error messages
Success Criteria
✅ Form fully populated and no errors
Running TEST 2: Edit & Save (5 min)
Setup
- Use same page from TEST 1 (form already populated)
- Open Network tab and filter:
encounter
Steps
- Change doctor to different one
- Click "Simpan" (Save) button
- Watch Network tab for PATCH request
- Watch Console for save logs
Expected Flow
1. Click save
2. Console shows: 💾 [EDIT MODE] Sending PATCH request: {id: 123, payload: {...}}
3. Network shows: PATCH /api/v1/encounter/123
4. After 1-2 seconds: Console shows: 📤 [SAVE] API Response: {success: true}
5. Console shows: ✅ [SAVE] Success - Redirecting to list page
6. Page navigates to list
Verify Network Tab
Click on the PATCH request and check:
- URL:
/api/v1/encounter/123(correct ID) - Method: PATCH (not PUT or POST)
- Headers:
Content-Type: application/json - Payload (Request body):
appointment_doctor_codeis stringregisteredAthas ISO format with ZpaymentMethod_codematches payment type
- Response:
"success": true
Success Criteria
✅ PATCH request sent and success toast shown
Running TEST 3: BPJS Conditional Fields (3 min)
Setup
- Navigate to new edit page:
/outpatient/encounter/456/edit - Form loads with SPM payment type
- Card number field is hidden/empty
Steps
- Find the "Jenis Pembayaran" (Payment Type) dropdown
- Change from SPM to JKN
- Observe form changes
Expected Behavior
- Card number field appears and required
- SEP type field appears and required
- SEP number field appears (if SEP type selected)
- Try to save without card number
- Validation error appears: "No. Kartu BPJS wajib diisi"
Fill Fields
- Enter BPJS card number (e.g., 0000123456789)
- Select SEP type
- Try to save again
- Now validation should pass
Success Criteria
✅ Conditional fields work and validation enforces requirements
Running TEST 4: Error Handling (5 min)
Setup (Simulate Error)
- Open DevTools
- Go to Network tab
- Find "Throttling" dropdown (set to "Slow 3G" or "Offline")
Scenario A: GET Failure
- Set network to Offline
- Navigate to edit page:
/outpatient/encounter/789/edit - Observe error handling
Expected Result
- Error toast appears: "Gagal memuat data kunjungan"
- Console shows: ❌ [EDIT MODE] Failed to load encounter
- Page auto-redirects to list
Scenario B: PATCH Failure
- Load page normally (turn network back on)
- Set network to Offline
- Try to save changes
- Observe error handling
Expected Result
- Error toast appears: "Gagal memperbarui kunjungan"
- Console shows: ❌ [SAVE] Failed
- Page stays on form (user can retry)
- Turn network back on and retry save
Success Criteria
✅ Error handling works correctly for both GET and PATCH
Running TEST 5: Data Types (3 min)
Verify in Browser Console
// 1. Check form object structure
// Go to any edit page, then in console:
window.__nuxt__ // If available
// 2. Check Network tab for PATCH payload
// Look at "Request body" for PATCH /api/v1/encounter/{id}
Manual Checks
Doctor ID Type:
- Form shows: "Dr. John Doe" (human readable)
- Network payload shows:
"appointment_doctor_code": "5"(string) - ✅ Correct
Date Format:
- Form shows: "2025-12-02" (YYYY-MM-DD)
- Network payload shows:
"registeredAt": "2025-12-02T10:30:00.000Z"(ISO) - ✅ Correct
Payment Type:
- Form shows: "BPJS" (human readable)
- Form value:
"jkn"(code) - Network payload shows:
"paymentMethod_code": "insurance"(API code) - ✅ Correct
Success Criteria
✅ All type conversions transparent and correct
Console Log Reference
Good Logs (No Issues)
✅ [EDIT MODE] Encounter detail loaded and form mapped successfully
✅ [SAVE] Success - Redirecting to list page
📥 [EDIT MODE] Loading encounter detail: {id: 123}
📋 [EDIT MODE] Mapped encounter to form: {...}
💾 [EDIT MODE] Sending PATCH request: {id: 123, payload: {...}}
📤 [SAVE] API Response: {success: true}
Bad Logs (Issues Found)
❌ [EDIT MODE] Failed to load encounter: 'Encounter not found'
❌ [SAVE] Failed: 'Validation error: invalid doctor_id'
❌ [SAVE] Error saving encounter: Error: Failed to put encounter
Action: If you see ❌, note the exact error and check troubleshooting guide
Common Issues During Testing
| Problem | Cause | Solution |
|---|---|---|
| Form not populated | API call failed | Check Network tab, verify API is running |
| Save button disabled | Validation fails | Check form for required fields marked in red |
| PATCH shows 422 | Invalid data type | Check Network payload vs expected schema |
| Doctor list empty | Specialist not selected | Select specialist first |
| Date shows wrong format | Conversion failed | Check console for mapping logs |
Quick Reference: Test URLs
Outpatient Tests
http://localhost:3000/outpatient/encounter/1/edit
http://localhost:3000/outpatient/encounter/2/edit
http://localhost:3000/outpatient/encounter/3/edit
Inpatient Tests
http://localhost:3000/inpatient/encounter/1/edit
http://localhost:3000/inpatient/encounter/2/edit
Emergency Tests
http://localhost:3000/emergency/encounter/1/edit
http://localhost:3000/emergency/encounter/2/edit
Testing Checklist Summary
TEST 1 - Load Edit Page
- Form loads without errors
- All fields populated
- Console shows success logs
- Time: 5 min
TEST 2 - Edit & Save
- Edit values
- PATCH request sent correctly
- Success message shown
- Navigates to list
- Time: 5 min
TEST 3 - BPJS Fields
- Conditional fields appear
- Validation enforced
- Save blocked without required fields
- Time: 3 min
TEST 4 - Error Handling
- GET errors handled correctly
- PATCH errors handled correctly
- User feedback appropriate
- Time: 5 min
TEST 5 - Data Types
- Doctor ID: string
- Dates: ISO format with Z
- Payment type: correct mapping
- Time: 3 min
Total Time: ~21 minutes
Success Indicators
All Tests Pass When:
✅ No ❌ in console logs
✅ All form fields populate correctly
✅ PATCH requests appear in Network tab
✅ Success toasts show after save
✅ Redirects work properly
✅ Validation enforces requirements
✅ Error messages are helpful
✅ Data types match expectations
Report Issues
If you encounter issues:
- Take a screenshot of the error
- Copy console logs (search for ❌ patterns)
- Check Network tab for failed requests
- Note the encounter ID and feature type (outpatient/inpatient/emergency)
- Describe what you were doing when issue occurred
Next Steps After Testing
If all tests pass:
- ✅ Feature is ready for deployment
- ✅ Can proceed to detail/readonly pages
- ✅ Can implement additional features
If issues found:
- Document the issue with error logs
- Check troubleshooting in ENCOUNTER_EDIT_TEST.md
- Review data mapping in ENCOUNTER_API_REFERENCE.md
- Check handler implementation in encounter-entry.handler.ts
Good Luck with Testing! 🚀
For more details, refer to:
ENCOUNTER_EDIT_TEST.md- Full test guide with detailed stepsENCOUNTER_API_REFERENCE.md- API and handler referenceIMPLEMENTATION_SUMMARY.md- Overall architecture overview