/** * generate-report.js * Generates the automation analysis report (qa_automation.html) with timestamp. * Output location: editor/output/reports/ */ const fs = require('fs'); const path = require('path'); const DATA_FILE = path.join(__dirname, '..', '..', 'legacy', 'data', 'testcases.json'); // legacy JSON (for export scripts) const OUTPUT_DIR = path.join(__dirname, '..', '..', 'output', 'reports'); function generateReport() { const tests = JSON.parse(fs.readFileSync(DATA_FILE, 'utf8')); // Calculate statistics const total = tests.length; const automated = tests.filter(t => t.status === 'automated').length; const partial = tests.filter(t => t.status === 'partial').length; const manual = tests.filter(t => t.status === 'manual').length; const autoPct = total > 0 ? ((automated / total) * 100).toFixed(1) : 0; const partialPct = total > 0 ? ((partial / total) * 100).toFixed(1) : 0; const manualPct = total > 0 ? ((manual / total) * 100).toFixed(1) : 0; // Group counts for the bar chart const groups = [...new Set(tests.map(t => t.group))].sort(); const groupStats = {}; groups.forEach(g => { groupStats[g] = { automated: tests.filter(t => t.group === g && t.status === 'automated').length, partial: tests.filter(t => t.group === g && t.status === 'partial').length, manual: tests.filter(t => t.group === g && t.status === 'manual').length }; }); // Embed data const embeddedData = JSON.stringify(tests); const html = `
Generated from Test Case Editor • ${new Date().toISOString().slice(0,10)}
| # | ID | Group | Status | Description |
|---|---|---|---|---|
| ${i+1} | ${t.id} | ${t.group} | ${t.status} | ${t.description} |