fix (接口定义): 修复执行接口定义相关优化问题

This commit is contained in:
fit2-zhao 2021-08-19 14:49:19 +08:00 committed by fit2-zhao
parent 94d546c924
commit 214106f890
9 changed files with 78 additions and 43 deletions

View File

@ -89,6 +89,11 @@
@showExecResult="showExecResult" @showExecResult="showExecResult"
ref="trashCaseList"/> ref="trashCaseList"/>
</div> </div>
<!-- 加载用例 -->
<ms-api-case-list
:createCase="createCase"
:currentApi="api"
ref="caseList"/>
</el-card> </el-card>
</template> </template>
@ -101,6 +106,8 @@ import MsRunTestDubboPage from "./runtest/RunTestDubboPage";
import MockConfig from "@/business/components/api/definition/components/mock/MockConfig"; import MockConfig from "@/business/components/api/definition/components/mock/MockConfig";
import TcpMockConfig from "@/business/components/api/definition/components/mock/TcpMockConfig"; import TcpMockConfig from "@/business/components/api/definition/components/mock/TcpMockConfig";
import ApiCaseSimpleList from "./list/ApiCaseSimpleList"; import ApiCaseSimpleList from "./list/ApiCaseSimpleList";
import MsApiCaseList from "./case/ApiCaseList";
import {getUUID} from "@/common/js/utils";
export default { export default {
name: "EditCompleteContainer", name: "EditCompleteContainer",
@ -112,7 +119,8 @@ export default {
MsRunTestDubboPage, MsRunTestDubboPage,
MockConfig, MockConfig,
TcpMockConfig, TcpMockConfig,
ApiCaseSimpleList ApiCaseSimpleList,
MsApiCaseList
}, },
data() { data() {
return { return {
@ -122,7 +130,9 @@ export default {
showMock: false, showMock: false,
showTestCaseList: false, showTestCaseList: false,
baseMockConfigData: {}, baseMockConfigData: {},
loading: false loading: false,
createCase: "",
api: {},
} }
}, },
props: { props: {
@ -151,6 +161,15 @@ export default {
watch: { watch: {
showMock() { showMock() {
this.mockSetting(); this.mockSetting();
},
'$store.state.currentApiCase.case'() {
if (this.$store.state.currentApiCase && this.$store.state.currentApiCase.api) {
this.refreshButtonActiveClass("testCase");
}
},
'$store.state.currentApiCase.mock'() {
this.mockSetting();
this.refreshButtonActiveClass("mock");
} }
}, },
methods: { methods: {
@ -221,21 +240,29 @@ export default {
this.showTestCaseList = true; this.showTestCaseList = true;
this.showTest = false; this.showTest = false;
this.showMock = false; this.showMock = false;
if (this.$store.state.currentApiCase && this.$store.state.currentApiCase.api) {
this.createCase = getUUID();
this.api = this.$store.state.currentApiCase.api;
this.$refs.caseList.open();
}
} else if (tabType === "test") { } else if (tabType === "test") {
this.showApiList = false; this.showApiList = false;
this.showTestCaseList = false; this.showTestCaseList = false;
this.showTest = true; this.showTest = true;
this.showMock = false; this.showMock = false;
this.$store.state.currentApiCase = undefined;
} else if (tabType === "mock") { } else if (tabType === "mock") {
this.showApiList = false; this.showApiList = false;
this.showTestCaseList = false; this.showTestCaseList = false;
this.showTest = false; this.showTest = false;
this.showMock = true; this.showMock = true;
this.$store.state.currentApiCase = undefined;
} else { } else {
this.showApiList = true; this.showApiList = true;
this.showTestCaseList = false; this.showTestCaseList = false;
this.showTest = false; this.showTest = false;
this.showMock = false; this.showMock = false;
this.$store.state.currentApiCase = undefined;
} }
} }
}, },

View File

@ -1,5 +1,5 @@
<template> <template>
<el-card style="margin-top: 5px" @click.native="selectTestCase(apiCase,$event)"> <el-card style="margin-top: 5px" @click.native="selectTestCase(apiCase,$event)" v-loading="loading">
<div @click="active(apiCase)" v-if="type!=='detail'"> <div @click="active(apiCase)" v-if="type!=='detail'">
<el-row> <el-row>
<el-col :span="3"> <el-col :span="3">
@ -220,7 +220,6 @@ export default {
{name: this.$t('test_track.case.batch_edit_case'), handleClick: this.handleEditBatch} {name: this.$t('test_track.case.batch_edit_case'), handleClick: this.handleEditBatch}
], ],
methodColorMap: new Map(API_METHOD_COLOUR), methodColorMap: new Map(API_METHOD_COLOUR),
maintainerOptions: [],
} }
}, },
props: { props: {
@ -252,13 +251,13 @@ export default {
default() { default() {
return false; return false;
} }
} },
maintainerOptions: Array,
}, },
created() { created() {
if (requireComponent != null && JSON.stringify(esbDefinition) != '{}' && JSON.stringify(esbDefinitionResponse) != '{}') { if (requireComponent != null && JSON.stringify(esbDefinition) != '{}' && JSON.stringify(esbDefinitionResponse) != '{}') {
this.showXpackCompnent = true; this.showXpackCompnent = true;
} }
this.getMaintainerOptions();
}, },
watch: { watch: {
'apiCase.selected'() { 'apiCase.selected'() {
@ -266,11 +265,6 @@ export default {
} }
}, },
methods: { methods: {
getMaintainerOptions() {
this.$post('/user/project/member/tester/list', {projectId: getCurrentProjectID()}, response => {
this.maintainerOptions = response.data;
});
},
openHis(row) { openHis(row) {
this.$refs.changeHistory.open(row.id); this.$refs.changeHistory.open(row.id);
}, },
@ -372,6 +366,12 @@ export default {
} }
}); });
}, },
reload() {
this.loading = true
this.$nextTick(() => {
this.loading = false
});
},
saveCase(row, hideAlert) { saveCase(row, hideAlert) {
let tmp = JSON.parse(JSON.stringify(row)); let tmp = JSON.parse(JSON.stringify(row));
this.isShowInput = false; this.isShowInput = false;
@ -411,6 +411,7 @@ export default {
row.updateTime = data.updateTime; row.updateTime = data.updateTime;
if (!row.message) { if (!row.message) {
this.$success(this.$t('commons.save_success')); this.$success(this.$t('commons.save_success'));
this.reload();
if (!hideAlert) { if (!hideAlert) {
this.$emit('refresh'); this.$emit('refresh');
} }

View File

@ -38,6 +38,7 @@
:is-case-edit="isCaseEdit" :is-case-edit="isCaseEdit"
:api="api" :api="api"
:runResult="runResult" :runResult="runResult"
:maintainerOptions="maintainerOptions"
:api-case="item" :index="index" ref="apiCaseItem"/> :api-case="item" :index="index" ref="apiCaseItem"/>
</div> </div>
</el-main> </el-main>
@ -122,6 +123,7 @@ export default {
method: REQ_METHOD, method: REQ_METHOD,
}, },
envMap: new Map, envMap: new Map,
maintainerOptions: [],
}; };
}, },
watch: { watch: {
@ -145,6 +147,7 @@ export default {
if (!this.environment && this.$store.state.useEnvironment) { if (!this.environment && this.$store.state.useEnvironment) {
this.environment = this.$store.state.useEnvironment; this.environment = this.$store.state.useEnvironment;
} }
this.getMaintainerOptions();
}, },
computed: { computed: {
isCaseEdit() { isCaseEdit() {
@ -155,6 +158,11 @@ export default {
}, },
}, },
methods: { methods: {
getMaintainerOptions() {
this.$post('/user/project/member/tester/list', {projectId: getCurrentProjectID()}, response => {
this.maintainerOptions = response.data;
});
},
apiCaseSelected() { apiCaseSelected() {
this.selectSize = 0; this.selectSize = 0;
if (this.apiCaseList.length > 0) { if (this.apiCaseList.length > 0) {
@ -172,6 +180,7 @@ export default {
this.condition = {components: API_CASE_CONFIGS}; this.condition = {components: API_CASE_CONFIGS};
this.getApiTest(true); this.getApiTest(true);
this.visible = true; this.visible = true;
this.$store.state.currentApiCase = undefined;
}, },
add(api) { add(api) {
this.api = api; this.api = api;

View File

@ -99,12 +99,15 @@
<p class="tip">{{ $t('test_track.plan_view.mock_info') }} </p> <p class="tip">{{ $t('test_track.plan_view.mock_info') }} </p>
<div class="base-info mock-info"> <div class="base-info mock-info">
<el-row> <el-row>
<el-col :span="24"> <el-col :span="20">
Mock地址 Mock地址
<el-link :href="getUrlPrefix" target="_blank" style="color: black" <el-link :href="getUrlPrefix" target="_blank" style="color: black"
type="primary">{{ this.getUrlPrefix }} type="primary">{{ this.getUrlPrefix }}
</el-link> </el-link>
</el-col> </el-col>
<el-col :span="4">
<el-link @click="mockSetting" type="primary">Mock设置</el-link>
</el-col>
</el-row> </el-row>
</div> </div>
@ -139,7 +142,7 @@
import MsJsr233Processor from "../../../automation/scenario/component/Jsr233Processor"; import MsJsr233Processor from "../../../automation/scenario/component/Jsr233Processor";
import MsSelectTree from "../../../../common/select-tree/SelectTree"; import MsSelectTree from "../../../../common/select-tree/SelectTree";
import MsChangeHistory from "../../../../history/ChangeHistory"; import MsChangeHistory from "../../../../history/ChangeHistory";
import {getCurrentProjectID} from "@/common/js/utils"; import {getCurrentProjectID, getUUID} from "@/common/js/utils";
export default { export default {
name: "MsAddCompleteHttpApi", name: "MsAddCompleteHttpApi",
@ -246,6 +249,9 @@
openHis(){ openHis(){
this.$refs.changeHistory.open(this.httpForm.id); this.$refs.changeHistory.open(this.httpForm.id);
}, },
mockSetting() {
this.$store.state.currentApiCase={mock : getUUID()};
},
runTest() { runTest() {
this.$refs['httpForm'].validate((valid) => { this.$refs['httpForm'].validate((valid) => {
if (valid) { if (valid) {

View File

@ -165,9 +165,7 @@ export default {
}, },
saveAsCase() { saveAsCase() {
// //
this.createCase = getUUID(); this.$store.state.currentApiCase = {case: getUUID(), api: this.api};
this.$refs.caseList.open();
this.loaded = false;
}, },
saveAsApi() { saveAsApi() {
let data = {}; let data = {};

View File

@ -44,7 +44,6 @@
</el-form-item> </el-form-item>
</el-form> </el-form>
<div v-loading="loading"> <div v-loading="loading">
<p class="tip">{{ $t('api_test.definition.request.req_param') }} </p> <p class="tip">{{ $t('api_test.definition.request.req_param') }} </p>
@ -204,9 +203,7 @@ export default {
}, },
saveAsCase() { saveAsCase() {
// //
this.createCase = getUUID(); this.$store.state.currentApiCase = {case: getUUID(), api: this.api};
this.$refs.caseList.open();
this.loaded = false;
}, },
saveAsApi() { saveAsApi() {
let data = {}; let data = {};

View File

@ -163,9 +163,7 @@ export default {
return bodyUploadFiles; return bodyUploadFiles;
}, },
saveAsCase() { saveAsCase() {
this.createCase = getUUID(); this.$store.state.currentApiCase = {case: getUUID(), api: this.api};
this.$refs.caseList.open();
this.loaded = false;
}, },
saveAsApi() { saveAsApi() {
let data = {}; let data = {};

View File

@ -194,9 +194,7 @@ export default {
return bodyUploadFiles; return bodyUploadFiles;
}, },
saveAsCase() { saveAsCase() {
this.createCase = getUUID(); this.$store.state.currentApiCase = {case: getUUID(), api: this.api};
this.$refs.caseList.open();
this.loaded = false;
}, },
saveAsApi() { saveAsApi() {
let data = {}; let data = {};

View File

@ -24,6 +24,7 @@ const state = {
useEnvironment: "", useEnvironment: "",
testPlanViewSelectNode: {}, testPlanViewSelectNode: {},
selectStep: {}, selectStep: {},
currentApiCase: {},
} }
const store = new Vuex.Store({ const store = new Vuex.Store({