mirror of
https://gitee.com/fit2cloud-feizhiyun/MeterSphere.git
synced 2024-12-02 20:19:16 +08:00
feat: 功能用例创建版本支持选择是否复制其他信息
This commit is contained in:
parent
e361c62c67
commit
d82cf735ad
@ -423,4 +423,15 @@ public class TestCaseController {
|
||||
public void deleteApiDefinition(@PathVariable String version, @PathVariable String refId) {
|
||||
testCaseService.deleteTestCaseByVersion(refId, version);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否有其他信息
|
||||
*
|
||||
* @param caseId 用例 ID
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("hasOtherInfo/{caseId}")
|
||||
public Boolean hasOtherInfo(@PathVariable String caseId) {
|
||||
return testCaseService.hasOtherInfo(caseId);
|
||||
}
|
||||
}
|
||||
|
@ -13,9 +13,30 @@ import java.util.List;
|
||||
public class EditTestCaseRequest extends TestCaseWithBLOBs {
|
||||
private List<FileMetadata> updatedFileList;
|
||||
private List<String> follows;
|
||||
private OtherInfoConfig otherInfoConfig;
|
||||
/**
|
||||
* 复制测试用例后,要进行复制的文件Id list
|
||||
*/
|
||||
private List<String> fileIds = new ArrayList<>();
|
||||
private List<List<String>> selected = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 创建新版本时 是否连带复制其他信息的配置类
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public static class OtherInfoConfig {
|
||||
//是否复制备注
|
||||
private boolean remark;
|
||||
//是否复制关联测试
|
||||
private boolean relateTest;
|
||||
//是否复制关联需求
|
||||
private boolean relateDemand;
|
||||
//是否复制关联缺陷
|
||||
private boolean relateIssue;
|
||||
//是否复制附件
|
||||
private boolean archive;
|
||||
//是否复制依赖
|
||||
private boolean dependency;
|
||||
}
|
||||
}
|
||||
|
@ -62,6 +62,7 @@ import org.apache.ibatis.session.SqlSession;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.mybatis.spring.SqlSessionUtils;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
@ -157,6 +158,9 @@ public class TestCaseService {
|
||||
@Resource
|
||||
private ProjectVersionService projectVersionService;
|
||||
@Resource
|
||||
@Lazy
|
||||
private IssuesService issuesService;
|
||||
@Resource
|
||||
private ExtProjectVersionMapper extProjectVersionMapper;
|
||||
|
||||
private void setNode(TestCaseWithBLOBs testCase) {
|
||||
@ -265,7 +269,7 @@ public class TestCaseService {
|
||||
return testCaseMapper.selectByPrimaryKey(testCaseId);
|
||||
}
|
||||
|
||||
public TestCaseWithBLOBs editTestCase(TestCaseWithBLOBs testCase) {
|
||||
public TestCaseWithBLOBs editTestCase(EditTestCaseRequest testCase) {
|
||||
checkTestCustomNum(testCase);
|
||||
testCase.setUpdateTime(System.currentTimeMillis());
|
||||
// 更新数据
|
||||
@ -274,6 +278,18 @@ public class TestCaseService {
|
||||
if (StringUtils.isNotBlank(testCase.getVersionId())) {
|
||||
example.getOredCriteria().get(0).andVersionIdEqualTo(testCase.getVersionId());
|
||||
}
|
||||
createNewVersionOrNot(testCase, example);
|
||||
testCaseMapper.updateByPrimaryKeySelective(testCase);
|
||||
return testCaseMapper.selectByPrimaryKey(testCase.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据前后端 verionId 判定是编辑旧数据还是创建新版本
|
||||
*
|
||||
* @param testCase
|
||||
* @param example
|
||||
*/
|
||||
private void createNewVersionOrNot(EditTestCaseRequest testCase, TestCaseExample example) {
|
||||
if (testCaseMapper.updateByExampleSelective(testCase, example) == 0) {
|
||||
// 插入新版本的数据
|
||||
TestCaseWithBLOBs oldTestCase = testCaseMapper.selectByPrimaryKey(testCase.getId());
|
||||
@ -285,10 +301,70 @@ public class TestCaseService {
|
||||
testCase.setCreateUser(SessionUtils.getUserId());
|
||||
testCase.setOrder(oldTestCase.getOrder());
|
||||
testCase.setRefId(oldTestCase.getRefId());
|
||||
DealWithOtherInfo(testCase, oldTestCase);
|
||||
testCaseMapper.insertSelective(testCase);
|
||||
}
|
||||
testCaseMapper.updateByPrimaryKeySelective(testCase);
|
||||
return testCaseMapper.selectByPrimaryKey(testCase.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理其他信息的复制问题
|
||||
*
|
||||
* @param testCase
|
||||
* @param oldTestCase
|
||||
*/
|
||||
private void DealWithOtherInfo(EditTestCaseRequest testCase, TestCaseWithBLOBs oldTestCase) {
|
||||
EditTestCaseRequest.OtherInfoConfig otherInfoConfig = testCase.getOtherInfoConfig();
|
||||
if (otherInfoConfig != null) {
|
||||
if (!otherInfoConfig.isRemark()) {
|
||||
testCase.setRemark(null);
|
||||
}
|
||||
if (!otherInfoConfig.isRelateDemand()) {
|
||||
testCase.setDemandId(null);
|
||||
testCase.setDemandName(null);
|
||||
}
|
||||
if (otherInfoConfig.isRelateIssue()) {
|
||||
List<IssuesDao> issuesDaos = issuesService.getIssues(oldTestCase.getId());
|
||||
if (CollectionUtils.isNotEmpty(issuesDaos)) {
|
||||
issuesDaos.forEach(issue -> {
|
||||
TestCaseIssues t = new TestCaseIssues();
|
||||
t.setId(UUID.randomUUID().toString());
|
||||
t.setTestCaseId(testCase.getId());
|
||||
t.setIssuesId(issue.getId());
|
||||
testCaseIssuesMapper.insertSelective(t);
|
||||
});
|
||||
}
|
||||
}
|
||||
if (otherInfoConfig.isRelateTest()) {
|
||||
List<TestCaseTestDao> testCaseTestDaos = getRelateTest(oldTestCase.getId());
|
||||
if (CollectionUtils.isNotEmpty(testCaseTestDaos)) {
|
||||
testCaseTestDaos.forEach(test -> {
|
||||
test.setTestCaseId(testCase.getId());
|
||||
testCaseTestMapper.insertSelective(test);
|
||||
});
|
||||
}
|
||||
}
|
||||
if (otherInfoConfig.isArchive()) {
|
||||
List<FileMetadata> files = fileService.getFileMetadataByCaseId(oldTestCase.getId());
|
||||
if (CollectionUtils.isNotEmpty(files)) {
|
||||
files.forEach(file -> {
|
||||
TestCaseFile testCaseFile = new TestCaseFile();
|
||||
testCaseFile.setCaseId(testCase.getId());
|
||||
testCaseFile.setFileId(file.getId());
|
||||
testCaseFileMapper.insertSelective(testCaseFile);
|
||||
});
|
||||
}
|
||||
}
|
||||
if (otherInfoConfig.isDependency()) {
|
||||
List<RelationshipEdgeDTO> preRelations = getRelationshipCase(testCase.getId(), "PRE");
|
||||
List<RelationshipEdgeDTO> postRelations = getRelationshipCase(testCase.getId(), "POST");
|
||||
if (CollectionUtils.isNotEmpty(preRelations)) {
|
||||
preRelations.forEach(relation -> {
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public TestCaseWithBLOBs checkTestCaseExist(TestCaseWithBLOBs testCase) {
|
||||
@ -712,7 +788,7 @@ public class TestCaseService {
|
||||
AtomicInteger sort = new AtomicInteger();
|
||||
AtomicInteger num = new AtomicInteger();
|
||||
num.set(getNextNum(projectId) + testCases.size());
|
||||
for (TestCaseWithBLOBs testcase: testCases) {
|
||||
for (TestCaseWithBLOBs testcase : testCases) {
|
||||
testcase.setId(UUID.randomUUID().toString());
|
||||
testcase.setCreateUser(SessionUtils.getUserId());
|
||||
testcase.setCreateTime(System.currentTimeMillis());
|
||||
@ -748,7 +824,7 @@ public class TestCaseService {
|
||||
num.set(getNextNum(projectId) + testCases.size());
|
||||
testCases.forEach(testcase -> {
|
||||
TestCaseWithBLOBs oldCase = testCaseMapper.selectByPrimaryKey(testcase.getId());
|
||||
String customFieldStr = this.updateCustomField(oldCase.getCustomFields(),testcase.getPriority());
|
||||
String customFieldStr = this.updateCustomField(oldCase.getCustomFields(), testcase.getPriority());
|
||||
testcase.setUpdateTime(System.currentTimeMillis());
|
||||
testcase.setNodeId(nodePathMap.get(testcase.getNodePath()));
|
||||
testcase.setSort(sort.getAndIncrement());
|
||||
@ -847,7 +923,7 @@ public class TestCaseService {
|
||||
.andProjectIdEqualTo(projectId);
|
||||
List<TestCase> testCasesList = testCaseMapper.selectByExample(example);
|
||||
Map<String, String> customIdMap = testCasesList.stream()
|
||||
.collect(Collectors.toMap(TestCase::getCustomNum, TestCase::getId, (k1,k2) -> k1));
|
||||
.collect(Collectors.toMap(TestCase::getCustomNum, TestCase::getId, (k1, k2) -> k1));
|
||||
|
||||
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
|
||||
TestCaseMapper mapper = sqlSession.getMapper(TestCaseMapper.class);
|
||||
@ -1649,7 +1725,9 @@ public class TestCaseService {
|
||||
if (editCustomFieldsPriority(dbCase, item.getPriority())) {
|
||||
item.setCustomFields(dbCase.getCustomFields());
|
||||
}
|
||||
editTestCase(item);
|
||||
EditTestCaseRequest editRequest = new EditTestCaseRequest();
|
||||
BeanUtils.copyBean(editRequest, item);
|
||||
editTestCase(editRequest);
|
||||
changeOrder(item, request.getProjectId());
|
||||
} else {
|
||||
item.setMaintainer(SessionUtils.getUserId());
|
||||
@ -2329,4 +2407,16 @@ public class TestCaseService {
|
||||
testCase.setRefId(refId);
|
||||
return extTestCaseMapper.deletePublic(testCase);
|
||||
}
|
||||
|
||||
public Boolean hasOtherInfo(String caseId) {
|
||||
TestCaseWithBLOBs tc = getTestCase(caseId);
|
||||
if (tc != null) {
|
||||
if (StringUtils.isNotBlank(tc.getRemark()) || StringUtils.isNotBlank(tc.getDemandId()) || CollectionUtils.isNotEmpty(getRelateTest(caseId))
|
||||
|| CollectionUtils.isNotEmpty(issuesService.getIssues(caseId)) || CollectionUtils.isNotEmpty(getRelationshipCase(caseId, "PRE")) || CollectionUtils.isNotEmpty(getRelationshipCase(caseId, "POST"))
|
||||
|| CollectionUtils.isNotEmpty(fileService.getFileMetadataByCaseId(caseId))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit b35dfb7f4571ed9e9496ff67339b9118232b4bbd
|
||||
Subproject commit ceffcd883aa519d3f7bfb2641337abaaae4c9295
|
@ -23,6 +23,8 @@
|
||||
ref="versionHistory"
|
||||
:version-data="versionData"
|
||||
:current-id="currentTestCaseInfo.id"
|
||||
:is-test-case-version="true"
|
||||
@confirmOtherInfo="confirmOtherInfo"
|
||||
:current-project-id="currentProjectId"
|
||||
@compare="compare" @checkout="checkout" @create="create" @del="del"/>
|
||||
<el-dropdown split-button type="primary" class="ms-api-buttion" @click="handleCommand"
|
||||
@ -139,7 +141,6 @@
|
||||
@getComments="getComments" ref="testCaseComment"/>
|
||||
|
||||
</el-form>
|
||||
|
||||
</div>
|
||||
<ms-change-history ref="changeHistory"/>
|
||||
<el-dialog
|
||||
@ -197,6 +198,7 @@ import MsChangeHistory from "../../../history/ChangeHistory";
|
||||
import {getTestTemplate} from "@/network/custom-field-template";
|
||||
import CustomFiledFormItem from "@/business/components/common/components/form/CustomFiledFormItem";
|
||||
import TestCaseVersionDiff from "@/business/components/track/case/version/TestCaseVersionDiff";
|
||||
import VersionCreateOtherInfoSelect from "@/business/components/track/case/components/VersionCreateOtherInfoSelect";
|
||||
|
||||
const requireComponent = require.context('@/business/components/xpack/', true, /\.vue$/);
|
||||
const versionHistory = requireComponent.keys().length > 0 ? requireComponent("./version/VersionHistory.vue") : {};
|
||||
@ -218,7 +220,8 @@ export default {
|
||||
MsTestCaseStepRichText,
|
||||
MsChangeHistory,
|
||||
'MsVersionHistory': versionHistory.default,
|
||||
TestCaseVersionDiff
|
||||
TestCaseVersionDiff,
|
||||
VersionCreateOtherInfoSelect,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@ -310,7 +313,8 @@ export default {
|
||||
versionData: [],
|
||||
dialogVisible: false,
|
||||
oldData: null,
|
||||
newData: null ,
|
||||
newData: null,
|
||||
selectedOtherInfo: null,
|
||||
currentProjectId: "" ,
|
||||
};
|
||||
},
|
||||
@ -767,6 +771,11 @@ export default {
|
||||
callback(this);
|
||||
}
|
||||
// 保存用例后刷新附件
|
||||
|
||||
//更新版本
|
||||
if (hasLicense()) {
|
||||
this.getVersionHistory();
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
@ -790,6 +799,10 @@ export default {
|
||||
param.type = 'functional';
|
||||
buildCustomFields(this.form, param, this.testCaseTemplate);
|
||||
this.parseOldFields(param);
|
||||
//配置多版本复制的时候是否要连带复制其他信息
|
||||
if (this.selectedOtherInfo) {
|
||||
param.otherInfoConfig = this.selectedOtherInfo;
|
||||
}
|
||||
return param;
|
||||
},
|
||||
parseOldFields(param) {
|
||||
@ -944,12 +957,13 @@ export default {
|
||||
}
|
||||
}
|
||||
},
|
||||
getVersionHistory() {
|
||||
getVersionHistory(param) {
|
||||
this.$get('/test/case/versions/' + this.currentTestCaseInfo.id, response => {
|
||||
for (let i = 0; i < response.data.length; i++) {
|
||||
this.currentProjectId = response.data[i].projectId;
|
||||
}
|
||||
this.versionData = response.data;
|
||||
this.$refs.versionHistory.cancelOtherInfo();
|
||||
this.$refs.versionHistory.loading = false;
|
||||
});
|
||||
},
|
||||
@ -988,10 +1002,16 @@ export default {
|
||||
});
|
||||
}
|
||||
},
|
||||
create(row) {
|
||||
async create(row) {
|
||||
// 创建新版本
|
||||
this.form.versionId = row.id;
|
||||
this.saveCase(this.getVersionHistory);
|
||||
let hasOtherInfo = await this.hasOtherInfo();
|
||||
if (hasOtherInfo) {
|
||||
this.$refs.versionHistory.loading = false;
|
||||
this.$refs.versionHistory.showOtherInfo();
|
||||
} else {
|
||||
this.saveCase();
|
||||
}
|
||||
},
|
||||
del(row) {
|
||||
let that = this;
|
||||
@ -1011,7 +1031,19 @@ export default {
|
||||
},
|
||||
changeType(type) {
|
||||
this.type = type;
|
||||
}
|
||||
},
|
||||
hasOtherInfo() {
|
||||
return new Promise((resolve) => {
|
||||
this.$get("test/case/hasOtherInfo/" + this.form.id, (res) => {
|
||||
resolve(res.data);
|
||||
})
|
||||
}
|
||||
);
|
||||
},
|
||||
confirmOtherInfo(selectedOtherInfo) {
|
||||
this.selectedOtherInfo = selectedOtherInfo;
|
||||
this.saveCase();
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
@ -0,0 +1,82 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-form ref="form" :model="form" label-width="10px" label-position="left">
|
||||
<el-row>
|
||||
<el-col :span="24">
|
||||
<el-form-item>
|
||||
<span>{{ $t('test_track.case.sync_to_new_version') }}</span>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="6">
|
||||
<el-form-item>
|
||||
<el-checkbox v-model="form.remark">{{ $t('commons.remark') }}</el-checkbox>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-form-item>
|
||||
<el-checkbox v-model="form.relateTest">{{ $t('test_track.case.relate_test') }}</el-checkbox>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-form-item>
|
||||
<el-checkbox v-model="form.relateDemand">{{ $t('test_track.related_requirements') }}</el-checkbox>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-form-item>
|
||||
<el-checkbox v-model="form.relateIssue">{{ $t('test_track.case.relate_issue') }}</el-checkbox>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="6">
|
||||
<el-form-item>
|
||||
<el-checkbox v-model="form.dependency">{{ $t('commons.relationship.name') }}</el-checkbox>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-form-item>
|
||||
<el-checkbox v-model="form.archive">{{ $t('test_track.case.attachment') }}</el-checkbox>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-form-item style="float:right">
|
||||
<el-button size="small" @click="$emit('cancelOtherInfo')">{{ $t('commons.cancel') }}</el-button>
|
||||
<el-button type="primary" size="small" @click="confirmOtherInfo">{{ $t('commons.confirm') }}</el-button>
|
||||
</el-form-item>
|
||||
</el-row>
|
||||
</el-form>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
export default {
|
||||
name: "VersionCreateOtherInfoSelect",
|
||||
data() {
|
||||
return {
|
||||
form: {
|
||||
remark: false,
|
||||
relateTest: false,
|
||||
relateDemand: false,
|
||||
relateIssue: false,
|
||||
archive: false,
|
||||
dependency: false,
|
||||
}
|
||||
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
confirmOtherInfo() {
|
||||
this.$emit("confirmOtherInfo", this.form);
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
@ -1 +1 @@
|
||||
Subproject commit b6c673194c6d57ecb19ece5319716068cfc37aab
|
||||
Subproject commit 0a7c20cc28e15d8036e9d29694ab284c6571af8b
|
@ -2324,7 +2324,8 @@ export default {
|
||||
all_case: "All Case",
|
||||
},
|
||||
reporter: 'Reporter',
|
||||
lastmodify: 'Last Modify'
|
||||
lastmodify: 'Last Modify',
|
||||
sync_to_new_version: "Sync to latest version",
|
||||
},
|
||||
test_resource_pool: {
|
||||
id: 'Resource Pool ID',
|
||||
|
@ -2031,7 +2031,8 @@ export default {
|
||||
},
|
||||
case_desc: "用例描述",
|
||||
passing_rate:'用例通过率',
|
||||
version: "版本"
|
||||
version: "版本",
|
||||
sync_to_new_version: "同步以下信息到新版本",
|
||||
},
|
||||
plan: {
|
||||
test_plan: "测试计划",
|
||||
|
@ -2030,8 +2030,8 @@ export default {
|
||||
export_tip: "請切換成接口列表勾選用例導出!"
|
||||
},
|
||||
case_desc: "用例描述",
|
||||
passing_rate: '用例通過率'
|
||||
|
||||
passing_rate: '用例通過率',
|
||||
sync_to_new_version: "同步以下信息到新版本",
|
||||
},
|
||||
plan: {
|
||||
test_plan: "測試計劃",
|
||||
@ -2328,7 +2328,7 @@ export default {
|
||||
all_case: "所有用例",
|
||||
},
|
||||
reporter: '報告人',
|
||||
lastmodify: '最後更改'
|
||||
lastmodify: '最後更改',
|
||||
},
|
||||
test_resource_pool: {
|
||||
id: "測試資源池ID",
|
||||
|
Loading…
Reference in New Issue
Block a user