/** * 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 = ` QA Automation Test Plan Report

QA Automation Test Plan Report

Generated from Test Case Editor • ${new Date().toISOString().slice(0,10)}

${total} test cases • ${autoPct}% automated
TOTAL TESTS
${total}
AUTOMATED
${automated}
${autoPct}%
PARTIAL
${partial}
${partialPct}%
MANUAL
${manual}
${manualPct}%
TEST CASES
${tests.map((t, i) => ` `).join('')}
# ID Group Status Description
${i+1} ${t.id} ${t.group} ${t.status} ${t.description}
Generated by Autotest • Data source: YAML under testcases/ (legacy JSON during transition)
`; // Ensure output directory exists if (!fs.existsSync(OUTPUT_DIR)) { fs.mkdirSync(OUTPUT_DIR, { recursive: true }); } // Generate timestamped filename const now = new Date(); const timestamp = now.toISOString().slice(0, 19).replace(/:/g, '-').replace('T', '_'); const finalFilename = `${timestamp}_qa_automation.html`; const finalPath = path.join(OUTPUT_DIR, finalFilename); fs.writeFileSync(finalPath, html); console.log(`✅ Automation report generated: ${finalPath}`); console.log(` ${total} tests | ${automated} automated (${autoPct}%)`); return finalPath; } if (require.main === module) { generateReport(); } module.exports = { generateReport };