fix(测试跟踪): 功能用例新旧版本对比不可用

--bug=1018788 --user=陈建星 【测试跟踪】功能用例-新旧版本对比功能不可用 https://www.tapd.cn/55049933/s/1276070
This commit is contained in:
chenjianxing 2022-10-25 15:34:06 +08:00 committed by jianxing
parent b03aff7979
commit c6aec2157b
5 changed files with 35 additions and 28 deletions

View File

@ -24,6 +24,7 @@
<script>
import {SYSTEM_FIELD_NAME_MAP} from "../../utils/table-constants";
import CustomFiledComponent from "../template/CustomFiledComponent";
import {sortCustomFields} from "../../utils/custom_field";
export default {
name: "CustomFiledFormRow",
@ -66,24 +67,7 @@ export default {
return SYSTEM_FIELD_NAME_MAP;
},
sortCustomFields() {
let total = 0;//total
let customFields = this.issueTemplate.customFields;
for (let i = 0; total < customFields.length; total++) {
if (typeof (customFields[i].defaultValue) === 'string' || customFields[i].defaultValue instanceof String) {
try {
customFields[i].defaultValue = JSON.parse(customFields[i].defaultValue);
} catch (e) {
// nothing
}
}
if (customFields[i].type === 'richText') {
//00arrpush0splicei+1i
customFields.push(customFields.splice(i, 1)[0]);
} else {
i++;//0
}
}
return customFields;
return sortCustomFields(this.issueTemplate.customFields);
},
}
}

View File

@ -161,3 +161,23 @@ export function buildTestCaseOldFields(testCase) {
oldFields.set('用例等级', testCase.priority);
return oldFields;
}
export function sortCustomFields(customFields) {
let total = 0;//定义total用于控制循环结束
for (let i = 0; total < customFields.length; total++) {
if (typeof (customFields[i].defaultValue) === 'string' || customFields[i].defaultValue instanceof String) {
try {
customFields[i].defaultValue = JSON.parse(customFields[i].defaultValue);
} catch (e) {
// nothing
}
}
if (customFields[i].type === 'richText') {
//循环到是0的位置就删除该元素0并且在arr末尾push进这个元素0由于splice删除了该位置元素所以i不用+1下次循环仍然检查i位置的元素
customFields.push(customFields.splice(i, 1)[0]);
} else {
i++;//循环到不是0的位置就继续往后循环
}
}
return customFields;
}

View File

@ -1017,10 +1017,10 @@ export default {
let p1 = getTestCase(response.data.id);
let p2 = getTestCase(this.currentTestCaseInfo.id);
let that = this;
Promise.all([p1, p2]).then(data => {
if (data[0] && data[1]) {
that.newData = data[0].data.data;
that.oldData = data[1].data.data;
Promise.all([p1, p2]).then(r => {
if (r[0] && r[1]) {
that.newData = r[0].data;
that.oldData = r[1].data;
that.newData.createTime = row.createTime;
that.oldData.createTime = this.$refs.versionHistory.versionOptions.filter(v => v.id === that.oldData.versionId)[0].createTime;
that.newData.versionName = that.versionData.filter(v => v.id === that.newData.id)[0].versionName;

View File

@ -60,8 +60,10 @@
<el-form v-if="oldData.isFormAlive" :model="oldData.customFieldForm" :rules="oldData.customFieldRules"
ref="oldCustomFieldForm"
class="case-form">
<custom-filed-form-item :form="oldData.customFieldForm" :form-label-width="oldData.formLabelWidth"
:issue-template="oldData.testCaseTemplate" :is-public="isPublic"/>
<custom-filed-form-row :form="oldData.customFieldForm"
:disabled="readOnly"
:default-open="defaultOpen"
:issue-template="oldData.testCaseTemplate"/>
</el-form>
<el-row v-if="oldData.isCustomNum">
@ -237,7 +239,7 @@ import MsFormDivider from "metersphere-frontend/src/components/MsFormDivider";
import MsInputTag from "metersphere-frontend/src/components/MsInputTag";
import {getCurrentProjectID, getCurrentUser} from "metersphere-frontend/src/utils/token";
import {removeGoBackListener} from "metersphere-frontend/src/utils";
import {buildTestCaseOldFields, parseCustomField} from "metersphere-frontend/src/utils/custom_field";
import {buildTestCaseOldFields, parseCustomField, sortCustomFields} from "metersphere-frontend/src/utils/custom_field";
import TestCaseEditOtherInfo from "@/business/case/components/TestCaseEditOtherInfo";
import TestCaseStepItem from "@/business/case/components/TestCaseStepItem";
import StepChangeItem from "@/business/case/components/StepChangeItem";
@ -250,7 +252,6 @@ import {useStore} from "@/store";
import {getProjectListAll, getProjectMemberOption} from "@/business/utils/sdk-utils";
import {getTestTemplate} from "@/api/custom-field-template";
import {testCaseCommentList} from "@/api/test-case-comment";
const {diff} = require("@/business/v_node_diff");
export default {
@ -407,8 +408,8 @@ export default {
this[prop].$get = this.$get;
let that = this;
getTestTemplate()
.then((r) => {
this[prop].testCaseTemplate = r.data;
.then((testCaseTemplate) => {
this[prop].testCaseTemplate = testCaseTemplate;
initFuc(prop, () => {
that.reloadForm(prop);
});
@ -443,6 +444,7 @@ export default {
this[prop].module = this[prop].nodeId;
//
this[prop].customFieldForm = parseCustomField(this[prop], this[prop].testCaseTemplate, null, this[prop] ? buildTestCaseOldFields(this[prop]) : null);
sortCustomFields(this[prop].testCaseTemplate.customFields);
},
setTestCaseExtInfo(prop) {
this[prop] = {};

View File

@ -1,6 +1,7 @@
export {operationConfirm, removeGoBackListener, handleCtrlSEvent, byteToSize, resizeTextarea,
getTypeByFileName, strMapToObj, getUUID, windowPrint} from "metersphere-frontend/src/utils";
export {parseCustomFilesForList, getCustomFieldFilter, buildBatchParam} from "metersphere-frontend/src/utils/tableUtils";
export {sortCustomFields, parseCustomField, buildCustomFields} from "metersphere-frontend/src/utils/custom_field";
export {getCurrentProjectID, getCurrentWorkspaceId, getCurrentUser} from "metersphere-frontend/src/utils/token";
export {hasLicense, hasPermissions, hasPermission} from "metersphere-frontend/src/utils/permission";
export {get, post, downloadFile, fileDownloadGet, fileDownloadPost, fileUpload, generateShareUrl, generateModuleUrl} from "metersphere-frontend/src/plugins/request";