fix security
Some checks are pending
Build Android App (Capacitor) / Build Android APK (push) Waiting to run
Some checks are pending
Build Android App (Capacitor) / Build Android APK (push) Waiting to run
This commit is contained in:
102
chat/src/test/run-all-tests.js
Normal file
102
chat/src/test/run-all-tests.js
Normal file
@@ -0,0 +1,102 @@
|
||||
/**
|
||||
* Comprehensive Test Suite Runner
|
||||
* Runs all tests for the Chat Application
|
||||
*
|
||||
* Usage: node src/test/run-all-tests.js
|
||||
*/
|
||||
|
||||
const { execSync } = require('child_process');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
console.log('╔════════════════════════════════════════════════════════╗');
|
||||
console.log('║ COMPREHENSIVE CHAT APPLICATION TEST SUITE ║');
|
||||
console.log('╚════════════════════════════════════════════════════════╝\n');
|
||||
|
||||
const testFiles = [
|
||||
'encryption.test.js',
|
||||
'userRepository.test.js',
|
||||
'sessionRepository.test.js',
|
||||
'authentication.test.js',
|
||||
'accountManagement.test.js',
|
||||
'payments.test.js',
|
||||
'modelRouting.test.js',
|
||||
'security.test.js'
|
||||
];
|
||||
|
||||
const results = {
|
||||
passed: [],
|
||||
failed: [],
|
||||
skipped: []
|
||||
};
|
||||
|
||||
function runTest(testFile) {
|
||||
const testPath = path.join(__dirname, testFile);
|
||||
|
||||
console.log(`\n${'─'.repeat(60)}`);
|
||||
console.log(`Running: ${testFile}`);
|
||||
console.log(`${'─'.repeat(60)}`);
|
||||
|
||||
try {
|
||||
const output = execSync(`node "${testPath}"`, {
|
||||
encoding: 'utf8',
|
||||
timeout: 30000,
|
||||
stdio: 'pipe'
|
||||
});
|
||||
|
||||
console.log(output);
|
||||
results.passed.push(testFile);
|
||||
return true;
|
||||
} catch (error) {
|
||||
console.log(error.stdout || error.message);
|
||||
results.failed.push({ file: testFile, error: error.message });
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function printSummary() {
|
||||
console.log('\n' + '═'.repeat(60));
|
||||
console.log(' TEST SUMMARY');
|
||||
console.log('═'.repeat(60));
|
||||
|
||||
console.log(`\n✓ Passed: ${results.passed.length} test files`);
|
||||
results.passed.forEach(file => {
|
||||
console.log(` ✓ ${file}`);
|
||||
});
|
||||
|
||||
if (results.failed.length > 0) {
|
||||
console.log(`\n✗ Failed: ${results.failed.length} test files`);
|
||||
results.failed.forEach(({ file, error }) => {
|
||||
console.log(` ✗ ${file}`);
|
||||
});
|
||||
}
|
||||
|
||||
if (results.skipped.length > 0) {
|
||||
console.log(`\n⊘ Skipped: ${results.skipped.length} test files`);
|
||||
results.skipped.forEach(file => {
|
||||
console.log(` ⊘ ${file}`);
|
||||
});
|
||||
}
|
||||
|
||||
console.log('\n' + '═'.repeat(60));
|
||||
console.log(`Total: ${testFiles.length} test files`);
|
||||
console.log(`Success Rate: ${Math.round((results.passed.length / testFiles.length) * 100)}%`);
|
||||
console.log('═'.repeat(60));
|
||||
|
||||
if (results.failed.length === 0) {
|
||||
console.log('\n🎉 All tests passed! 🎉\n');
|
||||
process.exit(0);
|
||||
} else {
|
||||
console.log('\n⚠️ Some tests failed. Please review the output above.\n');
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
// Run all tests
|
||||
console.log(`Running ${testFiles.length} test files...\n`);
|
||||
|
||||
for (const testFile of testFiles) {
|
||||
runTest(testFile);
|
||||
}
|
||||
|
||||
printSummary();
|
||||
Reference in New Issue
Block a user