update-dependencies.test.js
1 import { test } from 'node:test'; 2 import assert from 'node:assert'; 3 import { execSync } from 'child_process'; 4 import fs from 'fs'; 5 import path from 'path'; 6 import { fileURLToPath } from 'url'; 7 8 const __filename = fileURLToPath(import.meta.url); 9 const __dirname = path.dirname(__filename); 10 11 const NODE = process.execPath; // Always use the current node binary (v22) 12 13 test('update-dependencies.js --dry-run should run without errors', () => { 14 const result = execSync(`${NODE} scripts/update-dependencies.js --dry-run`, { 15 encoding: 'utf8', 16 cwd: path.join(__dirname, '../..'), 17 }); 18 19 assert.ok(result.includes('Automated Dependency Updater')); 20 assert.ok(result.includes('Dry run')); 21 }); 22 23 test('update-dependencies.js should check npm outdated', () => { 24 const result = execSync(`${NODE} scripts/update-dependencies.js --dry-run --verbose`, { 25 encoding: 'utf8', 26 cwd: path.join(__dirname, '../..'), 27 }); 28 29 assert.ok( 30 result.includes('Checking for outdated packages') || 31 result.includes('All dependencies are up to date') 32 ); 33 }); 34 35 test('deep-code-analysis.js should generate a report', () => { 36 const reportDir = path.join(__dirname, '../..', '.analysis-reports'); 37 38 // Run analysis with isolated DB to avoid lock conflicts with parallel tests 39 execSync(`${NODE} scripts/deep-code-analysis.js`, { 40 encoding: 'utf8', 41 cwd: path.join(__dirname, '../..'), 42 stdio: 'ignore', 43 env: { ...process.env, DATABASE_PATH: '/tmp/deep-analysis-test.db' }, 44 }); 45 46 // Check report was created 47 assert.ok(fs.existsSync(reportDir)); 48 49 const reportFiles = fs.readdirSync(reportDir).filter(f => f.startsWith('deep-analysis-')); 50 51 assert.ok(reportFiles.length > 0, 'Analysis report should be generated'); 52 53 // Verify report content 54 const reportPath = path.join(reportDir, reportFiles[0]); 55 const reportContent = fs.readFileSync(reportPath, 'utf8'); 56 57 assert.ok(reportContent.includes('Deep Code Analysis Report')); 58 assert.ok(reportContent.includes('TODO.md Review')); 59 assert.ok(reportContent.includes('Security Vulnerability Scan')); 60 }); 61 62 test('doc-code-check.js should generate a report', () => { 63 const reportDir = path.join(__dirname, '../..', '.analysis-reports'); 64 65 // Run check with isolated DB to avoid lock conflicts with parallel tests 66 execSync(`${NODE} scripts/doc-code-check.js`, { 67 encoding: 'utf8', 68 cwd: path.join(__dirname, '../..'), 69 stdio: 'ignore', 70 env: { ...process.env, DATABASE_PATH: '/tmp/doc-check-test.db' }, 71 }); 72 73 // Check report was created 74 assert.ok(fs.existsSync(reportDir)); 75 76 const reportFiles = fs.readdirSync(reportDir).filter(f => f.startsWith('doc-check-')); 77 78 assert.ok(reportFiles.length > 0, 'Documentation check report should be generated'); 79 80 // Verify report content 81 const reportPath = path.join(reportDir, reportFiles[0]); 82 const reportContent = fs.readFileSync(reportPath, 'utf8'); 83 84 assert.ok(reportContent.includes('Documentation/Code Consistency Report')); 85 assert.ok(reportContent.includes('NPM Scripts Documentation')); 86 assert.ok(reportContent.includes('Environment Variables Documentation')); 87 });