# Digital Signature on eRX - Test Plan

## Test Overview

**Feature**: Digital Signature on Electronic Prescriptions  
**Test Date**: January 20, 2026  
**Test Environment**: Development  
**Tester**: _____________  

## Prerequisites

- [x] Application running on `http://localhost:8000`
- [x] Database migrated (`php artisan migrate`)
- [x] Sample signature image files ready (PNG/JPG format)
- [x] Browser: Chrome, Firefox, or Safari (latest version)

## Test Scenarios

---

### Test 1: Complete Flow - Upload to Display

**Objective**: Verify end-to-end signature functionality

**Steps**:
1. Login as doctor (`doctor@rxnetworx.com`, any password)
2. Navigate to Profile → Due Diligence tab
3. Scroll to "Digital Signature" section
4. Upload a signature image
5. Navigate to Patients tab
6. Click "View Details" on patient "PT-001" (Sarah Johnson)
7. Scroll down and click "Approve & Sign"
8. Confirm success alert appears
9. Navigate to Prescriptions tab
10. Click "View" on the newly created prescription
11. Scroll to the bottom footer section

**Expected Results**:
- ✅ Signature upload shows success message
- ✅ Signature preview appears on profile page
- ✅ Prescription approval succeeds
- ✅ eRX ID is generated
- ✅ Signature image appears in "Electronically Signed By" section
- ✅ Signature is clear and properly sized
- ✅ Signature has a bordered container

**Actual Results**: _____________

**Status**: [ ] Pass [ ] Fail

**Notes**: _____________

---

### Test 2: Signature Display on Existing Prescriptions

**Objective**: Verify signature shows on demo prescriptions

**Steps**:
1. Login as doctor
2. Ensure signature is uploaded (Profile → Due Diligence)
3. Navigate to Prescriptions tab
4. Click "View" on prescription "eRX-0001" (John Smith - Lisinopril)
5. Scroll to footer section
6. Click back and view "eRX-0002" (Alice Williams - Metformin)
7. Click back and view "eRX-0003" (Robert Davis - Amoxicillin)

**Expected Results**:
- ✅ All three prescriptions show the uploaded signature
- ✅ Signature appears consistently across all prescriptions
- ✅ No console errors

**Actual Results**: _____________

**Status**: [ ] Pass [ ] Fail

**Notes**: _____________

---

### Test 3: Missing Signature Fallback

**Objective**: Verify graceful handling when no signature is uploaded

**Steps**:
1. Open browser in incognito/private mode
2. Navigate to `http://localhost:8000`
3. Login as doctor
4. Navigate to Prescriptions tab
5. Click "View" on any prescription
6. Scroll to footer section

**Expected Results**:
- ✅ Text shows "Digital signature on file" instead of image
- ✅ No broken image icons
- ✅ No JavaScript errors in console
- ✅ Page renders properly

**Actual Results**: _____________

**Status**: [ ] Pass [ ] Fail

**Notes**: _____________

---

### Test 4: Print Functionality

**Objective**: Verify signature prints correctly

**Steps**:
1. Login as doctor with signature uploaded
2. Navigate to Prescriptions → View eRX-0001
3. Click "Print" button
4. Examine print preview:
   - Check signature visibility
   - Check signature quality
   - Check page layout
5. Test on different browsers (Chrome, Firefox, Safari)

**Expected Results**:
- ✅ Signature is visible in print preview
- ✅ Signature maintains quality (not pixelated)
- ✅ Signature doesn't break page layout
- ✅ Border around signature is visible
- ✅ Works in all tested browsers

**Actual Results**: _____________

**Status**: [ ] Pass [ ] Fail

**Notes**: _____________

---

### Test 5: Signature Upload Validation

**Objective**: Verify file validation works correctly

**Steps**:
1. Login as doctor
2. Navigate to Profile → Due Diligence
3. Test invalid file types:
   - Try uploading a PDF file
   - Try uploading a TXT file
   - Try uploading a DOCX file
4. Test file size limit:
   - Try uploading an image > 2MB
5. Test valid files:
   - Upload a PNG file (< 2MB)
   - Upload a JPG file (< 2MB)
   - Upload a JPEG file (< 2MB)

**Expected Results**:
- ❌ PDF upload rejected with error message
- ❌ TXT upload rejected with error message
- ❌ DOCX upload rejected with error message
- ❌ Large file (>2MB) rejected with error message
- ✅ PNG upload succeeds
- ✅ JPG upload succeeds
- ✅ JPEG upload succeeds

**Actual Results**: _____________

**Status**: [ ] Pass [ ] Fail

**Notes**: _____________

---

### Test 6: Signature Update

**Objective**: Verify signature can be updated and reflects on new prescriptions

**Steps**:
1. Login as doctor
2. Upload signature #1 (e.g., signature-blue.png)
3. Approve patient PT-002 → Creates Prescription A
4. Navigate to Profile → Due Diligence
5. Upload signature #2 (e.g., signature-red.png)
6. Approve patient PT-003 → Creates Prescription B
7. View Prescription A
8. View Prescription B

**Expected Results**:
- ✅ Prescription A shows signature #1 (blue)
- ✅ Prescription B shows signature #2 (red)
- ✅ Each prescription retains its original signature
- ✅ No interference between signatures

**Actual Results**: _____________

**Status**: [ ] Pass [ ] Fail

**Notes**: _____________

---

### Test 7: Multiple Approvals Same Session

**Objective**: Verify consistent signature application across multiple approvals

**Steps**:
1. Login as doctor with signature uploaded
2. Approve patient PT-001
3. Approve patient PT-002
4. Approve patient PT-003
5. View all three prescriptions
6. Verify each shows the signature

**Expected Results**:
- ✅ All three prescriptions show the same signature
- ✅ Signature quality is consistent
- ✅ No missing signatures

**Actual Results**: _____________

**Status**: [ ] Pass [ ] Fail

**Notes**: _____________

---

### Test 8: Responsive Design

**Objective**: Verify signature displays correctly on different screen sizes

**Steps**:
1. Login as doctor with signature uploaded
2. View a prescription with signature
3. Test different viewport sizes:
   - Desktop (1920x1080)
   - Tablet (768x1024)
   - Mobile (375x667)
4. Use browser developer tools to resize

**Expected Results**:
- ✅ Signature visible on desktop
- ✅ Signature visible on tablet
- ✅ Signature visible on mobile
- ✅ Signature container doesn't overflow
- ✅ Text and signature are properly aligned

**Actual Results**: _____________

**Status**: [ ] Pass [ ] Fail

**Notes**: _____________

---

### Test 9: Session Persistence

**Objective**: Verify signature persists across page refreshes

**Steps**:
1. Login as doctor
2. Upload signature
3. Refresh the page
4. Check if signature is still visible on profile
5. Approve a prescription
6. Verify signature appears on eRX

**Expected Results**:
- ✅ Signature remains after refresh
- ✅ Can approve prescriptions after refresh
- ✅ Signature applies to prescriptions after refresh

**Actual Results**: _____________

**Status**: [ ] Pass [ ] Fail

**Notes**: _____________

---

### Test 10: Cross-Browser Compatibility

**Objective**: Verify feature works across different browsers

**Browsers to Test**:
- [ ] Google Chrome (latest)
- [ ] Mozilla Firefox (latest)
- [ ] Microsoft Edge (latest)
- [ ] Safari (latest, Mac only)

**Test Steps** (for each browser):
1. Login as doctor
2. Upload signature
3. Approve prescription
4. View prescription with signature
5. Test print preview

**Expected Results**:
- ✅ Signature uploads successfully in all browsers
- ✅ Signature displays correctly in all browsers
- ✅ Print works in all browsers
- ✅ No console errors in any browser

**Actual Results**:
- Chrome: _____________
- Firefox: _____________
- Edge: _____________
- Safari: _____________

**Status**: [ ] Pass [ ] Fail

**Notes**: _____________

---

### Test 11: Security - File Path Injection

**Objective**: Verify system is protected against path injection

**Steps**:
1. Open browser developer tools
2. Navigate to Profile → Due Diligence
3. Try to manipulate the upload form to upload to a different path
4. Try session manipulation (if possible)

**Expected Results**:
- ✅ Files are stored only in `public/uploads/signatures/`
- ✅ Filenames are timestamped (no user input in filename)
- ✅ Cannot upload outside designated directory

**Actual Results**: _____________

**Status**: [ ] Pass [ ] Fail

**Notes**: _____________

---

### Test 12: Error Handling - File Deletion

**Objective**: Verify system handles deleted signature files gracefully

**Steps**:
1. Login as doctor
2. Upload signature
3. Note the filename from profile preview
4. Manually delete the file from `public/uploads/signatures/`
5. Refresh the profile page
6. View a prescription
7. Try to approve a new prescription

**Expected Results**:
- ✅ Profile shows upload form (no broken image)
- ✅ Prescription view shows "Digital signature on file" text
- ✅ New prescription approval succeeds
- ✅ No PHP errors

**Actual Results**: _____________

**Status**: [ ] Pass [ ] Fail

**Notes**: _____________

---

## Test Summary

**Total Tests**: 12  
**Tests Passed**: ___  
**Tests Failed**: ___  
**Pass Rate**: ____%

### Critical Issues Found
1. _____________
2. _____________
3. _____________

### Non-Critical Issues Found
1. _____________
2. _____________
3. _____________

### Recommendations
1. _____________
2. _____________
3. _____________

## Sign-Off

**Tested By**: _____________  
**Date**: _____________  
**Signature**: _____________

**Approved By**: _____________  
**Date**: _____________  
**Signature**: _____________

---

## Additional Testing Notes

### Performance Metrics
- Page load time (with signature): _____________
- Upload time (signature): _____________
- Print rendering time: _____________

### Browser Console Errors
- Chrome: _____________
- Firefox: _____________
- Edge: _____________
- Safari: _____________

### Accessibility Notes
- Screen reader compatibility: _____________
- Keyboard navigation: _____________
- Color contrast: _____________

---

**Test Plan Version**: 1.0.0  
**Last Updated**: January 20, 2026
