diff --git a/frontend/src/api/modules/api-test/management.ts b/frontend/src/api/modules/api-test/management.ts index 8a0c04dd1f..493a1cb713 100644 --- a/frontend/src/api/modules/api-test/management.ts +++ b/frontend/src/api/modules/api-test/management.ts @@ -23,6 +23,7 @@ import { CaseBatchExportLogUrl, CaseExportLogUrl, CasePageUrl, + CaseStatisticsUrl, caseTableBatchSyncUrl, CheckDefinitionScheduleUrl, checkSharePsdUrl, @@ -124,6 +125,7 @@ import { ApiCaseExecuteHistoryItem, ApiCaseExecuteHistoryParams, ApiCasePageParams, + type ApiCaseStatisticsItem, ApiDefinitionBatchDeleteParams, type ApiDefinitionBatchExportParams, ApiDefinitionBatchMoveParams, @@ -719,3 +721,8 @@ export function getDocSharePluginScript(id: string | number, orgId: string) { export function getShareDefinitionDetail(id: string | number) { return MSR.get({ url: GetShareDefinitionDetailUrl, params: id }); } + +// 用例执行率统计 +export function getCaseStatistics(data: string[]) { + return MSR.post({ url: CaseStatisticsUrl, data }); +} diff --git a/frontend/src/api/modules/api-test/scenario.ts b/frontend/src/api/modules/api-test/scenario.ts index 96d4674d75..bdd38d4759 100644 --- a/frontend/src/api/modules/api-test/scenario.ts +++ b/frontend/src/api/modules/api-test/scenario.ts @@ -41,6 +41,7 @@ import { ScenarioPageUrl, ScenarioScheduleConfigDeleteUrl, ScenarioScheduleConfigUrl, + ScenarioStatisticsUrl, ScenarioStepTransferFileUrl, ScenarioTransferFileUrl, ScenarioTransferModuleOptionsUrl, @@ -77,6 +78,7 @@ import { ScenarioDetail, ScenarioHistoryItem, ScenarioHistoryPageParams, + type ScenarioStatisticsItem, ScenarioStepResourceInfo, } from '@/models/apiTest/scenario'; import { @@ -369,3 +371,8 @@ export function getScenarioDownloadFile(projectId: string, fileId: string) { export function scenarioBatchEditSchedule(data: ApiScenarioBatchScheduleConfig) { return MSR.post({ url: ScenarioBatchEditScheduleUrl, data }); } + +// 场景执行率统计 +export function getScenarioStatistics(data: string[]) { + return MSR.post({ url: ScenarioStatisticsUrl, data }); +} diff --git a/frontend/src/api/requrls/api-test/management.ts b/frontend/src/api/requrls/api-test/management.ts index ba9d726776..34cfd0bb09 100644 --- a/frontend/src/api/requrls/api-test/management.ts +++ b/frontend/src/api/requrls/api-test/management.ts @@ -99,6 +99,7 @@ export const GetCaseReportDetailUrl = '/api/report/case/get/detail/'; // 接口 export const CaseExportLogUrl = '/api/report/case/export'; // 接口用例导出报告日志记录 export const CaseBatchExportLogUrl = '/api/report/case/batch-export'; // 接口用例批量导出报告日志记录 export const GetCaseBatchExportParamsUrl = '/api/report/case/batch-param'; // 接口用例批量导出报告id集合 +export const CaseStatisticsUrl = '/api/case/statistics'; // 用例执行率统计 /** * 接口用例回收站 diff --git a/frontend/src/api/requrls/api-test/scenario.ts b/frontend/src/api/requrls/api-test/scenario.ts index cfdec54008..ee1ac629d5 100644 --- a/frontend/src/api/requrls/api-test/scenario.ts +++ b/frontend/src/api/requrls/api-test/scenario.ts @@ -28,6 +28,8 @@ export const BatchEditScenarioUrl = '/api/scenario/batch-operation/edit'; // 批 export const BatchRunScenarioUrl = '/api/scenario/batch-operation/run'; // 批量执行接口场景 export const UpdateScenarioPriorityUrl = '/api/scenario/update-priority'; // 场景更新等级 export const UpdateScenarioStatusUrl = '/api/scenario/update-status'; // 场景更新状态 +export const ScenarioStatisticsUrl = '/api/scenario/statistics'; // 场景执行率统计 + // 场景导入导出相关 export const ImportScenarioUrl = '/api/scenario/import'; // 导入场景 export const ExportScenarioUrl = '/api/scenario/export'; // 导出场景 diff --git a/frontend/src/models/apiTest/management.ts b/frontend/src/models/apiTest/management.ts index 797eb63984..f2bf13268e 100644 --- a/frontend/src/models/apiTest/management.ts +++ b/frontend/src/models/apiTest/management.ts @@ -475,3 +475,8 @@ export interface ShareDetailType { isPrivate: boolean; projectName?: string; } +// 接口用例统计项 +export interface ApiCaseStatisticsItem { + id: string; + passRate: string; +} diff --git a/frontend/src/models/apiTest/scenario.ts b/frontend/src/models/apiTest/scenario.ts index 9cd15cc7c8..cee3b93fed 100644 --- a/frontend/src/models/apiTest/scenario.ts +++ b/frontend/src/models/apiTest/scenario.ts @@ -558,3 +558,9 @@ export interface ExportScenarioParams extends BatchActionQueryParams { exportAllRelatedData: boolean; fileId: string; } + +// 场景统计项 +export interface ScenarioStatisticsItem { + id: string; + execPassRate: string; +} diff --git a/frontend/src/views/api-test/management/components/management/case/caseTable.vue b/frontend/src/views/api-test/management/components/management/case/caseTable.vue index 7ffe699b8e..09b9c881c9 100644 --- a/frontend/src/views/api-test/management/components/management/case/caseTable.vue +++ b/frontend/src/views/api-test/management/components/management/case/caseTable.vue @@ -345,6 +345,7 @@ dragSort, getCaseDetail, getCasePage, + getCaseStatistics, updateCasePriority, updateCaseStatus, } from '@/api/modules/api-test/management'; @@ -635,6 +636,22 @@ } return moduleIds; } + + async function initStatistics() { + try { + const res = await getCaseStatistics(propsRes.value.data.map((item) => item.id)); + propsRes.value.data.forEach((e) => { + const item = res.find((i: any) => i.scenarioId === e.id); + if (item) { + e.passRate = item.passRate; + } + }); + } catch (error) { + // eslint-disable-next-line no-console + console.log(error); + } + } + async function loadCaseList() { const selectModules = await getModuleIds(); const params = { @@ -648,7 +665,8 @@ combineSearch: advanceFilter, }; setLoadListParams(params); - loadList(); + await loadList(); + initStatistics(); } function loadCaseListAndResetSelector() { resetSelector(); diff --git a/frontend/src/views/api-test/scenario/components/scenarioTable.vue b/frontend/src/views/api-test/scenario/components/scenarioTable.vue index d290c24c3e..27388cf058 100644 --- a/frontend/src/views/api-test/scenario/components/scenarioTable.vue +++ b/frontend/src/views/api-test/scenario/components/scenarioTable.vue @@ -528,6 +528,7 @@ deleteScheduleConfig, dragSort, getScenarioPage, + getScenarioStatistics, recycleScenario, scenarioBatchEditSchedule, scenarioScheduleConfig, @@ -748,8 +749,8 @@ }, { title: 'apiScenario.table.columns.passRate', - dataIndex: 'requestPassRate', - slotName: 'requestPassRate', + dataIndex: 'execPassRate', + slotName: 'execPassRate', titleSlotName: 'requestPassRateColumn', showDrag: true, showInTable: false, @@ -847,7 +848,7 @@ }, (item) => ({ ...item, - requestPassRate: item.requestPassRate ? `${item.requestPassRate}%` : '-', + execPassRate: item.execPassRate ? `${item.execPassRate}%` : '-', createTime: dayjs(item.createTime).format('YYYY-MM-DD HH:mm:ss'), updateTime: dayjs(item.updateTime).format('YYYY-MM-DD HH:mm:ss'), }) @@ -960,6 +961,22 @@ } return moduleIds; } + + async function initStatistics() { + try { + const res = await getScenarioStatistics(propsRes.value.data.map((item) => item.id)); + propsRes.value.data.forEach((e) => { + const item = res.find((i: any) => i.scenarioId === e.id); + if (item) { + e.execPassRate = item.execPassRate; + } + }); + } catch (error) { + // eslint-disable-next-line no-console + console.log(error); + } + } + async function loadScenarioList(refreshTreeCount?: boolean) { const moduleIds = await getModuleIds(); const params = { @@ -969,6 +986,7 @@ }; setLoadListParams({ ...params, viewId: viewId.value, combineSearch: advanceFilter }); await loadList(); + initStatistics(); if (refreshTreeCount && !isAdvancedSearchMode.value) { emit('refreshModuleTree', params); }