Quick Start Testing Guide
π Get Started Testing the Task System in 5 Minutesβ
Prerequisitesβ
- API server running (
npm run devin attunelogic-api) - Valid JWT token
- At least one leg/job in your database
Step 1: Start the API Serverβ
cd /path/to/attunelogic-api
npm run dev
Expected Output:
[nodemon] starting `ts-node-dev --respawn --transpile-only index.ts`
Server running on port 3001
Database connected successfully
Step 2: Get Your Authentication Tokenβ
Option A: Login via APIβ
curl -X POST http://localhost:3001/api/v1/auth/login \
-H "Content-Type: application/json" \
-d '{
"email": "your@email.com",
"password": "yourpassword"
}'
Option B: Use existing token from mobile/web appβ
Check your browser's localStorage or mobile app storage for existing JWT token.
Save the token:
export JWT_TOKEN="your-jwt-token-here"
Step 3: Quick System Checkβ
Test Template Endpointsβ
# List available templates
curl -X GET "http://localhost:3001/api/v1/task-templates" \
-H "Authorization: Bearer $JWT_TOKEN"
# Should return JSON with templates array
Test Leg Tasksβ
# Get your legs (to find a leg ID)
curl -X GET "http://localhost:3001/api/v1/legs?limit=1" \
-H "Authorization: Bearer $JWT_TOKEN"
# Use the leg ID from above
LEG_ID="your-leg-id-here"
# Get tasks for that leg
curl -X GET "http://localhost:3001/api/v1/legs/$LEG_ID/tasks" \
-H "Authorization: Bearer $JWT_TOKEN"
Step 4: Run Automated Testsβ
Option A: Comprehensive Test Scriptβ
cd /path/to/attunelogic-api
node scripts/test-task-system.js
Expected Output:
π Starting Task System Manual Testing...
π Connecting to MongoDB...
β
Connected to MongoDB
π§ Setting up test data...
π Using test leg: LOAD123 (leg_id)
ποΈ TEMPLATE MANAGEMENT TESTS
π§ Testing: Template Creation
β
β Template Creation
π§ Testing: Template Retrieval
β
β Template Retrieval
π€ RULE ENGINE TESTS
π§ Testing: Rule Condition Evaluation
β
β Rule Condition Evaluation
π TEST SUMMARY
Total Tests: 8
Passed: 8
Failed: 0
π All tests passed!
Option B: API Endpoint Testsβ
cd /path/to/attunelogic-api
./scripts/test-api-endpoints.sh
Step 5: Test Rule Engine (Automatic Assignment)β
Seed System Templates Firstβ
node scripts/seed-templates.js
Trigger Automatic Assignmentβ
# Change a leg's status to trigger rule engine
curl -X PUT "http://localhost:3001/api/v1/legs/$LEG_ID" \
-H "Authorization: Bearer $JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{"status": "en_route"}'
Check Server Logs for:
π§ Rule Engine: Evaluating status change dispatched β en_route for leg LOAD123
π Found 2 templates with trigger status_change:en_route
β
Auto-assigned task: Pre-Delivery Inspection to leg LOAD123
Verify Tasks Were Assignedβ
curl -X GET "http://localhost:3001/api/v1/legs/$LEG_ID/tasks" \
-H "Authorization: Bearer $JWT_TOKEN"
Step 6: Test Mobile App Integrationβ
Open Mobile Appβ
- Navigate to any load
- Verify "Current Task" section appears in load details
- Tap on current task to open checklist
- Complete task steps and verify real-time updates
π Quick Troubleshootingβ
Server Won't Startβ
Error: Cannot find module '../../middlewares'
Fix:
# Check if taskTemplates route has correct import path
grep -n "middlewares" src/routes/api/v1/taskTemplates.js
# Should show: ../../../middlewares
No Templates Foundβ
Problem: API returns empty templates array Solution:
# Seed the database with system templates
node scripts/seed-templates.js
Authentication Errorsβ
Error: 401 Unauthorized
Fix:
- Verify JWT token is valid and not expired
- Check token format:
Authorization: Bearer <token> - Ensure user has proper organization access
Rule Engine Not Workingβ
Problem: Tasks not auto-assigned on status change Check:
- Templates exist with correct triggers
- Assignment conditions are met
- Server logs show rule engine activity
- Leg has required data (equipment, loadType, rate, etc.)
Mobile App Not Updatingβ
Problem: Task changes don't appear in mobile app Check:
- Internet connectivity
- RTK Query cache invalidation
- Backend API responses
- Authentication status
π Expected Test Resultsβ
Successful Template Creationβ
{
"data": {
"_id": "template_id",
"name": "Custom Safety Check",
"industry": "trucking",
"category": "safety",
"organizationId": "org_id",
"isActive": true
}
}
Successful Rule Engine Executionβ
{
"data": {
"id": "task_instance_id",
"templateId": "template_id",
"name": "Pre-Delivery Inspection",
"status": "PENDING",
"autoAssigned": true
},
"progress": {
"total": 3,
"completed": 0,
"pending": 3,
"percentage": 0
}
}
Successful Task Completionβ
{
"data": {
"id": "task_id",
"status": "COMPLETED",
"completedAt": "2025-09-14T16:30:00Z",
"steps": [
{
"id": "step_1",
"completed": true,
"completedAt": "2025-09-14T16:25:00Z"
}
]
},
"progress": {
"total": 3,
"completed": 1,
"pending": 2,
"percentage": 33.3
}
}
π― Key Features to Verifyβ
β Template Managementβ
- List system and custom templates
- Create organization-specific templates
- Update and delete custom templates
- Filter templates by industry/category
β Automatic Task Assignmentβ
- Templates auto-assign on status changes
- Rule conditions properly evaluated
- Template analytics updated
- Progress tracking works
β Manual Task Managementβ
- Apply templates to legs manually
- Create custom tasks
- Complete task steps
- Update task status
β Mobile Integrationβ
- Current task displays in load details
- Task checklist modal works
- Real-time progress updates
- Offline task completion
β Analytics and Monitoringβ
- Template usage analytics
- Task completion rates
- Rule engine performance logs
- Progress calculations
π Get Helpβ
If tests fail or you encounter issues:
- Check Logs: Server console for detailed error messages
- Verify Data: Ensure test legs and templates exist
- Test Isolation: Run individual test functions
- Documentation: Refer to full manual testing guide
- Support: Contact development team with specific error messages
Next Steps: Once basic testing passes, proceed to the comprehensive testing guide for advanced scenarios and edge cases.