fix(接口测试): 修复跳转到接口测试和接口场景页面的相关问题

修复跳转到接口测试和接口场景页面的相关问题
This commit is contained in:
song-tianyang 2023-01-11 15:21:23 +08:00 committed by 建国
parent c7112fbd32
commit e15930c08b
9 changed files with 677 additions and 451 deletions

View File

@ -372,10 +372,10 @@ export default {
} }
}, },
_getCurrentUserId() { _getCurrentUserId() {
const {id, userGroups} = getCurrentUser(); const { id, userGroups } = getCurrentUser();
if (userGroups) { if (userGroups) {
// //
let index = userGroups.findIndex(ug => ug.sourceId === getCurrentProjectID()); let index = userGroups.findIndex((ug) => ug.sourceId === getCurrentProjectID());
if (index !== -1) { if (index !== -1) {
return id; return id;
} }
@ -786,6 +786,7 @@ export default {
let automationData = this.$router.resolve({ let automationData = this.$router.resolve({
name: 'ApiAutomationWithQuery', name: 'ApiAutomationWithQuery',
params: { params: {
versionId: 'default',
redirectID: getUUID(), redirectID: getUUID(),
dataType: 'scenario', dataType: 'scenario',
dataSelectRange: 'edit:' + resource.id, dataSelectRange: 'edit:' + resource.id,

View File

@ -355,6 +355,7 @@ export default {
let automationData = this.$router.resolve({ let automationData = this.$router.resolve({
name: 'ApiAutomationWithQuery', name: 'ApiAutomationWithQuery',
params: { params: {
versionId: 'default',
redirectID: getUUID(), redirectID: getUUID(),
dataType: 'scenario', dataType: 'scenario',
dataSelectRange: 'edit:' + resource.id, dataSelectRange: 'edit:' + resource.id,

View File

@ -84,7 +84,7 @@
v-model="controller.countController.interval" v-model="controller.countController.interval"
:disabled="controller.disabled" :disabled="controller.disabled"
:placeholder="$t('commons.millisecond')" :placeholder="$t('commons.millisecond')"
:max="1000 * 10000000" :max="1000 * 1000000"
:min="0" :min="0"
:step="1000" :step="1000"
size="small" /> size="small" />
@ -129,7 +129,7 @@
:disabled="controller.disabled" :disabled="controller.disabled"
size="small" size="small"
:placeholder="$t('commons.millisecond')" :placeholder="$t('commons.millisecond')"
:max="1000 * 10000000" :max="1000 * 1000000"
:min="0" :min="0"
:step="1000" /> :step="1000" />
<span class="ms-span ms-radio">ms</span> <span class="ms-span ms-radio">ms</span>
@ -165,12 +165,11 @@
:disabled="controller.disabled" :disabled="controller.disabled"
size="small" size="small"
:placeholder="$t('commons.millisecond')" :placeholder="$t('commons.millisecond')"
:max="1000 * 10000000" :max="1000 * 1000000"
:min="3000" :min="3000"
:step="1000" /> :step="1000" />
<span class="ms-span ms-radio">ms</span> <span class="ms-span ms-radio">ms</span>
</div> </div>
<template v-slot:debugStepCode> <template v-slot:debugStepCode>
<span v-if="node.data.testing" class="ms-test-running"> <span v-if="node.data.testing" class="ms-test-running">
<i class="el-icon-loading" style="font-size: 16px" /> <i class="el-icon-loading" style="font-size: 16px" />

View File

@ -162,6 +162,7 @@ export default {
let automationData = this.$router.resolve({ let automationData = this.$router.resolve({
name: 'ApiAutomationWithQuery', name: 'ApiAutomationWithQuery',
params: { params: {
versionId: 'default',
redirectID: getUUID(), redirectID: getUUID(),
dataType: 'scenario', dataType: 'scenario',
dataSelectRange: 'edit:' + response.data.id, dataSelectRange: 'edit:' + response.data.id,

View File

@ -73,6 +73,7 @@ export default {
home = this.$router.resolve({ home = this.$router.resolve({
name: 'ApiDefinitionWithQuery', name: 'ApiDefinitionWithQuery',
params: { params: {
versionId: 'default',
redirectID: uuid, redirectID: uuid,
dataType: dataType, dataType: dataType,
dataSelectRange: selectRange, dataSelectRange: selectRange,
@ -84,6 +85,7 @@ export default {
home = this.$router.resolve({ home = this.$router.resolve({
name: 'ApiAutomationWithQuery', name: 'ApiAutomationWithQuery',
params: { params: {
versionId: 'default',
redirectID: uuid, redirectID: uuid,
dataType: dataType, dataType: dataType,
dataSelectRange: selectRange, dataSelectRange: selectRange,

View File

@ -246,6 +246,7 @@ export default {
let automationData = this.$router.resolve({ let automationData = this.$router.resolve({
name: 'ApiAutomationWithQuery', name: 'ApiAutomationWithQuery',
params: { params: {
versionId: 'default',
redirectID: getUUID(), redirectID: getUUID(),
dataType: 'scenario', dataType: 'scenario',
dataSelectRange: 'edit:' + resource.id, dataSelectRange: 'edit:' + resource.id,

View File

@ -6,8 +6,8 @@
:modal-append-to-body="false" :modal-append-to-body="false"
size="100%" size="100%"
ref="drawer" ref="drawer"
v-loading="loading"> v-loading="loading"
>
<template> <template>
<el-row> <el-row>
<el-col :span="17"> <el-col :span="17">
@ -16,11 +16,13 @@
<el-scrollbar> <el-scrollbar>
<el-header> <el-header>
<el-row type="flex" class="head-bar"> <el-row type="flex" class="head-bar">
<el-col :span="4"> <el-col :span="4">
<el-button plain size="mini" <el-button
icon="el-icon-back" plain
@click="cancel">{{ $t('test_track.return') }} size="mini"
icon="el-icon-back"
@click="cancel"
>{{ $t("test_track.return") }}
</el-button> </el-button>
</el-col> </el-col>
@ -35,9 +37,9 @@
:pre-page-data="prePageData" :pre-page-data="prePageData"
@pre="handlePre" @pre="handlePre"
@next="handleNext" @next="handleNext"
:list="testCases"/> :list="testCases"
/>
</el-col> </el-col>
</el-row> </el-row>
<el-row class="head-bar"> <el-row class="head-bar">
@ -47,82 +49,144 @@
class="test-case-name" class="test-case-name"
type="text" type="text"
:disabled="!hasProjectPermission" :disabled="!hasProjectPermission"
@click="openTestTestCase(testCase)"> @click="openTestTestCase(testCase)"
<span >
class="title-link" <span
:title="testCase.name" class="title-link"
:style="{'max-width': titleWith + 'px'}"> :title="testCase.name"
{{ testCase.customNum }}-{{ testCase.name }} :style="{ 'max-width': titleWith + 'px' }"
</span> >
{{ testCase.customNum }}-{{ testCase.name }}
</span>
</el-button> </el-button>
</el-divider> </el-divider>
</el-col> </el-col>
</el-row> </el-row>
</el-header> </el-header>
<div class="case_container"> <div class="case_container">
<el-form :model="testCase"> <el-form :model="testCase">
<el-row> <el-row>
<el-col :span="7"> <el-col :span="7">
<el-form-item :label="$t('test_track.case.module')" prop="nodePath" <el-form-item
:label-width="formLabelWidth"> :label="$t('test_track.case.module')"
prop="nodePath"
:label-width="formLabelWidth"
>
{{ testCase.nodePath }} {{ testCase.nodePath }}
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="7"> <el-col :span="7">
<el-form-item :label="$t('test_track.plan.plan_project')" prop="projectName" <el-form-item
:label-width="formLabelWidth"> :label="$t('test_track.plan.plan_project')"
prop="projectName"
:label-width="formLabelWidth"
>
{{ testCase.projectName }} {{ testCase.projectName }}
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="10"> <el-col :span="10">
<el-form-item :label="$t('test_track.plan.load_case.execution_status')" <el-form-item
:label-width="formLabelWidth"> :label="
<status-table-item :value="originalStatus"/> $t('test_track.plan.load_case.execution_status')
"
:label-width="formLabelWidth"
>
<status-table-item :value="originalStatus" />
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-form ref="customFieldForm" <el-form
v-if="isCustomFiledActive" ref="customFieldForm"
class="case-form"> v-if="isCustomFiledActive"
class="case-form"
>
<el-row> <el-row>
<el-col :span="7" v-for="(item, index) in testCaseTemplate.customFields" :key="index"> <el-col
<el-form-item :label-width="formLabelWidth" :span="7"
:label="item.system ? $t(systemNameMap[item.name]) : item.name" v-for="(item, index) in testCaseTemplate.customFields"
:prop="item.name"> :key="index"
<custom-filed-component :disabled="true" :data="item" :form="{}" prop="defaultValue"/> >
<el-form-item
:label-width="formLabelWidth"
:label="
item.system
? $t(systemNameMap[item.name])
: item.name
"
:prop="item.name"
>
<custom-filed-component
:disabled="true"
:data="item"
:form="{}"
prop="defaultValue"
/>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
</el-form> </el-form>
<form-rich-text-item :label-width="formLabelWidth" :disabled="true" <form-rich-text-item
:title="$t('test_track.case.prerequisite')" :data="testCase" :label-width="formLabelWidth"
prop="prerequisite"/> :disabled="true"
<step-change-item :disable="true" :label-width="formLabelWidth" :form="testCase"/> :title="$t('test_track.case.prerequisite')"
<test-plan-case-step-results-item :label-width="formLabelWidth" :is-read-only="isReadOnly" :data="testCase"
v-if="testCase.stepModel === 'STEP'" :test-case="testCase"/> prop="prerequisite"
<form-rich-text-item :label-width="formLabelWidth" v-if="testCase.stepModel === 'TEXT'" />
:disabled="true" :title="$t('test_track.case.step_desc')" :data="testCase" <step-change-item
prop="stepDescription"/> :disable="true"
<form-rich-text-item :label-width="formLabelWidth" v-if="testCase.stepModel === 'TEXT'" :label-width="formLabelWidth"
:disabled="true" :title="$t('test_track.case.expected_results')" :form="testCase"
:data="testCase" prop="expectedResult"/> />
<form-rich-text-item :label-width="formLabelWidth" v-if="testCase.stepModel === 'TEXT'" <test-plan-case-step-results-item
:title="$t('test_track.plan_view.actual_result')" :label-width="formLabelWidth"
:data="testCase" prop="actualResult"/> :is-read-only="isReadOnly"
v-if="testCase.stepModel === 'STEP'"
:test-case="testCase"
/>
<form-rich-text-item
:label-width="formLabelWidth"
v-if="testCase.stepModel === 'TEXT'"
:disabled="true"
:title="$t('test_track.case.step_desc')"
:data="testCase"
prop="stepDescription"
/>
<form-rich-text-item
:label-width="formLabelWidth"
v-if="testCase.stepModel === 'TEXT'"
:disabled="true"
:title="$t('test_track.case.expected_results')"
:data="testCase"
prop="expectedResult"
/>
<form-rich-text-item
:label-width="formLabelWidth"
v-if="testCase.stepModel === 'TEXT'"
:title="$t('test_track.plan_view.actual_result')"
:data="testCase"
prop="actualResult"
/>
<el-form-item
<el-form-item :label="$t('test_track.case.other_info')" :label-width="formLabelWidth"> :label="$t('test_track.case.other_info')"
<test-case-edit-other-info :plan-id="testCase.planId" v-if="otherInfoActive" @openTest="openTest" :label-width="formLabelWidth"
:is-test-plan-edit="true" >
@syncRelationGraphOpen="syncRelationGraphOpen" <test-case-edit-other-info
:read-only="true" :is-test-plan="true" :project-id="testCase.projectId" :plan-id="testCase.planId"
:form="testCase" :case-id="testCase.caseId" ref="otherInfo"/> v-if="otherInfoActive"
@openTest="openTest"
:is-test-plan-edit="true"
@syncRelationGraphOpen="syncRelationGraphOpen"
:read-only="true"
:is-test-plan="true"
:project-id="testCase.projectId"
:form="testCase"
:case-id="testCase.caseId"
ref="otherInfo"
/>
</el-form-item> </el-form-item>
</el-form> </el-form>
</div> </div>
</el-scrollbar> </el-scrollbar>
@ -135,11 +199,13 @@
:test-case="testCase" :test-case="testCase"
:is-read-only="isReadOnly" :is-read-only="isReadOnly"
:origin-status="originalStatus" :origin-status="originalStatus"
@saveCase="saveCase"/> @saveCase="saveCase"
/>
<review-comment <review-comment
default-type="PLAN" default-type="PLAN"
:case-id="testCase.caseId" :case-id="testCase.caseId"
ref="comment"/> ref="comment"
/>
</div> </div>
</el-col> </el-col>
</el-row> </el-row>
@ -148,30 +214,40 @@
</template> </template>
<script> <script>
import TestPlanTestCaseStatusButton from '../../../common/TestPlanTestCaseStatusButton'; import TestPlanTestCaseStatusButton from "../../../common/TestPlanTestCaseStatusButton";
import ClassicEditor from '@ckeditor/ckeditor5-build-classic'; import ClassicEditor from "@ckeditor/ckeditor5-build-classic";
import {getUUID, listenGoBack, removeGoBackListener} from "metersphere-frontend/src/utils" import {
import {hasPermission} from "metersphere-frontend/src/utils/permission"; getUUID,
listenGoBack,
removeGoBackListener,
} from "metersphere-frontend/src/utils";
import { hasPermission } from "metersphere-frontend/src/utils/permission";
import TestCaseAttachment from "@/business/case/components/TestCaseAttachment"; import TestCaseAttachment from "@/business/case/components/TestCaseAttachment";
import CaseComment from "@/business/case/components/CaseComment"; import CaseComment from "@/business/case/components/CaseComment";
import MsPreviousNextButton from "metersphere-frontend/src/components/MsPreviousNextButton"; import MsPreviousNextButton from "metersphere-frontend/src/components/MsPreviousNextButton";
import ReviewComment from "@/business/review/commom/ReviewComment"; import ReviewComment from "@/business/review/commom/ReviewComment";
import {buildTestCaseOldFields, parseCustomField} from "metersphere-frontend/src/utils/custom_field"; import {
buildTestCaseOldFields,
parseCustomField,
} from "metersphere-frontend/src/utils/custom_field";
import FormRichTextItem from "metersphere-frontend/src/components/FormRichTextItem"; import FormRichTextItem from "metersphere-frontend/src/components/FormRichTextItem";
import MsFormDivider from "metersphere-frontend/src/components/MsFormDivider"; import MsFormDivider from "metersphere-frontend/src/components/MsFormDivider";
import TestCaseEditOtherInfo from "@/business/case/components/TestCaseEditOtherInfo"; import TestCaseEditOtherInfo from "@/business/case/components/TestCaseEditOtherInfo";
import CustomFiledComponent from "metersphere-frontend/src/components/template/CustomFiledComponent"; import CustomFiledComponent from "metersphere-frontend/src/components/template/CustomFiledComponent";
import {SYSTEM_FIELD_NAME_MAP} from "metersphere-frontend/src/utils/table-constants"; import { SYSTEM_FIELD_NAME_MAP } from "metersphere-frontend/src/utils/table-constants";
import IssueDescriptionTableItem from "@/business/issue/IssueDescriptionTableItem"; import IssueDescriptionTableItem from "@/business/issue/IssueDescriptionTableItem";
import StepChangeItem from "@/business/case/components/StepChangeItem"; import StepChangeItem from "@/business/case/components/StepChangeItem";
import TestCaseStepItem from "@/business/case/components/TestCaseStepItem"; import TestCaseStepItem from "@/business/case/components/TestCaseStepItem";
import TestPlanCaseStepResultsItem from "@/business/plan/view/comonents/functional/TestPlanCaseStepResultsItem"; import TestPlanCaseStepResultsItem from "@/business/plan/view/comonents/functional/TestPlanCaseStepResultsItem";
import TestPlanFunctionalExecute from "@/business/plan/view/comonents/functional/TestPlanFunctionalExecute"; import TestPlanFunctionalExecute from "@/business/plan/view/comonents/functional/TestPlanFunctionalExecute";
import StatusTableItem from "@/business/common/tableItems/planview/StatusTableItem"; import StatusTableItem from "@/business/common/tableItems/planview/StatusTableItem";
import {testPlanTestCaseEdit, testPlanTestCaseGet} from "@/api/remote/plan/test-plan-test-case"; import {
import {testPlanEditStatus} from "@/api/remote/plan/test-plan"; testPlanTestCaseEdit,
import {getTestTemplate} from "@/api/custom-field-template"; testPlanTestCaseGet,
import {checkProjectPermission} from "@/api/testCase"; } from "@/api/remote/plan/test-plan-test-case";
import { testPlanEditStatus } from "@/api/remote/plan/test-plan";
import { getTestTemplate } from "@/api/custom-field-template";
import { checkProjectPermission } from "@/api/testCase";
export default { export default {
name: "FunctionalTestCaseEdit", name: "FunctionalTestCaseEdit",
@ -190,7 +266,7 @@ export default {
MsPreviousNextButton, MsPreviousNextButton,
CaseComment, CaseComment,
TestPlanTestCaseStatusButton, TestPlanTestCaseStatusButton,
TestCaseAttachment TestCaseAttachment,
}, },
data() { data() {
return { return {
@ -201,34 +277,34 @@ export default {
index: 0, index: 0,
editor: ClassicEditor, editor: ClassicEditor,
test: {}, test: {},
activeTab: 'detail', activeTab: "detail",
users: [], users: [],
tableData: [], tableData: [],
comments: [], comments: [],
testCaseTemplate: {}, testCaseTemplate: {},
formLabelWidth: '100px', formLabelWidth: "100px",
isCustomFiledActive: false, isCustomFiledActive: false,
otherInfoActive: true, otherInfoActive: true,
isReadOnly: false, isReadOnly: false,
testCases: [], testCases: [],
originalStatus: '', originalStatus: "",
titleWith: 0 titleWith: 0,
}; };
}, },
props: { props: {
total: { total: {
type: Number type: Number,
}, },
searchParam: { searchParam: {
type: Object type: Object,
}, },
pageNum: Number, pageNum: Number,
pageSize: { pageSize: {
type: Number, type: Number,
default: 1 default: 1,
}, },
nextPageData: Object, nextPageData: Object,
prePageData: Object prePageData: Object,
}, },
computed: { computed: {
systemNameMap() { systemNameMap() {
@ -243,18 +319,18 @@ export default {
removeGoBackListener(this.handleClose); removeGoBackListener(this.handleClose);
this.showDialog = false; this.showDialog = false;
this.searchParam.status = null; this.searchParam.status = null;
this.$emit('update:search-param', this.searchParam); this.$emit("update:search-param", this.searchParam);
}, },
cancel() { cancel() {
this.handleClose(); this.handleClose();
this.$emit('refreshTable'); this.$emit("refreshTable");
}, },
getOption(param) { getOption(param) {
let formData = new FormData(); let formData = new FormData();
let url = '/test/case/edit/testPlan'; let url = "/test/case/edit/testPlan";
if (this.$refs.otherInfo && this.$refs.otherInfo.uploadList) { if (this.$refs.otherInfo && this.$refs.otherInfo.uploadList) {
this.$refs.otherInfo.uploadList.forEach(f => { this.$refs.otherInfo.uploadList.forEach((f) => {
formData.append("file", f); formData.append("file", f);
}); });
} }
@ -271,17 +347,20 @@ export default {
return key === "file" ? undefined : value; return key === "file" ? undefined : value;
}); });
formData.append('request', new Blob([requestJson], { formData.append(
type: "application/json " "request",
})); new Blob([requestJson], {
type: "application/json ",
})
);
return { return {
method: 'POST', method: "POST",
url: url, url: url,
data: formData, data: formData,
headers: { headers: {
'Content-Type': undefined "Content-Type": undefined,
} },
}; };
}, },
saveCase() { saveCase() {
@ -302,12 +381,18 @@ export default {
result.actualResult = this.testCase.steptResults[i].actualResult; result.actualResult = this.testCase.steptResults[i].actualResult;
result.executeResult = this.testCase.steptResults[i].executeResult; result.executeResult = this.testCase.steptResults[i].executeResult;
if (result.actualResult && result.actualResult.length > 500) { if (result.actualResult && result.actualResult.length > 500) {
this.$warning(this.$t('test_track.plan_view.actual_result') this.$warning(
+ this.$t('test_track.length_less_than') + '500'); this.$t("test_track.plan_view.actual_result") +
this.$t("test_track.length_less_than") +
"500"
);
return; return;
} }
if (result.executeResult === 'Failure' && this.testCase.status === 'Pass') { if (
this.$warning(this.$t('test_track.plan_view.execute_tip')); result.executeResult === "Failure" &&
this.testCase.status === "Pass"
) {
this.$warning(this.$t("test_track.plan_view.execute_tip"));
this.testCase.status = this.originalStatus; this.testCase.status = this.originalStatus;
return; return;
} }
@ -315,20 +400,19 @@ export default {
} }
param.results = JSON.stringify(param.results); param.results = JSON.stringify(param.results);
param.actualResult = this.testCase.actualResult; param.actualResult = this.testCase.actualResult;
testPlanTestCaseEdit(param) testPlanTestCaseEdit(param).then(() => {
.then(() => { this.$request(option);
this.$request(option);
this.$success(this.$t('commons.save_success')); this.$success(this.$t("commons.save_success"));
this.updateTestCases(param); this.updateTestCases(param);
this.setPlanStatus(this.testCase.planId); this.setPlanStatus(this.testCase.planId);
if (this.testCase.comment) { if (this.testCase.comment) {
this.$refs.comment.getComments(); this.$refs.comment.getComments();
this.testCase.comment = ''; this.testCase.comment = "";
} }
this.originalStatus = this.testCase.status; this.originalStatus = this.testCase.status;
}); });
}, },
updateTestCases(param) { updateTestCases(param) {
for (let i = 0; i < this.testCases.length; i++) { for (let i = 0; i < this.testCases.length; i++) {
@ -345,7 +429,7 @@ export default {
if (this.isLastData()) { if (this.isLastData()) {
return; return;
} else if (this.index === this.testCases.length - 1) { } else if (this.index === this.testCases.length - 1) {
this.$emit('nextPage'); this.$emit("nextPage");
this.index = 0; this.index = 0;
return; return;
} }
@ -354,20 +438,23 @@ export default {
this.reloadOtherInfo(); this.reloadOtherInfo();
}, },
isLastData() { isLastData() {
return this.index === this.testCases.length - 1 && this.pageNum === this.pageTotal; return (
this.index === this.testCases.length - 1 &&
this.pageNum === this.pageTotal
);
}, },
reloadOtherInfo() { reloadOtherInfo() {
this.otherInfoActive = false; this.otherInfoActive = false;
this.$nextTick(() => { this.$nextTick(() => {
this.otherInfoActive = true; this.otherInfoActive = true;
}) });
}, },
handlePre() { handlePre() {
if (this.index === 0 && this.pageNum === 1) { if (this.index === 0 && this.pageNum === 1) {
this.$warning('已经是第一页'); this.$warning("已经是第一页");
return; return;
} else if (this.index === 0) { } else if (this.index === 0) {
this.$emit('prePage'); this.$emit("prePage");
this.index = this.pageSize - 1; this.index = this.pageSize - 1;
return; return;
} }
@ -378,66 +465,69 @@ export default {
getTestCase(id) { getTestCase(id) {
this.loading = true; this.loading = true;
// id TestPlanTestCase id // id TestPlanTestCase id
testPlanTestCaseGet(id) testPlanTestCaseGet(id).then((response) => {
.then(response => { this.loading = false;
this.loading = false; let item = {};
let item = {}; Object.assign(item, response.data);
Object.assign(item, response.data); if (item.results) {
if (item.results) { item.results = JSON.parse(item.results);
item.results = JSON.parse(item.results); } else if (item.steps) {
} else if (item.steps) { item.results = [item.steps.length];
item.results = [item.steps.length]; }
} if (item.issues) {
if (item.issues) { item.issues = JSON.parse(item.issues);
item.issues = JSON.parse(item.issues); } else {
} else { item.issues = {};
item.issues = {}; }
} item.steps = JSON.parse(item.steps);
item.steps = JSON.parse(item.steps); if (!item.stepModel) {
if (!item.stepModel) { item.stepModel = "STEP";
item.stepModel = 'STEP'; }
} item.steptResults = [];
item.steptResults = []; if (item.steps) {
if (item.steps) { for (let i = 0; i < item.steps.length; i++) {
for (let i = 0; i < item.steps.length; i++) { if (item.results) {
if (item.results) { if (item.results[i]) {
if (item.results[i]) { item.steps[i].actualResult = item.results[i].actualResult;
item.steps[i].actualResult = item.results[i].actualResult; item.steps[i].executeResult = item.results[i].executeResult;
item.steps[i].executeResult = item.results[i].executeResult;
}
item.steptResults.push(item.steps[i]);
} else {
item.steptResults.push({
actualResult: '',
executeResult: ''
});
} }
item.steptResults.push(item.steps[i]);
} else {
item.steptResults.push({
actualResult: "",
executeResult: "",
});
} }
} }
this.testCase = item; }
this.originalStatus = this.testCase.status; this.testCase = item;
parseCustomField(this.testCase, this.testCaseTemplate, null, buildTestCaseOldFields(this.testCase)); this.originalStatus = this.testCase.status;
this.testCaseTemplate.customFields.forEach(item => { parseCustomField(
try { this.testCase,
item.defaultValue = JSON.parse(item.defaultValue); this.testCaseTemplate,
} catch (e) { null,
// nothing buildTestCaseOldFields(this.testCase)
} );
}); this.testCaseTemplate.customFields.forEach((item) => {
this.isCustomFiledActive = true; try {
if (!this.testCase.actualResult) { item.defaultValue = JSON.parse(item.defaultValue);
// ,使 } catch (e) {
this.testCase.actualResult = this.testCaseTemplate.actualResult; // nothing
} }
}); });
this.isCustomFiledActive = true;
if (!this.testCase.actualResult) {
// ,使
this.testCase.actualResult = this.testCaseTemplate.actualResult;
}
});
}, },
openTestCaseEdit(testCase, tableData) { openTestCaseEdit(testCase, tableData) {
checkProjectPermission(testCase.projectId) checkProjectPermission(testCase.projectId).then((r) => {
.then(r => { this.hasProjectPermission = r.data;
this.hasProjectPermission = r.data; });
});
this.showDialog = true; this.showDialog = true;
this.activeTab = 'detail'; this.activeTab = "detail";
this.originalStatus = testCase.status; this.originalStatus = testCase.status;
this.setTitleWith(); this.setTitleWith();
@ -454,11 +544,10 @@ export default {
listenGoBack(this.handleClose); listenGoBack(this.handleClose);
let initFuc = this.getTestCase; let initFuc = this.getTestCase;
getTestTemplate(testCase.projectId) getTestTemplate(testCase.projectId).then((template) => {
.then((template) => { this.testCaseTemplate = template;
this.testCaseTemplate = template; initFuc(testCase.id);
initFuc(testCase.id); });
});
if (this.$refs.otherInfo) { if (this.$refs.otherInfo) {
this.$refs.otherInfo.reset(); this.$refs.otherInfo.reset();
} }
@ -466,16 +555,16 @@ export default {
testRun(reportId) { testRun(reportId) {
this.testCase.reportId = reportId; this.testCase.reportId = reportId;
this.saveReport(reportId); this.saveReport(reportId);
this.activeTab = 'result'; this.activeTab = "result";
}, },
testTabChange(data) { testTabChange(data) {
if (this.testCase.type === 'performance' && data.paneName === 'result') { if (this.testCase.type === "performance" && data.paneName === "result") {
this.$refs.performanceTestResult.checkReportStatus(); this.$refs.performanceTestResult.checkReportStatus();
this.$refs.performanceTestResult.init(); this.$refs.performanceTestResult.init();
} }
}, },
saveReport(reportId) { saveReport(reportId) {
testPlanTestCaseEdit({id: this.testCase.id, reportId: reportId}); testPlanTestCaseEdit({ id: this.testCase.id, reportId: reportId });
}, },
openTest(item) { openTest(item) {
const type = item.testType; const type = item.testType;
@ -483,25 +572,34 @@ export default {
switch (type) { switch (type) {
case "performance": { case "performance": {
let performanceData = this.$router.resolve({ let performanceData = this.$router.resolve({
path: '/performance/test/edit/' + id, path: "/performance/test/edit/" + id,
}) });
window.open(performanceData.href, '_blank'); window.open(performanceData.href, "_blank");
break; break;
} }
case "testcase": { case "testcase": {
let caseData = this.$router.resolve({ let caseData = this.$router.resolve({
name: 'ApiDefinition', name: "ApiDefinition",
params: {redirectID: getUUID(), dataType: "apiTestCase", dataSelectRange: 'single:' + id} params: {
versionId: "default",
redirectID: getUUID(),
dataType: "apiTestCase",
dataSelectRange: "single:" + id,
},
}); });
window.open(caseData.href, '_blank'); window.open(caseData.href, "_blank");
break; break;
} }
case "automation": { case "automation": {
let automationData = this.$router.resolve({ let automationData = this.$router.resolve({
name: 'ApiAutomation', name: "ApiAutomation",
params: {redirectID: getUUID(), dataType: "scenario", dataSelectRange: 'edit:' + id} params: {
redirectID: getUUID(),
dataType: "scenario",
dataSelectRange: "edit:" + id,
},
}); });
window.open(automationData.href, '_blank'); window.open(automationData.href, "_blank");
break; break;
} }
} }
@ -519,26 +617,28 @@ export default {
this.relationGraphOpen = val; this.relationGraphOpen = val;
}, },
openTestTestCase(item) { openTestTestCase(item) {
let TestCaseData = this.$router.resolve( let TestCaseData = this.$router.resolve({
{ path: "/track/case/all",
path: '/track/case/all', query: {
query: {redirectID: getUUID(), dataType: "testCase", dataSelectRange: item.caseId, projectId: item.projectId} redirectID: getUUID(),
} dataType: "testCase",
); dataSelectRange: item.caseId,
window.open(TestCaseData.href, '_blank'); projectId: item.projectId,
},
});
window.open(TestCaseData.href, "_blank");
}, },
addPLabel(str) { addPLabel(str) {
return "<p>" + str + "</p>"; return "<p>" + str + "</p>";
}, },
setPlanStatus(planId) { setPlanStatus(planId) {
testPlanEditStatus(planId); testPlanEditStatus(planId);
} },
} },
} };
</script> </script>
<style scoped> <style scoped>
.cast_label { .cast_label {
color: dimgray; color: dimgray;
} }
@ -587,7 +687,7 @@ export default {
} }
.el-switch :deep(.el-switch__label.is-active) { .el-switch :deep(.el-switch__label.is-active) {
color: #409EFF; color: #409eff;
} }
p { p {

View File

@ -1,5 +1,4 @@
<template> <template>
<el-drawer <el-drawer
:before-close="handleClose" :before-close="handleClose"
:visible.sync="showDialog" :visible.sync="showDialog"
@ -7,28 +6,27 @@
:modal-append-to-body="false" :modal-append-to-body="false"
size="100%" size="100%"
ref="drawer" ref="drawer"
v-loading="loading"> v-loading="loading"
>
<template> <template>
<el-row :gutter="10"> <el-row :gutter="10">
<el-col :span="17"> <el-col :span="17">
<div class="container"> <div class="container">
<el-card> <el-card>
<el-scrollbar> <el-scrollbar>
<el-header style="height: 100%">
<el-header style="height: 100%;">
<el-row type="flex" class="head-bar"> <el-row type="flex" class="head-bar">
<el-col :span="2"> <el-col :span="2">
<el-button plain size="mini" <el-button
icon="el-icon-back" plain
@click="cancel">{{ $t('test_track.return') }} size="mini"
icon="el-icon-back"
@click="cancel"
>{{ $t("test_track.return") }}
</el-button> </el-button>
</el-col> </el-col>
<el-col :span="22" class="head-right"> <el-col :span="22" class="head-right">
<ms-previous-next-button <ms-previous-next-button
:index="index" :index="index"
:page-num="pageNum" :page-num="pageNum"
@ -39,90 +37,146 @@
:pre-page-data="prePageData" :pre-page-data="prePageData"
:list="testCases" :list="testCases"
@pre="handlePre" @pre="handlePre"
@next="handleNext"/> @next="handleNext"
/>
</el-col> </el-col>
</el-row> </el-row>
<el-row style="margin-top: 0;"> <el-row style="margin-top: 0">
<el-col> <el-col>
<el-divider content-position="left" class="title-divider"> <el-divider content-position="left" class="title-divider">
<el-button class="test-case-name" type="text" @click="openTestTestCase(testCase)"> <el-button
<span class="test-case-name"
class="title-link" type="text"
:title="testCase.name" @click="openTestTestCase(testCase)"
:style="{'max-width': titleWith + 'px'}"> >
{{ testCase.num }}-{{ testCase.name }} <span
</span> class="title-link"
:title="testCase.name"
:style="{ 'max-width': titleWith + 'px' }"
>
{{ testCase.num }}-{{ testCase.name }}
</span>
</el-button> </el-button>
</el-divider> </el-divider>
</el-col> </el-col>
</el-row> </el-row>
</el-header> </el-header>
<div class="case_container"> <div class="case_container">
<el-form> <el-form>
<el-row> <el-row>
<el-col :span="7"> <el-col :span="7">
<el-form-item :label="$t('test_track.case.module')" prop="nodePath" <el-form-item
:label-width="formLabelWidth"> :label="$t('test_track.case.module')"
prop="nodePath"
:label-width="formLabelWidth"
>
{{ testCase.nodePath }} {{ testCase.nodePath }}
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="7"> <el-col :span="7">
<el-form-item :label="$t('test_track.plan.plan_project')" prop="projectName" <el-form-item
:label-width="formLabelWidth"> :label="$t('test_track.plan.plan_project')"
prop="projectName"
:label-width="formLabelWidth"
>
{{ testCase.projectName }} {{ testCase.projectName }}
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="10"> <el-col :span="10">
<el-form-item :label="$t('评审状态')" :label-width="formLabelWidth"> <el-form-item
<status-table-item :value="oldReviewStatus"/> :label="$t('评审状态')"
</el-form-item > :label-width="formLabelWidth"
>
<status-table-item :value="oldReviewStatus" />
</el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-form ref="customFieldForm" <el-form
v-if="isCustomFiledActive" ref="customFieldForm"
class="case-form"> v-if="isCustomFiledActive"
class="case-form"
>
<el-row> <el-row>
<el-col :span="7" v-for="(item, index) in testCaseTemplate.customFields" :key="index"> <el-col
<el-form-item :label="item.system ? $t(systemNameMap[item.name]) : item.name" :span="7"
:prop="item.name" v-for="(item, index) in testCaseTemplate.customFields"
:label-width="formLabelWidth"> :key="index"
<custom-filed-component :disabled="true" :data="item" :form="{}" prop="defaultValue"/> >
<el-form-item
:label="
item.system
? $t(systemNameMap[item.name])
: item.name
"
:prop="item.name"
:label-width="formLabelWidth"
>
<custom-filed-component
:disabled="true"
:data="item"
:form="{}"
prop="defaultValue"
/>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
</el-form> </el-form>
<form-rich-text-item :label-width="formLabelWidth" :disabled="true" <form-rich-text-item
:title="$t('test_track.case.prerequisite')" :label-width="formLabelWidth"
:data="testCase" prop="prerequisite"/> :disabled="true"
<step-change-item :disable="true" :label-width="formLabelWidth" :form="testCase"/> :title="$t('test_track.case.prerequisite')"
<form-rich-text-item :label-width="formLabelWidth" :disabled="true" :data="testCase"
v-if="testCase.stepModel === 'TEXT'" :title="$t('test_track.case.step_desc')" prop="prerequisite"
:data="testCase" prop="stepDescription"/> />
<form-rich-text-item :label-width="formLabelWidth" :disabled="true" <step-change-item
v-if="testCase.stepModel === 'TEXT'" :disable="true"
:title="$t('test_track.case.expected_results')" :data="testCase" :label-width="formLabelWidth"
prop="expectedResult"/> :form="testCase"
/>
<form-rich-text-item
:label-width="formLabelWidth"
:disabled="true"
v-if="testCase.stepModel === 'TEXT'"
:title="$t('test_track.case.step_desc')"
:data="testCase"
prop="stepDescription"
/>
<form-rich-text-item
:label-width="formLabelWidth"
:disabled="true"
v-if="testCase.stepModel === 'TEXT'"
:title="$t('test_track.case.expected_results')"
:data="testCase"
prop="expectedResult"
/>
<test-case-step-item :label-width="formLabelWidth" :read-only="true" <test-case-step-item
v-if="testCase.stepModel === 'STEP'" :form="testCase"/> :label-width="formLabelWidth"
:read-only="true"
v-if="testCase.stepModel === 'STEP'"
:form="testCase"
/>
<el-form-item :label="$t('test_track.case.other_info')" :label-width="formLabelWidth"> <el-form-item
<test-case-edit-other-info @openTest="openTest" :read-only="true" :label="$t('test_track.case.other_info')"
@syncRelationGraphOpen="syncRelationGraphOpen" :label-width="formLabelWidth"
:project-id="projectId" :form="testCase" :case-id="testCase.caseId" >
ref="otherInfo"/> <test-case-edit-other-info
@openTest="openTest"
:read-only="true"
@syncRelationGraphOpen="syncRelationGraphOpen"
:project-id="projectId"
:form="testCase"
:case-id="testCase.caseId"
ref="otherInfo"
/>
</el-form-item> </el-form-item>
</el-form> </el-form>
</div> </div>
</el-scrollbar> </el-scrollbar>
</el-card> </el-card>
</div> </div>
@ -133,30 +187,38 @@
:test-case="testCase" :test-case="testCase"
:is-read-only="isReadOnly" :is-read-only="isReadOnly"
:origin-status="oldReviewStatus" :origin-status="oldReviewStatus"
@saveCase="saveCase()"/> @saveCase="saveCase()"
/>
<review-comment <review-comment
default-type="REVIEW" default-type="REVIEW"
:case-id="testCase.caseId" :case-id="testCase.caseId"
@saveCaseReview="saveCaseReview" @saveCaseReview="saveCaseReview"
ref="comment"/> ref="comment"
/>
</div> </div>
</el-col> </el-col>
</el-row> </el-row>
</template> </template>
</el-drawer> </el-drawer>
</template> </template>
<script> <script>
import {getCurrentProjectID} from "metersphere-frontend/src/utils/token"; import { getCurrentProjectID } from "metersphere-frontend/src/utils/token";
import {getUUID, listenGoBack, removeGoBackListener} from "metersphere-frontend/src/utils" import {
getUUID,
listenGoBack,
removeGoBackListener,
} from "metersphere-frontend/src/utils";
import ReviewComment from "@/business/review/commom/ReviewComment"; import ReviewComment from "@/business/review/commom/ReviewComment";
import TestCaseAttachment from "@/business/case/components/TestCaseAttachment"; import TestCaseAttachment from "@/business/case/components/TestCaseAttachment";
import {buildTestCaseOldFields, getTemplate, parseCustomField} from "metersphere-frontend/src/utils/custom_field"; import {
buildTestCaseOldFields,
getTemplate,
parseCustomField,
} from "metersphere-frontend/src/utils/custom_field";
import TestCaseEditOtherInfo from "@/business/case/components/TestCaseEditOtherInfo"; import TestCaseEditOtherInfo from "@/business/case/components/TestCaseEditOtherInfo";
import {SYSTEM_FIELD_NAME_MAP} from "metersphere-frontend/src/utils/table-constants"; import { SYSTEM_FIELD_NAME_MAP } from "metersphere-frontend/src/utils/table-constants";
import FormRichTextItem from "metersphere-frontend/src/components/FormRichTextItem"; import FormRichTextItem from "metersphere-frontend/src/components/FormRichTextItem";
import CustomFiledComponent from "metersphere-frontend/src/components/template/CustomFiledComponent"; import CustomFiledComponent from "metersphere-frontend/src/components/template/CustomFiledComponent";
import StepChangeItem from "@/business/case/components/StepChangeItem"; import StepChangeItem from "@/business/case/components/StepChangeItem";
@ -164,12 +226,12 @@ import TestCaseStepItem from "@/business/case/components/TestCaseStepItem";
import MsPreviousNextButton from "metersphere-frontend/src/components/MsPreviousNextButton"; import MsPreviousNextButton from "metersphere-frontend/src/components/MsPreviousNextButton";
import TestReviewTestCaseExecute from "./TestReviewTestCaseExecute"; import TestReviewTestCaseExecute from "./TestReviewTestCaseExecute";
import StatusTableItem from "@/business/common/tableItems/planview/StatusTableItem"; import StatusTableItem from "@/business/common/tableItems/planview/StatusTableItem";
import {getTestTemplate} from "@/api/custom-field-template"; import { getTestTemplate } from "@/api/custom-field-template";
import { import {
editTestCaseReviewStatus, editTestCaseReviewStatus,
editTestReviewTestCase, editTestReviewTestCase,
getRelateTest, getRelateTest,
getTestReviewTestCase getTestReviewTestCase,
} from "@/api/test-review"; } from "@/api/test-review";
export default { export default {
@ -184,7 +246,7 @@ export default {
FormRichTextItem, FormRichTextItem,
TestCaseEditOtherInfo, TestCaseEditOtherInfo,
ReviewComment, ReviewComment,
TestCaseAttachment TestCaseAttachment,
}, },
data() { data() {
return { return {
@ -193,44 +255,44 @@ export default {
testCase: {}, testCase: {},
index: 0, index: 0,
testCases: [], testCases: [],
readConfig: {toolbar: []}, readConfig: { toolbar: [] },
test: {}, test: {},
activeTab: 'detail', activeTab: "detail",
isFailure: true, isFailure: true,
users: [], users: [],
activeName: 'comment', activeName: "comment",
comments: [], comments: [],
tableData: [], tableData: [],
currentScenario: {}, currentScenario: {},
mark: 'detail', mark: "detail",
api: {}, api: {},
apiCase: {}, apiCase: {},
testCaseTemplate: {}, testCaseTemplate: {},
formLabelWidth: '100px', formLabelWidth: "100px",
isCustomFiledActive: false, isCustomFiledActive: false,
oldReviewStatus: '', oldReviewStatus: "",
titleWith: 0, titleWith: 0,
relationGraphOpen: false, relationGraphOpen: false,
}; };
}, },
props: { props: {
total: { total: {
type: Number type: Number,
}, },
searchParam: { searchParam: {
type: Object type: Object,
}, },
isReadOnly: { isReadOnly: {
type: Boolean, type: Boolean,
default: false default: false,
}, },
pageNum: Number, pageNum: Number,
pageSize: { pageSize: {
type: Number, type: Number,
default: 1 default: 1,
}, },
nextPageData: Object, nextPageData: Object,
prePageData: Object prePageData: Object,
}, },
computed: { computed: {
projectId() { projectId() {
@ -241,7 +303,7 @@ export default {
}, },
pageTotal() { pageTotal() {
return Math.ceil(this.total / this.pageSize); return Math.ceil(this.total / this.pageSize);
} },
}, },
methods: { methods: {
openTest(item) { openTest(item) {
@ -250,25 +312,35 @@ export default {
switch (type) { switch (type) {
case "performance": { case "performance": {
let performanceData = this.$router.resolve({ let performanceData = this.$router.resolve({
path: '/performance/test/edit/' + id, path: "/performance/test/edit/" + id,
}); });
window.open(performanceData.href, '_blank'); window.open(performanceData.href, "_blank");
break; break;
} }
case "testcase": { case "testcase": {
let caseData = this.$router.resolve({ let caseData = this.$router.resolve({
name: 'ApiDefinition', name: "ApiDefinition",
params: {redirectID: getUUID(), dataType: "apiTestCase", dataSelectRange: 'single:' + id} params: {
versionId: "default",
redirectID: getUUID(),
dataType: "apiTestCase",
dataSelectRange: "single:" + id,
},
}); });
window.open(caseData.href, '_blank'); window.open(caseData.href, "_blank");
break; break;
} }
case "automation": { case "automation": {
let automationData = this.$router.resolve({ let automationData = this.$router.resolve({
name: 'ApiAutomation', name: "ApiAutomation",
params: {redirectID: getUUID(), dataType: "scenario", dataSelectRange: 'edit:' + id} params: {
versionId: "default",
redirectID: getUUID(),
dataType: "scenario",
dataSelectRange: "edit:" + id,
},
}); });
window.open(automationData.href, '_blank'); window.open(automationData.href, "_blank");
break; break;
} }
} }
@ -282,7 +354,7 @@ export default {
}, },
cancel() { cancel() {
this.handleClose(); this.handleClose();
this.$emit('refreshTable'); this.$emit("refreshTable");
}, },
saveCase() { saveCase() {
let param = {}; let param = {};
@ -291,22 +363,21 @@ export default {
param.reviewId = this.testCase.reviewId; param.reviewId = this.testCase.reviewId;
param.comment = this.testCase.comment; param.comment = this.testCase.comment;
param.status = this.testCase.reviewStatus; param.status = this.testCase.reviewStatus;
editTestReviewTestCase(param) editTestReviewTestCase(param).then(() => {
.then(() => { this.$success(this.$t("commons.save_success"));
this.$success(this.$t('commons.save_success')); this.updateTestCases(param);
this.updateTestCases(param); this.setReviewStatus(this.testCase.reviewId);
this.setReviewStatus(this.testCase.reviewId);
// //
this.testCases[this.index].status = this.testCase.status; this.testCases[this.index].status = this.testCase.status;
// //
this.oldReviewStatus = this.testCase.reviewStatus; this.oldReviewStatus = this.testCase.reviewStatus;
if (this.testCase.comment) { if (this.testCase.comment) {
this.$refs.comment.getComments(); this.$refs.comment.getComments();
this.testCase.comment = ''; this.testCase.comment = "";
} }
}) });
}, },
saveCaseReview() { saveCaseReview() {
let param = {}; let param = {};
@ -315,18 +386,17 @@ export default {
param.caseId = this.testCase.caseId; param.caseId = this.testCase.caseId;
param.reviewId = this.testCase.reviewId; param.reviewId = this.testCase.reviewId;
param.status = status; param.status = status;
editTestReviewTestCase(param) editTestReviewTestCase(param).then(() => {
.then(() => { this.updateTestCases(param);
this.updateTestCases(param); this.setReviewStatus(this.testCase.reviewId);
this.setReviewStatus(this.testCase.reviewId); this.oldReviewStatus = status;
this.oldReviewStatus = status; //
// this.testCases[this.index].status = status;
this.testCases[this.index].status = status; if (this.index < this.testCases.length - 1) {
if (this.index < this.testCases.length - 1) { this.handleNext();
this.handleNext(); }
} this.$success(this.$t("commons.save_success"));
this.$success(this.$t('commons.save_success')); });
});
}, },
updateTestCases(param) { updateTestCases(param) {
for (let i = 0; i < this.testCases.length; i++) { for (let i = 0; i < this.testCases.length; i++) {
@ -338,12 +408,15 @@ export default {
} }
}, },
handleNext() { handleNext() {
if (this.index === this.testCases.length - 1 && this.pageNum === this.pageTotal) { if (
this.index === this.testCases.length - 1 &&
this.pageNum === this.pageTotal
) {
// //
return; return;
} else if (this.index === this.testCases.length - 1) { } else if (this.index === this.testCases.length - 1) {
// //
this.$emit('nextPage'); this.$emit("nextPage");
this.index = 0; this.index = 0;
return; return;
} }
@ -351,13 +424,16 @@ export default {
this.getTestCase(this.testCases[this.index].id); this.getTestCase(this.testCases[this.index].id);
}, },
isLastData() { isLastData() {
return this.index === this.testCases.length - 1 && this.pageNum === this.pageTotal; return (
this.index === this.testCases.length - 1 &&
this.pageNum === this.pageTotal
);
}, },
handlePre() { handlePre() {
if (this.index === 0 && this.pageNum === 1) { if (this.index === 0 && this.pageNum === 1) {
return; return;
} else if (this.index === 0) { } else if (this.index === 0) {
this.$emit('prePage'); this.$emit("prePage");
this.index = this.pageSize - 1; this.index = this.pageSize - 1;
return; return;
} }
@ -366,31 +442,35 @@ export default {
}, },
getTestCase(id) { getTestCase(id) {
this.loading = true; this.loading = true;
getTestReviewTestCase(id) getTestReviewTestCase(id).then((response) => {
.then((response) => { this.loading = false;
this.loading = false; let item = {};
let item = {}; let data = response.data;
let data = response.data; Object.assign(item, data);
Object.assign(item, data); item.results = JSON.parse(item.results);
item.results = JSON.parse(item.results); if (item.issues) {
if (item.issues) { item.issues = JSON.parse(item.issues);
item.issues = JSON.parse(item.issues); } else {
} else { item.issues = {};
item.issues = {}; }
} item.steps = JSON.parse(item.steps);
item.steps = JSON.parse(item.steps); if (!item.stepModel) {
if (!item.stepModel) { item.stepModel = "STEP";
item.stepModel = 'STEP'; }
} parseCustomField(
parseCustomField(item, this.testCaseTemplate, null, buildTestCaseOldFields(item)); item,
this.isCustomFiledActive = true; this.testCaseTemplate,
this.testCase = item; null,
this.oldReviewStatus = this.testCase.reviewStatus; buildTestCaseOldFields(item)
if (!this.testCase.actualResult) { );
// ,使 this.isCustomFiledActive = true;
this.testCase.actualResult = this.testCaseTemplate.actualResult; this.testCase = item;
} this.oldReviewStatus = this.testCase.reviewStatus;
}); if (!this.testCase.actualResult) {
// ,使
this.testCase.actualResult = this.testCaseTemplate.actualResult;
}
});
}, },
setTitleWith() { setTitleWith() {
this.$nextTick(() => { this.$nextTick(() => {
@ -405,7 +485,7 @@ export default {
this.showDialog = true; this.showDialog = true;
// //
this.oldReviewStatus = testCase.reviewStatus; this.oldReviewStatus = testCase.reviewStatus;
this.activeTab = 'detail'; this.activeTab = "detail";
listenGoBack(this.handleClose); listenGoBack(this.handleClose);
let initFuc = this.getTestCase; let initFuc = this.getTestCase;
this.setTitleWith(); this.setTitleWith();
@ -421,26 +501,34 @@ export default {
} }
} }
getTestTemplate(testCase.projectId) getTestTemplate(testCase.projectId).then((response) => {
.then((response) => { this.testCaseTemplate = response;
this.testCaseTemplate = response; initFuc(testCase.id);
initFuc(testCase.id); });
});
if (this.$refs.otherInfo) { if (this.$refs.otherInfo) {
this.$refs.otherInfo.reset(); this.$refs.otherInfo.reset();
} }
}, },
openTestTestCase(item) { openTestTestCase(item) {
let testCaseData = this.$router.resolve( let testCaseData = this.$router.resolve({
{path: '/track/case/all', query: {redirectID: getUUID(), dataType: "testCase", dataSelectRange: item.caseId}} path: "/track/case/all",
); query: {
window.open(testCaseData.href, '_blank'); redirectID: getUUID(),
dataType: "testCase",
dataSelectRange: item.caseId,
},
});
window.open(testCaseData.href, "_blank");
}, },
getRelatedTest() { getRelatedTest() {
if (this.testCase.method === 'auto' && this.testCase.testId && this.testCase.testId !== 'other') { if (
getRelateTest(this.testCase.type, this.testCase.testId) this.testCase.method === "auto" &&
.then((response) => { this.testCase.testId &&
this.testCase.testId !== "other"
) {
getRelateTest(this.testCase.type, this.testCase.testId).then(
(response) => {
let data = response.data; let data = response.data;
if (data) { if (data) {
this.test = data; this.test = data;
@ -448,8 +536,9 @@ export default {
this.test = {}; this.test = {};
this.$warning(this.$t("test_track.case.relate_test_not_find")); this.$warning(this.$t("test_track.case.relate_test_not_find"));
} }
}); }
} else if (this.testCase.testId === 'other') { );
} else if (this.testCase.testId === "other") {
this.$warning(this.$t("test_track.case.other_relate_test_not_find")); this.$warning(this.$t("test_track.case.other_relate_test_not_find"));
} }
}, },
@ -457,18 +546,20 @@ export default {
editTestCaseReviewStatus(reviewId); editTestCaseReviewStatus(reviewId);
}, },
stepResultChange() { stepResultChange() {
if (this.testCase.method === 'manual') { if (this.testCase.method === "manual") {
this.isFailure = this.testCase.steptResults.filter(s => { this.isFailure =
return s.executeResult === 'Failure' || s.executeResult === 'Blocking'; this.testCase.steptResults.filter((s) => {
}).length > 0; return (
s.executeResult === "Failure" || s.executeResult === "Blocking"
);
}).length > 0;
} }
}, },
} },
} };
</script> </script>
<style scoped> <style scoped>
.border-hidden :deep(.el-textarea__inner) { .border-hidden :deep(.el-textarea__inner) {
border-style: hidden; border-style: hidden;
background-color: white; background-color: white;
@ -509,7 +600,7 @@ export default {
} }
.el-switch :deep(.el-switch__label.is-active) { .el-switch :deep(.el-switch__label.is-active) {
color: #409EFF; color: #409eff;
} }
.container :deep(.el-card__body) { .container :deep(.el-card__body) {

View File

@ -1,18 +1,32 @@
<template> <template>
<el-dialog :close-on-click-modal="false" :title="$t('api_test.automation.case_ref')" :visible.sync="visible" <el-dialog
:modal="false" width="45%" :destroy-on-close="true"> :close-on-click-modal="false"
<span>{{ $t('api_test.automation.scenario_ref') }}</span> :title="$t('api_test.automation.case_ref')"
:visible.sync="visible"
:modal="false"
width="45%"
:destroy-on-close="true"
>
<span>{{ $t("api_test.automation.scenario_ref") }}</span>
<div class="refs" v-loading="scenarioLoading"> <div class="refs" v-loading="scenarioLoading">
<div v-for="(item, index) in scenarioRefs" :key="index" class="el-button--text"> <div
v-for="(item, index) in scenarioRefs"
:key="index"
class="el-button--text"
>
<el-link @click="openScenario(item)"> <el-link @click="openScenario(item)">
{{ item.name }} {{ item.name }}
</el-link> </el-link>
</div> </div>
</div> </div>
<span>{{ $t('api_test.automation.plan_ref') }}</span> <span>{{ $t("api_test.automation.plan_ref") }}</span>
<div class="refs"> <div class="refs">
<div v-for="(item, index) in planRefs" :key="index" class="el-button--text"> <div
v-for="(item, index) in planRefs"
:key="index"
class="el-button--text"
>
<el-link @click="openTestPlan(item)"> <el-link @click="openTestPlan(item)">
{{ item.name }} {{ item.name }}
</el-link> </el-link>
@ -21,8 +35,12 @@
<template v-slot:footer> <template v-slot:footer>
<div class="dialog-footer"> <div class="dialog-footer">
<el-button type="primary" @click="visible = false" @keydown.enter.native.prevent> <el-button
{{ $t('commons.confirm') }} type="primary"
@click="visible = false"
@keydown.enter.native.prevent
>
{{ $t("commons.confirm") }}
</el-button> </el-button>
</div> </div>
</template> </template>
@ -30,93 +48,105 @@
</template> </template>
<script> <script>
import {
import {getCurrentProjectID, getCurrentWorkspaceId} from "metersphere-frontend/src/utils/token"; getCurrentProjectID,
import {getUUID} from "metersphere-frontend/src/utils"; getCurrentWorkspaceId,
import {getOwnerProjectIds, getProject} from "@/api/project"; } from "metersphere-frontend/src/utils/token";
import {getScenarioReference} from "@/api/scenario"; import { getUUID } from "metersphere-frontend/src/utils";
import { getOwnerProjectIds, getProject } from "@/api/project";
import { getScenarioReference } from "@/api/scenario";
export default { export default {
name: "MsReferenceView", name: "MsReferenceView",
components: {}, components: {},
data() { data() {
return { return {
visible: false, visible: false,
scenarioLoading: false, scenarioLoading: false,
scenarioRefs: [], scenarioRefs: [],
planRefs: [] planRefs: [],
};
},
methods: {
getReferenceData(row) {
if (row.id === undefined) {
return;
}
this.scenarioLoading = true;
this.scenarioRefs = [];
getScenarioReference(row).then((response) => {
this.scenarioRefs = response.data.scenarioList;
this.planRefs = response.data.testPlanList;
this.scenarioLoading = false;
});
},
open(row) {
this.getReferenceData(row);
this.visible = true;
},
openScenario(resource) {
let workspaceId = getCurrentWorkspaceId();
let isTurnSpace = true;
if (resource.projectId !== getCurrentProjectID()) {
isTurnSpace = false;
getProject(resource.projectId).then((response) => {
if (response.data) {
workspaceId = response.data.workspaceId;
isTurnSpace = true;
this.checkPermission(resource, workspaceId, isTurnSpace);
}
});
} else {
this.checkPermission(resource, workspaceId, isTurnSpace);
} }
}, },
methods: { gotoTurn(resource, workspaceId, isTurnSpace) {
getReferenceData(row) { let automationData = this.$router.resolve({
if (row.id === undefined) { name: "ApiAutomation",
return; params: {
} versionId: "default",
this.scenarioLoading = true; redirectID: getUUID(),
this.scenarioRefs = []; dataType: "scenario",
getScenarioReference(row).then(response => { dataSelectRange: "edit:" + resource.id,
this.scenarioRefs = response.data.scenarioList; projectId: resource.projectId,
this.planRefs = response.data.testPlanList; workspaceId: workspaceId,
this.scenarioLoading = false; },
}) });
}, if (isTurnSpace) {
open(row) { window.open(automationData.href, "_blank");
this.getReferenceData(row);
this.visible = true
},
openScenario(resource) {
let workspaceId = getCurrentWorkspaceId();
let isTurnSpace = true
if (resource.projectId !== getCurrentProjectID()) {
isTurnSpace = false;
getProject(resource.projectId).then(response => {
if (response.data) {
workspaceId = response.data.workspaceId;
isTurnSpace = true;
this.checkPermission(resource, workspaceId, isTurnSpace);
}
});
} else {
this.checkPermission(resource, workspaceId, isTurnSpace);
}
},
gotoTurn(resource, workspaceId, isTurnSpace) {
let automationData = this.$router.resolve({
name: 'ApiAutomation',
params: {redirectID: getUUID(), dataType: "scenario", dataSelectRange: 'edit:' + resource.id, projectId: resource.projectId, workspaceId: workspaceId}
});
if (isTurnSpace) {
window.open(automationData.href, '_blank');
}
},
checkPermission(resource, workspaceId, isTurnSpace) {
getOwnerProjectIds().then(res => {
const project = res.data.find(p => p === resource.projectId);
if (!project) {
this.$warning(this.$t('commons.no_permission'));
} else {
this.gotoTurn(resource, workspaceId, isTurnSpace)
}
})
},
openTestPlan(item){
let automationData = this.$router.resolve({
path: '/track/plan/view/' + item.id,
query: { workspaceId: item.workspaceId, projectId: item.projectId, charType: 'api'}
});
window.open(automationData.href, '_blank');
} }
} },
} checkPermission(resource, workspaceId, isTurnSpace) {
getOwnerProjectIds().then((res) => {
const project = res.data.find((p) => p === resource.projectId);
if (!project) {
this.$warning(this.$t("commons.no_permission"));
} else {
this.gotoTurn(resource, workspaceId, isTurnSpace);
}
});
},
openTestPlan(item) {
let automationData = this.$router.resolve({
path: "/track/plan/view/" + item.id,
query: {
workspaceId: item.workspaceId,
projectId: item.projectId,
charType: "api",
},
});
window.open(automationData.href, "_blank");
},
},
};
</script> </script>
<style scoped> <style scoped>
.refs { .refs {
min-height: 50px; min-height: 50px;
max-height: 200px; max-height: 200px;
overflow-y: auto; overflow-y: auto;
font-size: 12px; font-size: 12px;
padding-bottom: 10px; padding-bottom: 10px;
} }
</style> </style>