fix(测试计划): 执行历史结果展示问题

This commit is contained in:
song-cc-rock 2024-11-21 19:02:54 +08:00 committed by Craftsman
parent 255ae52f41
commit b91df98565
6 changed files with 10 additions and 46 deletions

View File

@ -555,7 +555,7 @@
<select id="getPlanChildrenTask" resultType="io.metersphere.plan.domain.TestPlanReport"> <select id="getPlanChildrenTask" resultType="io.metersphere.plan.domain.TestPlanReport">
select test_plan_report.id, test_plan.name from test_plan_report left join test_plan on test_plan_report.test_plan_id = test_plan.id select test_plan_report.id, test_plan.name from test_plan_report left join test_plan on test_plan_report.test_plan_id = test_plan.id
where parent_id = #{reportId} and integrated = false order by test_plan_report.create_time desc where parent_id = #{reportId} and test_plan_report.id != #{reportId} and integrated = false order by test_plan_report.create_time desc
</select> </select>
<update id="resetRerunReport"> <update id="resetRerunReport">

View File

@ -1441,10 +1441,10 @@ public class TestPlanReportService {
* @return 用例执行情况 * @return 用例执行情况
*/ */
private TestPlanReportDetailResponse calcTaskExecFinish(String reportId, String detailName, TestPlanReportDetailResponse detail) { private TestPlanReportDetailResponse calcTaskExecFinish(String reportId, String detailName, TestPlanReportDetailResponse detail) {
detail.setId(reportId);
detail.setName(detailName);
TestPlanReport report = checkReport(reportId); TestPlanReport report = checkReport(reportId);
BeanUtils.copyBean(detail, report); BeanUtils.copyBean(detail, report);
detail.setId(reportId);
detail.setName(detailName);
TestPlanReportSummary summary = getReportSummary(reportId); TestPlanReportSummary summary = getReportSummary(reportId);
// 任务执行结果只需统计 接口 + 场景 (数据来源: 报告汇总) // 任务执行结果只需统计 接口 + 场景 (数据来源: 报告汇总)
detail.setApiCaseCount(summary.getApiExecuteResult() == null ? CaseCount.builder().build() : JSON.parseObject(new String(summary.getApiExecuteResult()), CaseCount.class)); detail.setApiCaseCount(summary.getApiExecuteResult() == null ? CaseCount.builder().build() : JSON.parseObject(new String(summary.getApiExecuteResult()), CaseCount.class));
@ -1452,6 +1452,7 @@ public class TestPlanReportService {
detail.setApiCaseTotal(detail.getApiCaseCount().sum()); detail.setApiCaseTotal(detail.getApiCaseCount().sum());
detail.setApiScenarioTotal(detail.getApiScenarioCount().sum()); detail.setApiScenarioTotal(detail.getApiScenarioCount().sum());
detail.setExecuteCount(CountUtils.summarizeProperties(List.of(detail.getApiCaseCount(), detail.getApiScenarioCount()))); detail.setExecuteCount(CountUtils.summarizeProperties(List.of(detail.getApiCaseCount(), detail.getApiScenarioCount())));
detail.setCaseTotal(detail.getExecuteCount().sum());
CaseCount executeCount = detail.getExecuteCount(); CaseCount executeCount = detail.getExecuteCount();
detail.setExecuteRate(RateCalculateUtils.divWithPrecision((executeCount.sum() - executeCount.getPending()), executeCount.sum(), 2)); detail.setExecuteRate(RateCalculateUtils.divWithPrecision((executeCount.sum() - executeCount.getPending()), executeCount.sum(), 2));
detail.setPassRate(RateCalculateUtils.divWithPrecision(executeCount.getSuccess(), executeCount.sum(), 2)); detail.setPassRate(RateCalculateUtils.divWithPrecision(executeCount.getSuccess(), executeCount.sum(), 2));

View File

@ -724,7 +724,7 @@
showReportDetail(record); showReportDetail(record);
} else if ([ExecuteTaskType.TEST_PLAN_GROUP, ExecuteTaskType.TEST_PLAN].includes(record.taskType)) { } else if ([ExecuteTaskType.TEST_PLAN_GROUP, ExecuteTaskType.TEST_PLAN].includes(record.taskType)) {
showTestPlanDetailDrawer.value = true; showTestPlanDetailDrawer.value = true;
activeDetailId.value = record.reportId; activeDetailId.value = record.id;
isTestPlanGroup.value = record.taskType === ExecuteTaskType.TEST_PLAN_GROUP; isTestPlanGroup.value = record.taskType === ExecuteTaskType.TEST_PLAN_GROUP;
} }
} }

View File

@ -132,7 +132,6 @@
} from '@/api/modules/test-plan/report'; } from '@/api/modules/test-plan/report';
import { useI18n } from '@/hooks/useI18n'; import { useI18n } from '@/hooks/useI18n';
import useOpenNewPage from '@/hooks/useOpenNewPage'; import useOpenNewPage from '@/hooks/useOpenNewPage';
import { addCommasToNumber } from '@/utils';
import { ApiOrScenarioCaseItem } from '@/models/testPlan/report'; import { ApiOrScenarioCaseItem } from '@/models/testPlan/report';
import { ReportMetricsItemModel } from '@/models/testPlan/testPlanReport'; import { ReportMetricsItemModel } from '@/models/testPlan/testPlanReport';
@ -162,20 +161,7 @@
const activePlan = ref(''); const activePlan = ref('');
const reportAnalysisList = computed<ReportMetricsItemModel[]>(() => { const reportAnalysisList = computed<ReportMetricsItemModel[]>(() => {
if (props.isGroup) {
return [ return [
{
name: t('report.detail.testPlanTotal'),
value: detail.value.planCount,
unit: t('report.detail.number'),
icon: 'plan_total',
},
{
name: t('report.detail.testPlanCaseTotal'),
value: detail.value.caseTotal,
unit: t('report.detail.number'),
icon: 'case_total',
},
{ {
name: t('report.passRate'), name: t('report.passRate'),
value: detail.value.passRate, value: detail.value.passRate,
@ -183,38 +169,11 @@
icon: 'passRate', icon: 'passRate',
}, },
{ {
name: t('report.detail.totalDefects'), name: t('report.detail.rate_completion'),
value: addCommasToNumber(detail.value.bugCount),
unit: t('report.detail.number'),
icon: 'bugTotal',
},
];
}
return [
{
name: t('report.detail.threshold'),
value: detail.value.passThreshold,
unit: '%',
icon: 'threshold',
},
{
name: t('report.passRate'),
value: detail.value.passRate,
unit: '%',
icon: 'passRate',
},
{
name: t('report.detail.performCompletion'),
value: detail.value.executeRate, value: detail.value.executeRate,
unit: '%', unit: '%',
icon: 'passRate', icon: 'passRate',
}, },
{
name: t('report.detail.totalDefects'),
value: addCommasToNumber(detail.value.bugCount),
unit: t('report.detail.number'),
icon: 'bugTotal',
},
]; ];
}); });
@ -347,6 +306,8 @@
label: item.name, label: item.name,
})); }));
activePlan.value = res.children[0]?.id; activePlan.value = res.children[0]?.id;
} else {
testPlanGroups.value = [];
} }
searchList(); searchList();
} catch (error) { } catch (error) {

View File

@ -31,6 +31,7 @@ export default {
'report.detail.executionAnalysis': 'Execution Analysis', 'report.detail.executionAnalysis': 'Execution Analysis',
'report.detail.threshold': 'Pass threshold', 'report.detail.threshold': 'Pass threshold',
'report.detail.performCompletion': 'Perform completion', 'report.detail.performCompletion': 'Perform completion',
'report.detail.rate_completion': 'Rate of completion',
'report.detail.totalDefects': 'Total defects', 'report.detail.totalDefects': 'Total defects',
'report.detail.useCaseAnalysis': 'Function of use case analysis', 'report.detail.useCaseAnalysis': 'Function of use case analysis',
'report.detail.apiUseCaseAnalysis': 'Api use case analysis', 'report.detail.apiUseCaseAnalysis': 'Api use case analysis',

View File

@ -31,6 +31,7 @@ export default {
'report.detail.executionAnalysis': '执行分析', 'report.detail.executionAnalysis': '执行分析',
'report.detail.threshold': '通过阈值', 'report.detail.threshold': '通过阈值',
'report.detail.performCompletion': '执行完成率', 'report.detail.performCompletion': '执行完成率',
'report.detail.rate_completion': '完成率',
'report.detail.totalDefects': '缺陷总数', 'report.detail.totalDefects': '缺陷总数',
'report.detail.useCaseAnalysis': '功能用例分析', 'report.detail.useCaseAnalysis': '功能用例分析',
'report.detail.apiUseCaseAnalysis': '接口用例分析', 'report.detail.apiUseCaseAnalysis': '接口用例分析',