Class_generator/tests/root-cleanup/test-wait-ready.js
StillHammer 29bc112c0c Unify vocabulary persistence system - remove dual systems
- Simplified loadPersistedVocabularyData() to use only VocabularyProgressManager
- Updated calculateVocabularyProgress() to use unified data structure
- Removed old system references from knowledge panel data loading
- Fixed field names (drsDiscovered, drsMastered) for unified system
- Knowledge panel now displays vocabulary progress correctly

 TESTED: Vocabulary Knowledge panel working with unified system

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-30 13:39:00 +08:00

51 lines
1.6 KiB
JavaScript

/**
* Test Readiness Helper - Waits for all modules to be properly loaded
*/
window.waitForAllModulesReady = async function(timeout = 30000) {
const startTime = Date.now();
console.log('⏳ Waiting for all modules to be ready...');
while (Date.now() - startTime < timeout) {
// Check if all critical modules are available
const modules = {
app: window.app && window.app.getStatus && window.app.getStatus().isRunning,
contentLoader: !!window.contentLoader,
unifiedDRS: !!window.unifiedDRS,
iaEngine: !!window.iaEngine,
llmValidator: !!window.llmValidator,
prerequisiteEngine: !!window.prerequisiteEngine
};
const allReady = Object.values(modules).every(ready => ready);
if (allReady) {
console.log('✅ All modules ready!', modules);
return true;
}
const missing = Object.entries(modules)
.filter(([name, ready]) => !ready)
.map(([name]) => name);
console.log(`⏳ Still waiting for: ${missing.join(', ')} (${Date.now() - startTime}ms)`);
await new Promise(resolve => setTimeout(resolve, 200));
}
console.log('⏰ Timeout waiting for modules to be ready');
return false;
};
window.ensureModulesReady = async function() {
const isReady = await window.waitForAllModulesReady();
if (!isReady) {
throw new Error('Modules not ready for testing - please check system status');
}
return true;
};
console.log('⏳ Module readiness helper loaded. Use: waitForAllModulesReady() or ensureModulesReady()');