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
b3896e8022
commit
1b00732b97
|
@ -3,40 +3,40 @@
|
||||||
<ms-drawer :size="60" @close="apiCaseClose" direction="bottom" ref="testCaseDrawer">
|
<ms-drawer :size="60" @close="apiCaseClose" direction="bottom" ref="testCaseDrawer">
|
||||||
<template v-slot:header>
|
<template v-slot:header>
|
||||||
<api-case-header
|
<api-case-header
|
||||||
:api="api"
|
:api="api"
|
||||||
@setEnvironment="setEnvironment"
|
@setEnvironment="setEnvironment"
|
||||||
@addCase="addCase"
|
@addCase="addCase"
|
||||||
@saveCase="saveCase"
|
@saveCase="saveCase"
|
||||||
:condition="condition"
|
:condition="condition"
|
||||||
:priorities="priorities"
|
:priorities="priorities"
|
||||||
:project-id="projectId"
|
:project-id="projectId"
|
||||||
:useEnvironment="environment"
|
:useEnvironment="environment"
|
||||||
:is-case-edit="isCaseEdit"
|
:is-case-edit="isCaseEdit"
|
||||||
:button-text="saveButtonText"
|
:button-text="saveButtonText"
|
||||||
ref="header" v-if="refreshHeader"/>
|
ref="header" v-if="refreshHeader"/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<el-container v-if="!result.loading">
|
<el-container v-if="!result.loading">
|
||||||
<el-main>
|
<el-main>
|
||||||
<div v-for="item in apiCaseList" :key="item.id ? item.id : item.uuid">
|
<div v-for="item in apiCaseList" :key="item.id ? item.id : item.uuid">
|
||||||
<api-case-item
|
<api-case-item
|
||||||
:loading="singleLoading && singleRunId ===item.id || batchLoadingIds.indexOf(item.id) > -1"
|
:loading="singleLoading && singleRunId ===item.id || batchLoadingIds.indexOf(item.id) > -1"
|
||||||
@refresh="refresh"
|
@refresh="refresh"
|
||||||
@singleRun="singleRun"
|
@singleRun="singleRun"
|
||||||
@stop="stop"
|
@stop="stop"
|
||||||
@refreshModule="refreshModule"
|
@refreshModule="refreshModule"
|
||||||
@copyCase="copyCase"
|
@copyCase="copyCase"
|
||||||
@showExecResult="showExecResult"
|
@showExecResult="showExecResult"
|
||||||
@showHistory="showHistory"
|
@showHistory="showHistory"
|
||||||
@reLoadCase="reLoadCase"
|
@reLoadCase="reLoadCase"
|
||||||
:environment="environment"
|
:environment="environment"
|
||||||
@setSelectedCaseId="setSelectedCaseId"
|
@setSelectedCaseId="setSelectedCaseId"
|
||||||
:is-case-edit="isCaseEdit"
|
:is-case-edit="isCaseEdit"
|
||||||
:api="api"
|
:api="api"
|
||||||
:currentApi="currentApi"
|
:currentApi="currentApi"
|
||||||
:loaded="loaded"
|
:loaded="loaded"
|
||||||
:maintainerOptions="maintainerOptions"
|
:maintainerOptions="maintainerOptions"
|
||||||
:api-case="item" ref="apiCaseItem"/>
|
:api-case="item" ref="apiCaseItem"/>
|
||||||
</div>
|
</div>
|
||||||
</el-main>
|
</el-main>
|
||||||
</el-container>
|
</el-container>
|
||||||
|
@ -62,6 +62,7 @@ import MsDrawer from "../../../../common/components/MsDrawer";
|
||||||
import {CASE_ORDER} from "../../model/JsonData";
|
import {CASE_ORDER} from "../../model/JsonData";
|
||||||
import {API_CASE_CONFIGS} from "@/business/components/common/components/search/search-components";
|
import {API_CASE_CONFIGS} from "@/business/components/common/components/search/search-components";
|
||||||
import {parseEnvironment} from "@/business/components/api/definition/model/EnvironmentModel";
|
import {parseEnvironment} from "@/business/components/api/definition/model/EnvironmentModel";
|
||||||
|
import {Body} from "@/business/components/api/definition/model/ApiTestModel";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'ApiCaseList',
|
name: 'ApiCaseList',
|
||||||
|
@ -325,12 +326,12 @@ export default {
|
||||||
this.$get('/api/environment/list/' + this.projectId, response => {
|
this.$get('/api/environment/list/' + this.projectId, response => {
|
||||||
this.environments = response.data;
|
this.environments = response.data;
|
||||||
// 获取原数据源名称
|
// 获取原数据源名称
|
||||||
if(env === obj.originalEnvironmentId && obj.originalDataSourceId){
|
if (env === obj.originalEnvironmentId && obj.originalDataSourceId) {
|
||||||
obj.dataSourceId = obj.originalDataSourceId;
|
obj.dataSourceId = obj.originalDataSourceId;
|
||||||
obj.environmentId = env;
|
obj.environmentId = env;
|
||||||
this.getTargetSourceName(this.environments, obj);
|
this.getTargetSourceName(this.environments, obj);
|
||||||
}
|
}
|
||||||
if(!obj.targetDataSourceName){
|
if (!obj.targetDataSourceName) {
|
||||||
this.getTargetSourceName(this.environments, obj);
|
this.getTargetSourceName(this.environments, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -344,12 +345,12 @@ export default {
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// 获取原数据源名称
|
// 获取原数据源名称
|
||||||
if(env === obj.originalEnvironmentId && obj.originalDataSourceId){
|
if (env === obj.originalEnvironmentId && obj.originalDataSourceId) {
|
||||||
obj.dataSourceId = obj.originalDataSourceId;
|
obj.dataSourceId = obj.originalDataSourceId;
|
||||||
obj.environmentId = env;
|
obj.environmentId = env;
|
||||||
this.getTargetSourceName(this.environments, obj);
|
this.getTargetSourceName(this.environments, obj);
|
||||||
}
|
}
|
||||||
if(!obj.targetDataSourceName){
|
if (!obj.targetDataSourceName) {
|
||||||
this.getTargetSourceName(this.environments, obj);
|
this.getTargetSourceName(this.environments, obj);
|
||||||
}
|
}
|
||||||
// 设置新环境
|
// 设置新环境
|
||||||
|
@ -418,6 +419,28 @@ export default {
|
||||||
}
|
}
|
||||||
if (Object.prototype.toString.call(apiCase.request).match(/\[object (\w+)\]/)[1].toLowerCase() !== 'object') {
|
if (Object.prototype.toString.call(apiCase.request).match(/\[object (\w+)\]/)[1].toLowerCase() !== 'object') {
|
||||||
apiCase.request = JSON.parse(apiCase.request);
|
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) {
|
if (!apiCase.request.hashTree) {
|
||||||
apiCase.request.hashTree = [];
|
apiCase.request.hashTree = [];
|
||||||
|
@ -529,7 +552,7 @@ export default {
|
||||||
this.$emit('showExecResult', row);
|
this.$emit('showExecResult', row);
|
||||||
},
|
},
|
||||||
singleRun(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) {
|
if (row.apiMethod && methods.indexOf(row.apiMethod) === -1 && !this.environment) {
|
||||||
this.$warning(this.$t('api_test.environment.select_environment'));
|
this.$warning(this.$t('api_test.environment.select_environment'));
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -676,6 +676,50 @@ export default {
|
||||||
item.tags = JSON.parse(item.tags);
|
item.tags = JSON.parse(item.tags);
|
||||||
}
|
}
|
||||||
item.caseTotal = parseInt(item.caseTotal);
|
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');
|
this.$emit('getTrashApi');
|
||||||
if (this.$refs.table) {
|
if (this.$refs.table) {
|
||||||
|
|
Loading…
Reference in New Issue