feat(测试跟踪): 保存评审结果

This commit is contained in:
shiziyuan9527 2020-09-19 11:52:49 +08:00
parent 3135bf3406
commit b9579d61a0
12 changed files with 598 additions and 26 deletions

View File

@ -10,4 +10,5 @@ import java.util.List;
public interface ExtTestReviewCaseMapper {
List<TestReviewCaseDTO> list(@Param("request") QueryCaseReviewRequest request);
List<String> getStatusByReviewId(String planId);
}

View File

@ -180,4 +180,10 @@
</foreach>
</if>
</select>
<select id="getStatusByReviewId" resultType="java.lang.String">
select status
from test_case_review_test_case
where review_id = #{reviewId}
</select>
</mapper>

View File

@ -0,0 +1,5 @@
package io.metersphere.commons.constants;
public enum TestReviewCaseStatus {
Prepare, Pass, UnPass
}

View File

@ -4,7 +4,6 @@ import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import io.metersphere.base.domain.Project;
import io.metersphere.base.domain.TestCaseReview;
import io.metersphere.base.domain.TestPlan;
import io.metersphere.base.domain.User;
import io.metersphere.commons.constants.RoleConstants;
import io.metersphere.commons.utils.PageUtils;
@ -108,4 +107,10 @@ public class TestCaseReviewController {
public TestCaseReview getTestReview(@PathVariable String reviewId) {
return testCaseReviewService.getTestReview(reviewId);
}
@PostMapping("/edit/status/{reviewId}")
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
public void editTestPlanStatus(@PathVariable String reviewId) {
testCaseReviewService.editTestReviewStatus(reviewId);
}
}

View File

@ -2,6 +2,7 @@ package io.metersphere.track.controller;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import io.metersphere.base.domain.TestCaseReviewTestCase;
import io.metersphere.commons.constants.RoleConstants;
import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager;
@ -40,4 +41,15 @@ public class TestReviewTestCaseController {
public void deleteTestCaseBath(@RequestBody TestReviewCaseBatchRequest request) {
testReviewTestCaseService.deleteTestCaseBath(request);
}
@PostMapping("/list/all")
public List<TestReviewCaseDTO> getTestPlanCases(@RequestBody QueryCaseReviewRequest request) {
return testReviewTestCaseService.list(request);
}
@PostMapping("/edit")
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
public void editTestCase(@RequestBody TestCaseReviewTestCase testCaseReviewTestCase) {
testReviewTestCaseService.editTestCase(testCaseReviewTestCase);
}
}

View File

@ -3,7 +3,10 @@ package io.metersphere.track.service;
import io.metersphere.base.domain.*;
import io.metersphere.base.mapper.*;
import io.metersphere.base.mapper.ext.ExtTestCaseReviewMapper;
import io.metersphere.base.mapper.ext.ExtTestReviewCaseMapper;
import io.metersphere.commons.constants.TestCaseReviewStatus;
import io.metersphere.commons.constants.TestPlanStatus;
import io.metersphere.commons.constants.TestPlanTestCaseStatus;
import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.ServiceUtils;
import io.metersphere.commons.utils.SessionUtils;
@ -40,9 +43,9 @@ public class TestCaseReviewService {
@Resource
private UserMapper userMapper;
@Resource
private TestCaseMapper testCaseMapper;
@Resource
SqlSessionFactory sqlSessionFactory;
@Resource
ExtTestReviewCaseMapper extTestReviewCaseMapper;
public void saveTestCaseReview(SaveTestCaseReviewRequest reviewRequest) {
checkCaseReviewExist(reviewRequest);
@ -210,4 +213,20 @@ public class TestCaseReviewService {
public TestCaseReview getTestReview(String reviewId) {
return Optional.ofNullable(testCaseReviewMapper.selectByPrimaryKey(reviewId)).orElse(new TestCaseReview());
}
public void editTestReviewStatus(String reviewId) {
List<String> statusList = extTestReviewCaseMapper.getStatusByReviewId(reviewId);
TestCaseReview testCaseReview = new TestCaseReview();
testCaseReview.setId(reviewId);
for (String status : statusList) {
if (StringUtils.equals(status, TestPlanTestCaseStatus.Prepare.name())) {
testCaseReview.setStatus(TestPlanStatus.Underway.name());
testCaseReviewMapper.updateByPrimaryKeySelective(testCaseReview);
return;
}
}
testCaseReview.setStatus(TestPlanStatus.Completed.name());
testCaseReviewMapper.updateByPrimaryKeySelective(testCaseReview);
}
}

View File

@ -1,8 +1,6 @@
package io.metersphere.track.service;
import io.metersphere.base.domain.TestCaseReviewTestCaseExample;
import io.metersphere.base.domain.TestPlanTestCaseExample;
import io.metersphere.base.domain.User;
import io.metersphere.base.domain.*;
import io.metersphere.base.mapper.TestCaseReviewTestCaseMapper;
import io.metersphere.base.mapper.ext.ExtTestReviewCaseMapper;
import io.metersphere.commons.utils.ServiceUtils;
@ -53,4 +51,11 @@ public class TestReviewTestCaseService {
example.createCriteria().andIdIn(request.getIds());
testCaseReviewTestCaseMapper.deleteByExample(example);
}
public void editTestCase(TestCaseReviewTestCase testCaseReviewTestCase) {
testCaseReviewTestCase.setStatus(testCaseReviewTestCase.getStatus());
testCaseReviewTestCase.setReviewer(SessionUtils.getUser().getId());
testCaseReviewTestCase.setUpdateTime(System.currentTimeMillis());
testCaseReviewTestCaseMapper.updateByPrimaryKeySelective(testCaseReviewTestCase);
}
}

View File

@ -3,6 +3,7 @@
<ms-tag v-if="value == 'Prepare'" type="info" :content="$t('test_track.plan.plan_status_prepare')"/>
<ms-tag v-if="value == 'Underway'" type="primary" :content="$t('test_track.plan.plan_status_running')"/>
<ms-tag v-if="value == 'Pass'" type="success" :content="$t('test_track.plan_view.pass')"/>
<ms-tag v-if="value == 'UnPass'" type="danger" content="未通过"/>
<ms-tag v-if="value == 'Failure'" type="danger" :content="$t('test_track.plan_view.failure')"/>
<ms-tag v-if="value == 'Blocking'" type="warning" :content="$t('test_track.plan_view.blocking')"/>
<ms-tag v-if="value == 'Skip'" type="info" :content="$t('test_track.plan_view.skip')"/>

View File

@ -0,0 +1,45 @@
<template>
<div>
<div class="main">
<review-comment-item/>
</div>
<div>
<el-input
type="textarea"
placeholder="发表评论"
v-model="textarea"
maxlength="60"
show-word-limit
resize="none"
:autosize="{ minRows: 4, maxRows: 4}"
>
</el-input>
<el-button type="primary" size="mini" class="send-btn">发送</el-button>
</div>
</div>
</template>
<script>
import ReviewCommentItem from "./ReviewCommentItem";
export default {
name: "ReviewComment",
components: {ReviewCommentItem},
data() {
return {
commentData: [],
textarea: ''
}
}
}
</script>
<style scoped>
.main {
height: 60vh;
}
.send-btn {
float: right;
margin-top: 5px;
}
</style>

View File

@ -0,0 +1,37 @@
<template>
<div style="height: 60px;">
<div class="comment-left">
<span>
<i class="el-icon-user-solid review-comment-user"/>
</span>
</div>
<div class="comment-right">
张三 <span style="color: #8a8b8d">9月8日</span><br/>
<span>优先级为2</span>
</div>
</div>
</template>
<script>
export default {
name: "ReviewCommentItem"
}
</script>
<style scoped>
.review-comment-user {
font-size: 19px;
}
.comment-left {
float: left;
width: 10%;
height: 100%;
}
.comment-right {
float: left;
width: 90%;
height: 100%;
padding: 0;
line-height: 25px;
}
</style>

View File

@ -1,15 +1,464 @@
<template>
<div>
</div>
<el-drawer
:before-close="handleClose"
:visible.sync="showDialog"
:with-header="false"
:modal-append-to-body="false"
size="100%"
ref="drawer"
v-loading="result.loading">
<template v-slot:default="scope">
<el-row :gutter="10">
<div class="container">
<el-col :span="17">
<el-card>
<el-scrollbar>
<el-header>
<el-row type="flex" class="head-bar">
<el-col :span="12">
<el-button plain size="mini"
icon="el-icon-back"
@click="cancel">{{$t('test_track.return')}}
</el-button>
</el-col>
<el-col :span="12" class="head-right">
<span class="head-right-tip" v-if="index + 1 == testCases.length">
{{$t('test_track.plan_view.pre_case')}} : {{testCases[index - 1] ? testCases[index - 1].name : ''}}
</span>
<span class="head-right-tip" v-if="index + 1 != testCases.length">
{{$t('test_track.plan_view.next_case')}} : {{testCases[index + 1] ? testCases[index + 1].name : ''}}
</span>
<el-button plain size="mini" icon="el-icon-arrow-up"
:disabled="index + 1 <= 1"
@click="handlePre()"/>
<span> {{index + 1}}/{{testCases.length}} </span>
<el-button plain size="mini" icon="el-icon-arrow-down"
:disabled="index + 1 >= testCases.length"
@click="handleNext()"/>
<el-divider direction="vertical"></el-divider>
<el-button type="success" size="mini" :disabled="isReadOnly" plain @click="saveCase('Pass')">
通过
</el-button>
<el-button type="danger" size="mini" :disabled="isReadOnly" plain @click="saveCase('UnPass')">
未通过
</el-button>
</el-col>
</el-row>
<el-row style="margin-top: 0px;">
<el-col>
<el-divider content-position="left">{{testCase.name}}</el-divider>
</el-col>
</el-row>
</el-header>
<div class="case_container">
<el-row>
<el-col :span="4" :offset="1">
<span class="cast_label">{{$t('test_track.case.priority')}}</span>
<span class="cast_item">{{testCase.priority}}</span>
</el-col>
<el-col :span="5">
<span class="cast_label">{{$t('test_track.case.case_type')}}</span>
<span class="cast_item" v-if="testCase.type == 'functional'">{{$t('commons.functional')}}</span>
<span class="cast_item" v-if="testCase.type == 'performance'">{{$t('commons.performance')}}</span>
<span class="cast_item" v-if="testCase.type == 'api'">{{$t('commons.api')}}</span>
</el-col>
</el-row>
<el-row>
<el-col :span="4" :offset="1">
<span class="cast_label">{{$t('test_track.case.method')}}</span>
<span v-if="testCase.method == 'manual'">{{$t('test_track.case.manual')}}</span>
<span v-if="testCase.method == 'auto'">{{$t('test_track.case.auto')}}</span>
</el-col>
<el-col :span="5">
<span class="cast_label">{{$t('test_track.case.module')}}</span>
<span class="cast_item">{{testCase.nodePath}}</span>
</el-col>
<el-col :span="4" :offset="1">
<span class="cast_label">{{$t('test_track.plan.plan_project')}}</span>
<span class="cast_item">{{testCase.projectName}}</span>
</el-col>
</el-row>
<el-row>
<el-col :offset="1">
<span class="cast_label">{{$t('test_track.case.prerequisite')}}</span>
<span class="cast_item">{{testCase.prerequisite}}</span>
</el-col>
</el-row>
<el-row v-if="testCase.method == 'auto' && testCase.testId">
<el-col class="test-detail" :span="20" :offset="1">
<el-tabs v-model="activeTab" type="border-card" @tab-click="testTabChange">
<el-tab-pane name="detail" :label="$t('test_track.plan_view.test_detail')">
<api-test-detail :is-read-only="isReadOnly" v-if="testCase.type == 'api'" @runTest="testRun"
:id="testCase.testId" ref="apiTestDetail"/>
<performance-test-detail :is-read-only="isReadOnly" v-if="testCase.type == 'performance'"
@runTest="testRun" :id="testCase.testId"
ref="performanceTestDetail"/>
</el-tab-pane>
<el-tab-pane name="result" :label="$t('test_track.plan_view.test_result')">
<api-test-result :report-id="testCase.reportId" v-if=" testCase.type == 'api'"
ref="apiTestResult"/>
<performance-test-result :is-read-only="isReadOnly" :report-id="testCase.reportId"
v-if="testCase.type == 'performance'" ref="performanceTestResult"/>
</el-tab-pane>
</el-tabs>
</el-col>
</el-row>
<el-row v-if="testCase.method && testCase.method != 'auto'">
<el-col :span="20" :offset="1">
<div>
<span class="cast_label">{{$t('test_track.case.steps')}}</span>
</div>
<el-table
:data="testCase.steptResults"
class="tb-edit"
size="mini"
:border="true"
:default-sort="{prop: 'num', order: 'ascending'}"
highlight-current-row>
<el-table-column :label="$t('test_track.case.number')" prop="num"
min-width="5%"></el-table-column>
<el-table-column :label="$t('test_track.case.step_desc')" prop="desc" min-width="21%">
<template v-slot:default="scope">
<el-input
size="mini"
class="border-hidden"
type="textarea"
:autosize="{ minRows: 1, maxRows: 4}"
:disabled="true"
v-model="scope.row.desc"/>
</template>
</el-table-column>
<el-table-column :label="$t('test_track.case.expected_results')" prop="result" min-width="21%">
<template v-slot:default="scope">
<el-input
size="mini"
class="border-hidden"
type="textarea"
:autosize="{ minRows: 1, maxRows: 4}"
:disabled="true"
v-model="scope.row.result"/>
</template>
</el-table-column>
<el-table-column :label="$t('test_track.plan_view.actual_result')" min-width="21%">
<template v-slot:default="scope">
<el-input
class="table-edit-input"
size="mini"
type="textarea"
:autosize="{ minRows: 2, maxRows: 4}"
:rows="2"
:disabled="isReadOnly"
v-model="scope.row.actualResult"
:placeholder="$t('commons.input_content')"
clearable/>
</template>
</el-table-column>
<el-table-column :label="$t('test_track.plan_view.step_result')" min-width="12%">
<template v-slot:default="scope">
<el-select
:disabled="isReadOnly"
v-model="scope.row.executeResult"
@change="stepResultChange()"
size="mini">
<el-option :label="$t('test_track.plan_view.pass')" value="Pass"
style="color: #7ebf50;"/>
<el-option :label="$t('test_track.plan_view.failure')" value="Failure"
style="color: #e57471;"/>
<el-option :label="$t('test_track.plan_view.blocking')" value="Blocking"
style="color: #dda451;"/>
<el-option :label="$t('test_track.plan_view.skip')" value="Skip"
style="color: #919399;"/>
</el-select>
</template>
</el-table-column>
</el-table>
</el-col>
</el-row>
<el-row>
<el-col :span="15" :offset="1">
<div>
<span class="cast_label">{{$t('commons.remark')}}</span>
<span v-if="testCase.remark == null || testCase.remark == ''" style="color: darkgrey">{{$t('commons.not_filled')}}</span>
</div>
<div>
<el-input :rows="3"
type="textarea"
v-if="testCase.remark"
disabled
v-model="testCase.remark"/>
</div>
</el-col>
</el-row>
</div>
</el-scrollbar>
</el-card>
</el-col>
<el-col :span="7">
<el-card>
<el-tabs class="system-setting" v-model="activeName">
<el-tab-pane label="评论" name="comment">
<review-comment/>
</el-tab-pane>
</el-tabs>
</el-card>
</el-col>
</div>
</el-row>
</template>
</el-drawer>
</template>
<script>
import PerformanceTestResult from "../../../plan/view/comonents/test/PerformanceTestResult";
import PerformanceTestDetail from "../../../plan/view/comonents/test/PerformanceTestDetail";
import ApiTestResult from "../../../plan/view/comonents/test/ApiTestResult";
import ApiTestDetail from "../../../plan/view/comonents/test/ApiTestDetail";
import TestPlanTestCaseStatusButton from "../../../plan/common/TestPlanTestCaseStatusButton";
import {listenGoBack, removeGoBackListener} from "../../../../../../common/js/utils";
import ReviewComment from "../../commom/ReviewComment";
export default {
name: "TestReviewTestCaseEdit"
name: "TestReviewTestCaseEdit",
components: {
PerformanceTestResult,
PerformanceTestDetail,
ApiTestResult,
ApiTestDetail,
TestPlanTestCaseStatusButton,
ReviewComment
},
data() {
return {
result: {},
showDialog: false,
testCase: {},
index: 0,
testCases: [],
readConfig: {toolbar: []},
test: {},
activeTab: 'detail',
isFailure: true,
users: [],
activeName: 'comment'
};
},
props: {
total: {
type: Number
},
searchParam: {
type: Object
},
isReadOnly: {
type: Boolean,
default: false
}
},
methods: {
handleClose() {
removeGoBackListener(this.handleClose);
this.showDialog = false;
},
cancel() {
this.handleClose();
this.$emit('refreshTable');
},
saveCase(status) {
let param = {};
param.id = this.testCase.id;
param.status = status;
this.$post('/test/review/case/edit', param, () => {
this.$success(this.$t('commons.save_success'));
this.updateTestCases(param);
this.setReviewStatus(this.testCase.reviewId);
});
},
updateTestCases(param) {
for (let i = 0; i < this.testCases.length; i++) {
let testCase = this.testCases[i];
if (testCase.id === param.id) {
testCase.status = param.status;
return;
}
}
},
handleNext() {
this.index++;
this.getTestCase(this.index);
},
handlePre() {
this.index--;
this.getTestCase(this.index);
},
getTestCase(index) {
let testCase = this.testCases[index];
let item = {};
Object.assign(item, testCase);
item.steps = JSON.parse(item.steps);
item.steptResults = [];
for (let i = 0; i < item.steps.length; i++) {
item.steps[i].actualResult = '';
item.steps[i].executeResult = '';
item.steptResults.push(item.steps[i]);
}
this.testCase = item;
this.initTest();
},
openTestCaseEdit(testCase) {
this.showDialog = true;
this.activeTab = 'detail';
listenGoBack(this.handleClose);
this.initData(testCase);
},
initTest() {
this.$nextTick(() => {
if (this.testCase.method == 'auto') {
if (this.$refs.apiTestDetail && this.testCase.type == 'api') {
this.$refs.apiTestDetail.init();
} else if (this.testCase.type == 'performance') {
this.$refs.performanceTestDetail.init();
}
}
});
},
testRun(reportId) {
this.testCase.reportId = reportId;
this.saveReport(reportId);
},
testTabChange(data) {
if (this.testCase.type == 'performance' && data.paneName == 'result') {
this.$refs.performanceTestResult.checkReportStatus();
this.$refs.performanceTestResult.init();
}
},
saveReport(reportId) {
this.$post('/test/plan/case/edit', {id: this.testCase.id, reportId: reportId});
},
initData(testCase) {
this.result = this.$post('/test/review/case/list/all', this.searchParam, response => {
this.testCases = response.data;
for (let i = 0; i < this.testCases.length; i++) {
if (this.testCases[i].id === testCase.id) {
this.index = i;
this.getTestCase(i);
this.getRelatedTest();
}
}
});
},
getRelatedTest() {
if (this.testCase.method == 'auto' && this.testCase.testId && this.testCase.testId != 'other') {
console.log(this.testCase.type)
this.$get('/' + this.testCase.type + '/get/' + this.testCase.testId, response => {
let data = response.data;
if (data) {
this.test = data;
} else {
this.test = {};
this.$warning(this.$t("test_track.case.relate_test_not_find"));
}
});
} else if (this.testCase.testId === 'other') {
this.$warning(this.$t("test_track.case.other_relate_test_not_find"));
}
},
setReviewStatus(reviewId) {
this.$post('/test/case/review/edit/status/' + reviewId);
},
stepResultChange() {
if (this.testCase.method == 'manual') {
this.isFailure = this.testCase.steptResults.filter(s => {
return s.executeResult === 'Failure' || s.executeResult === 'Blocking';
}).length > 0;
}
},
}
}
</script>
<style scoped>
.border-hidden >>> .el-textarea__inner {
border-style: hidden;
background-color: white;
color: #606266;
}
.cast_label {
color: dimgray;
}
.status-button {
padding-left: 4%;
}
.head-right {
text-align: right;
}
.el-col:not(.test-detail) {
line-height: 50px;
}
.issues-edit >>> p {
line-height: 16px;
}
.status-button {
float: right;
}
.head-right-tip {
color: darkgrey;
}
.el-scrollbar {
height: 100%;
}
.container {
height: 100vh;
}
.case_container > .el-row {
margin-top: 1%;
}
.el-switch >>> .el-switch__label {
color: dimgray;
}
.el-switch >>> .el-switch__label.is-active {
color: #409EFF;
}
.container >>> .el-card__body {
height: 85vh !important;
}
</style>

View File

@ -146,16 +146,8 @@
<el-dropdown-item :disabled="!isTestManagerOrTestUser" :command="{id: scope.row.id, status: 'Pass'}">
{{$t('test_track.plan_view.pass')}}
</el-dropdown-item>
<el-dropdown-item :disabled="!isTestManagerOrTestUser"
:command="{id: scope.row.id, status: 'Failure'}">
{{$t('test_track.plan_view.failure')}}
</el-dropdown-item>
<el-dropdown-item :disabled="!isTestManagerOrTestUser"
:command="{id: scope.row.id, status: 'Blocking'}">
{{$t('test_track.plan_view.blocking')}}
</el-dropdown-item>
<el-dropdown-item :disabled="!isTestManagerOrTestUser" :command="{id: scope.row.id, status: 'Skip'}">
{{$t('test_track.plan_view.skip')}}
<el-dropdown-item :disabled="!isTestManagerOrTestUser" :command="{id: scope.row.id, status: 'UnPass'}">
未通过
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
@ -233,9 +225,7 @@ export default {
data() {
return {
result: {},
condition: {
components: TEST_CASE_CONFIGS
},
condition: {},
tableData: [],
currentPage: 1,
pageSize: 10,
@ -262,10 +252,7 @@ export default {
statusFilters: [
{text: this.$t('test_track.plan.plan_status_prepare'), value: 'Prepare'},
{text: this.$t('test_track.plan_view.pass'), value: 'Pass'},
{text: this.$t('test_track.plan_view.failure'), value: 'Failure'},
{text: this.$t('test_track.plan_view.blocking'), value: 'Blocking'},
{text: this.$t('test_track.plan_view.skip'), value: 'Skip'},
{text: this.$t('test_track.plan.plan_status_running'), value: 'Underway'},
{text: '未通过', value: 'UnPass'},
],
showMore: false,
buttons: [