cambios profundos con grok

This commit is contained in:
2026-05-26 00:42:42 +02:00
parent ee8cfa03ea
commit 19ea13dadd
99 changed files with 1447 additions and 2597 deletions
+59 -4
View File
@@ -38,8 +38,17 @@ app.post('/api/testcases', (req, res) => {
// Primary: persist to YAML tree
saveTestcases(testcases);
// Transition: still write the legacy JSON so other tools don't break yet
fs.writeFileSync(DATA_FILE, JSON.stringify(testcases, null, 2), 'utf8');
// Transition: still write the legacy JSON so other tools don't break yet (best effort)
try {
const legacyDir = path.dirname(DATA_FILE);
if (!fs.existsSync(legacyDir)) {
fs.mkdirSync(legacyDir, { recursive: true });
}
fs.writeFileSync(DATA_FILE, JSON.stringify(testcases, null, 2), 'utf8');
} catch (legacyErr) {
console.warn('Warning: Could not write legacy JSON file:', legacyErr.message);
// Continue anyway - YAML is the source of truth now
}
res.json({ success: true, count: testcases.length, source: 'yaml+json' });
} catch (e) {
@@ -81,7 +90,7 @@ app.get('/api/export/report', (req, res) => {
// Simple summary HTML (lightweight)
app.get('/api/export/summary', (req, res) => {
try {
const tests = JSON.parse(fs.readFileSync(DATA_FILE, 'utf8'));
const tests = loadTestcases();
const total = tests.length;
const automated = tests.filter(t => t.status === 'automated').length;
const autoPct = ((automated / total) * 100).toFixed(1);
@@ -113,6 +122,29 @@ const PLANS_DIR = path.join(__dirname, '..', 'output', 'testplans', 'plans');
// Ensure plans dir
if (!fs.existsSync(PLANS_DIR)) fs.mkdirSync(PLANS_DIR, { recursive: true });
function computeAutomationSummary(tests) {
const total = tests.length;
let automated = 0, partial = 0, manual = 0;
tests.forEach(t => {
const status = t.automation_status || t.status || 'manual';
if (status === 'automated') automated++;
else if (status === 'partial') partial++;
else manual++;
});
const automatable = automated + partial;
const automatable_percentage = total > 0 ? Math.round((automatable / total) * 100 * 10) / 10 : 0;
return {
total,
automated,
partial,
manual,
automatable_percentage
};
}
function getPlanPath(planId) {
return path.join(PLANS_DIR, `${planId}.json`);
}
@@ -126,7 +158,8 @@ app.post('/api/test-plans', (req, res) => {
return res.status(400).json({ error: 'No test IDs provided' });
}
const allTests = JSON.parse(fs.readFileSync(DATA_FILE, 'utf8'));
// Use the proper loader instead of the broken legacy JSON file
const allTests = loadTestcases();
const selectedTests = allTests.filter(t => ids.includes(t.id));
if (selectedTests.length === 0) {
@@ -151,6 +184,8 @@ app.post('/api/test-plans', (req, res) => {
}))
};
plan.automation_summary = computeAutomationSummary(plan.tests);
fs.writeFileSync(getPlanPath(planId), JSON.stringify(plan, null, 2));
res.json({ success: true, planId, name: plan.name });
@@ -166,6 +201,9 @@ app.get('/api/test-plans/:id', (req, res) => {
if (!fs.existsSync(planPath)) return res.status(404).json({ error: 'Plan not found' });
const plan = JSON.parse(fs.readFileSync(planPath, 'utf8'));
if (!plan.automation_summary && plan.tests) {
plan.automation_summary = computeAutomationSummary(plan.tests);
}
res.json(plan);
} catch (e) {
res.status(500).json({ error: 'Error loading plan' });
@@ -185,6 +223,8 @@ app.post('/api/test-plans/:id', (req, res) => {
updatedAt: new Date().toISOString()
};
updated.automation_summary = computeAutomationSummary(updated.tests || []);
fs.writeFileSync(planPath, JSON.stringify(updated, null, 2));
res.json({ success: true });
} catch (e) {
@@ -192,6 +232,21 @@ app.post('/api/test-plans/:id', (req, res) => {
}
});
// Delete a plan
app.delete('/api/test-plans/:id', (req, res) => {
try {
const planPath = getPlanPath(req.params.id);
if (!fs.existsSync(planPath)) {
return res.status(404).json({ error: 'Plan not found' });
}
fs.unlinkSync(planPath);
res.json({ success: true });
} catch (e) {
res.status(500).json({ error: 'Failed to delete plan' });
}
});
// List all plans (for future tester portal)
app.get('/api/test-plans', (req, res) => {
try {