fix(接口测试): 解决文件导入时缺少一些默认属性的问题
--user=郭雨琦 --bug=1014998 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001014998 --bug=1014819 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001014819
This commit is contained in:
parent
cefdbffb4b
commit
76f96b6d71
|
@ -3,40 +3,40 @@
|
|||
<ms-drawer :size="60" @close="apiCaseClose" direction="bottom" ref="testCaseDrawer">
|
||||
<template v-slot:header>
|
||||
<api-case-header
|
||||
:api="api"
|
||||
@setEnvironment="setEnvironment"
|
||||
@addCase="addCase"
|
||||
@saveCase="saveCase"
|
||||
:condition="condition"
|
||||
:priorities="priorities"
|
||||
:project-id="projectId"
|
||||
:useEnvironment="environment"
|
||||
:is-case-edit="isCaseEdit"
|
||||
:button-text="saveButtonText"
|
||||
ref="header" v-if="refreshHeader"/>
|
||||
:api="api"
|
||||
@setEnvironment="setEnvironment"
|
||||
@addCase="addCase"
|
||||
@saveCase="saveCase"
|
||||
:condition="condition"
|
||||
:priorities="priorities"
|
||||
:project-id="projectId"
|
||||
:useEnvironment="environment"
|
||||
:is-case-edit="isCaseEdit"
|
||||
:button-text="saveButtonText"
|
||||
ref="header" v-if="refreshHeader"/>
|
||||
</template>
|
||||
|
||||
<el-container v-if="!result.loading">
|
||||
<el-main>
|
||||
<div v-for="item in apiCaseList" :key="item.id ? item.id : item.uuid">
|
||||
<api-case-item
|
||||
:loading="singleLoading && singleRunId ===item.id || batchLoadingIds.indexOf(item.id) > -1"
|
||||
@refresh="refresh"
|
||||
@singleRun="singleRun"
|
||||
@stop="stop"
|
||||
@refreshModule="refreshModule"
|
||||
@copyCase="copyCase"
|
||||
@showExecResult="showExecResult"
|
||||
@showHistory="showHistory"
|
||||
@reLoadCase="reLoadCase"
|
||||
:environment="environment"
|
||||
@setSelectedCaseId="setSelectedCaseId"
|
||||
:is-case-edit="isCaseEdit"
|
||||
:api="api"
|
||||
:currentApi="currentApi"
|
||||
:loaded="loaded"
|
||||
:maintainerOptions="maintainerOptions"
|
||||
:api-case="item" ref="apiCaseItem"/>
|
||||
:loading="singleLoading && singleRunId ===item.id || batchLoadingIds.indexOf(item.id) > -1"
|
||||
@refresh="refresh"
|
||||
@singleRun="singleRun"
|
||||
@stop="stop"
|
||||
@refreshModule="refreshModule"
|
||||
@copyCase="copyCase"
|
||||
@showExecResult="showExecResult"
|
||||
@showHistory="showHistory"
|
||||
@reLoadCase="reLoadCase"
|
||||
:environment="environment"
|
||||
@setSelectedCaseId="setSelectedCaseId"
|
||||
:is-case-edit="isCaseEdit"
|
||||
:api="api"
|
||||
:currentApi="currentApi"
|
||||
:loaded="loaded"
|
||||
:maintainerOptions="maintainerOptions"
|
||||
:api-case="item" ref="apiCaseItem"/>
|
||||
</div>
|
||||
</el-main>
|
||||
</el-container>
|
||||
|
@ -62,6 +62,7 @@ import MsDrawer from "../../../../common/components/MsDrawer";
|
|||
import {CASE_ORDER} from "../../model/JsonData";
|
||||
import {API_CASE_CONFIGS} from "@/business/components/common/components/search/search-components";
|
||||
import {parseEnvironment} from "@/business/components/api/definition/model/EnvironmentModel";
|
||||
import {Body} from "@/business/components/api/definition/model/ApiTestModel";
|
||||
|
||||
export default {
|
||||
name: 'ApiCaseList',
|
||||
|
@ -325,12 +326,12 @@ export default {
|
|||
this.$get('/api/environment/list/' + this.projectId, response => {
|
||||
this.environments = response.data;
|
||||
// 获取原数据源名称
|
||||
if(env === obj.originalEnvironmentId && obj.originalDataSourceId){
|
||||
if (env === obj.originalEnvironmentId && obj.originalDataSourceId) {
|
||||
obj.dataSourceId = obj.originalDataSourceId;
|
||||
obj.environmentId = env;
|
||||
this.getTargetSourceName(this.environments, obj);
|
||||
}
|
||||
if(!obj.targetDataSourceName){
|
||||
if (!obj.targetDataSourceName) {
|
||||
this.getTargetSourceName(this.environments, obj);
|
||||
}
|
||||
|
||||
|
@ -344,12 +345,12 @@ export default {
|
|||
});
|
||||
} else {
|
||||
// 获取原数据源名称
|
||||
if(env === obj.originalEnvironmentId && obj.originalDataSourceId){
|
||||
if (env === obj.originalEnvironmentId && obj.originalDataSourceId) {
|
||||
obj.dataSourceId = obj.originalDataSourceId;
|
||||
obj.environmentId = env;
|
||||
this.getTargetSourceName(this.environments, obj);
|
||||
}
|
||||
if(!obj.targetDataSourceName){
|
||||
if (!obj.targetDataSourceName) {
|
||||
this.getTargetSourceName(this.environments, obj);
|
||||
}
|
||||
// 设置新环境
|
||||
|
@ -418,6 +419,28 @@ export default {
|
|||
}
|
||||
if (Object.prototype.toString.call(apiCase.request).match(/\[object (\w+)\]/)[1].toLowerCase() !== 'object') {
|
||||
apiCase.request = JSON.parse(apiCase.request);
|
||||
if (!apiCase.request.body) {
|
||||
apiCase.request.body = new Body();
|
||||
}
|
||||
if (!apiCase.request.headers) {
|
||||
apiCase.request.headers = [];
|
||||
}
|
||||
if (!apiCase.request.rest) {
|
||||
apiCase.request.rest = [];
|
||||
}
|
||||
if (!apiCase.request.arguments) {
|
||||
apiCase.request.arguments = [
|
||||
{
|
||||
contentType: "text/plain",
|
||||
enable: true,
|
||||
file: false,
|
||||
required: false,
|
||||
type: "text",
|
||||
urlEncode: false,
|
||||
valid: false
|
||||
}
|
||||
];
|
||||
}
|
||||
}
|
||||
if (!apiCase.request.hashTree) {
|
||||
apiCase.request.hashTree = [];
|
||||
|
@ -529,7 +552,7 @@ export default {
|
|||
this.$emit('showExecResult', row);
|
||||
},
|
||||
singleRun(row) {
|
||||
let methods =["SQL","DUBBO","dubbo://","TCP" ];
|
||||
let methods = ["SQL", "DUBBO", "dubbo://", "TCP"];
|
||||
if (row.apiMethod && methods.indexOf(row.apiMethod) === -1 && !this.environment) {
|
||||
this.$warning(this.$t('api_test.environment.select_environment'));
|
||||
return;
|
||||
|
|
|
@ -676,6 +676,50 @@ export default {
|
|||
item.tags = JSON.parse(item.tags);
|
||||
}
|
||||
item.caseTotal = parseInt(item.caseTotal);
|
||||
if (!item.response) {
|
||||
let response = {headers: [], body: new Body(), statusCode: [], type: "HTTP"};
|
||||
item.response = JSON.stringify(response);
|
||||
}
|
||||
if (item.response) {
|
||||
item.response = JSON.parse(item.response);
|
||||
if (!item.response.body) {
|
||||
item.response.body = new Body();
|
||||
}
|
||||
if (!item.response.headers) {
|
||||
item.response.headers = [];
|
||||
}
|
||||
if (!item.response.statusCode) {
|
||||
item.response.statusCode = [];
|
||||
}
|
||||
item.response = JSON.stringify(item.response);
|
||||
}
|
||||
//request
|
||||
if (item.request) {
|
||||
item.request = JSON.parse(item.request);
|
||||
if (!item.request.body) {
|
||||
item.request.body = new Body();
|
||||
}
|
||||
if (!item.request.headers) {
|
||||
item.request.headers = [];
|
||||
}
|
||||
if (!item.request.rest) {
|
||||
item.request.rest = [];
|
||||
}
|
||||
if (!item.request.arguments) {
|
||||
item.request.arguments = [
|
||||
{
|
||||
contentType: "text/plain",
|
||||
enable: true,
|
||||
file: false,
|
||||
required: false,
|
||||
type: "text",
|
||||
urlEncode: false,
|
||||
valid: false
|
||||
}
|
||||
];
|
||||
}
|
||||
item.request = JSON.stringify(item.request);
|
||||
}
|
||||
});
|
||||
this.$emit('getTrashApi');
|
||||
if (this.$refs.table) {
|
||||
|
|
Loading…
Reference in New Issue