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
+21 -25
View File
@@ -2,7 +2,7 @@
* save-testcases.js
*
* Writes an array of legacy-shaped testcases back to the individual YAML files.
* Tries to preserve existing per-step automation flags and custom data.
* Steps are kept simple (action + expected + optional notes). Automation decision lives at testcase level.
*
* This is part of the transition so that the editor can save directly to YAML.
*/
@@ -14,52 +14,43 @@ const yaml = require('js-yaml');
const TESTCASES_ROOT = path.join(__dirname, '..', '..', 'testcases');
function getYamlPath(legacyTest) {
const project = 'pbx'; // transition: all current data lives under pbx project
const module = legacyTest.module || 'unknown';
const top = legacyTest.module || 'unknown'; // core or pbx (top level per new structure)
const rawGroup = legacyTest.group || 'unknown';
const group = rawGroup.replace(/^core-|^pbx-/, '');
return path.join(TESTCASES_ROOT, project, module, group, `${legacyTest.id}.yaml`);
return path.join(TESTCASES_ROOT, top, group, `${legacyTest.id}.yaml`);
}
function buildCanonicalDoc(legacy, existing = {}) {
const cf = legacy.custom_fields || existing.custom_fields || {};
// Support rich steps from new per-step editor (Fase B+)
// Steps are now simple: action + expected + optional notes (no per-step automation flags)
let steps = [];
const incomingSteps = legacy.steps || [];
if (incomingSteps.length > 0 && typeof incomingSteps[0] === 'object' && incomingSteps[0] !== null) {
// Rich steps sent from frontend
steps = incomingSteps.map(s => ({
action: s.action || '',
expected: s.expected || '',
automatable: s.automatable !== undefined ? !!s.automatable : (legacy.status !== 'manual'),
...(s.reason_not_automatable ? { reason_not_automatable: s.reason_not_automatable } : {})
}));
steps = incomingSteps.map(s => {
const step = {
action: s.action || '',
expected: s.expected || '',
};
if (s.notes) step.notes = s.notes;
return step;
});
} else {
// Legacy flat strings
steps = incomingSteps.map((action, i) => {
const prev = (existing.steps && existing.steps[i]) || {};
return {
const step = {
action: action,
expected: prev.expected || '',
automatable: prev.automatable !== undefined ? prev.automatable : (legacy.status !== 'manual'),
...(prev.reason_not_automatable ? { reason_not_automatable: prev.reason_not_automatable } : {})
};
if (prev.notes) step.notes = prev.notes;
return step;
});
}
// If existing had more detailed steps, prefer their automatable flags
if (existing.steps && existing.steps.length === steps.length) {
steps = existing.steps.map((prev, i) => ({
...prev,
action: steps[i].action
}));
}
const doc = {
id: legacy.id,
project: 'pbx',
module: legacy.module,
group: legacy.group,
title: legacy.description || legacy.title,
@@ -72,6 +63,7 @@ function buildCanonicalDoc(legacy, existing = {}) {
postconditions: existing.postconditions || [],
steps,
automation_status: legacy.status,
reason_not_automatable: legacy.reason_not_automatable || existing.reason_not_automatable || undefined,
file: legacy.file || existing.file || null,
custom_fields: {
...cf,
@@ -79,10 +71,14 @@ function buildCanonicalDoc(legacy, existing = {}) {
}
};
// Carry over extra legacy fields the UI might send
// Carry over legacy fields the UI might still send
if (legacy.manualReason) doc.custom_fields.manualReason = legacy.manualReason;
if (legacy.partialNotes) doc.custom_fields.partialNotes = legacy.partialNotes;
// Keep high-level summaries if present
if (legacy.automatable) doc.automatable = legacy.automatable;
if (legacy.notYet) doc.notYet = legacy.notYet;
return doc;
}