feat: 测试计划添加脑图

This commit is contained in:
chenjianxing 2021-03-16 12:55:56 +08:00
parent 0ab8899820
commit 0edc4d136f
10 changed files with 201 additions and 9 deletions

View File

@ -112,7 +112,9 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
apiModuleDTO.setName(name);
apiModuleDTO.setLabel(name);
apiModuleDTO.setChildren(nodeList);
list.add(apiModuleDTO);
if (!org.springframework.util.CollectionUtils.isEmpty(nodeList)) {
list.add(apiModuleDTO);
}
});
return list;
}

View File

@ -100,7 +100,9 @@ public class ApiScenarioModuleService extends NodeTreeService<ApiScenarioModuleD
scenarioModuleDTO.setName(name);
scenarioModuleDTO.setLabel(name);
scenarioModuleDTO.setChildren(nodeList);
list.add(scenarioModuleDTO);
if (!org.springframework.util.CollectionUtils.isEmpty(nodeList)) {
list.add(scenarioModuleDTO);
}
});
return list;
}

View File

@ -45,4 +45,6 @@ public interface ExtTestPlanTestCaseMapper {
void deleteByTestCaseID(String id);
List<String> getExecResultByPlanId(String planId);
List<TestPlanCaseDTO> listForMinder(@Param("planId") String planId);
}

View File

@ -405,6 +405,23 @@
</where>
</select>
<select id="listForMinder" resultType="io.metersphere.track.dto.TestPlanCaseDTO">
select pc.id as id,
pc.executor, pc.status,
pc.update_time,
pc.plan_id as planId,
t.name, t.priority,
t.type, t.node_id,
t.steps, t.prerequisite,
t.remark,
t.node_path, t.method, t.num
from test_plan_test_case pc
inner join test_case t on pc.case_id = t.id
<where>
pc.plan_id = #{planId}
</where>
</select>
<update id="updateTestCaseStates" parameterType="java.lang.String">
update test_plan_test_case
<set>
@ -423,4 +440,4 @@
from test_plan_api_case
where api_case_id = #{id,jdbcType=VARCHAR}
</delete>
</mapper>
</mapper>

View File

@ -39,6 +39,13 @@ public class TestPlanTestCaseController {
return testPlanTestCaseService.listByPlanId(request);
}
@GetMapping("/list/minder/{planId}")
public List<TestPlanCaseDTO> listForMinder(@PathVariable String planId) {
QueryTestPlanCaseRequest request = new QueryTestPlanCaseRequest();
request.setPlanId(planId);
return testPlanTestCaseService.listForMinder(planId);
}
@GetMapping("/list/node/{planId}/{nodePaths}")
public List<TestPlanCaseDTO> getTestPlanCasesByNodePath(@PathVariable String planId, @PathVariable String nodePaths) {
String nodePath = nodePaths.replace("f", "/");

View File

@ -189,7 +189,9 @@ public class TestCaseNodeService extends NodeTreeService<TestCaseNodeDTO> {
testCaseNodeDTO.setName(name);
testCaseNodeDTO.setLabel(name);
testCaseNodeDTO.setChildren(nodeList);
list.add(testCaseNodeDTO);
if (!CollectionUtils.isEmpty(nodeList)) {
list.add(testCaseNodeDTO);
}
}
});

View File

@ -150,4 +150,8 @@ public class TestPlanTestCaseService {
public int updateTestCaseStates(List<String> ids, String reportStatus) {
return extTestPlanTestCaseMapper.updateTestCaseStates(ids, reportStatus);
}
public List<TestPlanCaseDTO> listForMinder(String planId) {
return extTestPlanTestCaseMapper.listForMinder(planId);
}
}

View File

@ -0,0 +1,128 @@
<template>
<ms-module-minder
v-loading="result.loading"
:tree-nodes="treeNodes"
:data-map="dataMap"
@save="save"
/>
</template>
<script>
import MsModuleMinder from "@/business/components/common/components/MsModuleMinder";
import {getTestCaseDataMap} from "@/business/components/track/common/minder/minderUtils";
export default {
name: "TestPlanMinder",
components: {MsModuleMinder},
data() {
return{
testCase: [],
dataMap: new Map(),
result: {}
}
},
props: {
treeNodes: {
type: Array,
default() {
return []
}
},
selectNodeIds: {
type: Array
},
planId: {
type: String
},
projectId: String
},
mounted() {
this.$nextTick(() => {
this.getTestCases();
})
},
methods: {
getTestCases() {
if (this.projectId) {
this.result = this.$get('/test/plan/case/list/minder/' + this.planId, response => {
this.testCase = response.data;
this.dataMap = getTestCaseDataMap(this.testCase);
});
}
},
save(data) {
// let saveCases = [];
// this.buildSaveCase(data.root, saveCases, undefined);
// console.log(saveCases);
// let param = {
// projectId: this.projectId,
// data: saveCases
// }
// this.result = this.$post('/test/case/minder/edit', param, () => {
// this.$success(this.$t('commons.save_success'));
// });
},
buildSaveCase(root, saveCases, parent) {
let data = root.data;
if (data.resource && data.resource.indexOf("用例") > -1) {
this._buildSaveCase(root, saveCases, parent);
} else {
if (root.children) {
root.children.forEach((childNode) => {
this.buildSaveCase(childNode, saveCases, root.data);
})
}
}
},
_buildSaveCase(node, saveCases, parent) {
let data = node.data;
let isChange = false;
let testCase = {
id: data.id,
name: data.text,
nodeId: parent ? parent.id : "",
nodePath: parent ? parent.path : "",
type: data.type ? data.type : 'functional',
method: data.method ? data.method : 'manual',
maintainer: data.maintainer,
priority: 'P' + data.priority,
};
if (data.changed) isChange = true;
let steps = [];
let stepNum = 1;
if (node.children) {
node.children.forEach((childNode) => {
let childData = childNode.data;
if (childData.resource && childData.resource.indexOf('前置条件') > -1) {
testCase.prerequisite = childData.text;
} else if (childData.resource && childData.resource.indexOf('备注') > -1) {
testCase.remark = childData.text;
} else {
//
let step = {};
step.num = stepNum++;
step.desc = childData.text;
if (childNode.children) {
let result = "";
childNode.children.forEach((child) => {
result += child.data.text;
if (child.data.changed) isChange = true;
})
step.result = result;
}
steps.push(step);
}
if (childData.changed) isChange = true;
})
}
testCase.steps = JSON.stringify(steps);
if (isChange) {
saveCases.push(testCase);
}
},
}
}
</script>
<style scoped>
</style>

View File

@ -1,7 +1,7 @@
<template>
<div class="card-container">
<el-card class="card-content" v-loading="result.loading">
<template v-slot:header>
<!-- <el-card class="card-content" v-loading="result.loading">-->
<!-- <template v-slot:header>-->
<ms-table-header :is-tester-permission="true" :condition.sync="condition" @search="initTableData"
:show-create="false" :tip="$t('commons.search_by_id_name_tag')">
<template v-slot:title>
@ -19,7 +19,7 @@
:content="$t('test_track.plan_view.cancel_all_relevance')" @click="handleDeleteBatch"/>
</template>
</ms-table-header>
</template>
<!-- </template>-->
<executor-edit ref="executorEdit" :select-ids="new Set(Array.from(this.selectRows).map(row => row.id))"
@refresh="initTableData"/>
@ -250,7 +250,7 @@
:is-read-only="isReadOnly"
@refreshTable="search"/>
</el-card>
<!-- </el-card>-->
<batch-edit ref="batchEdit" @batchEdit="batchEdit"
:type-arr="typeArr" :value-arr="valueArr" :dialog-title="$t('test_track.case.batch_edit_case')"/>
</div>
@ -671,6 +671,9 @@ export default {
</script>
<style scoped>
.ms-table-header {
margin: 20px;
}
.search {
margin-left: 10px;

View File

@ -9,8 +9,16 @@
ref="nodeTree"/>
</template>
<template v-slot:main>
<ms-tab-button
:active-dom.sync="activeDom"
:left-tip="'用例列表'"
:left-content="'CASE'"
:right-tip="'脑图'"
:right-content="'脑图'"
:middle-button-enable="false">
<functional-test-case-list
class="table-list"
v-if="activeDom === 'left'"
@openTestCaseRelevanceDialog="openTestCaseRelevanceDialog"
@refresh="refresh"
:plan-id="planId"
@ -18,6 +26,13 @@
:select-node-ids="selectNodeIds"
:select-parent-nodes="selectParentNodes"
ref="testPlanTestCaseList"/>
<test-plan-minder
:tree-nodes="treeNodes"
:project-id="projectId"
:plan-id="planId"
v-if="activeDom === 'right'"
/>
</ms-tab-button>
</template>
<test-case-functional-relevance
@ -34,10 +49,15 @@
import MsTestPlanCommonComponent from "../base/TestPlanCommonComponent";
import TestCaseFunctionalRelevance from "./TestCaseFunctionalRelevance";
import FunctionalTestCaseList from "./FunctionalTestCaseList";
import MsTabButton from "@/business/components/common/components/MsTabButton";
import TestPlanMinder from "@/business/components/track/common/minder/TestPlanMinder";
import {getCurrentProjectID} from "@/common/js/utils";
export default {
name: "TestPlanFunctional",
components: {
TestPlanMinder,
MsTabButton,
FunctionalTestCaseList,
TestCaseFunctionalRelevance,
MsTestPlanCommonComponent,
@ -50,6 +70,8 @@
selectNodeIds: [],
selectParentNodes: [],
treeNodes: [],
activeDom: 'left',
projectId: ""
}
},
props: [
@ -58,6 +80,7 @@
'clickType'
],
mounted() {
this.projectId = getCurrentProjectID();
this.initData();
},
activated(){
@ -121,5 +144,7 @@
</script>
<style scoped>
/deep/ .el-button-group>.el-button:first-child {
padding: 4px 1px !important;
}
</style>