fix(接口定义): 修复xml断言相关问题的缺陷
--bug=1018082 --user=王孝刚 【接口测试】文档结构断言-xml-跟随接口定义,断言没有生效 https://www.tapd.cn/55049933/s/1264707 --bug=1018081 --user=王孝刚 【接口测试】接口文档断言 - 跟随接口定义,关闭后重新打开才显示 https://www.tapd.cn/55049933/s/1264710 --bug=1018080 --user=王孝刚 【接口测试】接口文档结构断言-xml格式,删除、添加断言内容报错 https://www.tapd.cn/55049933/s/1264715 --bug=1018078 --user=王孝刚 【接口测试】xml文档结构断言错误,并且关闭后再打开就没有了 https://www.tapd.cn/55049933/s/1264740
This commit is contained in:
parent
80e2a7fed0
commit
6a7e7c5386
|
@ -3,11 +3,11 @@ package io.metersphere.commons.utils;
|
|||
import io.metersphere.api.dto.definition.request.assertions.document.DocumentElement;
|
||||
import io.metersphere.commons.constants.PropertyConstant;
|
||||
import io.metersphere.utils.DocumentUtils;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import net.sf.json.util.JSONTokener;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.dom4j.Element;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import org.json.XML;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
@ -71,6 +71,7 @@ public class JSONToDocumentUtil {
|
|||
JSONArray array = JSONUtil.parseArray(json);
|
||||
jsonDataFormatting(array, children);
|
||||
} else {
|
||||
roots.add(new DocumentElement().newRoot(PropertyConstant.ARRAY, children));
|
||||
JSONArray array = JSONUtil.parseArray(json);
|
||||
jsonDataFormatting(array, roots);
|
||||
}
|
||||
|
@ -80,6 +81,7 @@ public class JSONToDocumentUtil {
|
|||
JSONObject object = JSONUtil.parseObject(json);
|
||||
jsonDataFormatting(object, children);
|
||||
} else {
|
||||
roots.add(new DocumentElement().newRoot(PropertyConstant.OBJECT, children));
|
||||
JSONObject object = JSONUtil.parseObject(json);
|
||||
jsonDataFormatting(object, roots);
|
||||
}
|
||||
|
|
|
@ -235,7 +235,11 @@ export function mergeRequestDocumentData(request) {
|
|||
if (index !== -1) {
|
||||
if (request.hashTree[index].document && request.hashTree[index].document.originalData && request.hashTree[index].document.tableData.size && request.hashTree[index].document.tableData.size !== 0) {
|
||||
mergeDocumentData(request.hashTree[index].document.originalData, request.hashTree[index].document.tableData);
|
||||
if (request.hashTree[index].document.type === 'json') {
|
||||
request.hashTree[index].document.data.json = request.hashTree[index].document.originalData;
|
||||
} else {
|
||||
request.hashTree[index].document.data.xml = request.hashTree[index].document.originalData;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -198,7 +198,7 @@ export default {
|
|||
if (this.document.type === "JSON") {
|
||||
this.document.data.json = this.originalData;
|
||||
} else if (this.document.type === "XML") {
|
||||
this.document.data.xml = this.tableData;
|
||||
this.document.data.xml = this.originalData;
|
||||
}
|
||||
},
|
||||
tableDataList(data) {
|
||||
|
@ -298,20 +298,19 @@ export default {
|
|||
changeData() {
|
||||
if (this.document.data) {
|
||||
this.tableData = [];
|
||||
if (this.document.type === "JSON") {
|
||||
if (this.document.type === 'JSON') {
|
||||
this.document.data.jsonFollowAPI = this.checked ? this.apiId : "";
|
||||
if (this.document.data.jsonFollowAPI) {
|
||||
this.getDocument();
|
||||
} else {
|
||||
this.tableDataList(this.document.data.json);
|
||||
}
|
||||
|
||||
} else if (this.document.type === "XML") {
|
||||
} else if (this.document.type === 'XML') {
|
||||
this.document.data.xmlFollowAPI = this.checked ? this.apiId : "";
|
||||
if (this.document.data.xmlFollowAPI) {
|
||||
this.getDocument();
|
||||
} else {
|
||||
this.tableData = this.document.data.xml;
|
||||
this.tableDataList(this.document.data.xml);
|
||||
}
|
||||
}
|
||||
this.reload();
|
||||
|
|
|
@ -122,7 +122,7 @@
|
|||
:showScript="true"
|
||||
:headers="apiCase.request.headers "
|
||||
:response="apiCase.responseData"
|
||||
:request="apiCase.request" v-if="api.protocol==='HTTP'"/>
|
||||
:request="apiCase.request" :case-id="apiCase.apiDefinitionId" v-if="api.protocol==='HTTP'"/>
|
||||
<tcp-format-parameters
|
||||
:showScript="true"
|
||||
:show-pre-script="true"
|
||||
|
@ -215,18 +215,11 @@
|
|||
<script>
|
||||
import {citedScenarioCount, deleteToGc, editApiCase, editFollowsByParam, getApiCaseFollow} from "@/api/api-test-case";
|
||||
import {createDefinition} from "@/api/definition";
|
||||
import {relationGet} from "@/api/xpack";
|
||||
import {updateRuleRelation} from "@/api/xpack";
|
||||
import {relationGet, updateRuleRelation} from "@/api/xpack";
|
||||
import {getUUID} from "metersphere-frontend/src/utils";
|
||||
import {
|
||||
getCurrentProjectID,
|
||||
getCurrentUser
|
||||
} from "metersphere-frontend/src/utils/token";
|
||||
import {
|
||||
hasLicense,
|
||||
hasPermission
|
||||
} from "metersphere-frontend/src/utils/permission";
|
||||
import {_getBodyUploadFiles} from "@/business/definition/api-definition";
|
||||
import {getCurrentProjectID, getCurrentUser} from "metersphere-frontend/src/utils/token";
|
||||
import {hasLicense, hasPermission} from "metersphere-frontend/src/utils/permission";
|
||||
import {_getBodyUploadFiles, mergeRequestDocumentData} from "@/business/definition/api-definition";
|
||||
import {API_METHOD_COLOUR, API_STATUS, PRIORITY} from "../../model/JsonData";
|
||||
import MsTag from "metersphere-frontend/src/components/MsTag";
|
||||
import MsTipButton from "metersphere-frontend/src/components/MsTipButton";
|
||||
|
@ -244,7 +237,6 @@ import ShowMoreBtn from "@/business/commons/ShowMoreBtn";
|
|||
import MsChangeHistory from "@/business/history/ApiHistory";
|
||||
import {TYPE_TO_C} from "@/business/automation/scenario/Setting";
|
||||
import ApiCaseHeader from "./ApiCaseHeader";
|
||||
import {mergeRequestDocumentData} from "@/business/definition/api-definition";
|
||||
import {deepClone} from "metersphere-frontend/src/utils/tableUtils";
|
||||
import {useApiStore} from "@/store";
|
||||
|
||||
|
|
|
@ -163,7 +163,7 @@
|
|||
</span>
|
||||
<ms-jmx-step
|
||||
:request="request"
|
||||
:apiId="request.id"
|
||||
:apiId="caseId || request.id"
|
||||
:scenarioId="scenarioId"
|
||||
:response="response"
|
||||
@reload="reloadBody"
|
||||
|
@ -215,6 +215,7 @@ export default {
|
|||
props: {
|
||||
method: String,
|
||||
request: {},
|
||||
caseId: String,
|
||||
response: {},
|
||||
definitionTest: {
|
||||
type: Boolean,
|
||||
|
|
|
@ -197,7 +197,7 @@ export default {
|
|||
if (this.document.type === "JSON") {
|
||||
this.document.data.json = this.originalData;
|
||||
} else if (this.document.type === "XML") {
|
||||
this.document.data.xml = this.tableData;
|
||||
this.document.data.xml = this.originalData;
|
||||
}
|
||||
},
|
||||
tableDataList(data) {
|
||||
|
@ -310,7 +310,7 @@ export default {
|
|||
if (this.document.data.xmlFollowAPI) {
|
||||
this.getDocument();
|
||||
} else {
|
||||
this.tableData = this.document.data.xml;
|
||||
this.tableDataList(this.document.data.xml);
|
||||
}
|
||||
}
|
||||
this.reload();
|
||||
|
|
Loading…
Reference in New Issue