Merge remote-tracking branch 'origin/master'

This commit is contained in:
song.tianyang 2020-12-22 19:04:29 +08:00
commit cac54095aa
9 changed files with 121 additions and 104 deletions

View File

@ -84,7 +84,7 @@
<if test="request.moduleId != null"> <if test="request.moduleId != null">
AND api_scenario_module_id = #{request.moduleId} AND api_scenario_module_id = #{request.moduleId}
</if> </if>
and scenario_definition like CONCAT('%', #{request.id},'%') and scenario_definition like CONCAT('%', #{request.id},'%') and id != #{request.id}
</where> </where>
</select> </select>

View File

@ -1,5 +1,5 @@
<template> <template>
<el-dialog :close-on-click-modal="false" :title="$t('api_test.automation.case_ref')" :visible.sync="visible" <el-dialog :close-on-click-modal="false" :title="$t('api_test.automation.scenario_ref')" :visible.sync="visible"
width="45%" :destroy-on-close="true"> width="45%" :destroy-on-close="true">
<span>{{ $t('api_test.automation.scenario_ref') }}</span> <span>{{ $t('api_test.automation.scenario_ref') }}</span>
<div class="refs" v-loading="scenarioLoading"> <div class="refs" v-loading="scenarioLoading">

View File

@ -88,6 +88,9 @@
} else { } else {
this.request = JSON.parse(this.currentApi.request); this.request = JSON.parse(this.currentApi.request);
} }
if (!this.request.headers) {
this.request.headers = [];
}
this.currentApi.request = this.request; this.currentApi.request = this.request;
return true; return true;
} }
@ -135,6 +138,9 @@
if (!this.request.hashTree) { if (!this.request.hashTree) {
this.request.hashTree = []; this.request.hashTree = [];
} }
if (!this.request.body.binary) {
this.request.body.binary = [];
}
// //
if (this.response.body) { if (this.response.body) {
let body = new Body(); let body = new Body();
@ -145,6 +151,9 @@
if (!body.kvs) { if (!body.kvs) {
body.kvs = []; body.kvs = [];
} }
if (!body.binary) {
body.binary = [];
}
this.response.body = body; this.response.body = body;
} }
if (this.currentApi.moduleId && this.currentApi.moduleId === "root") { if (this.currentApi.moduleId && this.currentApi.moduleId === "root") {

View File

@ -1,5 +1,5 @@
<template> <template>
<div style="min-width: 1000px;margin-bottom: 20px"> <div style="min-width: 1200px;margin-bottom: 20px">
<el-radio-group v-model="body.type" size="mini"> <el-radio-group v-model="body.type" size="mini">
<el-radio :disabled="isReadOnly" :label="type.FORM_DATA" @change="modeChange"> <el-radio :disabled="isReadOnly" :label="type.FORM_DATA" @change="modeChange">
{{ $t('api_test.definition.request.body_form_data') }} {{ $t('api_test.definition.request.body_form_data') }}

View File

@ -16,7 +16,7 @@
@click="active(apiCase)"/> @click="active(apiCase)"/>
<el-input v-if="!apiCase.id || isShowInput" size="small" v-model="apiCase.name" :name="index" :key="index" <el-input v-if="!apiCase.id || isShowInput" size="small" v-model="apiCase.name" :name="index" :key="index"
class="ms-api-header-select" style="width: 180px" class="ms-api-header-select" style="width: 180px"
@blur="saveTestCase(apiCase)"/> @blur="saveTestCase(apiCase)" placeholder="请输入用例名称"/>
<span v-else> <span v-else>
{{apiCase.id ? apiCase.name:''}} {{apiCase.id ? apiCase.name:''}}
<i class="el-icon-edit" style="cursor:pointer" @click="showInput(apiCase)"/> <i class="el-icon-edit" style="cursor:pointer" @click="showInput(apiCase)"/>
@ -149,7 +149,7 @@
this.$emit('singleRun', data); this.$emit('singleRun', data);
}, },
copyCase(data) { copyCase(data) {
let obj = {name: "copy_" + data.name, priority: data.priority, active: false, request: data.request}; let obj = {name: "copy_" + data.name, priority: data.priority, active: true, request: data.request};
this.$emit('copyCase', obj); this.$emit('copyCase', obj);
}, },
@ -182,6 +182,7 @@
} }
let bodyFiles = this.getBodyUploadFiles(row); let bodyFiles = this.getBodyUploadFiles(row);
row.projectId = getCurrentProjectID(); row.projectId = getCurrentProjectID();
row.active = true;
row.apiDefinitionId = row.apiDefinitionId || this.api.id; row.apiDefinitionId = row.apiDefinitionId || this.api.id;
let url = "/api/testcase/create"; let url = "/api/testcase/create";
if (row.id) { if (row.id) {

View File

@ -187,7 +187,7 @@
} else { } else {
request = JSON.parse(this.api.request); request = JSON.parse(this.api.request);
} }
let obj = {apiDefinitionId: this.api.id, name: '', priority: 'P0', active: false}; let obj = {apiDefinitionId: this.api.id, name: '', priority: 'P0', active: true};
obj.request = request; obj.request = request;
this.apiCaseList.unshift(obj); this.apiCaseList.unshift(obj);
} }

View File

@ -1,119 +1,126 @@
<template> <template>
<div v-loading="result.loading"> <div v-loading="result.loading">
<el-tabs type="border-card" :stretch="true"> <el-tabs type="border-card" :stretch="true" @tab-click="selectTab">
<el-tab-pane v-for="item in resource" :key="item.resourceId" :label="item.resourceName" class="logging-content"> <el-tab-pane v-for="item in resource" :key="item.resourceId" :label="item.resourceName" class="logging-content">
<ul class="infinite-list" v-infinite-scroll="load(item.resourceId)" infinite-scroll-disabled="disabled"> <ul class="infinite-list" v-infinite-scroll="load(item.resourceId)" infinite-scroll-disabled="disabled">
<li class="infinite-list-item" v-for="(log, index) in logContent" :key="index">{{ log.content }}</li> <li class="infinite-list-item" v-for="(log, index) in logContent" :key="index">{{ log.content }}</li>
</ul> </ul>
<el-link type="primary" @click="downloadLogFile(item)">{{$t('load_test.download_log_file')}}</el-link> <el-link type="primary" @click="downloadLogFile(item)">{{ $t('load_test.download_log_file') }}</el-link>
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
</div> </div>
</template> </template>
<script> <script>
export default { export default {
name: "LogDetails", name: "LogDetails",
data() { data() {
return { return {
resource: [], resource: [],
logContent: [], logContent: [],
result: {}, result: {},
id: '', id: '',
page: 1, page: 1,
pageCount: 5, pageCount: 5,
loading: false, loading: false,
} }
}, },
computed: { computed: {
disabled() { disabled() {
return this.loading || this.page > this.pageCount; return this.loading || this.page > this.pageCount;
} }
}, },
methods: { methods: {
getResource() { getResource() {
this.result = this.$get("/performance/report/log/resource/" + this.id, data => { this.result = this.$get("/performance/report/log/resource/" + this.id, data => {
this.resource = data.data; this.resource = data.data;
this.page = 1; this.page = 1;
this.logContent = []; this.logContent = [];
}) })
},
load(resourceId) {
if (this.loading || this.page > this.pageCount) return;
this.loading = true;
let url = "/performance/report/log/" + this.id + "/" + resourceId + "/" + this.page;
this.$get(url, res => {
let data = res.data;
data.listObject.forEach(log => {
this.logContent.push(log);
})
this.page++;
this.loading = false;
})
},
downloadLogFile(item) {
let config = {
url: '/performance/report/log/download/' + this.id + '/' + item.resourceId,
method: 'get',
responseType: 'blob'
};
this.result = this.$request(config).then(response => {
const filename = 'jmeter.log'
const blob = new Blob([response.data]);
if ("download" in document.createElement("a")) {
// IE
// chrome/firefox
let aTag = document.createElement('a');
aTag.download = filename;
aTag.href = URL.createObjectURL(blob);
aTag.click();
URL.revokeObjectURL(aTag.href)
} else {
// IE10+
navigator.msSaveBlob(blob, filename);
}
});
}
}, },
watch: { load(resourceId) {
report: { if (this.loading || this.page > this.pageCount) return;
handler(val) { this.loading = true;
if (!val.status || !val.id) { let url = "/performance/report/log/" + this.id + "/" + resourceId + "/" + this.page;
return; this.$get(url, res => {
} let data = res.data;
let status = val.status; data.listObject.forEach(log => {
this.id = val.id; this.logContent.push(log);
if (status === "Completed" || status === "Running") { })
this.getResource(); this.page++;
} else { this.loading = false;
this.resource = []; })
}
},
deep: true
}
}, },
props: ['report'] selectTab(tab) {
} let resourceId = tab.$vnode.key;
this.loading = false;
this.page = 1;
this.logContent = [];
this.load(resourceId);
},
downloadLogFile(item) {
let config = {
url: '/performance/report/log/download/' + this.id + '/' + item.resourceId,
method: 'get',
responseType: 'blob'
};
this.result = this.$request(config).then(response => {
const filename = 'jmeter.log'
const blob = new Blob([response.data]);
if ("download" in document.createElement("a")) {
// IE
// chrome/firefox
let aTag = document.createElement('a');
aTag.download = filename;
aTag.href = URL.createObjectURL(blob);
aTag.click();
URL.revokeObjectURL(aTag.href)
} else {
// IE10+
navigator.msSaveBlob(blob, filename);
}
});
}
},
watch: {
report: {
handler(val) {
if (!val.status || !val.id) {
return;
}
let status = val.status;
this.id = val.id;
if (status === "Completed" || status === "Running") {
this.getResource();
} else {
this.resource = [];
}
},
deep: true
}
},
props: ['report']
}
</script> </script>
<style scoped> <style scoped>
.logging-content { .logging-content {
white-space: pre-line; white-space: pre-line;
overflow: auto; overflow: auto;
} }
.infinite-list { .infinite-list {
height: 500px; height: 500px;
padding: 0; padding: 0;
margin: 0; margin: 0;
list-style: none; list-style: none;
overflow: auto overflow: auto
} }
.infinite-list-item { .infinite-list-item {
overflow: hidden; overflow: hidden;
} }
</style> </style>

View File

@ -4,7 +4,7 @@
<meta charset="utf-8"> <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0"> <meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico"> <link rel="shortcut icon" href="<%= BASE_URL %>favicon.ico">
<title>MeterSphere</title> <title>MeterSphere</title>
</head> </head>
<body> <body>

View File

@ -4,7 +4,7 @@
<meta charset="utf-8"> <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0"> <meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico"> <link rel="shortcut icon" href="<%= BASE_URL %>favicon.ico">
<title>MeterSphere</title> <title>MeterSphere</title>
</head> </head>
<body> <body>