fix(测试跟踪): 测试计划功能用例,步骤执行结果显示错乱

--bug=1043845 --user=陈建星 【测试跟踪】github#32006,测试计划执行用例后,修改用例,步骤执行结果会错乱 https://www.tapd.cn/55049933/s/1602641
This commit is contained in:
AgAngle 2024-10-31 14:04:38 +08:00 committed by Craftsman
parent 6ebbd3da7a
commit 364f7efa4c
3 changed files with 38 additions and 15 deletions

View File

@ -452,6 +452,7 @@ export default {
nodeId: '', nodeId: '',
steps: [ steps: [
{ {
id: this.newStepId(),
num: 1, num: 1,
desc: "", desc: "",
result: "", result: "",
@ -1138,6 +1139,11 @@ export default {
}, },
]; ];
} }
tmp.steps.forEach(step => {
if (!step.id) {
step.id = this.newStepId();
}
});
tmp.tags = JSON.parse(tmp.tags); tmp.tags = JSON.parse(tmp.tags);
Object.assign(this.form, tmp); Object.assign(this.form, tmp);
if (!this.form.stepModel) { if (!this.form.stepModel) {
@ -1167,6 +1173,9 @@ export default {
// //
this.reloadForm(); this.reloadForm();
}, },
newStepId() {
return getUUID().substring(0, 8);
},
resetSystemField() { resetSystemField() {
if (!this.caseId) { if (!this.caseId) {
return; return;
@ -1458,6 +1467,7 @@ export default {
this.form.testName = ""; this.form.testName = "";
this.form.steps = [ this.form.steps = [
{ {
id: this.newStepId(),
num: 1, num: 1,
desc: "", desc: "",
result: "", result: "",

View File

@ -66,7 +66,7 @@
</template> </template>
<script> <script>
import { resizeTextarea } from "@/business/utils/sdk-utils"; import {getUUID, resizeTextarea} from "@/business/utils/sdk-utils";
export default { export default {
name: "CaseStepItem", name: "CaseStepItem",
@ -119,6 +119,7 @@ export default {
}, },
handleAddStep(index, data) { handleAddStep(index, data) {
let step = {}; let step = {};
step.id = this.newStepId();
step.num = data.num + 1; step.num = data.num + 1;
step.desc = ""; step.desc = "";
step.result = ""; step.result = "";
@ -129,11 +130,15 @@ export default {
}); });
this.form.steps.splice(index + 1, 0, step); this.form.steps.splice(index + 1, 0, step);
}, },
newStepId() {
return getUUID().substring(0, 8);
},
handleCopyStep(index, data) { handleCopyStep(index, data) {
if (this.readOnly) { if (this.readOnly) {
return return
} }
let step = {}; let step = {};
step.id = this.newStepId();
step.num = data.num + 1; step.num = data.num + 1;
step.desc = data.desc; step.desc = data.desc;
step.result = data.result; step.result = data.result;

View File

@ -317,6 +317,7 @@ export default {
param.comment = this.testCase.comment; param.comment = this.testCase.comment;
for (let i = 0; i < this.testCase.steptResults.length; i++) { for (let i = 0; i < this.testCase.steptResults.length; i++) {
let result = {}; let result = {};
result.id = this.testCase.steptResults[i].id;
result.actualResult = this.testCase.steptResults[i].actualResult; result.actualResult = this.testCase.steptResults[i].actualResult;
result.executeResult = this.testCase.steptResults[i].executeResult; result.executeResult = this.testCase.steptResults[i].executeResult;
if (result.actualResult && result.actualResult.length > 500) { if (result.actualResult && result.actualResult.length > 500) {
@ -433,11 +434,6 @@ export default {
this.loading = false; this.loading = false;
let item = {}; let item = {};
Object.assign(item, response.data); Object.assign(item, response.data);
if (item.results) {
item.results = JSON.parse(item.results);
} else if (item.steps) {
item.results = [item.steps.length];
}
if (item.issues) { if (item.issues) {
item.issues = JSON.parse(item.issues); item.issues = JSON.parse(item.issues);
} else { } else {
@ -448,20 +444,32 @@ export default {
item.stepModel = "STEP"; item.stepModel = "STEP";
} }
item.steptResults = []; item.steptResults = [];
if (item.results) {
item.results = JSON.parse(item.results);
} else if (item.steps) {
item.results = [item.steps.length];
}
if (item.steps) { if (item.steps) {
let resultHasId = item.results.find((r) => r.id);
for (let i = 0; i < item.steps.length; i++) { for (let i = 0; i < item.steps.length; i++) {
if (item.results) { let step = item.steps[i];
if (item.results[i]) { if (resultHasId) {
item.steps[i].actualResult = item.results[i].actualResult; // ID
item.steps[i].executeResult = item.results[i].executeResult; let result = item.results.find((r) => r.id === step.id);
if (result) {
step.actualResult = result.actualResult;
step.executeResult = result.executeResult;
} }
item.steptResults.push(item.steps[i]);
} else { } else {
item.steptResults.push({ //
actualResult: "", if (item.results[i]) {
executeResult: "", step.actualResult = item.results[i].actualResult;
}); step.executeResult = item.results[i].executeResult;
}
} }
item.steptResults.push(step);
} }
} }
this.testCase = item; this.testCase = item;