refactor(测试跟踪): 重构功能用例编辑页版本相关代码

This commit is contained in:
chenjianxing 2023-02-17 15:38:14 +08:00 committed by jianxing
parent 4f46efacdb
commit 012a38c3f3
12 changed files with 253 additions and 327 deletions

View File

@ -164,6 +164,11 @@ public class TestCaseController {
return testCaseService.getTestCase(testCaseId);
}
@GetMapping("/get/version/{refId}/{versionId}")
public TestCaseDTO getTestCaseByVersion(@PathVariable String refId, @PathVariable String versionId) {
return testCaseService.getTestCaseByVersion(refId, versionId);
}
@GetMapping("/get/step/{testCaseId}")
public TestCaseWithBLOBs getTestCaseStep(@PathVariable String testCaseId) {
return testCaseService.getTestCaseStep(testCaseId);

View File

@ -288,7 +288,8 @@ export function getIssuePartTemplateWithProject(callback, reject) {
template.customFields.push(...pluginFields);
if (callback)
callback(template, currentProject);
});
})
.catch(() => {reject(r)});
}
});
});

View File

@ -22,6 +22,10 @@ export function getTestCase(id) {
return get(BASE_URL + `get/${id}`);
}
export function getTestCaseByVersionId(refId, versionId) {
return get(BASE_URL + `get/version/${refId}/${versionId}`);
}
export function hasTestCaseOtherInfo(id) {
return get(BASE_URL + `hasOtherInfo/${id}`);
}

View File

@ -178,8 +178,6 @@
:currentTestCaseInfo="item.testCaseInfo"
:version-enable="versionEnable"
@refresh="refreshAll"
@caseEdit="handleCaseCreateOrEdit($event, 'edit')"
@caseCreate="handleCaseCreateOrEdit($event, 'add')"
@checkout="checkout($event, item)"
:is-public="item.isPublic"
:read-only="testCaseReadOnly"
@ -234,7 +232,7 @@ import {versionEnableByProjectId} from "@/api/project";
import TestCasePublicNodeTree from "@/business/module/TestCasePublicNodeTree";
import TestCaseTrashNodeTree from "@/business/module/TestCaseTrashNodeTree";
import PublicTestCaseList from "@/business/case/components/public/PublicTestCaseList";
import {openCaseEdit} from "@/business/case/test-case";
import {openCaseCreate, openCaseEdit} from "@/business/case/test-case";
const store = useStore();
export default {
@ -377,8 +375,9 @@ export default {
methods: {
hasPermission,
handleCreateCase(){
let TestCaseData = this.$router.resolve({path: "/track/case/create",});
window.open(TestCaseData.href, "_blank");
openCaseCreate({
projectId: this.projectId
}, this);
},
closeTab(){
this.handleTabClose();

View File

@ -21,19 +21,24 @@
<div>
<!-- 版本历史 v-xpack -->
<mx-version-history
v-xpack
v-if="versionEnable"
ref="versionHistory"
:version-data="versionData"
:current-id="currentTestCaseInfo.id"
:is-read="readOnly"
:current-version-id="form.versionId"
@confirmOtherInfo="confirmOtherInfo"
:current-project-id="currentProjectId"
:current-project-id="projectId"
:has-latest="hasLatest"
@setLatest="setLatest"
@compare="compare"
@compareBranch="compareBranch"
@checkout="checkout"
@create="create"
@create="createVersion"
@del="del"
@setIsLastedVersion="setIsLastedVersion"
@setCurrentVersionName="setCurrentVersionName"
@setLatestVersionId="setLatestVersionId"
>
<div class="version-box case-version" slot="versionLabel">
<div class="version-icon">
@ -242,7 +247,7 @@
<div class="save-create-row">
<el-button
size="small"
@click="handleCommand('ADD_AND_CREATE')"
@click="handleCommand(2)"
v-if="showAddBtn"
:disabled="readOnly">
{{ $t("case.saveAndCreate") }}
@ -252,7 +257,7 @@
<div
class="save-add-pub-row"
v-if="showPublic"
@click="handleCommand('ADD_AND_PUBLIC')">
@click="handleCommand(3)">
<el-button size="small" :disabled="readOnly">
{{ $t("test_track.case.save_add_public") }}
</el-button>
@ -261,7 +266,7 @@
<div
class="save-btn-row"
v-if="showAddBtn">
<el-button size="small" @click="handleCommand" :disabled="readOnly" type="primary">
<el-button size="small" @click="handleCommand(1)" :disabled="readOnly" type="primary">
{{ $t("commons.save") }}
</el-button>
</div>
@ -306,7 +311,6 @@ import {
} from "metersphere-frontend/src/utils/permission";
import {
getUUID,
getNodePath,
listenGoBack,
removeGoBackListener,
handleCtrlSEvent,
@ -350,7 +354,7 @@ import {
hasTestCaseOtherInfo,
testCaseEditFollows,
testCaseGetByVersionId,
testCaseDeleteToGc, getTestCaseNodesByCaseFilter,
testCaseDeleteToGc, getTestCaseNodesByCaseFilter, getTestCaseByVersionId,
} from "@/api/testCase";
import {
@ -359,16 +363,12 @@ import {
} from "@/business/utils/sdk-utils";
import { testCaseCommentList } from "@/api/test-case-comment";
import {
getDefaultVersion,
setLatestVersionById,
} from "metersphere-frontend/src/api/version";
import CaseEditInfoComponent from "./case/CaseEditInfoComponent";
import CaseBaseInfo from "./case/CaseBaseInfo";
import PriorityTableItem from "../../common/tableItems/planview/PriorityTableItem";
import MxVersionHistory from "./common/CaseVersionHistory"
import {
getProjectVersions,
} from "metersphere-frontend/src/api/version";
import {buildTree} from "metersphere-frontend/src/model/NodeTree";
import {versionEnableByProjectId} from "@/api/project";
import {openCaseEdit} from "@/business/case/test-case";
@ -538,19 +538,20 @@ export default {
oldData: null,
newData: null,
selectedOtherInfo: null,
currentProjectId: "",
casePublic: false,
isClickAttachmentTab: false,
latestVersionId: "",
hasLatest: false,
treeNodes: [],
currentTestCaseInfo: {},
versionOptions: [],
currentVersionName: "",
versionEnable: false,
//
isLastedVersion: true,
caseId: ""
// 1
// 2
// 3
saveType: 1
};
},
props: {
@ -570,7 +571,8 @@ export default {
},
computed: {
projectId() {
return getCurrentProjectID();
let pId = this.$route.params.projectId;
return pId ? pId : getCurrentProjectID();
},
moduleOptions() {
return useStore().testCaseModuleOptions;
@ -594,14 +596,9 @@ export default {
!hasPermission("PROJECT_TRACK_CASE:READ+EDIT")
);
},
// caseId: {
// get: function(){
// return !this.isPublicShow ? this.$route.params.caseId : this.publicCaseId;
// },
// set: function(val){
// this.$route.params.caseId = val;
// }
// },
caseId() {
return !this.isPublicShow ? this.$route.params.caseId : this.publicCaseId;
},
editType() {
return this.$route.query.type;
},
@ -635,14 +632,6 @@ export default {
change = change + 1;
useStore().testCaseMap.set(this.form.id, change);
}
if(val.versionId && !this.currentVersionName){
this.fetchVersionName();
}
if(!this.editable && val.versionId){
//
this.checkIsLatestVersion(val.versionId);
}
},
deep: true,
},
@ -665,8 +654,6 @@ export default {
);
},
mounted() {
this.caseId = !this.isPublicShow ? this.$route.params.caseId : this.publicCaseId;
this.getSelectOptions();
// Cascader : input
@ -685,8 +672,6 @@ export default {
useStore().testCaseMap.set(this.form.id, 0);
}
//
this.getVersionOptionList();
},
activated() {
this.loadTestCase();
@ -697,7 +682,7 @@ export default {
methods: {
checkoutLatest(){
//
this.checkout({id: this.latestVersionId})
this.checkoutByVersionId(this.latestVersionId);
},
//
diffWithLatest(){
@ -709,25 +694,16 @@ export default {
}
this.compareBranchWithVersionId(this.latestVersionId, this.currentTestCaseInfo.versionId);
},
async checkIsLatestVersion(id){
let allCaseVersions = await getTestCaseVersions(this.currentTestCaseInfo.id);
if (allCaseVersions.data) {
this.isLastedVersion = allCaseVersions.data.length === 1;
return true;
}
if(!this.versionOptions || this.versionOptions.length <= 0){
this.isLastedVersion = true;
return true;
}
let version = this.versionOptions.filter(v => v.id == id);
if(!version || version.length <= 0){
this.isLastedVersion = true;
return true;
}
this.isLastedVersion = version[0].latest;
return version[0].latest;
setLatestVersionId(versionId) {
this.latestVersionId = versionId;
},
setIsLastedVersion(isLastedVersion) {
this.isLastedVersion = isLastedVersion;
},
loadTestCase() {
//
this.checkCurrentProject();
let initFuc = this.initEdit;
this.loading = true;
getTestTemplate().then((template) => {
@ -776,9 +752,6 @@ export default {
} else {
this.isXpack = false;
}
if (hasLicense()) {
this.getDefaultVersion();
}
//
this.$nextTick(() => {
@ -788,11 +761,11 @@ export default {
this.checkVersionEnable();
},
editPublicCase() {
openCaseEdit(this.caseId, "", this)
editPublicCase(type) {
openCaseEdit({caseId: this.caseId, projectId: this.projectId, type}, this)
},
copyPublicCase() {
openCaseEdit(this.caseId, "copy", this)
this.editPublicCase('copy');
},
closePublicCase() {
this.$emit("close");
@ -877,23 +850,11 @@ export default {
this.saveCase();
},
handleCommand(e) {
if (e === "ADD_AND_CREATE") {
if (!this.validateForm()) {
this.saveCase();
} else {
this.saveCase(function (t) {
if(t){
t.$router.push({path: "/track/case/create",});
location.reload();
}
});
}
} else if (e === "ADD_AND_PUBLIC") {
this.saveType = e;
if (e === 3) {
this.casePublic = true;
this.saveCase();
} else {
this.saveCase();
}
this.saveCase();
},
openComment() {
this.$refs.testCaseComment.open();
@ -912,7 +873,6 @@ export default {
if (!this.customizeVisible) {
this.selectedTreeNode = undefined;
}
//this.reload();
},
reload() {
this.isStepTableAlive = false;
@ -970,6 +930,13 @@ export default {
callback();
}
},
checkCurrentProject() {
//
if (getCurrentProjectID() !== this.projectId) {
setCurrentProjectID(this.projectId);
location.reload();
}
},
getTestCase() {
if (!this.caseId) {
return;
@ -993,11 +960,7 @@ export default {
});
this.form.id = null;
} else {
//
if (this.projectId !== testCase.projectId) {
setCurrentProjectID(testCase.projectId);
location.reload();
}
this.checkCurrentProject(testCase.projectId);
}
this.currentTestCaseInfo = testCase;
this.setFormData(testCase);
@ -1078,9 +1041,9 @@ export default {
removeGoBackListener(this.close);
this.dialogFormVisible = false;
},
saveCase(callback) {
saveCase() {
if (this.validateForm()) {
this._saveCase(callback);
this._saveCase();
} else {
if (this.$refs.versionHistory) {
this.$refs.versionHistory.loading = false;
@ -1090,7 +1053,7 @@ export default {
}
}
},
_saveCase(callback) {
_saveCase() {
let param = this.buildParam();
if (this.validate(param)) {
let option = this.getOption(param);
@ -1113,37 +1076,31 @@ export default {
this.$emit("caseEdit", param);
} else {
param.id = response.data.id;
this.$emit("caseCreate", param);
this.close();
if (this.saveType === 2) {
//
location.reload();
} else {
this.routerToEdit(response.data.id);
}
}
this.form.id = response.data.id;
this.currentTestCaseInfo.id = response.data.id;
this.form.refId = response.data.refId;
this.currentTestCaseInfo.refId = response.data.refId;
if (this.currentTestCaseInfo.isCopy) {
this.currentTestCaseInfo.isCopy = null;
}
if (callback) {
callback(this);
return;
}
//
//
if (hasLicense()) {
this.getDefaultVersion();
}
this.$router.push({path: "/track/case/edit/" + this.form.id})
})
.catch(() => {
this.loading = false;
});
}
},
routerToEdit(id) {
this.$router.push({path: '/track/' + this.projectId + '/case/edit/' + id});
setTimeout(() => {
window.location.reload();
}, 300);
},
buildParam() {
let param = {};
if (this.isAdd) {
this.form.id = null;
}
Object.assign(param, this.form);
param.steps = JSON.stringify(this.form.steps);
param.nodeId = this.form.module;
@ -1347,35 +1304,6 @@ export default {
});
}
},
getDefaultVersion() {
getDefaultVersion(this.projectId).then((response) => {
this.latestVersionId = response.data;
this.getVersionHistory();
});
},
getVersionHistory() {
getTestCaseVersions(this.caseId).then((response) => {
if (response.data.length > 0) {
for (let i = 0; i < response.data.length; i++) {
this.currentProjectId = response.data[i].projectId;
}
} else {
this.currentProjectId = getCurrentProjectID();
}
this.versionData = response.data;
let latestVersionData = response.data.filter(
(v) => v.versionId === this.latestVersionId
);
if (latestVersionData.length > 0) {
this.hasLatest = false;
} else {
this.hasLatest = true;
}
if (this.$refs.versionHistory) {
this.$refs.versionHistory.loading = false;
}
});
},
setSpecialPropForCompare: function (that) {
that.newData.tags = JSON.parse(that.newData.tags || "{}");
that.newData.steps = JSON.parse(that.newData.steps || "{}");
@ -1384,32 +1312,8 @@ export default {
that.newData.readOnly = true;
that.oldData.readOnly = true;
},
async fetchVersionName(){
if(this.form.versionName){
this.currentVersionName = this.form.versionName;
return;
}
if(this.currentVersionName){
return;
}
//
await this.getVersionOptionList();
this.currentVersionName = this.findVersionNameByID(this.form.versionId)
},
async getVersionOptionList() {
if (!hasLicense()) {
return;
}
let res = await getProjectVersions(getCurrentProjectID());
this.versionOptions = res.data ?? [];
},
findVersionNameByID(versionId){
let versionName = "";
let version = this.versionOptions.filter(v => v.id === versionId);
if(Array.isArray(version) && version.length > 0){
return version[0].name;
}
return versionName;
setCurrentVersionName(versionName) {
this.currentVersionName = versionName;
},
compareBranchWithVersionId(originId, targetId){
//
@ -1418,26 +1322,6 @@ export default {
},
compareBranch(t1, t2) {
this.compareBranchWithVersionId(t1.id, t2.id);
// let t1Case = await testCaseGetByVersionId(t1.id, this.currentTestCaseInfo.id);
// let t2Case = await testCaseGetByVersionId(t2.id, this.currentTestCaseInfo.id);
// let p1 = getTestCase(t1Case.data.id);
// let p2 = getTestCase(t2Case.data.id);
// let that = this;
// Promise.all([p1, p2]).then((r) => {
// if (r[0] && r[1]) {
// that.newData = r[0].data;
// that.oldData = r[1].data;
// that.newData.createTime = t1.createTime;
// that.oldData.createTime = t2.createTime;
// that.newData.versionName = t1.name;
// that.oldData.versionName = t2.name;
// that.newData.userName = t1Case.data.createName;
// that.oldData.userName = t2Case.data.createName;
// this.setSpecialPropForCompare(that);
// that.dialogVisible = true;
// }
// });
},
compare(row) {
testCaseGetByVersionId(row.id, this.currentTestCaseInfo.refId).then(
@ -1471,24 +1355,14 @@ export default {
}
);
},
checkout(row) {
this.getVersionHistory();
this.$refs.versionHistory.loading = true;
let testCase = this.versionData.filter((v) => v.versionId === row.id)[0];
if (testCase) {
getTestCase(testCase.id).then((response) => {
let testCase = response.data;
this.currentTestCaseInfo = testCase;
this.form = testCase;
this.caseId = testCase.id;
//
this.currentVersionName = this.findVersionNameByID(this.form.versionId)
this.checkIsLatestVersion(this.form.versionId);
this.$emit("checkout", testCase);
this.$refs.versionHistory.loading = false;
checkoutByVersionId(versionId) {
getTestCaseByVersionId(this.form.refId, versionId)
.then((response) => {
this.routerToEdit(response.data.id);
});
}
},
checkout(testCase) {
this.routerToEdit(testCase.id);
},
validateForm() {
let isValidate = true;
@ -1528,7 +1402,7 @@ export default {
}
return isValidate;
},
async create(row) {
async createVersion(row) {
if (this.validateForm()) {
//
this.form.versionId = row.id;
@ -1541,11 +1415,9 @@ export default {
if (this.$refs.versionHistory) {
this.$refs.versionHistory.loading = false;
}
this.checkoutByVersionId(row.id);
});
}
setTimeout(() => {
this.checkout(row);
}, 3000);
} else {
this.$refs.versionHistory.loading = false;
}
@ -1562,8 +1434,7 @@ export default {
if (action === "confirm") {
deleteTestCaseVersion(row.id, this.form.refId).then(() => {
this.$success(this.$t("commons.delete_success"));
this.getVersionHistory();
this.$emit("refresh");
this.$refs.versionHistory.getVersionOptionList();
});
} else {
that.$refs.versionHistory.loading = false;
@ -1572,16 +1443,16 @@ export default {
}
);
},
setLatest(row) {
setLatest(version) {
let param = {
projectId: getCurrentProjectID(),
type: "TEST_CASE",
versionId: row.id,
versionId: version.id,
resourceId: this.caseId,
};
setLatestVersionById(param).then(() => {
this.$success(this.$t("commons.modify_success"));
this.checkout(row);
this.checkoutByVersionId(version.id);
});
},
hasOtherInfo() {
@ -1600,7 +1471,7 @@ export default {
this.saveCase();
},
copyRow() {
openCaseEdit(this.testCase.id, "copy", this);
openCaseEdit({caseId: this.testCase.id, projectId: this.testCase.projectId, type: 'copy'}, this);
},
deleteRow() {
getTestCaseVersions(this.testCase.id)

View File

@ -849,7 +849,7 @@ export default {
this.$refs.table.resetHeader();
},
handleEdit(testCase, type) {
openCaseEdit(testCase.id, type, this);
openCaseEdit({caseId: testCase.id, projectId: testCase.projectId, type}, this);
},
getCase(id) {
this.$refs.testCasePreview.open();

View File

@ -13,7 +13,7 @@
<div class="label">{{ $t("project.version.name") }}</div>
</div>
<div class="history-container">
<div class="item-row" v-for="item in versionOptions" :key="item.id">
<div class="item-row" v-for="item in versionOptions" :key="item.id" @click="checkout(item)">
<div class="left-detail-row">
<div class="version-info-row">
<div
@ -29,57 +29,45 @@
{{ $t("case.last_version") }}
</div>
</div>
<div class="version-detail">
<div class="version-detail" v-if="item.createName">
<div class="creator">
{{ item.createUserName }} {{ $t("commons.create") }}
{{ item.createName }} {{ $t("commons.create") }}
</div>
</div>
</div>
<div class="right-opt-row">
<div
class="updated opt-row"
@click="setLatest(item)"
v-if="
hasLatest &&
item.isCheckout &&
!(isRead || item.id === dataLatestId)
"
@click.stop="setLatest(item)"
v-if="caseVersionMap.has(item.id)
&& !(isRead || item.id === dataLatestId)"
>
{{ $t("case.set_new") }}
</div>
<div
class="checkout opt-row"
@click="checkout(item)"
v-if="item.isCheckout && !item.isCurrent"
>
{{ $t("project.version.checkout") }}
</div>
<div
class="create opt-row"
v-if="!item.isCheckout && item.status === 'open' && !isRead"
@click="create(item)"
v-if="!caseVersionMap.has(item.id)
&& !isRead"
@click.stop="create(item)"
>
{{ $t("commons.create") }}
</div>
<div
class="delete opt-row"
@click="del(item)"
v-if="item.isCheckout && !(item.isCurrent || isRead)"
@click.stop="del(item)"
v-if="caseVersionMap.has(item.id)
&& !(item.id === currentVersionId)
&& !isRead"
>
{{ $t("commons.delete") }}
</div>
<!-- <div
@click="compare(item)"
v-if="item.isCheckout && !item.isCurrent"
>
{{ $t("project.version.compare") }}
</div> -->
</div>
</div>
</div>
<div class="compare-row" @click.stop="compareDialogVisible = true">
<div class="compare-row" :disabled="!versionCompareOptions || versionCompareOptions.length < 2"
@click.stop="compareDialogVisible = true">
<div class="icon">
<img src="/assets/module/figma/icon_contrast_outlined.svg" alt="" />
<img src="/assets/module/figma/icon_contrast_outlined.svg" alt=""/>
</div>
<div class="label">{{ $t("case.version_comparison") }}</div>
</div>
@ -104,7 +92,7 @@
<div class="version-left-box">
<el-select v-model="versionLeftId" size="small">
<el-option
v-for="item in versionLeftOptions"
v-for="item in versionCompareOptions"
:key="item.id"
:label="item.name"
:value="item.id"
@ -115,24 +103,25 @@
<div class="version-right-box">
<el-select v-model="versionRightId" size="small">
<el-option
v-for="item in versionRightOptions"
v-for="item in versionCompareOptions"
:key="item.id"
:label="item.name"
:value="item.id"
></el-option
></el-select>
>
</el-select>
</div>
</div>
<span slot="footer" class="dialog-footer">
<el-button @click="closeCompareVersionDialog" size="small">{{
$t("commons.cancel")
}}</el-button>
$t("commons.cancel")
}}</el-button>
<el-button
:type="enableCompare ? 'primary' : 'info'"
:disabled="!enableCompare"
@click="compareBranch"
size="small"
>{{ $t("commons.confirm") }}</el-button
>{{ $t("commons.confirm") }}</el-button
>
</span>
</el-dialog>
@ -140,20 +129,20 @@
</template>
<script>
import { getCurrentProjectID } from "metersphere-frontend/src/utils/token";
import { hasLicense } from "metersphere-frontend/src/utils/permission";
import {getCurrentProjectID} from "metersphere-frontend/src/utils/token";
import {hasLicense} from "metersphere-frontend/src/utils/permission";
import {
getProjectMembers,
getProjectVersions,
isProjectVersionEnable,
} from "metersphere-frontend/src/api/version";
import { getTestCaseVersions } from "@/api/testCase";
import {getTestCaseVersions} from "@/api/testCase";
export default {
name: "CaseVersionHistory",
props: {
versionData: Array,
currentId: String,
currentVersionId: String,
testUsers: Array,
useExternalUsers: Boolean,
isTestCaseVersion: {
@ -180,6 +169,7 @@ export default {
loading: false,
versionEnable: false,
versionOptions: [],
versionCompareOptions: [],
userData: {},
currentVersion: {},
dataLatestId: "",
@ -187,18 +177,14 @@ export default {
//
versionLeftId: "",
versionRightId: "",
//
caseVersionMap: new Map()
};
},
computed: {
enableCompare() {
return this.versionLeftId && this.versionRightId;
},
versionLeftOptions() {
return this.versionOptions;
},
versionRightOptions() {
return this.versionOptions;
},
},
beforeDestroy() {
this.clearSelectData();
@ -214,7 +200,7 @@ export default {
this.versionRightId = "";
},
findVersionById(id) {
let version = this.versionOptions.filter((v) => v.id === id);
let version = this.versionCompareOptions.filter((v) => v.id === id);
return Array.isArray(version) ? version[0] : version || {};
},
compareBranch() {
@ -225,27 +211,23 @@ export default {
);
this.clearSelectData();
},
async getVersionOptionList(callback) {
// getProjectVersions(this.currentProjectId).then((response) => {
// this.versionOptions = response.data.filter((v) => v.status === "open");
// if (callback) {
// callback(this.versionOptions);
// }
// });
let response = await getProjectVersions(this.currentProjectId);
let versions = response.data || [];
let getAllVersions = await getTestCaseVersions(this.currentId);
let allVersionCases = getAllVersions.data || [];
let tempMap = new Map();
allVersionCases.forEach((c) => {
tempMap.set(c.versionId, c);
});
this.versionOptions = versions.filter((v) => {
return tempMap.get(v.id);
});
if (callback) {
callback(this.versionOptions);
async getVersionOptionList() {
if (!this.currentProjectId) {
return;
}
let response = await getProjectVersions(this.currentProjectId);
let versions = response.data.filter((v) => v.status === "open") || [];
this.versionOptions = versions;
response = await getTestCaseVersions(this.currentId);
let allVersionCases = response.data || [];
this.caseVersionMap = new Map();
allVersionCases.forEach((c) => this.caseVersionMap.set(c.versionId, c));
//
this.versionCompareOptions = this.versionOptions.filter((v) => this.caseVersionMap.has(v.id));
this.handleVersionOptions();
},
updateUserDataByExternal() {
if (this.testUsers && this.testUsers.length > 0) {
@ -270,8 +252,12 @@ export default {
this.$emit("compare", row);
},
checkout(row) {
let versionCase = this.caseVersionMap.get(row.id);
if (!versionCase) {
return;
}
this.loading = true;
this.$emit("checkout", row);
this.$emit("checkout", versionCase);
},
create(row) {
this.loading = true;
@ -286,49 +272,54 @@ export default {
this.$emit("setLatest", row);
},
handleVersionOptions() {
let versionData = this.versionData;
if (versionData.length === 0) {
this.currentVersion =
this.versionOptions.filter(
(v) => v.status === "open" && v.latest
)[0] || {};
this.loading = false;
return;
}
let latestData = versionData.filter((v) => v.latest === true);
if (latestData && latestData.length > 0) {
this.dataLatestId = latestData[0].versionId;
}
this.versionOptions.forEach((version) => {
let vs = versionData.filter((v) => v.versionId === version.id);
version.isCheckout = vs.length > 0; //
if (version.isCheckout) {
version.createUser =
vs[0].createUser || vs[0].userId || vs[0].creator;
} else {
version.createUser = null;
let latestData = {};
this.versionOptions.forEach(v => {
//
if (v.id === this.currentVersionId) {
v.isCurrent = true;
this.currentVersion = v;
this.$emit('setCurrentVersionName', this.currentVersion.name);
}
let lastItem = versionData.filter((v) => v.id === this.currentId)[0];
if (lastItem) {
version.isCurrent = lastItem.versionId === version.id;
if (version.isCurrent) {
this.currentVersion = version;
let versionCase = this.caseVersionMap.get(v.id);
if (versionCase) {
//
v.createName = versionCase.createName;
//
if (versionCase.latest) {
latestData = v;
this.dataLatestId = v.id;
this.$emit('setLatestVersionId', this.dataLatestId);
}
}
});
if (!this.currentVersionId) {
// versionId , versionId
this.currentVersion = latestData;
}
this.$emit('setIsLastedVersion', this.currentVersionId === this.dataLatestId);
this.loading = false;
},
},
watch: {
versionData() {
currentId() {
if (!hasLicense()) {
return;
}
isProjectVersionEnable(this.currentProjectId).then((response) => {
this.versionEnable = response.data;
});
this.getUserOptions();
this.getVersionOptionList(this.handleVersionOptions);
isProjectVersionEnable(this.currentProjectId)
.then((response) => {
this.versionEnable = response.data;
if (this.versionEnable) {
this.getUserOptions();
this.getVersionOptionList();
}
});
},
testUsers() {
this.updateUserDataByExternal();
@ -339,16 +330,20 @@ export default {
<style scoped lang="scss">
@import "@/business/style/index.scss";
:deep(.el-popover) {
width: 392px !important;
}
.version-history-wrap {
width: 392px;
height: 271px;
.label-row {
height: 32px;
line-height: 32px;
margin-top: 8px;
.label {
font-weight: 500;
color: #1f2329;
@ -362,9 +357,11 @@ export default {
.history-container {
height: 182px;
overflow: scroll;
.item-row:hover {
background: rgba(31, 35, 41, 0.1);
}
.item-row {
cursor: pointer;
margin-top: 8px;
@ -372,12 +369,15 @@ export default {
display: flex;
padding: 0 11px;
justify-content: space-between;
.left-detail-row {
display: flex;
flex-direction: column;
justify-content: center;
.version-info-row {
display: flex;
.version-label {
height: 22px;
font-weight: 500;
@ -410,11 +410,13 @@ export default {
.right-opt-row {
display: flex;
align-items: center;
justify-content: flex-end;
align-items: flex-start;
.opt-row:not(:first-child) {
margin-left: 16px;
}
.opt-row {
margin-top: 4px;
height: 22px;
@ -424,11 +426,13 @@ export default {
color: #646a73;
cursor: pointer;
}
.opt-row:hover {
background: rgba(120, 56, 135, 0.1);
border-radius: 4px;
cursor: pointer;
}
.updated {
}
@ -440,9 +444,11 @@ export default {
}
}
}
.active {
color: #783887;
}
.compare-row {
cursor: pointer;
display: flex;
@ -452,6 +458,7 @@ export default {
margin-top: 3px;
border-top: 1px solid rgba(31, 35, 41, 0.15);
align-items: center;
.icon {
margin-left: 11.67px;
margin-right: 4.6px;
@ -473,11 +480,14 @@ export default {
.compare-wrap {
display: flex;
:deep(.el-select--small) {
width: 100%;
}
.version-left-box {
width: 254px;
el-select {
}
}
@ -491,9 +501,11 @@ export default {
.version-right-box {
width: 254px;
el-select {
}
}
margin-top: 24px;
margin-bottom: 24px;
}

View File

@ -449,7 +449,7 @@ export default {
this.selectCounts = this.$refs.table.selectDataCounts;
},
handleEdit(testCase, type) {
openCaseEdit(testCase.id, type, this);
openCaseEdit({caseId: testCase.id, projectId: testCase.projectId, type}, this);
},
handleEditShow(testCase, column) {
this.$refs.publicTestCaseShow.open(testCase.id);

View File

@ -1,4 +1,4 @@
import {getAdvSearchCustomField, OPERATORS} from "@/business/utils/sdk-utils";
import {getAdvSearchCustomField, getCurrentProjectID, OPERATORS} from "@/business/utils/sdk-utils";
import i18n from "@/i18n";
export function initTestCaseConditionComponents(condition, customFields, trashEnable) {
@ -48,18 +48,51 @@ export function initTestCaseConditionComponents(condition, customFields, trashEn
return conditionComponents;
}
export function openCaseEdit(caseId, type, v) {
if (!caseId) {
/**
* 跳转到用例编辑页面
* @param query
* {
* projectId: 项目ID
* caseId: 用例ID
* type: 特殊跳转copy 表示复制操作
* }
*/
export function openCaseEdit(query, v) {
if (!query.caseId) {
return;
}
let query = {};
if (type) {
query.type = type;
if (!query.type) {
delete query.type;
}
if (!query.projectId) {
query.projectId = getCurrentProjectID();
}
let path = '/track/' + query.projectId + '/case/edit/' + query.caseId;
delete query.projectId;
delete query.caseId;
let TestCaseData = v.$router.resolve({
path: "/track/case/edit/" + caseId,
path,
query,
});
window.open(TestCaseData.href, "_blank");
window.open(TestCaseData.href, '_blank');
}
/**
* 跳转到用例创建页面
* @param query
* {
* projectId: 项目ID
* }
*/
export function openCaseCreate(query, v) {
if (!query.projectId) {
query.projectId = getCurrentProjectID();
}
let path = '/track/' + query.projectId + '/case/create';
delete query.projectId;
let TestCaseData = v.$router.resolve({
path,
query,
});
window.open(TestCaseData.href, '_blank');
}

View File

@ -78,7 +78,7 @@ export default {
}
},
openTestCase() {
openCaseEdit(this.testCase.caseId, null, this);
openCaseEdit({caseId: this.testCase.caseId, projectId: this.testCase.projectId}, this);
},
close() {
this.$emit('close');

View File

@ -12,7 +12,7 @@ export default {
component: () => import('@/business/home/TrackHome'),
},
{
path: 'case/create',
path: ':projectId/case/create',
name: 'testCaseCreate',
component: () => import('@/business/case/components/TestCaseEdit'),
},
@ -27,7 +27,7 @@ export default {
component: () => import('@/business/case/TestCase'),
},
{
path: 'case/edit/:caseId',
path: ':projectId/case/edit/:caseId',
name: 'testCaseEdit',
component: () => import('@/business/case/components/TestCaseEdit'),
},

View File

@ -23,6 +23,7 @@
import MsBorderPieChart from "metersphere-frontend/src/components/MsBorderPieChart";
import {getMyCreatedCaseGroupContMap} from "@/api/workstation";
import {getCurrentProject} from "@/api/project";
export default{
@ -74,7 +75,7 @@ export default{
},
toCreatCase(){
let caseData = this.$router.resolve({
path: '/track/case/create',
path: '/track/' + getCurrentProject() + '/case/create',
});
window.open(caseData.href, '_blank');
},