-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_tier_system.js
More file actions
106 lines (90 loc) · 3.73 KB
/
test_tier_system.js
File metadata and controls
106 lines (90 loc) · 3.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
// Test script to verify the tier-based quest system
// Run this in the browser console to test quest progression
const testTierSystem = async () => {
console.log('🧪 Testing Tier-based Quest System...\n');
// Test athlete ID - use your actual athlete ID
const athleteId = 'test-athlete-123';
console.log('1. Testing tier progress initialization...');
try {
// Initialize tier progress (this should create bronze tier with first quest unlocked)
const initResult = await initializeAthleteTierProgress(athleteId);
console.log('✅ Tier progress initialized:', initResult);
// Get tier progress
const tierResult = await getAthleteTierProgress(athleteId);
console.log('📊 Current tier progress:', tierResult);
} catch (error) {
console.error('❌ Tier initialization failed:', error);
}
console.log('\n2. Testing available quests by tier...');
try {
// Get available quests
const questsResult = await getAvailableQuestsForAthlete(athleteId);
if (questsResult.success) {
console.log('🎯 Available quests:', questsResult.quests.length);
// Group by tier
const questsByTier = {};
questsResult.quests.forEach(quest => {
// Find which tier this quest belongs to
for (const [tier, quests] of Object.entries(QUEST_TIERS)) {
if (Object.values(quests).some(q => q.id === quest.id)) {
if (!questsByTier[tier]) questsByTier[tier] = [];
questsByTier[tier].push(quest.title);
break;
}
}
});
console.log('📝 Quests by tier:', questsByTier);
}
} catch (error) {
console.error('❌ Quest retrieval failed:', error);
}
console.log('\n3. Testing quest start and progress...');
try {
// Start a bronze tier quest
const questsResult = await getAvailableQuestsForAthlete(athleteId);
if (questsResult.success && questsResult.quests.length > 0) {
const firstQuest = questsResult.quests[0];
console.log('🚀 Starting quest:', firstQuest.title);
const startResult = await startQuest(athleteId, firstQuest.id);
console.log('✅ Quest started:', startResult);
// Simulate some progress
if (startResult.success) {
console.log('📈 Simulating quest progress...');
// Create a mock training session
const mockSession = {
athleteId,
sport: firstQuest.requirements?.sport || 'running',
duration: 30, // 30 minutes
distance: 3, // 3 km
intensity: 'medium',
notes: 'Test session for quest progress',
date: new Date().toISOString().split('T')[0]
};
// This would normally be done through the TrainingLogForm
console.log('🏃 Mock training session:', mockSession);
}
}
} catch (error) {
console.error('❌ Quest start failed:', error);
}
console.log('\n4. Testing tier unlocking simulation...');
try {
// Get current tier progress
const tierResult = await getAthleteTierProgress(athleteId);
if (tierResult.success && tierResult.tierProgress) {
const progress = tierResult.tierProgress;
console.log('🏆 Current tier:', progress.currentTier);
console.log('🔓 Unlocked tiers:', progress.unlockedTiers);
console.log('✅ Completed tiers:', progress.completedTiers);
console.log('📊 Tier progress:', progress.tierProgress);
}
} catch (error) {
console.error('❌ Tier progress check failed:', error);
}
console.log('\n✨ Tier system test completed!');
};
// Run the test
if (typeof window !== 'undefined') {
window.testTierSystem = testTierSystem;
console.log('🎮 Tier system test loaded! Run testTierSystem() to begin testing.');
}