run button

This commit is contained in:
q4speed 2020-04-23 17:08:48 +08:00
parent 39fc93946b
commit 1294739df6
5 changed files with 44 additions and 16 deletions

View File

@ -60,9 +60,9 @@ public class APITestController {
public void delete(@RequestBody DeleteAPITestRequest request) { public void delete(@RequestBody DeleteAPITestRequest request) {
apiTestService.delete(request); apiTestService.delete(request);
} }
//
// @PostMapping("/run") @PostMapping("/run")
// public void run(@RequestBody RunTestPlanRequest request) { public void run(@RequestBody SaveAPITestRequest request) {
// apiTestService.run(request); apiTestService.run(request);
// } }
} }

View File

@ -66,6 +66,10 @@ public class ApiTestService {
apiTestMapper.deleteByPrimaryKey(request.getId()); apiTestMapper.deleteByPrimaryKey(request.getId());
} }
public void run(SaveAPITestRequest request) {
save(request);
}
private ApiTestWithBLOBs updateTest(SaveAPITestRequest request) { private ApiTestWithBLOBs updateTest(SaveAPITestRequest request) {
final ApiTestWithBLOBs test = new ApiTestWithBLOBs(); final ApiTestWithBLOBs test = new ApiTestWithBLOBs();
test.setId(request.getId()); test.setId(request.getId());

View File

@ -11,7 +11,15 @@
<el-option v-for="project in projects" :key="project.id" :label="project.name" :value="project.id"/> <el-option v-for="project in projects" :key="project.id" :label="project.name" :value="project.id"/>
</el-select> </el-select>
</el-input> </el-input>
<el-button type="primary" plain :disabled="isDisabled" @click="saveTest">{{$t('commons.save')}}</el-button>
<el-button type="primary" plain :disabled="isDisabled" @click="saveTest">
{{$t('commons.save')}}
</el-button>
<el-button type="primary" plain :disabled="isDisabled" @click="runTest">
{{$t('load_test.save_and_run')}}
</el-button>
<el-button type="warning" plain @click="clear">{{$t('commons.cancel')}}</el-button>
</el-row> </el-row>
</el-header> </el-header>
<ms-api-scenario-config :scenarios="test.scenarioDefinition" ref="config"/> <ms-api-scenario-config :scenarios="test.scenarioDefinition" ref="config"/>
@ -43,7 +51,7 @@
watch: { watch: {
'$route'(to) { '$route'(to) {
if (to.params.type === "edit") { if (to.query.id) {
this.getTest(to.query.id); this.getTest(to.query.id);
} else { } else {
this.test = new Test(); this.test = new Test();
@ -75,20 +83,35 @@
saveTest: function () { saveTest: function () {
this.change = false; this.change = false;
let param = { this.result = this.$post("/api/save", this.getParam(), response => {
id: this.test.id,
projectId: this.test.projectId,
name: this.test.name,
scenarioDefinition: JSON.stringify(this.test.scenarioDefinition)
}
this.result = this.$post("/api/save", param, response => {
this.test.id = response.data; this.test.id = response.data;
this.$message({ this.$message({
message: this.$t('commons.save_success'), message: this.$t('commons.save_success'),
type: 'success' type: 'success'
}); });
}); });
},
runTest: function () {
this.change = false;
this.result = this.$post("/api/run", this.getParam(), response => {
this.test.id = response.data;
this.$message({
message: this.$t('commons.save_success'),
type: 'success'
});
});
},
clear: function () {
this.test = new Test();
},
getParam: function () {
return {
id: this.test.id,
projectId: this.test.projectId,
name: this.test.name,
scenarioDefinition: JSON.stringify(this.test.scenarioDefinition)
}
} }
}, },

View File

@ -4,7 +4,7 @@
<el-card> <el-card>
<template v-slot:header> <template v-slot:header>
<ms-table-header :condition.sync="condition" @search="search" :title="$t('commons.test')" <ms-table-header :condition.sync="condition" @search="search" :title="$t('commons.test')"
@create="create"/> @create="create" :createTip="$t('load_test.create')"/>
</template> </template>
<el-table :data="tableData" class="test-content"> <el-table :data="tableData" class="test-content">
<el-table-column <el-table-column

View File

@ -171,6 +171,7 @@ export default {
'resource_pool_is_null': '资源池为空', 'resource_pool_is_null': '资源池为空',
}, },
api_test: { api_test: {
save_and_run: "保存并执行",
input_name: "请输入测试名称", input_name: "请输入测试名称",
select_project: "请选择项目", select_project: "请选择项目",
scenario: { scenario: {