从接口测试 创建 性能测试

This commit is contained in:
q4speed 2020-05-29 14:57:19 +08:00
parent edea4644ce
commit 11979fd663
7 changed files with 106 additions and 44 deletions

View File

@ -1,32 +1,28 @@
<template>
<div class="relate_report">
<el-button type="success" plain @click="search">{{$t('api_report.title')}}</el-button>
<el-dialog :title="$t('api_report.title')" :visible.sync="reportVisible">
<el-table :data="tableData" v-loading="result.loading">
<el-table-column :label="$t('commons.name')" width="150" show-overflow-tooltip>
<template v-slot:default="scope">
<el-link type="info" @click="link(scope.row)">{{ scope.row.name }}</el-link>
</template>
</el-table-column>
<el-table-column width="250" :label="$t('commons.create_time')">
<template v-slot:default="scope">
<span>{{ scope.row.createTime | timestampFormatDate }}</span>
</template>
</el-table-column>
<el-table-column width="250" :label="$t('commons.update_time')">
<template v-slot:default="scope">
<span>{{ scope.row.updateTime | timestampFormatDate }}</span>
</template>
</el-table-column>
<el-table-column prop="status" :label="$t('commons.status')">
<template v-slot:default="{row}">
<ms-api-report-status :row="row"/>
</template>
</el-table-column>
</el-table>
</el-dialog>
</div>
<el-dialog :title="$t('api_report.title')" :visible.sync="reportVisible">
<el-table :data="tableData" v-loading="result.loading">
<el-table-column :label="$t('commons.name')" width="150" show-overflow-tooltip>
<template v-slot:default="scope">
<el-link type="info" @click="link(scope.row)">{{ scope.row.name }}</el-link>
</template>
</el-table-column>
<el-table-column width="250" :label="$t('commons.create_time')">
<template v-slot:default="scope">
<span>{{ scope.row.createTime | timestampFormatDate }}</span>
</template>
</el-table-column>
<el-table-column width="250" :label="$t('commons.update_time')">
<template v-slot:default="scope">
<span>{{ scope.row.updateTime | timestampFormatDate }}</span>
</template>
</el-table-column>
<el-table-column prop="status" :label="$t('commons.status')">
<template v-slot:default="{row}">
<ms-api-report-status :row="row"/>
</template>
</el-table-column>
</el-table>
</el-dialog>
</template>
<script>
@ -49,7 +45,7 @@
},
methods: {
search() {
open() {
this.reportVisible = true;
let url = "/api/report/list/" + this.testId;
@ -69,7 +65,4 @@
</script>
<style scoped>
.relate_report {
margin-left: 10px;
}
</style>

View File

@ -27,7 +27,19 @@
<el-button type="warning" plain @click="cancel">{{$t('commons.cancel')}}</el-button>
<ms-api-report-dialog :test-id="id" v-if="test.status === 'Completed'"/>
<el-dropdown trigger="click" @command="handleCommand">
<el-button class="el-dropdown-link more" icon="el-icon-more" plain/>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="report" v-if="test.status === 'Completed'">
{{$t('api_report.title')}}
</el-dropdown-item>
<el-dropdown-item command="performance">
{{$t('api_test.create_performance_test')}}
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
<ms-api-report-dialog :test-id="id" ref="reportDialog"/>
</el-row>
</el-header>
<ms-api-scenario-config :scenarios="test.scenarioDefinition" ref="config"/>
@ -72,7 +84,7 @@
},
methods: {
init: function () {
init() {
this.result = this.$get("/project/listAll", response => {
this.projects = response.data;
})
@ -87,7 +99,7 @@
}
}
},
getTest: function (id) {
getTest(id) {
this.result = this.$get("/api/get/" + id, response => {
if (response.data) {
let item = response.data;
@ -103,7 +115,7 @@
}
});
},
save: function (callback) {
save(callback) {
this.change = false;
let url = this.create ? "/api/create" : "/api/update";
this.result = this.$request(this.getOptions(url), () => {
@ -111,7 +123,7 @@
if (callback) callback();
});
},
saveTest: function () {
saveTest() {
this.save(() => {
this.$success(this.$t('commons.save_success'));
if (this.create) {
@ -121,7 +133,7 @@
}
})
},
runTest: function () {
runTest() {
this.result = this.$post("/api/run", {id: this.test.id}, (response) => {
this.$success(this.$t('api_test.running'));
this.$router.push({
@ -129,7 +141,7 @@
})
});
},
saveRunTest: function () {
saveRunTest() {
this.change = false;
this.save(() => {
@ -137,11 +149,11 @@
this.runTest();
})
},
cancel: function () {
cancel() {
// console.log(this.test.toJMX().xml)
this.$router.push('/api/test/list/all');
},
getOptions: function (url) {
getOptions(url) {
let formData = new FormData();
let request = {
id: this.test.id,
@ -166,6 +178,23 @@
'Content-Type': undefined
}
};
},
handleCommand(command) {
switch (command) {
case "report":
this.$refs.reportDialog.open();
break;
case "performance":
this.$store.commit('setTest', {
projectId: this.test.projectId,
name: this.test.name,
jmx: this.test.toJMX()
})
this.$router.push({
path: "/performance/test/create"
})
break;
}
}
},
@ -199,4 +228,8 @@
.test-project {
min-width: 150px;
}
.test-container .more {
margin-left: 10px;
}
</style>

View File

@ -115,7 +115,23 @@
this.listProjects();
},
mounted() {
this.importAPITest();
},
methods: {
importAPITest() {
let apiTest = this.$store.state.api.test;
if (apiTest && apiTest.name) {
this.testPlan.projectId = apiTest.projectId;
this.testPlan.name = apiTest.name;
let blob = new Blob([apiTest.jmx.xml], {type: "application/octet-stream"});
let file = new File([blob], apiTest.jmx.name);
this.$refs.basicConfig.beforeUpload(file);
this.$refs.basicConfig.handleUpload({file: file});
this.active = '1';
this.$store.commit("clearTest");
}
},
listProjects() {
this.result = this.$get(this.listProjectPath, response => {
this.projects = response.data;

View File

@ -3,7 +3,24 @@ import Vuex from 'vuex'
Vue.use(Vuex);
const API = {
state: {
test: {}
},
mutations: {
setTest(state, test) {
state.test = test;
},
clearTest(state) {
state.test = {};
}
},
actions: {},
getters: {}
}
export default new Vuex.Store({})
export default new Vuex.Store({
modules: {
api: API
}
})

View File

@ -262,6 +262,7 @@ export default {
copied: "copied",
key: "Key",
value: "Value",
create_performance_test: "Create Performance Test",
scenario: {
config: "Scenario Config",
input_name: "Please enter the scenario name",

View File

@ -259,6 +259,7 @@ export default {
copied: "已拷贝",
key: "键",
value: "值",
create_performance_test: "创建性能测试",
scenario: {
config: "场景配置",
input_name: "请输入场景名称",

View File

@ -260,6 +260,7 @@ export default {
copied: "已拷貝",
key: "鍵",
value: "值",
create_performance_test: "創建性能測試",
scenario: {
creator: "創建人",
config: "場景配寘",