fix(接口定义): 快捷调试另存为用例,并自动创建一条接口
This commit is contained in:
parent
7035f6c0e3
commit
f84db83a4c
|
@ -77,16 +77,16 @@
|
|||
document.removeEventListener("keydown", this.createCtrlSHandle);
|
||||
},
|
||||
createCtrlSHandle(event) {
|
||||
if(this.$refs.httpApi) {
|
||||
if (this.$refs.httpApi) {
|
||||
handleCtrlSEvent(event, this.$refs.httpApi.saveApi);
|
||||
}
|
||||
else if(this.$refs.tcpApi) {
|
||||
else if (this.$refs.tcpApi) {
|
||||
handleCtrlSEvent(event, this.$refs.tcpApi.saveApi);
|
||||
}
|
||||
else if(this.$refs.dubboApi) {
|
||||
else if (this.$refs.dubboApi) {
|
||||
handleCtrlSEvent(event, this.$refs.dubboApi.saveApi);
|
||||
}
|
||||
else if(this.$refs.sqlApi) {
|
||||
else if (this.$refs.sqlApi) {
|
||||
handleCtrlSEvent(event, this.$refs.sqlApi.saveApi);
|
||||
}
|
||||
},
|
||||
|
@ -192,27 +192,10 @@
|
|||
let bodyFiles = this.getBodyUploadFiles(data);
|
||||
this.$fileUpload(this.reqUrl, null, bodyFiles, data, () => {
|
||||
this.$success(this.$t('commons.save_success'));
|
||||
if (this.reqUrl.endsWith('/create')) {
|
||||
this.saveTestCase(data);
|
||||
}
|
||||
this.reqUrl = "/api/definition/update";
|
||||
this.$emit('saveApi', data);
|
||||
});
|
||||
},
|
||||
saveTestCase(row) {
|
||||
let tmp = {request: JSON.parse(JSON.stringify(row.request))};
|
||||
tmp.projectId = getCurrentProjectID();
|
||||
tmp.active = true;
|
||||
tmp.priority = "P0";
|
||||
tmp.name = row.name;
|
||||
tmp.request.path = row.path;
|
||||
tmp.request.method = row.method;
|
||||
tmp.apiDefinitionId = row.id;
|
||||
let bodyFiles = this.getBodyUploadFiles(tmp);
|
||||
let url = "/api/testcase/create";
|
||||
this.$fileUpload(url, null, bodyFiles, tmp, (response) => {
|
||||
});
|
||||
},
|
||||
setParameters(data) {
|
||||
data.projectId = this.projectId;
|
||||
this.request.name = this.currentApi.name;
|
||||
|
|
|
@ -108,7 +108,7 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import {_getBodyUploadFiles, getCurrentProjectID} from "../../../../../../common/js/utils";
|
||||
import {_getBodyUploadFiles, getCurrentProjectID, getUUID} from "@/common/js/utils";
|
||||
import {PRIORITY, RESULT_MAP} from "../../model/JsonData";
|
||||
import MsTag from "../../../../common/components/MsTag";
|
||||
import MsTipButton from "../../../../common/components/MsTipButton";
|
||||
|
@ -236,7 +236,32 @@
|
|||
this.saveTestCase(row);
|
||||
}
|
||||
},
|
||||
saveTestCase(row) {
|
||||
setParameters(data) {
|
||||
data.projectId = getCurrentProjectID();
|
||||
data.request.name = data.name;
|
||||
if (data.protocol === "DUBBO" || data.protocol === "dubbo://") {
|
||||
data.request.protocol = "dubbo://";
|
||||
} else {
|
||||
data.request.protocol = data.protocol;
|
||||
}
|
||||
data.id = data.request.id;
|
||||
if (!data.method) {
|
||||
data.method = data.protocol;
|
||||
}
|
||||
},
|
||||
saveApi(row) {
|
||||
let data = this.api;
|
||||
data.name = this.apiCase.name;
|
||||
this.setParameters(data);
|
||||
let bodyFiles = this.getBodyUploadFiles(data);
|
||||
this.$fileUpload("/api/definition/create", null, bodyFiles, data, () => {
|
||||
if (row) {
|
||||
this.api.saved = false;
|
||||
this.saveCase(row);
|
||||
}
|
||||
});
|
||||
},
|
||||
saveCase(row) {
|
||||
let tmp = JSON.parse(JSON.stringify(row));
|
||||
this.isShowInput = false;
|
||||
if (this.validate(tmp)) {
|
||||
|
@ -267,6 +292,14 @@
|
|||
}
|
||||
});
|
||||
},
|
||||
saveTestCase(row) {
|
||||
if (this.api.saved) {
|
||||
this.saveApi(row);
|
||||
} else {
|
||||
this.saveCase(row);
|
||||
}
|
||||
|
||||
},
|
||||
showInput(row) {
|
||||
// row.type = "create";
|
||||
this.isShowInput = true;
|
||||
|
|
|
@ -144,6 +144,12 @@
|
|||
this.getApiTest(true);
|
||||
this.visible = true;
|
||||
},
|
||||
saveApiAndCase(api) {
|
||||
this.visible = true;
|
||||
this.api = api;
|
||||
console.log(api)
|
||||
this.addCase();
|
||||
},
|
||||
setEnvironment(environment) {
|
||||
this.environment = environment;
|
||||
},
|
||||
|
|
|
@ -26,6 +26,9 @@
|
|||
<div v-if="scenario">
|
||||
<el-button style="float: right;margin: 20px" type="primary" @click="handleCommand('save_as')"> {{$t('commons.save')}}</el-button>
|
||||
</div>
|
||||
<!-- 加载用例 -->
|
||||
<ms-api-case-list :loaded="false" ref="caseList"/>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
@ -40,10 +43,11 @@
|
|||
import MsRequestResultTail from "../response/RequestResultTail";
|
||||
import MsBasisParameters from "../request/dubbo/BasisParameters";
|
||||
import MsJmxStep from "../step/JmxStep";
|
||||
import MsApiCaseList from "../case/ApiCaseList";
|
||||
|
||||
export default {
|
||||
name: "ApiConfig",
|
||||
components: {MsRequestResultTail, MsResponseResult, MsRequestMetric, MsResponseText, MsRun, MsBasisParameters, MsJmxStep},
|
||||
components: {MsRequestResultTail, MsResponseResult, MsRequestMetric, MsResponseText, MsRun, MsBasisParameters, MsJmxStep, MsApiCaseList},
|
||||
props: {
|
||||
currentProtocol: String,
|
||||
scenario: Boolean,
|
||||
|
@ -120,7 +124,11 @@
|
|||
saveAs() {
|
||||
let obj = {request: this.request};
|
||||
obj.request.id = getUUID();
|
||||
this.$emit('saveAs', obj);
|
||||
obj.saved = true;
|
||||
obj.protocol = this.currentProtocol;
|
||||
obj.status = "Underway";
|
||||
obj.method = this.currentProtocol;
|
||||
this.$refs.caseList.saveApiAndCase(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,6 +41,8 @@
|
|||
<div v-if="scenario">
|
||||
<el-button style="float: right;margin: 20px" type="primary" @click="handleCommand('save_as')"> {{$t('commons.save')}}</el-button>
|
||||
</div>
|
||||
<!-- 加载用例 -->
|
||||
<ms-api-case-list :loaded="false" ref="caseList"/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
@ -56,10 +58,11 @@
|
|||
import MsRequestResultTail from "../response/RequestResultTail";
|
||||
import MsJmxStep from "../step/JmxStep";
|
||||
import {KeyValue} from "../../model/ApiTestModel";
|
||||
import MsApiCaseList from "../case/ApiCaseList";
|
||||
|
||||
export default {
|
||||
name: "ApiConfig",
|
||||
components: {MsRequestResultTail, MsResponseResult, MsApiRequestForm, MsRequestMetric, MsResponseText, MsRun, MsJmxStep},
|
||||
components: {MsRequestResultTail, MsResponseResult, MsApiRequestForm, MsRequestMetric, MsResponseText, MsRun, MsJmxStep, MsApiCaseList},
|
||||
props: {
|
||||
currentProtocol: String,
|
||||
testCase: {},
|
||||
|
@ -92,6 +95,7 @@
|
|||
runData: [],
|
||||
reportId: "",
|
||||
reqOptions: REQ_METHOD,
|
||||
createCase: "",
|
||||
request: {},
|
||||
}
|
||||
},
|
||||
|
@ -156,13 +160,17 @@
|
|||
saveAs() {
|
||||
this.$refs['debugForm'].validate((valid) => {
|
||||
if (valid) {
|
||||
this.debugForm.id = null;
|
||||
this.request.id = getUUID();
|
||||
this.request.method = this.debugForm.method;
|
||||
this.request.path = this.debugForm.path;
|
||||
this.protocol = this.currentProtocol;
|
||||
this.debugForm.id = this.request.id;
|
||||
this.debugForm.request = this.request;
|
||||
this.debugForm.userId = getCurrentUser().id;
|
||||
this.debugForm.status = "Underway";
|
||||
this.debugForm.protocol = this.currentProtocol;
|
||||
this.$emit('saveAs', this.debugForm);
|
||||
this.debugForm.saved = true;
|
||||
this.$refs.caseList.saveApiAndCase(this.debugForm);
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
|
@ -170,10 +178,13 @@
|
|||
})
|
||||
},
|
||||
urlChange() {
|
||||
if (!this.debugForm.url || this.debugForm.url.indexOf('?') === -1) return;
|
||||
if (!this.debugForm.url) return;
|
||||
let url = this.getURL(this.addProtocol(this.debugForm.url));
|
||||
if (url) {
|
||||
this.debugForm.url = decodeURIComponent(this.debugForm.url.substr(0, this.debugForm.url.indexOf("?")));
|
||||
if (this.debugForm.url.indexOf('?') != -1) {
|
||||
this.debugForm.url = decodeURIComponent(this.debugForm.url.substr(0, this.debugForm.url.indexOf("?")));
|
||||
}
|
||||
this.debugForm.path = url.pathname;
|
||||
}
|
||||
},
|
||||
addProtocol(url) {
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
<div v-if="scenario">
|
||||
<el-button style="float: right;margin: 20px" type="primary" @click="handleCommand('save_as')"> {{$t('commons.save')}}</el-button>
|
||||
</div>
|
||||
<!-- 加载用例 -->
|
||||
<ms-api-case-list :loaded="false" ref="caseList"/>
|
||||
|
||||
</div>
|
||||
|
||||
|
@ -43,10 +45,11 @@
|
|||
import MsRequestResultTail from "../response/RequestResultTail";
|
||||
import MsBasisParameters from "../request/database/BasisParameters";
|
||||
import MsJmxStep from "../step/JmxStep";
|
||||
import MsApiCaseList from "../case/ApiCaseList";
|
||||
|
||||
export default {
|
||||
name: "ApiConfig",
|
||||
components: {MsRequestResultTail, MsResponseResult, MsRequestMetric, MsResponseText, MsRun, MsBasisParameters, MsJmxStep},
|
||||
components: {MsRequestResultTail, MsResponseResult, MsRequestMetric, MsResponseText, MsRun, MsBasisParameters, MsJmxStep,MsApiCaseList},
|
||||
props: {
|
||||
currentProtocol: String,
|
||||
scenario: Boolean,
|
||||
|
@ -123,7 +126,11 @@
|
|||
saveAs() {
|
||||
let obj = {request: this.request};
|
||||
obj.request.id = getUUID();
|
||||
this.$emit('saveAs', obj);
|
||||
obj.saved = true;
|
||||
obj.protocol = this.currentProtocol;
|
||||
obj.status = "Underway";
|
||||
obj.method = this.currentProtocol;
|
||||
this.$refs.caseList.saveApiAndCase(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,6 +37,9 @@
|
|||
<div v-if="scenario">
|
||||
<el-button style="float: right;margin: 20px" type="primary" @click="handleCommand('save_as')"> {{$t('commons.save')}}</el-button>
|
||||
</div>
|
||||
<!-- 加载用例 -->
|
||||
<ms-api-case-list :loaded="false" ref="caseList"/>
|
||||
|
||||
</div>
|
||||
|
||||
</template>
|
||||
|
@ -53,13 +56,15 @@
|
|||
import MsRequestResultTail from "../response/RequestResultTail";
|
||||
import TcpBasisParameters from "../request/tcp/TcpBasisParameters";
|
||||
import MsJmxStep from "../step/JmxStep";
|
||||
import MsApiCaseList from "../case/ApiCaseList";
|
||||
|
||||
export default {
|
||||
name: "ApiConfig",
|
||||
components: {
|
||||
MsJmxStep,
|
||||
TcpBasisParameters,
|
||||
MsRequestResultTail, MsResponseResult, MsApiRequestForm, MsRequestMetric, MsResponseText, MsRun},
|
||||
MsRequestResultTail, MsResponseResult, MsApiRequestForm, MsRequestMetric, MsResponseText, MsRun, MsApiCaseList
|
||||
},
|
||||
props: {
|
||||
currentProtocol: String,
|
||||
scenario: Boolean,
|
||||
|
@ -135,8 +140,16 @@
|
|||
},
|
||||
saveAs() {
|
||||
let obj = {request: this.request};
|
||||
obj.request.server = this.debugForm.server;
|
||||
obj.request.port = this.debugForm.port;
|
||||
obj.server = this.debugForm.server;
|
||||
obj.port = this.debugForm.port;
|
||||
obj.request.id = getUUID();
|
||||
this.$emit('saveAs', obj);
|
||||
obj.saved = true;
|
||||
obj.protocol = this.currentProtocol;
|
||||
obj.status = "Underway";
|
||||
obj.method = this.currentProtocol;
|
||||
this.$refs.caseList.saveApiAndCase(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue