# ShiftOps Testing & Maintenance

**Last Updated:** 2026-01-09

Complete testing procedures and maintenance checklist for ShiftOps, including browser testing, performance monitoring, and update requirements.

## Testing Procedures

### Browser Testing

**Desktop Browsers:**
- Chrome (latest)
- Firefox (latest)
- Safari (latest)
- Edge (latest)

**Mobile Testing:**
- iOS Safari
- Android Chrome

**Test Scenarios:**

1. **Search Flow**
   - Test Google Places autocomplete
   - Test business selection
   - Test error handling for invalid selections

2. **Loading Screen**
   - Test chat-style sequence timing
   - Test rotating messages
   - Test data fetching (essential/enhanced)

3. **Report Page**
   - Test data loading from localStorage
   - Test progressive rendering
   - Test email gating flow
   - Test PDF export
   - Test NPS survey

4. **Error Scenarios**
   - Test API timeout handling
   - Test missing data handling
   - Test localStorage quota exceeded
   - Test network failure recovery

### Performance Testing

**Target Metrics:**
- Essential mode: < 2 seconds
- Enhanced mode: 3-5 seconds (background)
- Page load: < 2 seconds
- PDF export: 2-5 seconds

**Testing Tools:**
- Google PageSpeed Insights
- Chrome DevTools Performance tab
- Network tab for API timing

### Accessibility Testing

**Requirements:**
- Keyboard navigation (Tab through all interactive elements)
- Screen reader compatibility (ARIA labels)
- Color contrast (WCAG AA standards)
- Focus management (modal open/close)

**Testing Tools:**
- Chrome DevTools Accessibility tab
- Screen reader (NVDA/JAWS)
- Color contrast checker

## Maintenance Checklist

### Daily Monitoring

- [ ] Check error logs: `logs/shiftops-debug.log`
- [ ] Check HubSpot submission logs: `logs/shiftops-hubspot.log`
- [ ] Check NPS survey logs: `logs/shiftops-nps.log`
- [ ] Monitor API response times
- [ ] Check cache directory size

### Weekly Tasks

- [ ] Review user feedback (NPS scores)
- [ ] Check Google Places API usage
- [ ] Review error patterns
- [ ] Test critical user flows

### Monthly Tasks

- [ ] Update customer list (if needed)
- [ ] Review industry benchmarks
- [ ] Check for API changes (Google Places, HubSpot)
- [ ] Performance audit
- [ ] Security audit

### Annual Updates (January)

- [ ] Update "Last Updated" date
- [ ] Review and update industry benchmarks if needed
- [ ] Update meta tags if needed
- [ ] Test API integration (Google Places, HubSpot, weather, holidays)
- [ ] Verify export functionality (PDF)
- [ ] Review and update FAQs if needed
- [ ] Test responsive design
- [ ] Verify accessibility features
- [ ] Update year references in content (2026 → 2027)
- [ ] Document changes in change log

## Update Requirements

### 2026 Update Checklist

**Content:**
- [x] Update "Last Updated" date to 2026-01-09
- [x] Create comprehensive documentation
- [ ] Verify all year references are 2026 (not 2025)
- [ ] Update meta tags if needed

**Priority:** High

### Throughout 2026 Updates

**Scheduled Updates:**
- Quarterly: Review industry benchmarks and update if needed
- Monthly: Monitor API usage and performance
- As needed: Update recommendations based on user feedback

## Monitoring Requirements

### API Performance

- **Google Places API:** Monitor response times and error rates
- **HubSpot API:** Monitor submission success rates
- **Weather API:** Monitor response times (Open-Meteo)
- **Holiday API:** Monitor response times (Nager.Date)

### User Feedback

- **NPS Scores:** Track average NPS score and trends
- **NPS Categories:** Monitor Promoter/Passive/Detractor distribution
- **Feedback Text:** Review qualitative feedback for improvement opportunities

### Usage Analytics

- **Search Completion Rate:** Track how many users complete search
- **Report Unlock Rate:** Track email submission rate
- **PDF Downloads:** Track PDF export usage
- **NPS Response Rate:** Track NPS survey completion rate

### Error Logs

**Log Files:**
- `logs/shiftops-debug.log` - General errors and debug info
- `logs/shiftops-hubspot.log` - HubSpot submission logs
- `logs/shiftops-nps.log` - NPS survey logs

**Monitoring:**
- Check for fatal errors
- Monitor error frequency
- Review error patterns
- Track API failures

## Known Issues

### Current Issues

- Report page is very large (18,310 lines) - consider splitting into modules
- Some JavaScript functions are duplicated across files - consider consolidation
- Cache directory may need periodic cleanup (old cache files accumulate)

### Future Improvements

- Add URL-based sharing functionality
- Implement report history (store multiple reports)
- Add comparison feature (compare multiple businesses)
- Implement email notifications for report updates
- Add more export formats (Excel, CSV)
- Implement report scheduling (recurring analyses)
- Add API access for third-party integrations
- Implement report templates for different industries

## Troubleshooting

### Common Issues

**Issue: API Timeout**
- **Symptom:** Analysis takes too long or fails
- **Solution:** Check API response times, verify API keys, check network connectivity
- **Fallback:** System uses fallback data automatically

**Issue: Missing Data**
- **Symptom:** Report shows incomplete data
- **Solution:** Check Google Places API response, verify business data completeness
- **Fallback:** System shows available data only

**Issue: localStorage Full**
- **Symptom:** Data not saving
- **Solution:** Clear old localStorage data, check browser storage limits
- **Fallback:** System continues without localStorage, data passed via redirect

**Issue: PDF Export Fails**
- **Symptom:** PDF generation fails or incomplete
- **Solution:** Check jsPDF/html2canvas libraries, verify report data structure
- **Fallback:** User can retry export

### Debugging

**Enable Debug Mode:**
- Check `is_production()` function in PHP files
- Console logs enabled for localhost automatically
- Production: Console logs disabled

**Request ID Tracking:**
- All API requests include unique `request_id`
- Use request_id to trace errors in logs
- Request ID format: `shiftops_{uniqid}`

## Related Documentation

- [Technical Implementation](03-technical-implementation.md) - Code structure
- [System Troubleshooting](../../../systems/shiftops/SHIFTOPS_TROUBLESHOOTING.md) - Advanced troubleshooting
