refactor(测试计划): 优化测试计划报告分享页面获取报告详情
This commit is contained in:
parent
8fd70d8479
commit
a37d09f3ed
|
@ -60,5 +60,7 @@ public interface ExtTestPlanReportMapper {
|
|||
|
||||
List<ReportDTO> getScenarioReports(@Param("ids") List<String> ids);
|
||||
|
||||
void batchUpdateExecuteTimeAndStatus(@Param("startTime") long startTime,@Param("ids")List<String> ids);
|
||||
void batchUpdateExecuteTimeAndStatus(@Param("startTime") long startTime, @Param("ids") List<String> ids);
|
||||
|
||||
List<ReportDTO> getReportsByIds(@Param("ids") List<String> ids);
|
||||
}
|
||||
|
|
|
@ -217,6 +217,18 @@
|
|||
</foreach>
|
||||
</select>
|
||||
|
||||
<select id="getReportsByIds" resultType="io.metersphere.api.dto.report.ReportDTO">
|
||||
select
|
||||
test_plan_report.id,
|
||||
test_plan_report.name,
|
||||
test_plan_report.project_id
|
||||
from test_plan_report where test_plan_report.deleted = false
|
||||
and test_plan_report.id in
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<update id="batchUpdateExecuteTimeAndStatus" parameterType="java.lang.String">
|
||||
update test_plan_report
|
||||
set start_time = #{startTime}, exec_status = 'RUNNING'
|
||||
|
|
|
@ -291,6 +291,7 @@ public class TestPlanTaskCenterService {
|
|||
detailReport(request, apiReports, userId, module, ApiExecuteResourceType.TEST_PLAN_API_CASE.name());
|
||||
List<ReportDTO> scenarioReports = extTestPlanReportMapper.getScenarioReports(subList);
|
||||
detailReport(request, scenarioReports, userId, module, ApiExecuteResourceType.TEST_PLAN_API_SCENARIO.name());
|
||||
saveLog(subList, userId, StringUtils.join(module, "_REAL_TIME_TEST_PLAN"));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -331,20 +332,13 @@ public class TestPlanTaskCenterService {
|
|||
MsHttpClient.stopApi(endpoint, subList);
|
||||
} catch (Exception e) {
|
||||
LogUtils.error(e);
|
||||
} finally {
|
||||
saveLog(subList, userId, StringUtils.join(module, "_REAL_TIME_TEST_PLAN"), resourceType);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private void saveLog(List<String> ids, String userId, String module, String type) {
|
||||
List<ReportDTO> reports = new ArrayList<>();
|
||||
if (StringUtils.equals(type, ApiExecuteResourceType.TEST_PLAN_API_CASE.name())) {
|
||||
reports = extApiReportMapper.selectByIds(ids);
|
||||
} else if (StringUtils.equals(type, ApiExecuteResourceType.TEST_PLAN_API_SCENARIO.name())) {
|
||||
reports = extApiScenarioReportMapper.selectByIds(ids);
|
||||
}
|
||||
private void saveLog(List<String> ids, String userId, String module) {
|
||||
List<ReportDTO> reports = extTestPlanReportMapper.getReportsByIds(ids);
|
||||
//取出所有的项目id
|
||||
List<String> projectIds = reports.stream().map(ReportDTO::getProjectId).distinct().toList();
|
||||
//根据项目id取出组织id
|
||||
|
|
|
@ -2,6 +2,7 @@ import MSR from '@/api/http';
|
|||
import * as reportUrl from '@/api/requrls/test-plan/report';
|
||||
|
||||
import type { GetShareId } from '@/models/apiTest/report';
|
||||
import { ReportDetail, ReportStepDetail } from "@/models/apiTest/report";
|
||||
import { CommonList, TableQueryParams } from '@/models/common';
|
||||
import {
|
||||
ApiOrScenarioCaseItem,
|
||||
|
@ -116,4 +117,37 @@ export function getReportDetailSharePage(data: TableQueryParams) {
|
|||
return MSR.post<CommonList<PlanReportDetail>>({ url: reportUrl.ReportDetailSharePageUrl, data });
|
||||
}
|
||||
|
||||
export function reportScenarioDetail(reportId: string, shareId?: string | undefined) {
|
||||
if (shareId) {
|
||||
return MSR.get<ReportDetail>({ url: `${reportUrl.ReportShareScenarioUrlGet}/${shareId}/${reportId}` });
|
||||
}
|
||||
return MSR.get<ReportDetail>({ url: `${reportUrl.ReportScenarioUrl}/${reportId}` });
|
||||
}
|
||||
// 报告步骤详情
|
||||
export function reportStepDetail(reportId?: string, stepId?: string, shareId?: string | undefined) {
|
||||
if (shareId) {
|
||||
return MSR.get<ReportStepDetail>({
|
||||
url: `${reportUrl.ReportShareScenarioUrlGetDetail}/${shareId}/${reportId}/${stepId}`,
|
||||
});
|
||||
}
|
||||
return MSR.get<ReportStepDetail>({ url: `${reportUrl.ReportDetailScenarioUrl}/${reportId}/${stepId}` });
|
||||
}
|
||||
// 用例报告详情
|
||||
export function reportCaseDetail(reportId: string, shareId?: string | undefined) {
|
||||
if (shareId) {
|
||||
return MSR.get<ReportDetail>({ url: `${reportUrl.ReportShareApiUrlGet}/${shareId}/${reportId}` });
|
||||
}
|
||||
return MSR.get<ReportDetail>({ url: `${reportUrl.ReportApiUrl}/${reportId}` });
|
||||
}
|
||||
|
||||
// 报告步骤详情
|
||||
export function reportCaseStepDetail(reportId: string, stepId: string, shareId?: string | undefined) {
|
||||
if (shareId) {
|
||||
return MSR.get<ReportStepDetail[]>({
|
||||
url: `${reportUrl.ReportShareApiUrlGetDetail}/${shareId}/${reportId}/${stepId}`,
|
||||
});
|
||||
}
|
||||
return MSR.get<ReportStepDetail[]>({ url: `${reportUrl.ReportDetailApiUrl}/${reportId}/${stepId}` });
|
||||
}
|
||||
|
||||
export default {};
|
||||
|
|
|
@ -40,3 +40,20 @@ export const ReportShareScenarioUrl = '/test-plan/report/share/detail/scenario/c
|
|||
export const ReportDetailPageUrl = '/test-plan/report/detail/plan/report/page';
|
||||
// 测试计划-聚合报告-报告明细-分享
|
||||
export const ReportDetailSharePageUrl = '/test-plan/report/share/detail/plan/report/page';
|
||||
|
||||
// 测试计划-报告明细-接口报告-分享
|
||||
export const ReportShareApiUrlGet = '/test-plan/report/share/detail/api-report';
|
||||
export const ReportShareApiUrlGetDetail = '/test-plan/report/share/detail/api-report/get';
|
||||
|
||||
// 测试计划-报告明细-接口报告
|
||||
export const ReportApiUrl = '/test-plan/api/case/report/get';
|
||||
export const ReportDetailApiUrl = '/test-plan/api/case/report/get/detail';
|
||||
|
||||
// 测试计划-报告明细-场景报告-分享
|
||||
export const ReportShareScenarioUrlGet = '/test-plan/report/share/detail/scenario-report';
|
||||
export const ReportShareScenarioUrlGetDetail = '/test-plan/report/share/detail/scenario-report/get';
|
||||
|
||||
// 测试计划-报告明细-场景报告
|
||||
export const ReportScenarioUrl = '/test-plan/api/scenario/report/get';
|
||||
export const ReportDetailScenarioUrl = '/test-plan/api/scenario/report/get/detail';
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
v-model:model-value="numberValue"
|
||||
class="w-[120px]"
|
||||
:min="1"
|
||||
:max="1000"
|
||||
hide-button
|
||||
size="small"
|
||||
:disabled="props.disabled"
|
||||
|
|
|
@ -904,6 +904,18 @@ export const pathMap: PathMapItem[] = [
|
|||
type: TaskCenterEnum.API_SCENARIO,
|
||||
},
|
||||
},
|
||||
{
|
||||
key: 'PROJECT_MANAGEMENT_TASK_CENTER_REAL_TIME_TEST_PLAN', // 项目管理-任务中心-实时任务-接口场景
|
||||
locale: 'project.taskCenter.testPlan',
|
||||
route: '',
|
||||
permission: [],
|
||||
level: MENU_LEVEL[2],
|
||||
routeQuery: {
|
||||
task: true,
|
||||
tab: 'real',
|
||||
type: TaskCenterEnum.TEST_PLAN,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
|
@ -937,6 +949,18 @@ export const pathMap: PathMapItem[] = [
|
|||
type: TaskCenterEnum.API_IMPORT,
|
||||
},
|
||||
},
|
||||
{
|
||||
key: 'PROJECT_MANAGEMENT_TASK_CENTER_TIME_TEST_PLAN', // 项目管理-任务中心-定时任务-测试计划
|
||||
locale: 'project.taskCenter.testPlan',
|
||||
route: '',
|
||||
permission: [],
|
||||
level: MENU_LEVEL[2],
|
||||
routeQuery: {
|
||||
task: true,
|
||||
tab: 'timing',
|
||||
type: TaskCenterEnum.TEST_PLAN,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
v-model:visible="reportVisible"
|
||||
:is-scenario="props.activeTab === 'scenarioCase'"
|
||||
:report-id="apiReportId"
|
||||
do-not-show-share
|
||||
:share-id="props.shareId"
|
||||
/>
|
||||
</template>
|
||||
|
||||
|
@ -31,8 +31,8 @@
|
|||
import type { MsTableColumn } from '@/components/pure/ms-table/type';
|
||||
import useTable from '@/components/pure/ms-table/useTable';
|
||||
import caseLevel from '@/components/business/ms-case-associate/caseLevel.vue';
|
||||
import CaseAndScenarioReportDrawer from '@/views/api-test/components/caseAndScenarioReportDrawer.vue';
|
||||
import ExecutionStatus from '@/views/api-test/report/component/reportStatus.vue';
|
||||
import CaseAndScenarioReportDrawer from '@/views/test-plan/report/detail/component/caseAndScenarioReportDrawer.vue';
|
||||
|
||||
import { getApiPage, getScenarioPage } from '@/api/modules/test-plan/report';
|
||||
|
||||
|
@ -41,7 +41,6 @@
|
|||
import { FilterSlotNameEnum } from '@/enums/tableFilterEnum';
|
||||
|
||||
import { casePriorityOptions, lastReportStatusListOptions } from '@/views/api-test/components/config';
|
||||
import { executionResultMap } from '@/views/case-management/caseManagementFeature/components/utils';
|
||||
|
||||
const props = defineProps<{
|
||||
reportId: string;
|
||||
|
|
|
@ -0,0 +1,115 @@
|
|||
<template>
|
||||
<MsDrawer
|
||||
v-model:visible="innerVisible"
|
||||
:title="reportStepDetail.name"
|
||||
:width="1200"
|
||||
:footer="false"
|
||||
unmount-on-close
|
||||
no-content-padding
|
||||
show-full-screen
|
||||
>
|
||||
<CaseReportCom
|
||||
v-if="!props.isScenario"
|
||||
:detail-info="reportStepDetail"
|
||||
:get-report-step-detail="props.getReportStepDetail"
|
||||
/>
|
||||
<ScenarioCom v-else :detail-info="reportStepDetail" :get-report-step-detail="props.getReportStepDetail" />
|
||||
</MsDrawer>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue';
|
||||
import { useClipboard } from '@vueuse/core';
|
||||
|
||||
import MsDrawer from '@/components/pure/ms-drawer/index.vue';
|
||||
import CaseReportCom from '@/views/api-test/report/component/caseReportCom.vue';
|
||||
import ScenarioCom from '@/views/api-test/report/component/scenarioCom.vue';
|
||||
|
||||
import { reportCaseDetail,reportScenarioDetail } from '@/api/modules/test-plan/report';
|
||||
|
||||
import type { ReportDetail } from '@/models/apiTest/report';
|
||||
|
||||
const props = defineProps<{
|
||||
reportId: string;
|
||||
isScenario?: boolean;
|
||||
reportDetail?: (...args: any) => Promise<any>; // 获取报告接口
|
||||
getReportStepDetail?: (...args: any) => Promise<any>; // 获取步骤的详情内容接口
|
||||
shareId?: string;
|
||||
}>();
|
||||
|
||||
const { copy, isSupported } = useClipboard({ legacy: true });
|
||||
|
||||
const innerVisible = defineModel<boolean>('visible', {
|
||||
required: true,
|
||||
});
|
||||
|
||||
const initReportStepDetail = {
|
||||
id: '',
|
||||
name: '', // 报告名称
|
||||
testPlanId: '',
|
||||
createUser: '',
|
||||
deleteTime: 0,
|
||||
deleteUser: '',
|
||||
deleted: false,
|
||||
updateUser: '',
|
||||
updateTime: 0,
|
||||
startTime: 0, // 开始时间/同创建时间一致
|
||||
endTime: 0, // 结束时间/报告执行完成
|
||||
requestDuration: 0, // 请求总耗时
|
||||
status: '', // 报告状态/SUCCESS/ERROR
|
||||
triggerMode: '', // 触发方式
|
||||
runMode: '', // 执行模式
|
||||
poolId: '', // 资源池
|
||||
poolName: '', // 资源池名称
|
||||
versionId: '',
|
||||
integrated: false, // 是否是集成报告
|
||||
projectId: '',
|
||||
environmentId: '', // 环境id
|
||||
environmentName: '', // 环境名称
|
||||
errorCount: 0, // 失败数
|
||||
fakeErrorCount: 0, // 误报数
|
||||
pendingCount: 0, // 未执行数
|
||||
successCount: 0, // 成功数
|
||||
assertionCount: 0, // 总断言数
|
||||
assertionSuccessCount: 0, // 成功断言数
|
||||
requestErrorRate: '', // 请求失败率
|
||||
requestPendingRate: '', // 请求未执行率
|
||||
requestFakeErrorRate: '', // 请求误报率
|
||||
requestPassRate: '', // 请求通过率
|
||||
assertionPassRate: '', // 断言通过率
|
||||
scriptIdentifier: '', // 脚本标识
|
||||
children: [], // 步骤列表
|
||||
stepTotal: 0, // 步骤总数
|
||||
console: '',
|
||||
};
|
||||
const reportStepDetail = ref<ReportDetail>({
|
||||
...initReportStepDetail,
|
||||
});
|
||||
async function getReportDetail() {
|
||||
try {
|
||||
if (props.reportDetail) {
|
||||
reportStepDetail.value = await props.reportDetail(props.reportId);
|
||||
return;
|
||||
}
|
||||
if (props.isScenario) {
|
||||
reportStepDetail.value = await reportScenarioDetail(props.reportId, props.shareId);
|
||||
} else {
|
||||
reportStepDetail.value = await reportCaseDetail(props.reportId, props.shareId);
|
||||
}
|
||||
} catch (error) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
watch(
|
||||
() => innerVisible.value,
|
||||
async (val) => {
|
||||
if (val) {
|
||||
reportStepDetail.value = { ...initReportStepDetail };
|
||||
await getReportDetail();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
</script>
|
Loading…
Reference in New Issue