增加失败场景

This commit is contained in:
q4speed 2020-05-22 17:49:48 +08:00
parent b2f6866237
commit 063e3ec03d
8 changed files with 114 additions and 88 deletions

View File

@ -5,34 +5,22 @@
<section class="report-container" v-if="this.report.testId"> <section class="report-container" v-if="this.report.testId">
<header class="report-header"> <header class="report-header">
<span>{{report.projectName}} / </span> <span>{{report.projectName}} / </span>
<router-link :to="path">{{report.testName}} [{{report.createTime | timestampFormatDate}}]</router-link> <router-link :to="path">{{report.testName}}</router-link>
<span class="time">{{report.createTime | timestampFormatDate}}</span>
</header> </header>
<main v-if="this.isCompleted"> <main v-if="this.isCompleted">
<div class="scenario-chart"> <ms-metric-chart :content="content"/>
<ms-metric-chart :content="content"></ms-metric-chart> <el-tabs v-model="activeName">
</div> <el-tab-pane :label="$t('api_report.total')" name="total">
<el-card> <ms-scenario-results :scenarios="content.scenarios"/>
<div class="scenario-header"> </el-tab-pane>
<el-row :gutter="10"> <el-tab-pane name="fail">
<el-col :span="16"> <template slot="label">
{{$t('api_report.scenario_name')}} <span class="fail">{{$t('api_report.fail')}}</span>
</el-col> </template>
<el-col :span="2"> <ms-scenario-results :scenarios="fails"/>
{{$t('api_report.response_time')}} </el-tab-pane>
</el-col> </el-tabs>
<el-col :span="2">
{{$t('api_report.error')}}
</el-col>
<el-col :span="2">
{{$t('api_report.assertions')}}
</el-col>
<el-col :span="2">
{{$t('api_report.result')}}
</el-col>
</el-row>
</div>
<ms-scenario-result v-for="(scenario, index) in content.scenarios" :key="index" :scenario="scenario"/>
</el-card>
</main> </main>
</section> </section>
</el-card> </el-card>
@ -45,23 +33,30 @@
import MsRequestResult from "./components/RequestResult"; import MsRequestResult from "./components/RequestResult";
import MsScenarioResult from "./components/ScenarioResult"; import MsScenarioResult from "./components/ScenarioResult";
import MsMetricChart from "./components/MetricChart"; import MsMetricChart from "./components/MetricChart";
import MsScenarioResults from "./components/ScenarioResults";
export default { export default {
name: "MsApiReportView", name: "MsApiReportView",
components: {MsMetricChart, MsScenarioResult, MsRequestResult}, components: {MsScenarioResults, MsMetricChart, MsScenarioResult, MsRequestResult},
data() { data() {
return { return {
activeName: "total",
content: {}, content: {},
report: {}, report: {},
loading: true loading: true,
fails: []
} }
}, },
methods: { methods: {
getReport() { init() {
this.loading = true; this.loading = true;
this.report = {}; this.report = {};
this.content = {}; this.content = {};
this.fails = [];
},
getReport() {
this.init();
if (this.reportId) { if (this.reportId) {
let url = "/api/report/get/" + this.reportId; let url = "/api/report/get/" + this.reportId;
@ -69,12 +64,32 @@
this.report = response.data || {}; this.report = response.data || {};
if (this.isCompleted) { if (this.isCompleted) {
this.content = JSON.parse(this.report.content); this.content = JSON.parse(this.report.content);
this.getFails();
this.loading = false; this.loading = false;
} else { } else {
setTimeout(this.getReport, 2000) setTimeout(this.getReport, 2000)
} }
}); });
} }
},
getFails() {
if (this.isCompleted) {
this.fails = [];
this.content.scenarios.forEach((scenario) => {
let failScenario = Object.assign({}, scenario);
if (scenario.error > 0) {
this.fails.push(failScenario);
failScenario.requestResults = [];
scenario.requestResults.forEach((request) => {
if (!request.success) {
let failRequest = Object.assign({}, request);
failScenario.requestResults.push(failRequest);
}
})
}
})
}
} }
}, },
@ -99,6 +114,11 @@
} }
} }
</script> </script>
<style>
.report-container .el-tabs__header {
margin-bottom: 1px;
}
</style>
<style scoped> <style scoped>
.report-container { .report-container {
@ -115,11 +135,16 @@
text-decoration: none; text-decoration: none;
} }
.scenario-header { .report-header .time {
border: 1px solid #EBEEF5; color: #909399;
background-color: #F9FCFF; margin-left: 10px;
border-left: 0; }
border-right: 0;
padding: 5px 0; .report-container .fail {
color: #F56C6C;
}
.report-container .is-active .fail {
color: inherit;
} }
</style> </style>

View File

@ -1,9 +1,7 @@
<template> <template>
<el-table :data="assertions" :row-style="getRowStyle" :header-cell-style="getRowStyle"> <el-table :data="assertions" :row-style="getRowStyle" :header-cell-style="getRowStyle">
<el-table-column prop="name" :label="$t('api_report.assertions_name')" width="300"> <el-table-column prop="name" :label="$t('api_report.assertions_name')" width="300"/>
</el-table-column> <el-table-column prop="message" :label="$t('api_report.assertions_error_message')"/>
<el-table-column prop="message" :label="$t('api_report.assertions_error_message')">
</el-table-column>
<el-table-column prop="pass" :label="$t('api_report.assertions_is_success')" width="180"> <el-table-column prop="pass" :label="$t('api_report.assertions_is_success')" width="180">
<template v-slot:default="{row}"> <template v-slot:default="{row}">
<el-tag size="mini" type="success" v-if="row.pass"> <el-tag size="mini" type="success" v-if="row.pass">

View File

@ -1,29 +0,0 @@
<template>
<div>
<div>
LogDetails
</div>
<div>
</div>
</div>
</template>
<script>
export default {
name: "LogDetails",
data() {
return {
seleniumLog: '',
browserDriverLog: ''
}
},
methods: {
}
}
</script>
<style scoped>
</style>

View File

@ -1,20 +0,0 @@
<template>
<div>
ResultDetails
</div>
</template>
<script>
export default {
name: "ResultDetails"
}
</script>
<style scoped>
#video {
height: 50%;
width: 50%;
}
</style>

View File

@ -0,0 +1,49 @@
<template>
<el-card>
<div class="scenario-header">
<el-row :gutter="10">
<el-col :span="16">
{{$t('api_report.scenario_name')}}
</el-col>
<el-col :span="2">
{{$t('api_report.response_time')}}
</el-col>
<el-col :span="2">
{{$t('api_report.error')}}
</el-col>
<el-col :span="2">
{{$t('api_report.assertions')}}
</el-col>
<el-col :span="2">
{{$t('api_report.result')}}
</el-col>
</el-row>
</div>
<ms-scenario-result v-for="(scenario, index) in scenarios" :key="index" :scenario="scenario"/>
</el-card>
</template>
<script>
import MsScenarioResult from "./ScenarioResult";
export default {
name: "MsScenarioResults",
components: {MsScenarioResult},
props: {
scenarios: Array
}
}
</script>
<style scoped>
.scenario-header {
border: 1px solid #EBEEF5;
background-color: #F9FCFF;
border-left: 0;
border-right: 0;
padding: 5px 0;
}
</style>

View File

@ -332,6 +332,7 @@ export default {
result: "Result", result: "Result",
success: "Success", success: "Success",
fail: "Fail", fail: "Fail",
total: "Total",
test_name: "Test" test_name: "Test"
}, },
test_track: { test_track: {

View File

@ -329,6 +329,7 @@ export default {
result: "结果", result: "结果",
success: "成功", success: "成功",
fail: "失败", fail: "失败",
total: "全部",
test_name: "所属测试" test_name: "所属测试"
}, },
test_track: { test_track: {

View File

@ -323,6 +323,7 @@ export default {
result: "結果", result: "結果",
success: "成功", success: "成功",
fail: "失敗", fail: "失敗",
total: "全部",
test_name: "所屬測試" test_name: "所屬測試"
}, },
test_track: { test_track: {