feat(接口自动化): 添加接口引用功能

This commit is contained in:
fit2-zhao 2020-12-11 13:46:51 +08:00
parent 5e22b003df
commit 53458630d8
4 changed files with 34 additions and 41 deletions

View File

@ -237,7 +237,7 @@
<!--接口列表--> <!--接口列表-->
<el-drawer :visible.sync="apiListVisible" :destroy-on-close="true" direction="ltr" :withHeader="false" :title="$t('api_test.automation.api_list_import')" :modal="false" size="90%"> <el-drawer :visible.sync="apiListVisible" :destroy-on-close="true" direction="ltr" :withHeader="false" :title="$t('api_test.automation.api_list_import')" :modal="false" size="90%">
<ms-api-definition :visible="true" :currentRow="currentRow"/> <ms-api-definition :visible="visibleRef" :currentRow="currentRow"/>
<el-button style="float: right;margin: 0px 20px 0px" type="primary" @click="copyApi('REF')">{{$t('api_test.scenario.reference')}}</el-button> <el-button style="float: right;margin: 0px 20px 0px" type="primary" @click="copyApi('REF')">{{$t('api_test.scenario.reference')}}</el-button>
<el-button style="float: right;" type="primary" @click="copyApi('Copy')">{{ $t('commons.copy') }}</el-button> <el-button style="float: right;" type="primary" @click="copyApi('Copy')">{{ $t('commons.copy') }}</el-button>
</el-drawer> </el-drawer>
@ -348,6 +348,7 @@
debugData: {}, debugData: {},
reportId: "", reportId: "",
projectId: "", projectId: "",
visibleRef: "",
} }
}, },
created() { created() {
@ -417,6 +418,7 @@
this.reload(); this.reload();
}, },
apiListImport() { apiListImport() {
this.visibleRef = getUUID();
this.apiListVisible = true; this.apiListVisible = true;
}, },
recursiveSorting(arr) { recursiveSorting(arr) {

View File

@ -72,7 +72,7 @@
<el-card style="margin-top: 5px"> <el-card style="margin-top: 5px">
<el-row> <el-row>
<el-col :span="1"> <el-col :span="1">
<el-checkbox v-if="visible" @change="caseChecked(item)"/> <el-checkbox v-model="item.checked" @change="caseChecked(item)"/>
</el-col> </el-col>
<el-col :span="5"> <el-col :span="5">
<div class="el-step__icon is-text ms-api-col"> <div class="el-step__icon is-text ms-api-col">
@ -169,10 +169,8 @@
api: { api: {
type: Object type: Object
}, },
createCase: String,
visible: { visible: {
type: Boolean, type: String,
default: false,
}, },
loaded: Boolean, loaded: Boolean,
refreshSign: String, refreshSign: String,
@ -202,7 +200,7 @@
api() { api() {
this.getApiTest(); this.getApiTest();
}, },
createCase() { visible() {
this.getApiTest(); this.getApiTest();
} }
}, },
@ -212,21 +210,6 @@
this.getApiTest(); this.getApiTest();
}, },
methods: { methods: {
sysAddition() {
let condition = {};
condition.projectId = this.api.projectId;
condition.apiDefinitionId = this.api.id;
condition.priority = this.priorityValue;
condition.name = this.name;
this.$post("/api/testcase/list", condition, response => {
for (let index in response.data) {
let test = response.data[index];
test.request = JSON.parse(test.request);
}
this.apiCaseList = response.data;
this.addCase();
});
},
getResult(data) { getResult(data) {
if (RESULT_MAP.get(data)) { if (RESULT_MAP.get(data)) {
return RESULT_MAP.get(data); return RESULT_MAP.get(data);
@ -352,21 +335,27 @@
return bodyUploadFiles; return bodyUploadFiles;
}, },
getApiTest() { getApiTest() {
if (this.currentRow) { if (this.api) {
this.currentRow.cases = []; this.checkedCases = new Set();
} this.loading = true;
let condition = {}; if (this.currentRow) {
condition.projectId = this.api.projectId; this.currentRow.cases = [];
condition.apiDefinitionId = this.api.id;
condition.priority = this.priorityValue;
condition.name = this.name;
this.$post("/api/testcase/list", condition, response => {
for (let index in response.data) {
let test = response.data[index];
test.request = JSON.parse(test.request);
} }
this.apiCaseList = response.data; let condition = {};
}); condition.projectId = this.projectId;
condition.apiDefinitionId = this.api.id;
condition.priority = this.priorityValue;
condition.name = this.name;
this.$post("/api/testcase/list", condition, response => {
for (let index in response.data) {
let test = response.data[index];
test.checked = false;
test.request = JSON.parse(test.request);
}
this.loading = false;
this.apiCaseList = response.data;
});
}
}, },
validate(row) { validate(row) {
if (!row.name) { if (!row.name) {
@ -383,7 +372,7 @@
}); });
let hasEnvironment = false; let hasEnvironment = false;
for (let i in this.environments) { for (let i in this.environments) {
if (this.environments[i].id === this.api.environmentId) { if (this.api && this.environments[i].id === this.api.environmentId) {
hasEnvironment = true; hasEnvironment = true;
break; break;
} }

View File

@ -50,8 +50,7 @@
}, },
props: { props: {
visible: { visible: {
type: Boolean, type: String,
default: false,
}, },
currentRow: { currentRow: {
type: Object, type: Object,

View File

@ -142,8 +142,7 @@
currentProtocol: String, currentProtocol: String,
currentModule: Object, currentModule: Object,
visible: { visible: {
type: Boolean, type: String,
default: false,
}, },
currentRow: { currentRow: {
type: Object, type: Object,
@ -161,6 +160,10 @@
this.initApiTable(); this.initApiTable();
this.apiCaseClose(); this.apiCaseClose();
}, },
visible() {
this.initApiTable();
this.apiCaseClose();
},
currentProtocol() { currentProtocol() {
this.initApiTable(); this.initApiTable();
this.apiCaseClose(); this.apiCaseClose();
@ -321,8 +324,8 @@
}); });
}, },
apiCaseClose() { apiCaseClose() {
this.selectApi = {};
let h = window.screen.height; let h = window.screen.height;
let svgTop = document.getElementById("svgTop"); let svgTop = document.getElementById("svgTop");
svgTop.style.height = h - 200 + "px"; svgTop.style.height = h - 200 + "px";