Before testing, ensure:
- You have a Supabase project set up
- All migrations have been run in order:
20260119064145_5c3fc727-e03b-4e75-80ca-d27267150d93.sql20260119065541_af69017e-df74-43bb-9634-c0e9b6d3473f.sql20260119070601_add_session_logging.sql20260119094000_rename_weight_to_weight_kg.sql20260119110000_add_stat_calculations.sql20260119110100_update_xp_calculation.sql
- Environment variables are configured in
.env
Run the following SQL files in your Supabase SQL Editor in this exact order:
# 1. Core tables (profiles, goals, preferences)
supabase/migrations/20260119064145_5c3fc727-e03b-4e75-80ca-d27267150d93.sql
# 2. Additional profile function
supabase/migrations/20260119065541_af69017e-df74-43bb-9634-c0e9b6d3473f.sql
# 3. Workout logging tables and XP system
supabase/migrations/20260119070601_add_session_logging.sql
# 4. Weight column rename
supabase/migrations/20260119094000_rename_weight_to_weight_kg.sql
# 5. Stat calculation functions
supabase/migrations/20260119110000_add_stat_calculations.sql
# 6. Updated XP formula
supabase/migrations/20260119110100_update_xp_calculation.sqlObjective: Verify default stats for new user
Steps:
- Register a new account
- Navigate to System Status page
- Verify default values:
- Level: 1
- XP: 0
- Strength: 30
- Endurance: 25
- Recovery: 50
- Consistency: 0
- Mobility: 30
- Health: 25 (avg of END, REC, CON)
Expected Result: All stats show default values, no errors
Objective: Verify XP calculation and stat updates
Steps:
- Click "Log Workout"
- Add exercise: "Bench Press"
- Add set: 50kg × 12 reps
- Add set: 50kg × 10 reps
- Add set: 50kg × 8 reps
- Set session duration: 60 minutes
- Complete workout
Expected Calculations:
- Volume = 50 × (12 + 10 + 8) = 1,500kg
- XP = (1500 / 100) + (60 × 0.5) = 15 + 30 = 45 XP
- Strength: Should increase from 30 (base) to ~32
- Endurance: Should increase from 25 (1 hour training)
- Consistency: Should show ~8% (1 of 12 ideal sessions)
Expected Result:
- Profile shows Level 1, 45 XP
- Stats increased appropriately
- Session appears in history
Objective: Verify progressive stat increases
Steps:
- Log 3 more workout sessions over different days
- Each with similar volume (1,500-2,000kg)
- Duration: 45-60 minutes each
Expected Result:
- XP increases after each session
- Level may increase if XP crosses 100
- Strength increases (more sessions)
- Endurance increases (more hours)
- Consistency increases (4 sessions = ~33%)
- Calendar shows all training days
Objective: Verify XP only granted on completion, not editing
Steps:
- Open an existing session
- Click "Edit"
- Add a new exercise
- Add sets
- Save changes
Expected Result:
- Session updated successfully
- XP does NOT change
- Profile level does NOT change
- Stats remain the same
Objective: Verify Recovery stat decreases with overtraining
Steps:
- Log 6 sessions in one week (6 consecutive days)
- Check Recovery stat
Expected Result:
- Recovery stat should DECREASE from baseline
- Penalty applied for training >5 days/week
- Health bar may drop
Objective: Verify consistency percentage
Steps:
- Log exactly 12 sessions over 30 days
- Check Consistency stat
Expected Result:
- Consistency should be 100% (12 sessions = ideal)
Alternative:
- 6 sessions = 50% consistency
- 18 sessions = 100% (capped at 100%)
Objective: Verify rest days improve Recovery
Steps:
- After overtraining test, take 2-3 rest days
- Log a new session
- Check Recovery stat
Expected Result:
- Recovery should increase
- Health bar should improve
Objective: Verify calendar shows correct training days
Steps:
- Navigate to different months
- Verify highlighted days match actual sessions
- Check session counts for each month
Expected Result:
- Training days correctly highlighted
- Session counts accurate
- Month navigation works
Objective: Verify goal progress tracking
Steps:
- Set a goal in profile: "Bench 100kg", target: 100, current: 0
- Log sessions with progressive bench press increases
- Manually update current_value in profile
Expected Result:
- Goal progress bar updates
- Percentage calculated correctly
Objective: Verify behavior pattern calculations
Steps:
- After logging 12+ sessions over 30 days
- Check Potions panel
- Verify counts
Expected Result:
- Rest Days: 18-20 (30 days - training days)
- Consistency Streaks: 3-4 (weeks with 3+ sessions)
- Deload Weeks: 0-1 (weeks with 1-2 sessions)
- Recovery Patterns: Based on rest day count
Objective: Verify skill points calculation
Steps:
- Check Skill Points after earning XP
- Verify calculation: Skill Points = Total XP / 10
Expected Result:
- If total XP = 250, Skill Points = 25
- Circular progress shows correct value
- Bar chart shows recent activity
Objective: Verify level up mechanics
Steps:
- Earn enough XP to reach 100
- Check if level increases to 2
- Verify remaining XP carries over
Expected Result:
- Level increases from 1 to 2
- Remaining XP shown (e.g., if 120 XP earned, shows level 2 with 20 XP)
- Next level requires 200 XP
You can verify calculations directly in Supabase SQL editor:
-- Check user stats
SELECT * FROM calculate_user_stats('your-user-id');
-- Check behavior patterns
SELECT * FROM calculate_behavior_patterns('your-user-id');
-- Check training calendar for current month
SELECT * FROM get_training_calendar('your-user-id', 2026, 1);
-- Check session XP
SELECT
id,
session_date,
total_xp_earned,
duration_minutes
FROM workout_sessions
WHERE user_id = 'your-user-id'
ORDER BY session_date DESC;
-- Check profile
SELECT level, xp FROM profiles WHERE user_id = 'your-user-id';Solution:
- Ensure migrations ran successfully
- Check if functions were created (check Supabase functions list)
- Verify RLS policies are enabled
Solution:
- Check if trigger is only on INSERT, not UPDATE
- Verify the
update_profile_after_sessiontrigger
Solution:
- This is expected! Users need to log workouts to see stats increase
- Base values are: STR=30, END=25, REC=50, CON=0, MOB=30
Solution:
- Check session_date timestamps
- Verify timezone settings in Supabase
- Check
get_training_calendarfunction
Solution:
- Verify stats are being calculated
- Check formula: (REC + END + CON) / 3
- Ensure all three stats are returning values
- Load Testing: Add 50+ sessions, verify performance
- Cache Testing: Refresh page multiple times, verify stats load quickly
- Concurrent Users: Test with multiple users simultaneously
- RLS Verification: Try accessing another user's data
- SQL Injection: Try malicious inputs (should be prevented by parameterized queries)
- Auth Testing: Try accessing stats without authentication
After any code changes:
- Run all migration files in fresh database
- Execute all test scenarios
- Verify no broken functionality
- Check for console errors
All tests pass if:
- ✅ Stats calculate correctly from real data
- ✅ XP only granted on session completion
- ✅ No XP on editing existing sessions
- ✅ Level up mechanics work correctly
- ✅ Calendar shows accurate training days
- ✅ Recovery penalizes overtraining
- ✅ Consistency rewards regular training
- ✅ All UI components render without errors
- ✅ RLS prevents unauthorized data access
- ✅ Build succeeds without errors