| name | testing-and-debugging |
| description | Diagnose and debug issues in the vehicle insurance data analysis platform. Use when user encounters errors, data not refreshing, filters not working, charts not displaying, API failures, or performance issues. Provides quick diagnostic checklists and proven troubleshooting steps specific to this Vue 3 + Flask + Pandas stack. |
| allowed-tools | Read, Bash, Grep, Glob |
Testing and Debugging Guide
You are assisting with debugging the vehicle insurance data analysis platform (Vue 3 frontend + Flask backend + Pandas data processing).
When to Use This Skill
Activate this skill when the user reports:
- Data not updating or refreshing
- Filters/็ญ้ not working correctly
- Charts/ๅพ่กจ not displaying
- API errors or slow responses
- Style/ๆ ทๅผ rendering issues
- Performance problems
- Build or deployment failures
Quick Diagnostic Workflow
Step 1: Identify the Problem Layer
Ask the user to describe the symptom, then categorize:
Frontend Issues (Vue/UI):
- UI not updating โ Check reactive data and computed properties
- Chart not showing โ Verify ECharts initialization and data format
- Filters ineffective โ Check Store state and API params
- Styles broken โ Inspect CSS variables and scoped styles
Backend Issues (Flask/Pandas):
- API errors โ Check backend logs (
backend/backend.log)
- Slow responses โ Profile Pandas operations
- Missing data โ Verify CSV file existence and permissions
Integration Issues:
- CORS errors โ Check Flask-CORS configuration
- Network failures โ Inspect browser Network tab
Step 2: Run Diagnostic Commands
Guide the user through these checks:
For Frontend Issues
lsof -i :5173
For Backend Issues
lsof -i :5000
tail -f backend/backend.log
curl http://localhost:5000/api/latest-date
Step 3: Common Problems & Solutions
Refer to the Common Issues Reference for detailed troubleshooting steps.
Current Project Structure (for context)
้กน็ฎ/
โโโ frontend/ # Vue 3 + Vite
โ โโโ src/
โ โ โโโ components/ # KpiCard, FilterPanel, ChartView
โ โ โโโ stores/ # data.js, filter.js, app.js (Pinia)
โ โ โโโ views/ # Dashboard.vue
โ โ โโโ services/ # api.js (Axios)
โ โโโ package.json # NO testing libraries installed yet
โโโ backend/
โ โโโ api_server.py # Flask routes
โ โโโ data_processor.py # Pandas logic
โ โโโ backend.log # Runtime logs
โโโ data/ # CSV files
Important Context:
- Project does NOT currently have Vitest, pytest, or any testing framework installed
- Testing is manual through browser DevTools and curl commands
- No CI/CD pipeline configured
Debugging Strategies by Component
KpiCard Component Issues
Symptom: KPI values not updating
Diagnostic checklist:
- Open Vue DevTools โ Components โ Find KpiCard instance
- Check props:
value, trend, loading
- Verify parent Dashboard component is passing correct data
- Check DataStore state:
store.kpiData
Common causes:
- API returned data but Store didn't update โ Check
fetchKpiData() action
- Store updated but component didn't re-render โ Verify reactive refs
- Data is correct but formatting is wrong โ Check
valueType prop
FilterPanel Issues
Symptom: Filters applied but data doesn't change
Diagnostic steps:
- Open Vue DevTools โ Pinia โ FilterStore
- Verify
activeInstitution, activeTeam, etc. are updated
- Check if
applyFilters() action was triggered
- Inspect Network tab โ Verify API request includes filter params
Quick fix:
const filterStore = useFilterStore()
console.log('Active filters:', filterStore.activeInstitution, filterStore.activeTeam)
const dataStore = useDataStore()
dataStore.fetchFilteredData()
ChartView Issues
Symptom: Chart not rendering
Diagnostic checklist:
- Open browser console โ Check for ECharts errors
- Verify chart container has non-zero dimensions
- Check
chartData prop structure matches ECharts format
- Confirm ECharts instance initialized
Quick fixes:
onMounted(() => {
console.log('Chart container:', chartRef.value)
console.log('Chart data:', props.chartData)
console.log('Container size:', chartRef.value?.offsetWidth, chartRef.value?.offsetHeight)
})
Backend API Errors
Symptom: API returns 500 or 404
Diagnostic steps:
- Check
backend/backend.log for Python exceptions
- Test API endpoint with curl:
curl -X GET 'http://localhost:5000/api/kpi?period=day'
- Verify Flask is running:
ps aux | grep api_server
- Check if CSV file exists and is readable
Common causes:
่ฝฆ้ฉๆธ
ๅ_2025ๅนด10-11ๆ_ๅๅนถ.csv not found โ Run scan_and_process_new_files()
- Pandas DataFrame empty โ Check data cleaning logic in
data_processor.py
- Column name mismatch โ Verify CSV headers match expected field names
Performance Debugging
Slow Data Loading
Check these:
- CSV file size โ Large files slow Pandas reads
- Pandas operations โ Avoid row-by-row iteration
- Network latency โ Time API requests in Network tab
Optimization tips:
for index, row in df.iterrows():
df.at[index, 'new_col'] = some_function(row)
df['new_col'] = df.apply(lambda row: some_function(row), axis=1)
Memory Issues
Symptoms: Browser/Python crashes
Diagnostic:
top -o MEM
ps aux | grep python | awk '{print $11, $6/1024 "MB"}'
Solutions:
- Reduce CSV data loaded into memory
- Clear browser cache
- Restart backend process
Logging Best Practices
Frontend Logging
Current approach (add to components as needed):
export const useDataStore = defineStore('data', {
actions: {
async fetchKpiData() {
console.log('[DataStore] Fetching KPI data...')
try {
const response = await api.getKpiData()
console.log('[DataStore] KPI data loaded:', response.data)
this.kpiData = response.data
} catch (error) {
console.error('[DataStore] Fetch error:', error)
this.error = error.message
}
}
}
})
Backend Logging
Current configuration (already in place):
import logging
logging.basicConfig(
level=logging.DEBUG,
format='%(asctime)s [%(levelname)s] %(name)s: %(message)s',
handlers=[
logging.FileHandler('backend/backend.log'),
logging.StreamHandler()
]
)
View logs:
tail -f backend/backend.log
grep -i "error" backend/backend.log
tail -n 50 backend/backend.log
Browser DevTools Checklist
Essential Tabs
- Console: JavaScript errors and log messages
- Network: API requests/responses, timing, status codes
- Vue DevTools: Component tree, Pinia stores, events
- Elements: Inspect DOM and CSS
Common Workflow
1. User reports: "Data not refreshing"
2. Open Console โ Check for errors
3. Open Network โ Filter by XHR โ Check API calls
4. Open Vue DevTools โ Pinia โ Inspect DataStore state
5. If API failed โ Check backend logs
6. If API succeeded but UI not updated โ Check component reactive data
Quick Reference Links
Testing Future Plans
Note: Project does not currently have automated testing configured.
If user wants to add testing:
- Frontend: Recommend Vitest + @vue/test-utils
- Backend: Recommend pytest + pytest-flask
- Refer to TESTING_SETUP.md for installation guide
Emergency Fixes
Nuclear Option: Full Restart
pkill -f api_server
pkill -f vite
rm -rf frontend/node_modules/.vite
rm -rf frontend/dist
cd backend && python api_server.py &
cd frontend && npm run dev
Data Corruption Recovery
cp ่ฝฆ้ฉๆธ
ๅ_2025ๅนด10-11ๆ_ๅๅนถ.csv ่ฝฆ้ฉๆธ
ๅ_backup.csv
from data_processor import DataProcessor
processor = DataProcessor()
processor.scan_and_process_new_files()
Summary
This skill focuses on practical debugging for the current project state. It assumes:
- No testing framework installed (manual testing only)
- Simple deployment (no Docker/Kubernetes)
- Standard Vue 3 + Flask stack
For advanced testing setup, refer to companion guides. For deployment debugging, use the deployment-and-ops skill.
Key principle: Always start with logs (browser Console + backend.log) before diving into code.