arreglos de grok

This commit is contained in:
2026-05-22 13:25:01 +02:00
parent 2ebd8fb16b
commit 8f7f14c95b
641 changed files with 78143 additions and 941 deletions
+150
View File
@@ -0,0 +1,150 @@
/**
* 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, '..', 'data', 'testcases.json');
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 = `<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>QA Automation Test Plan Report</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<style>
body { background: #0b1120; color: #e2e8f0; font-family: system-ui, -apple-system, sans-serif; }
.card { background: #1e2937; border: 1px solid #334155; }
.status-automated { background:#052e16; color:#4ade80; }
.status-partial { background:#451a03; color:#fbbf24; }
.status-manual { background:#450a0a; color:#f87171; }
</style>
</head>
<body class="text-sm">
<div class="max-w-[1500px] mx-auto p-8">
<div class="flex justify-between items-end mb-8">
<div>
<h1 class="text-3xl font-bold">QA Automation Test Plan Report</h1>
<p class="text-[#64748b]">Generated from Test Case Editor • ${new Date().toISOString().slice(0,10)}</p>
</div>
<div class="text-right text-xs text-[#64748b]">
${total} test cases • ${autoPct}% automated
</div>
</div>
<!-- Summary Cards -->
<div class="grid grid-cols-4 gap-4 mb-8">
<div class="card p-5 rounded-2xl">
<div class="text-[#64748b] text-xs">TOTAL TESTS</div>
<div class="text-5xl font-bold mt-1">${total}</div>
</div>
<div class="card p-5 rounded-2xl border-l-4 border-emerald-500">
<div class="text-emerald-400 text-xs">AUTOMATED</div>
<div class="text-5xl font-bold text-emerald-400 mt-1">${automated}</div>
<div class="text-xs mt-1">${autoPct}%</div>
</div>
<div class="card p-5 rounded-2xl border-l-4 border-amber-500">
<div class="text-amber-400 text-xs">PARTIAL</div>
<div class="text-5xl font-bold text-amber-400 mt-1">${partial}</div>
<div class="text-xs mt-1">${partialPct}%</div>
</div>
<div class="card p-5 rounded-2xl border-l-4 border-red-500">
<div class="text-red-400 text-xs">MANUAL</div>
<div class="text-5xl font-bold text-red-400 mt-1">${manual}</div>
<div class="text-xs mt-1">${manualPct}%</div>
</div>
</div>
<div class="mb-4 text-[#64748b] text-xs font-semibold">TEST CASES</div>
<div class="card rounded-2xl overflow-hidden">
<table class="w-full">
<thead class="bg-[#0f172a] text-[#64748b] text-xs">
<tr>
<th class="px-4 py-3 text-left">#</th>
<th class="px-4 py-3 text-left">ID</th>
<th class="px-4 py-3 text-left">Group</th>
<th class="px-4 py-3">Status</th>
<th class="px-4 py-3 text-left">Description</th>
</tr>
</thead>
<tbody class="divide-y divide-[#334155]">
${tests.map((t, i) => `
<tr class="hover:bg-[#162032]">
<td class="px-4 py-3 text-[#64748b]">${i+1}</td>
<td class="px-4 py-3 font-mono text-xs">${t.id}</td>
<td class="px-4 py-3">${t.group}</td>
<td class="px-4 py-3">
<span class="px-3 py-0.5 rounded-full text-xs font-semibold status-${t.status}">${t.status}</span>
</td>
<td class="px-4 py-3 text-[#cbd5e1]">${t.description}</td>
</tr>
`).join('')}
</tbody>
</table>
</div>
<div class="mt-8 text-center text-xs text-[#64748b]">
Generated by Test Case Editor • Data source: editor/data/testcases.json
</div>
</div>
</body>
</html>`;
// 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 };
+150
View File
@@ -0,0 +1,150 @@
/**
* generate-test-plan.js
* Generates a self-contained, fully inline-styled HTML Test Plan
* for manual execution by testers.
*
* Output: editor/output/testplans/YYYY-MM-DD_HH-MM-SS_{baseName}.html
*/
const fs = require('fs');
const path = require('path');
const OUTPUT_DIR = path.join(__dirname, '..', 'output', 'testplans');
function generateTestPlan(selectedTests, baseName = 'Manual-Test-Plan') {
if (!Array.isArray(selectedTests) || selectedTests.length === 0) {
throw new Error('No test cases selected for the Test Plan');
}
// 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 safeBase = baseName.replace(/[^a-zA-Z0-9-_]/g, '').slice(0, 60) || 'Manual-Test-Plan';
const filename = `${timestamp}_${safeBase}.html`;
const finalPath = path.join(OUTPUT_DIR, filename);
// Group tests by group
const grouped = {};
selectedTests.forEach(test => {
const g = test.group || 'Other';
if (!grouped[g]) grouped[g] = [];
grouped[g].push(test);
});
const groups = Object.keys(grouped).sort();
// Build HTML
const html = `<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Manual Test Plan - ${safeBase}</title>
<style>
body { font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 1.45; color: #222; margin: 20px; background: #fff; }
h1 { font-size: 22px; margin-bottom: 4px; }
h2 { font-size: 16px; margin-top: 24px; margin-bottom: 8px; border-bottom: 2px solid #333; padding-bottom: 4px; }
table { width: 100%; border-collapse: collapse; margin-bottom: 16px; }
th, td { border: 1px solid #999; padding: 6px 8px; vertical-align: top; }
th { background: #f0f0f0; text-align: left; font-weight: 600; }
.meta { margin-bottom: 16px; color: #555; }
.test-id { font-family: monospace; font-weight: 600; }
.steps { margin: 4px 0; padding-left: 18px; }
.field-label { font-weight: 600; font-size: 11px; color: #444; margin-top: 6px; }
textarea, select { width: 100%; box-sizing: border-box; font-size: 12px; }
textarea { min-height: 50px; }
.header { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 12px; }
.generated { font-size: 11px; color: #666; }
</style>
</head>
<body>
<div class="header">
<div>
<h1>Manual Test Plan</h1>
<div class="meta"><strong>${safeBase}</strong> — Generated on ${now.toLocaleString()}</div>
</div>
<div class="generated">Total cases: ${selectedTests.length}</div>
</div>
<table>
<tr>
<th style="width: 18%;">Test ID</th>
<th style="width: 28%;">Description &amp; Expected Result</th>
<th style="width: 22%;">Steps</th>
<th style="width: 12%;">Severity</th>
<th style="width: 20%;">Result / Comments</th>
</tr>
${groups.map(group => `
<tr>
<td colspan="5" style="background:#e8e8e8; font-weight:700; padding:8px 10px;">${group}</td>
</tr>
${grouped[group].map(test => {
const expected = test.description || '';
const stepsHtml = (test.steps || []).map((s, i) => `<li>${escapeHtml(s)}</li>`).join('');
const depsHtml = (test.dependencies || []).map(d => `<div>${escapeHtml(d.label)}: ${escapeHtml(d.value)}</div>`).join('');
return `
<tr>
<td class="test-id">${escapeHtml(test.id)}</td>
<td>
<strong>${escapeHtml(test.description || '')}</strong>
<div class="field-label">Expected Result</div>
<textarea>${escapeHtml(expected)}</textarea>
</td>
<td>
<ol class="steps">${stepsHtml}</ol>
${depsHtml ? `<div class="field-label">Dependencies</div><div style="font-size:11px;">${depsHtml}</div>` : ''}
</td>
<td>
<select>
<option>Low</option>
<option>Medium</option>
<option selected>High</option>
<option>Critical</option>
</select>
</td>
<td>
<div class="field-label">Status</div>
<select>
<option>Pass</option>
<option>Fail</option>
<option>Blocked</option>
<option selected>N/A</option>
</select>
<div class="field-label" style="margin-top:8px;">Actual Result / Comments</div>
<textarea></textarea>
</td>
</tr>`;
}).join('')}
`).join('')}
</table>
<p style="font-size:11px; color:#666; margin-top:30px;">
Generated by QA Automation Test Plan Editor • All results and comments should be filled by the tester.
</p>
</body>
</html>`;
fs.writeFileSync(finalPath, html);
console.log(`✅ Manual Test Plan generated: ${finalPath}`);
return finalPath;
}
function escapeHtml(str) {
if (!str) return '';
return String(str)
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;');
}
module.exports = { generateTestPlan };