539 lines
16 KiB
JavaScript
539 lines
16 KiB
JavaScript
// ========================================
|
|
// TESTS GÉNÉRÉS AUTOMATIQUEMENT - ModeManager
|
|
// Module: modes/ModeManager.js
|
|
// Générés le: 2025-09-08T23:48:03.033Z
|
|
// ========================================
|
|
|
|
const assert = require('assert');
|
|
const { test, describe } = require('node:test');
|
|
const ModeManager = require('../../modes/ModeManager.js');
|
|
|
|
describe('ModeManager - Tests automatiques', () => {
|
|
|
|
// Setup avant les tests
|
|
let testContext = {};
|
|
|
|
test('Module loading', () => {
|
|
assert.ok(ModeManager, 'Module should be loaded');
|
|
console.log('📦 Module ModeManager loaded successfully');
|
|
});
|
|
|
|
|
|
test('initialize - Async Operation', async () => {
|
|
const input = undefined;
|
|
|
|
try {
|
|
const startTime = Date.now();
|
|
const result = await ModeManager.initialize(input);
|
|
const duration = Date.now() - startTime;
|
|
|
|
// Validations de base
|
|
assert.ok(result !== undefined, 'Should return a result');
|
|
assert.ok(duration < 30000, 'Should complete within 30 seconds');
|
|
|
|
console.log(`✅ initialize: Completed in ${duration}ms`);
|
|
|
|
} catch (error) {
|
|
console.error('❌ initialize: Async operation failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('catch - Basic Function', () => {
|
|
const input = undefined;
|
|
|
|
try {
|
|
const result = ModeManager.catch(input);
|
|
|
|
// Validations de base
|
|
assert.ok(result !== undefined, 'Should return a result');
|
|
assert.ok(typeof result !== 'undefined', 'Result should be defined');
|
|
|
|
console.log('✅ catch: Function executed successfully');
|
|
|
|
} catch (error) {
|
|
console.error('❌ catch: Function failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('detectIntendedMode - Basic Function', () => {
|
|
const input = undefined;
|
|
|
|
try {
|
|
const result = ModeManager.detectIntendedMode(input);
|
|
|
|
// Validations de base
|
|
assert.ok(result !== undefined, 'Should return a result');
|
|
assert.ok(typeof result !== 'undefined', 'Result should be defined');
|
|
|
|
console.log('✅ detectIntendedMode: Function executed successfully');
|
|
|
|
} catch (error) {
|
|
console.error('❌ detectIntendedMode: Function failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('if - Basic Function', () => {
|
|
const input = undefined;
|
|
|
|
try {
|
|
const result = ModeManager.if(input);
|
|
|
|
// Validations de base
|
|
assert.ok(result !== undefined, 'Should return a result');
|
|
assert.ok(typeof result !== 'undefined', 'Result should be defined');
|
|
|
|
console.log('✅ if: Function executed successfully');
|
|
|
|
} catch (error) {
|
|
console.error('❌ if: Function failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('switchToMode - Async Operation', async () => {
|
|
const input = undefined;
|
|
|
|
try {
|
|
const startTime = Date.now();
|
|
const result = await ModeManager.switchToMode(input);
|
|
const duration = Date.now() - startTime;
|
|
|
|
// Validations de base
|
|
assert.ok(result !== undefined, 'Should return a result');
|
|
assert.ok(duration < 30000, 'Should complete within 30 seconds');
|
|
|
|
console.log(`✅ switchToMode: Completed in ${duration}ms`);
|
|
|
|
} catch (error) {
|
|
console.error('❌ switchToMode: Async operation failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('canSwitchToMode - Async Operation', async () => {
|
|
const input = undefined;
|
|
|
|
try {
|
|
const startTime = Date.now();
|
|
const result = await ModeManager.canSwitchToMode(input);
|
|
const duration = Date.now() - startTime;
|
|
|
|
// Validations de base
|
|
assert.ok(result !== undefined, 'Should return a result');
|
|
assert.ok(duration < 30000, 'Should complete within 30 seconds');
|
|
|
|
console.log(`✅ canSwitchToMode: Completed in ${duration}ms`);
|
|
|
|
} catch (error) {
|
|
console.error('❌ canSwitchToMode: Async operation failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('switch - Basic Function', () => {
|
|
const input = undefined;
|
|
|
|
try {
|
|
const result = ModeManager.switch(input);
|
|
|
|
// Validations de base
|
|
assert.ok(result !== undefined, 'Should return a result');
|
|
assert.ok(typeof result !== 'undefined', 'Result should be defined');
|
|
|
|
console.log('✅ switch: Function executed successfully');
|
|
|
|
} catch (error) {
|
|
console.error('❌ switch: Function failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('canSwitchToManual - Async Operation', async () => {
|
|
const input = undefined;
|
|
|
|
try {
|
|
const startTime = Date.now();
|
|
const result = await ModeManager.canSwitchToManual(input);
|
|
const duration = Date.now() - startTime;
|
|
|
|
// Validations de base
|
|
assert.ok(result !== undefined, 'Should return a result');
|
|
assert.ok(duration < 30000, 'Should complete within 30 seconds');
|
|
|
|
console.log(`✅ canSwitchToManual: Completed in ${duration}ms`);
|
|
|
|
} catch (error) {
|
|
console.error('❌ canSwitchToManual: Async operation failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('canSwitchToAuto - Async Operation', async () => {
|
|
const input = undefined;
|
|
|
|
try {
|
|
const startTime = Date.now();
|
|
const result = await ModeManager.canSwitchToAuto(input);
|
|
const duration = Date.now() - startTime;
|
|
|
|
// Validations de base
|
|
assert.ok(result !== undefined, 'Should return a result');
|
|
assert.ok(duration < 30000, 'Should complete within 30 seconds');
|
|
|
|
console.log(`✅ canSwitchToAuto: Completed in ${duration}ms`);
|
|
|
|
} catch (error) {
|
|
console.error('❌ canSwitchToAuto: Async operation failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('startMode - Async Operation', async () => {
|
|
const input = undefined;
|
|
|
|
try {
|
|
const startTime = Date.now();
|
|
const result = await ModeManager.startMode(input);
|
|
const duration = Date.now() - startTime;
|
|
|
|
// Validations de base
|
|
assert.ok(result !== undefined, 'Should return a result');
|
|
assert.ok(duration < 30000, 'Should complete within 30 seconds');
|
|
|
|
console.log(`✅ startMode: Completed in ${duration}ms`);
|
|
|
|
} catch (error) {
|
|
console.error('❌ startMode: Async operation failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('startManualMode - Async Operation', async () => {
|
|
const input = undefined;
|
|
|
|
try {
|
|
const startTime = Date.now();
|
|
const result = await ModeManager.startManualMode(input);
|
|
const duration = Date.now() - startTime;
|
|
|
|
// Validations de base
|
|
assert.ok(result !== undefined, 'Should return a result');
|
|
assert.ok(duration < 30000, 'Should complete within 30 seconds');
|
|
|
|
console.log(`✅ startManualMode: Completed in ${duration}ms`);
|
|
|
|
} catch (error) {
|
|
console.error('❌ startManualMode: Async operation failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('startAutoMode - Async Operation', async () => {
|
|
const input = undefined;
|
|
|
|
try {
|
|
const startTime = Date.now();
|
|
const result = await ModeManager.startAutoMode(input);
|
|
const duration = Date.now() - startTime;
|
|
|
|
// Validations de base
|
|
assert.ok(result !== undefined, 'Should return a result');
|
|
assert.ok(duration < 30000, 'Should complete within 30 seconds');
|
|
|
|
console.log(`✅ startAutoMode: Completed in ${duration}ms`);
|
|
|
|
} catch (error) {
|
|
console.error('❌ startAutoMode: Async operation failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('stopCurrentMode - Async Operation', async () => {
|
|
const input = undefined;
|
|
|
|
try {
|
|
const startTime = Date.now();
|
|
const result = await ModeManager.stopCurrentMode(input);
|
|
const duration = Date.now() - startTime;
|
|
|
|
// Validations de base
|
|
assert.ok(result !== undefined, 'Should return a result');
|
|
assert.ok(duration < 30000, 'Should complete within 30 seconds');
|
|
|
|
console.log(`✅ stopCurrentMode: Completed in ${duration}ms`);
|
|
|
|
} catch (error) {
|
|
console.error('❌ stopCurrentMode: Async operation failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('stopManualMode - Async Operation', async () => {
|
|
const input = undefined;
|
|
|
|
try {
|
|
const startTime = Date.now();
|
|
const result = await ModeManager.stopManualMode(input);
|
|
const duration = Date.now() - startTime;
|
|
|
|
// Validations de base
|
|
assert.ok(result !== undefined, 'Should return a result');
|
|
assert.ok(duration < 30000, 'Should complete within 30 seconds');
|
|
|
|
console.log(`✅ stopManualMode: Completed in ${duration}ms`);
|
|
|
|
} catch (error) {
|
|
console.error('❌ stopManualMode: Async operation failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('stopAutoMode - Async Operation', async () => {
|
|
const input = undefined;
|
|
|
|
try {
|
|
const startTime = Date.now();
|
|
const result = await ModeManager.stopAutoMode(input);
|
|
const duration = Date.now() - startTime;
|
|
|
|
// Validations de base
|
|
assert.ok(result !== undefined, 'Should return a result');
|
|
assert.ok(duration < 30000, 'Should complete within 30 seconds');
|
|
|
|
console.log(`✅ stopAutoMode: Completed in ${duration}ms`);
|
|
|
|
} catch (error) {
|
|
console.error('❌ stopAutoMode: Async operation failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('getStatus - Basic Function', () => {
|
|
const input = undefined;
|
|
|
|
try {
|
|
const result = ModeManager.getStatus(input);
|
|
|
|
// Validations de base
|
|
assert.ok(result !== undefined, 'Should return a result');
|
|
assert.ok(typeof result !== 'undefined', 'Result should be defined');
|
|
|
|
console.log('✅ getStatus: Function executed successfully');
|
|
|
|
} catch (error) {
|
|
console.error('❌ getStatus: Function failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('isManualMode - Basic Function', () => {
|
|
const input = undefined;
|
|
|
|
try {
|
|
const result = ModeManager.isManualMode(input);
|
|
|
|
// Validations de base
|
|
assert.ok(result !== undefined, 'Should return a result');
|
|
assert.ok(typeof result !== 'undefined', 'Result should be defined');
|
|
|
|
console.log('✅ isManualMode: Function executed successfully');
|
|
|
|
} catch (error) {
|
|
console.error('❌ isManualMode: Function failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('isAutoMode - Basic Function', () => {
|
|
const input = undefined;
|
|
|
|
try {
|
|
const result = ModeManager.isAutoMode(input);
|
|
|
|
// Validations de base
|
|
assert.ok(result !== undefined, 'Should return a result');
|
|
assert.ok(typeof result !== 'undefined', 'Result should be defined');
|
|
|
|
console.log('✅ isAutoMode: Function executed successfully');
|
|
|
|
} catch (error) {
|
|
console.error('❌ isAutoMode: Function failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('lockMode - Basic Function', () => {
|
|
const input = undefined;
|
|
|
|
try {
|
|
const result = ModeManager.lockMode(input);
|
|
|
|
// Validations de base
|
|
assert.ok(result !== undefined, 'Should return a result');
|
|
assert.ok(typeof result !== 'undefined', 'Result should be defined');
|
|
|
|
console.log('✅ lockMode: Function executed successfully');
|
|
|
|
} catch (error) {
|
|
console.error('❌ lockMode: Function failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('unlockMode - Basic Function', () => {
|
|
const input = undefined;
|
|
|
|
try {
|
|
const result = ModeManager.unlockMode(input);
|
|
|
|
// Validations de base
|
|
assert.ok(result !== undefined, 'Should return a result');
|
|
assert.ok(typeof result !== 'undefined', 'Result should be defined');
|
|
|
|
console.log('✅ unlockMode: Function executed successfully');
|
|
|
|
} catch (error) {
|
|
console.error('❌ unlockMode: Function failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('cleanupPreviousState - Async Operation', async () => {
|
|
const input = undefined;
|
|
|
|
try {
|
|
const startTime = Date.now();
|
|
const result = await ModeManager.cleanupPreviousState(input);
|
|
const duration = Date.now() - startTime;
|
|
|
|
// Validations de base
|
|
assert.ok(result !== undefined, 'Should return a result');
|
|
assert.ok(duration < 30000, 'Should complete within 30 seconds');
|
|
|
|
console.log(`✅ cleanupPreviousState: Completed in ${duration}ms`);
|
|
|
|
} catch (error) {
|
|
console.error('❌ cleanupPreviousState: Async operation failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('emergencyRecovery - Async Operation', async () => {
|
|
const input = undefined;
|
|
|
|
try {
|
|
const startTime = Date.now();
|
|
const result = await ModeManager.emergencyRecovery(input);
|
|
const duration = Date.now() - startTime;
|
|
|
|
// Validations de base
|
|
assert.ok(result !== undefined, 'Should return a result');
|
|
assert.ok(duration < 30000, 'Should complete within 30 seconds');
|
|
|
|
console.log(`✅ emergencyRecovery: Completed in ${duration}ms`);
|
|
|
|
} catch (error) {
|
|
console.error('❌ emergencyRecovery: Async operation failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('forceStopAllServices - Async Operation', async () => {
|
|
const input = undefined;
|
|
|
|
try {
|
|
const startTime = Date.now();
|
|
const result = await ModeManager.forceStopAllServices(input);
|
|
const duration = Date.now() - startTime;
|
|
|
|
// Validations de base
|
|
assert.ok(result !== undefined, 'Should return a result');
|
|
assert.ok(duration < 30000, 'Should complete within 30 seconds');
|
|
|
|
console.log(`✅ forceStopAllServices: Completed in ${duration}ms`);
|
|
|
|
} catch (error) {
|
|
console.error('❌ forceStopAllServices: Async operation failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('for - Basic Function', () => {
|
|
const input = undefined;
|
|
|
|
try {
|
|
const result = ModeManager.for(input);
|
|
|
|
// Validations de base
|
|
assert.ok(result !== undefined, 'Should return a result');
|
|
assert.ok(typeof result !== 'undefined', 'Result should be defined');
|
|
|
|
console.log('✅ for: Function executed successfully');
|
|
|
|
} catch (error) {
|
|
console.error('❌ for: Function failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('saveModeState - Basic Function', () => {
|
|
const input = undefined;
|
|
|
|
try {
|
|
const result = ModeManager.saveModeState(input);
|
|
|
|
// Validations de base
|
|
assert.ok(result !== undefined, 'Should return a result');
|
|
assert.ok(typeof result !== 'undefined', 'Result should be defined');
|
|
|
|
console.log('✅ saveModeState: Function executed successfully');
|
|
|
|
} catch (error) {
|
|
console.error('❌ saveModeState: Function failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('loadModeState - Basic Function', () => {
|
|
const input = undefined;
|
|
|
|
try {
|
|
const result = ModeManager.loadModeState(input);
|
|
|
|
// Validations de base
|
|
assert.ok(result !== undefined, 'Should return a result');
|
|
assert.ok(typeof result !== 'undefined', 'Result should be defined');
|
|
|
|
console.log('✅ loadModeState: Function executed successfully');
|
|
|
|
} catch (error) {
|
|
console.error('❌ loadModeState: Function failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('Export - ModeManager', () => {
|
|
assert.ok(ModeManager.ModeManager !== undefined, 'Export ModeManager should be available');
|
|
console.log('✅ Export ModeManager: Available');
|
|
});
|
|
|
|
|
|
// Test d'intégration général
|
|
test('Integration - Module health check', async () => {
|
|
try {
|
|
// Vérification exports
|
|
const exports = Object.keys(ModeManager);
|
|
assert.ok(exports.length > 0, 'Module should export functions');
|
|
|
|
console.log(`✅ ModeManager: ${exports.length} exports available`);
|
|
console.log('📋 Exports:', exports.join(', '));
|
|
|
|
} catch (error) {
|
|
console.error('❌ Integration test failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
}); |