fix(测试计划): 修复测试计划导出时资源池没展示、失败重跑按钮没隐藏的问题

--bug=1024375 --user=宋天阳 【测试跟踪】测试计划最终报告导出,不显示“失败重跑”按钮
https://www.tapd.cn/55049933/s/1349388
This commit is contained in:
song-tianyang 2023-03-14 11:41:58 +08:00 committed by 建国
parent 6b2061547c
commit 758f4df165
8 changed files with 249 additions and 176 deletions

View File

@ -78,16 +78,4 @@ public class ShareController {
HttpHeaderUtils.clearUser();
return reportExtInfo;
}
@GetMapping("test/plan/ext/plan/{shareId}/{planId}")
public ExecutionModeDTO getExtPlan(@PathVariable String shareId, @PathVariable String planId) throws JsonProcessingException {
shareInfoService.validate(shareId, planId);
if (SessionUtils.getUser() == null) {
HttpHeaderUtils.runAsUser("admin");
}
// testPlanService.getExtInfoByPlanId 这个方法逻辑有问题分不清楚干嘛用的方法删了调用地方先注释了
// TestPlanExtReportDTO reportExtInfo = testPlanService.getExtInfoByPlanId(planId);
HttpHeaderUtils.clearUser();
return new ExecutionModeDTO();
}
}

View File

@ -14,7 +14,6 @@ import io.metersphere.dto.TestPlanRerunParametersDTO;
import io.metersphere.i18n.Translator;
import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.notice.annotation.SendNotice;
import io.metersphere.plan.dto.ExecutionModeDTO;
import io.metersphere.plan.dto.TestCaseReportStatusResultDTO;
import io.metersphere.plan.dto.TestPlanDTO;
import io.metersphere.plan.dto.TestPlanReportDataStruct;
@ -380,14 +379,4 @@ public class TestPlanController {
public void resetStatus(@PathVariable String planId) {
testPlanService.resetStatus(planId);
}
@GetMapping("/ext/report/{reportId}")
public ExecutionModeDTO getExtReport(@PathVariable String reportId) throws JsonProcessingException {
return new ExecutionModeDTO();
}
@GetMapping("/ext/plan/{planId}")
public ExecutionModeDTO getExtPlan(@PathVariable String planId) throws JsonProcessingException {
return new ExecutionModeDTO();
}
}

View File

@ -1124,7 +1124,11 @@ public class TestPlanReportService {
});
String resourcePoolNames = StringUtils.join(resourcePoolName.toArray(), StringUtils.SPACE);
report.setResourcePool(resourcePoolNames);
} else {
report.setResourcePool("LOCAL");
}
} else {
report.setResourcePool("LOCAL");
}
return report;
}
@ -1156,7 +1160,11 @@ public class TestPlanReportService {
});
String resourcePoolNames = StringUtils.join(resourcePoolName.toArray(), StringUtils.SPACE);
testPlanReportDTO.setResourcePool(resourcePoolNames);
} else {
testPlanReportDTO.setResourcePool("LOCAL");
}
} else {
testPlanReportDTO.setResourcePool("LOCAL");
}
// 环境组/运行环境
if (StringUtils.isNotEmpty(runInfoDTO.getEnvGroupId())) {

View File

@ -390,23 +390,3 @@ export function reportSocket(reportId) {
export function testPlanLoadCaseEditStatus(planId) {
return post(BASE_URL + `edit/status/${planId}`, new Promise(() => {}));
}
export function getTestPlanExtReport(planId, reportId) {
if (reportId) {
return get(BASE_URL + "ext/report/" + reportId);
} else if (planId) {
return get(BASE_URL + "ext/plan/" + planId);
} else {
return new Promise(() => {});
}
}
export function getShareTestPlanExtReport(shareId, planId, reportId) {
if (reportId) {
return get("/share" + BASE_URL + `ext/report/${shareId}/${reportId}`);
} else if (planId) {
return get("/share" + BASE_URL + `ext/plan/${shareId}/${planId}`);
} else {
return new Promise(() => {});
}
}

View File

@ -1,56 +1,152 @@
<template>
<test-plan-report-container id="api" :title="$t('test_track.report.analysis_api')">
<test-plan-report-container
id="api"
:title="$t('test_track.report.analysis_api')"
>
<el-tabs v-model="activeName" @tab-click="handleClick">
<el-tab-pane v-if="resultEnable" :label="$t('test_track.report.test_result')" name="first">
<api-result :api-result="report.apiResult"/>
<el-tab-pane
v-if="resultEnable"
:label="$t('test_track.report.test_result')"
name="first"
>
<api-result :api-result="report.apiResult" />
</el-tab-pane>
<el-tab-pane v-if="failureEnable" name="second">
<template v-slot:label>
<tab-pane-count :title="$t('test_track.report.fail_case')" :count="failureSize"/>
<tab-pane-count
:title="$t('test_track.report.fail_case')"
:count="failureSize"
/>
</template>
<api-cases :is-db="isDb" :share-id="shareId" :is-share="isShare" :report="report" :is-template="isTemplate"
:plan-id="planId" @setSize="setFailureSize"/>
<el-button class="rerun-button" plain size="mini"
v-if="showRerunBtn && (failureSize > 0 || unExecuteSize > 0) && isRerun" @click="rerun">
{{ $t('api_test.automation.rerun') }}
<api-cases
:is-db="isDb"
:share-id="shareId"
:is-share="isShare"
:report="report"
:is-template="isTemplate"
:plan-id="planId"
@setSize="setFailureSize"
/>
<el-button
class="rerun-button"
plain
size="mini"
v-if="
!isTemplate &&
showRerunBtn &&
(failureSize > 0 || unExecuteSize > 0) &&
isRerun
"
@click="rerun"
>
{{ $t("api_test.automation.rerun") }}
</el-button>
</el-tab-pane>
<el-tab-pane style="min-height: 500px" name="third" v-if="errorReportEnable">
<el-tab-pane
style="min-height: 500px"
name="third"
v-if="errorReportEnable"
>
<template v-slot:label>
<tab-pane-count :title="$t('error_report_library.option.name')" :count="errorReportSize"/>
<tab-pane-count
:title="$t('error_report_library.option.name')"
:count="errorReportSize"
/>
</template>
<api-cases :is-db="isDb" :is-error-report="true" :share-id="shareId" :is-share="isShare" :report="report"
:is-template="isTemplate" :plan-id="planId" @setSize="setErrorReportSize"/>
<el-button class="rerun-button" plain size="mini"
v-if="showRerunBtn && (failureSize > 0 || unExecuteSize > 0) && isRerun" @click="rerun">
{{ $t('api_test.automation.rerun') }}
<api-cases
:is-db="isDb"
:is-error-report="true"
:share-id="shareId"
:is-share="isShare"
:report="report"
:is-template="isTemplate"
:plan-id="planId"
@setSize="setErrorReportSize"
/>
<el-button
class="rerun-button"
plain
size="mini"
v-if="
!isTemplate &&
showRerunBtn &&
(failureSize > 0 || unExecuteSize > 0) &&
isRerun
"
@click="rerun"
>
{{ $t("api_test.automation.rerun") }}
</el-button>
</el-tab-pane>
<el-tab-pane style="min-height: 500px" name="fourth" v-if="unExecuteEnable">
<el-tab-pane
style="min-height: 500px"
name="fourth"
v-if="unExecuteEnable"
>
<template v-slot:label>
<tab-pane-count :title="$t('api_test.home_page.detail_card.unexecute')" :count="unExecuteSize"/>
<tab-pane-count
:title="$t('api_test.home_page.detail_card.unexecute')"
:count="unExecuteSize"
/>
</template>
<api-cases :is-db="isDb" :is-un-execute="true" :share-id="shareId" :is-share="isShare" :report="report"
:is-template="isTemplate" :plan-id="planId" @setSize="setUnExecuteSize"/>
<api-cases
:is-db="isDb"
:is-un-execute="true"
:share-id="shareId"
:is-share="isShare"
:report="report"
:is-template="isTemplate"
:plan-id="planId"
@setSize="setUnExecuteSize"
/>
<el-button class="rerun-button" plain size="mini"
v-if="showRerunBtn && (failureSize > 0 || unExecuteSize > 0) && isRerun" @click="rerun">
{{ $t('api_test.automation.rerun') }}
<el-button
class="rerun-button"
plain
size="mini"
v-if="
!isTemplate &&
showRerunBtn &&
(failureSize > 0 || unExecuteSize > 0) &&
isRerun
"
@click="rerun"
>
{{ $t("api_test.automation.rerun") }}
</el-button>
</el-tab-pane>
<el-tab-pane style="min-height: 500px" name="fifth" v-if="allEnable">
<template v-slot:label>
<tab-pane-count :title="$t('test_track.report.all_case')" :count="allSize"/>
<tab-pane-count
:title="$t('test_track.report.all_case')"
:count="allSize"
/>
</template>
<api-cases :is-db="isDb" :is-all="true" :share-id="shareId" :is-share="isShare" :report="report"
:is-template="isTemplate" :plan-id="planId" @setSize="setAllSize"/>
<el-button class="rerun-button" plain size="mini"
v-if="showRerunBtn && (failureSize > 0 || unExecuteSize > 0) && isRerun" @click="rerun">
{{ $t('api_test.automation.rerun') }}
<api-cases
:is-db="isDb"
:is-all="true"
:share-id="shareId"
:is-share="isShare"
:report="report"
:is-template="isTemplate"
:plan-id="planId"
@setSize="setAllSize"
/>
<el-button
class="rerun-button"
plain
size="mini"
v-if="
!isTemplate &&
showRerunBtn &&
(failureSize > 0 || unExecuteSize > 0) &&
isRerun
"
@click="rerun"
>
{{ $t("api_test.automation.rerun") }}
</el-button>
</el-tab-pane>
</el-tabs>
</test-plan-report-container>
@ -62,14 +158,20 @@ import ApiResult from "@/business/plan/view/comonents/report/detail/component/Ap
import TestPlanReportContainer from "@/business/plan/view/comonents/report/detail/TestPlanReportContainer";
import ApiCases from "@/business/plan/view/comonents/report/detail/component/ApiCases";
import TabPaneCount from "@/business/plan/view/comonents/report/detail/component/TabPaneCount";
import {apiTestExecRerun} from "@/api/remote/ui/api-test";
import { apiTestExecRerun } from "@/api/remote/ui/api-test";
export default {
name: "TestPlanApiReport",
components: {TabPaneCount, ApiCases, TestPlanReportContainer, ApiResult, MsFormDivider},
components: {
TabPaneCount,
ApiCases,
TestPlanReportContainer,
ApiResult,
MsFormDivider,
},
data() {
return {
activeName: 'first',
activeName: "first",
failureSize: 0,
errorReportSize: 0,
unExecuteSize: 0,
@ -80,40 +182,56 @@ export default {
created() {
this.showRerunBtn = !this.isShare;
},
props: [
'report', 'planId', 'isTemplate', 'isShare', 'shareId', 'isDb'
],
props: ["report", "planId", "isTemplate", "isShare", "shareId", "isDb"],
computed: {
resultEnable() {
let disable = this.report.config && this.report.config.api.children.result.enable === false;
return !disable && this.report.apiResult && (
(this.report.apiResult.apiCaseData && this.report.apiResult.apiCaseData.length > 0)
|| (this.report.apiResult.apiScenarioData && this.report.apiResult.apiScenarioData.length > 0)
let disable =
this.report.config &&
this.report.config.api.children.result.enable === false;
return (
!disable &&
this.report.apiResult &&
((this.report.apiResult.apiCaseData &&
this.report.apiResult.apiCaseData.length > 0) ||
(this.report.apiResult.apiScenarioData &&
this.report.apiResult.apiScenarioData.length > 0))
);
},
failureEnable() {
let disable = this.report.config && this.report.config.api.children.failure.enable === false;
let disable =
this.report.config &&
this.report.config.api.children.failure.enable === false;
return !disable;
},
errorReportEnable() {
let disable = this.report.config && this.report.config.api.children.errorReport && this.report.config.api.children.errorReport.enable === false;
let disable =
this.report.config &&
this.report.config.api.children.errorReport &&
this.report.config.api.children.errorReport.enable === false;
return !disable;
},
unExecuteEnable() {
let disable = this.report.config && this.report.config.api.children.unExecute && this.report.config.api.children.unExecute.enable === false;
let disable =
this.report.config &&
this.report.config.api.children.unExecute &&
this.report.config.api.children.unExecute.enable === false;
return !disable;
},
allEnable() {
let disable = this.report.config && this.report.config.api.children.all.enable === false;
let disable =
this.report.config &&
this.report.config.api.children.all.enable === false;
return !disable;
},
isRerun() {
return ((this.report && this.report.apiFailureCases)
|| (this.report && this.report.unExecuteCases)
|| (this.report && this.report.scenarioFailureCases)
|| (this.report && this.report.unExecuteScenarios)
|| (this.report && this.report.loadFailureCases));
}
return (
(this.report && this.report.apiFailureCases) ||
(this.report && this.report.unExecuteCases) ||
(this.report && this.report.scenarioFailureCases) ||
(this.report && this.report.unExecuteScenarios) ||
(this.report && this.report.loadFailureCases)
);
},
},
watch: {
resultEnable() {
@ -135,13 +253,13 @@ export default {
methods: {
initActiveName() {
if (this.resultEnable) {
this.activeName = 'first';
this.activeName = "first";
} else if (this.failureEnable) {
this.activeName = 'second';
this.activeName = "second";
} else if (this.errorReportEnable) {
this.activeName = 'third';
this.activeName = "third";
} else if (this.allEnable) {
this.activeName = 'fourth';
this.activeName = "fourth";
}
},
setFailureSize(size) {
@ -156,8 +274,7 @@ export default {
setAllSize(size) {
this.allSize = size;
},
handleClick(tab, event) {
},
handleClick(tab, event) {},
rerun() {
let type = "TEST_PLAN";
let scenarios = [];
@ -168,8 +285,8 @@ export default {
reportId: this.report.id,
scenarios: scenarios,
cases: cases,
performanceCases: performanceCases
}
performanceCases: performanceCases,
};
//
if (this.report && this.report.apiFailureCases) {
this.format(cases, this.report.apiFailureCases);
@ -188,27 +305,30 @@ export default {
if (this.report && this.report.loadFailureCases) {
this.format(performanceCases, this.report.loadFailureCases);
}
apiTestExecRerun(rerunObj)
.then(res => {
if (res.data !== 'SUCCESS') {
this.$error(res.data);
} else {
this.$success(this.$t('api_test.automation.rerun_success'));
}
});
apiTestExecRerun(rerunObj).then((res) => {
if (res.data !== "SUCCESS") {
this.$error(res.data);
} else {
this.$success(this.$t("api_test.automation.rerun_success"));
}
});
},
format(cases, data) {
if (this.report && data) {
data.forEach(item => {
data.forEach((item) => {
if (item) {
let obj = {id: item.id, reportId: item.reportId, userId: item.createUser};
let obj = {
id: item.id,
reportId: item.reportId,
userId: item.createUser,
};
cases.push(obj);
}
});
}
}
}
}
},
},
};
</script>
<style scoped>
@ -218,7 +338,7 @@ export default {
right: 10px;
margin-right: 10px;
z-index: 1100;
background-color: #F2F9EF;
color: #87C45D;
background-color: #f2f9ef;
color: #87c45d;
}
</style>

View File

@ -99,7 +99,6 @@ import TestPlanReportContainer from "@/business/plan/view/comonents/report/detai
import MsInstructionsIcon from "metersphere-frontend/src/components/MsInstructionsIcon";
import MsTag from "metersphere-frontend/src/components/MsTag";
import { datetimeFormat } from "fit2cloud-ui/src/filters/time";
import { getTestPlanExtReport } from "@/api/remote/plan/test-plan";
export default {
name: "TestPlanOverviewReport",

View File

@ -85,7 +85,6 @@
<script>
import TestPlanFunctionalReport from "@/business/plan/view/comonents/report/detail/TestPlanFunctionalReport";
import {
getShareTestPlanExtReport,
getShareTestPlanReport,
getShareTestPlanReportContent,
getTestPlanReport,
@ -254,6 +253,8 @@ export default {
this.loading = false;
this.report = r.data;
this.report.config = this.getDefaultConfig(this.report);
this.runMode = this.report.runMode;
this.resourcePool = this.report.resourcePool;
});
}
} else {
@ -268,20 +269,6 @@ export default {
});
}
}
if (!this.isTemplate) {
if (this.isShare) {
getShareTestPlanExtReport(
this.shareId,
this.planId,
this.reportId
).then((response) => {
if (response.data) {
this.runMode = response.data.runMode;
this.resourcePool = response.data.resourcePool;
}
});
}
}
},
getDefaultConfig(report) {
let dbConfig = null;

View File

@ -1,11 +1,11 @@
<template>
<test-case-relevance-base
@setProject="setProject"
@save="saveCaseRelevance"
:plan-id="planId"
ref="baseRelevance">
:is-saving="isSaving"
ref="baseRelevance"
>
<template v-slot:aside>
<ui-scenario-module
@nodeSelectEvent="nodeChange"
@ -14,7 +14,8 @@
:relevance-project-id="projectId"
:is-read-only="true"
:show-case-num="false"
ref="nodeTree"/>
ref="nodeTree"
/>
</template>
<relevance-ui-scenario-list
@ -24,24 +25,20 @@
:plan-id="planId"
:project-id="projectId"
@selectCountChange="setSelectCounts"
ref="apiScenarioList"/>
ref="apiScenarioList"
/>
</test-case-relevance-base>
</template>
<script>
import TestCaseRelevanceBase from "../base/TestCaseRelevanceBase";
import {strMapToObj} from "metersphere-frontend/src/utils";
import {ENV_TYPE} from "metersphere-frontend/src/utils/constants";
import { strMapToObj } from "metersphere-frontend/src/utils";
import { ENV_TYPE } from "metersphere-frontend/src/utils/constants";
import RelevanceUiScenarioList from "@/business/plan/view/comonents/ui/RelevanceUiScenarioList";
import {testPlanAutoCheck} from "@/api/remote/plan/test-plan";
import {
testPlanUiScenarioRelevanceListIds
} from "@/api/remote/ui/test-plan-ui-scenario-case";
import { testPlanAutoCheck } from "@/api/remote/plan/test-plan";
import { testPlanUiScenarioRelevanceListIds } from "@/api/remote/ui/test-plan-ui-scenario-case";
import UiScenarioModule from "@/business/plan/view/comonents/ui/UiScenarioModule";
import {uiAutomationRelevance} from "@/api/remote/ui/api-scenario";
import { uiAutomationRelevance } from "@/api/remote/ui/api-scenario";
export default {
name: "TestCaseUiScenarioRelevance",
@ -60,17 +57,18 @@ export default {
trashEnable: false,
condition: {},
currentRow: {},
projectId: ""
isSaving: false,
projectId: "",
};
},
props: {
planId: {
type: String
type: String,
},
versionEnable: {
type: Boolean,
default: false
}
default: false,
},
},
watch: {
planId() {
@ -125,41 +123,42 @@ export default {
param.environmentType = envType;
param.envGroupId = envGroupId;
this.loading = true;
uiAutomationRelevance(param)
.then(() => {
this.loading = false;
this.$success(this.$t('commons.save_success'));
this.$emit('refresh');
this.refresh();
this.autoCheckStatus();
this.$refs.baseRelevance.close();
});
uiAutomationRelevance(param).then(() => {
this.loading = false;
this.$success(this.$t("commons.save_success"));
this.$emit("refresh");
this.refresh();
this.autoCheckStatus();
this.$refs.baseRelevance.close();
});
},
getAllId(param) {
return new Promise((resolve) => {
testPlanUiScenarioRelevanceListIds(param)
.then((r) => {
resolve(r.data);
});
testPlanUiScenarioRelevanceListIds(param).then((r) => {
resolve(r.data);
});
});
},
async saveCaseRelevance() {
this.isSaving = true;
let selectIds = [];
let selectRows = this.$refs.apiScenarioList.selectRows;
const envMap = this.$refs.apiScenarioList.projectEnvMap;
let map = this.$refs.apiScenarioList.map;
let envGroupId = this.$refs.apiScenarioList.envGroupId;
selectRows.forEach(row => {
selectRows.forEach((row) => {
selectIds.push(row.id);
})
});
if (selectIds.length < 1) {
this.$warning(this.$t('test_track.plan_view.please_choose_test_case'));
this.isSaving = false;
this.$warning(this.$t("test_track.plan_view.please_choose_test_case"));
return;
}
if (!envMap || envMap.size == 0) {
this.$warning(this.$t('api_test.environment.select_environment'));
this.isSaving = false;
this.$warning(this.$t("api_test.environment.select_environment"));
return;
}
@ -180,14 +179,19 @@ export default {
uiAutomationRelevance(param)
.then(() => {
this.loading = false;
this.$success(this.$t('commons.save_success'));
this.$emit('refresh');
this.isSaving = false;
this.$success(this.$t("commons.save_success"));
this.$emit("refresh");
this.refresh();
this.autoCheckStatus();
this.$refs.baseRelevance.close();
})
.catch(() => {
this.isSaving = false;
});
},
autoCheckStatus() { //
autoCheckStatus() {
//
if (!this.planId) {
return;
}
@ -195,13 +199,12 @@ export default {
},
setSelectCounts(data) {
this.$refs.baseRelevance.selectCounts = data;
}
}
},
},
};
</script>
<style scoped>
:deep(.select-menu) {
margin-bottom: 15px;
}
@ -222,5 +225,4 @@ export default {
left: -30px;
width: 30px;
}
</style>