2.4 KiB
2.4 KiB
Debugging the Spelling Practice App
This document provides guidance on debugging and testing the app's data handling functionality.
Testing Tools
1. API Test Page
A user-friendly interface for testing the API endpoints:
- URL: http://localhost:3000/api-test.html
- Features:
- Test the
/getResultsendpoint to retrieve session data - Create and save new test sessions with customizable parameters
- View session details for specific users
- Test the
2. Test Script
A Node.js script to verify the saveResults endpoint functionality:
node test-save-results.js
This script:
- Verifies the server is running
- Creates a test session for "testuser"
- Validates the session was saved correctly
- Shows summary information about the saved session
Common Issues
File Access Issues
If you're experiencing issues with data storage or retrieval:
-
Check file permissions:
- Make sure the
datadirectory is writable by the Node.js process - In Docker environments, ensure volume mounts are set up correctly
- Make sure the
-
Verify file formats:
- The app expects JSON files in a specific format
- If manually editing files, validate the JSON structure before restarting
-
Inspect server logs:
- The server outputs detailed logs with emoji indicators
- Look for error messages marked with ❌
Session Data Troubleshooting
If sessions aren't appearing correctly:
-
Format compatibility:
- The app supports multiple data formats for backward compatibility
- Session data may use either
timestampordatefields - Word data may be in
answersorwordsarrays
-
Data verification flow:
- Save a session using the API test page
- Check the response from the
/saveResultsendpoint - Verify data using the
/getResultsendpoint - Confirm it appears in the UI
Server Recovery
If the server stops working:
-
Restart the server:
node server.js -
Check for errors in the logs
-
Data integrity check:
- Inspect JSON files in the
datadirectory for formatting issues - Restore from backups or seed files if needed
- Inspect JSON files in the
Recent Fixes
- Added backup data display when
results.jsoncan't be read - Improved error handling in saveResults endpoint
- Created helper functions to handle different session data formats
- Added SVG clipping paths to fix analytics graph display issues