fix(接口测试): 场景&用例表格通过率统计

This commit is contained in:
baiqi 2024-11-07 17:59:34 +08:00 committed by 刘瑞斌
parent 66eac32742
commit 7b3a920f25
8 changed files with 68 additions and 4 deletions

View File

@ -23,6 +23,7 @@ import {
CaseBatchExportLogUrl, CaseBatchExportLogUrl,
CaseExportLogUrl, CaseExportLogUrl,
CasePageUrl, CasePageUrl,
CaseStatisticsUrl,
caseTableBatchSyncUrl, caseTableBatchSyncUrl,
CheckDefinitionScheduleUrl, CheckDefinitionScheduleUrl,
checkSharePsdUrl, checkSharePsdUrl,
@ -124,6 +125,7 @@ import {
ApiCaseExecuteHistoryItem, ApiCaseExecuteHistoryItem,
ApiCaseExecuteHistoryParams, ApiCaseExecuteHistoryParams,
ApiCasePageParams, ApiCasePageParams,
type ApiCaseStatisticsItem,
ApiDefinitionBatchDeleteParams, ApiDefinitionBatchDeleteParams,
type ApiDefinitionBatchExportParams, type ApiDefinitionBatchExportParams,
ApiDefinitionBatchMoveParams, ApiDefinitionBatchMoveParams,
@ -719,3 +721,8 @@ export function getDocSharePluginScript(id: string | number, orgId: string) {
export function getShareDefinitionDetail(id: string | number) { export function getShareDefinitionDetail(id: string | number) {
return MSR.get<ApiDefinitionDetail>({ url: GetShareDefinitionDetailUrl, params: id }); return MSR.get<ApiDefinitionDetail>({ url: GetShareDefinitionDetailUrl, params: id });
} }
// 用例执行率统计
export function getCaseStatistics(data: string[]) {
return MSR.post<ApiCaseStatisticsItem[]>({ url: CaseStatisticsUrl, data });
}

View File

@ -41,6 +41,7 @@ import {
ScenarioPageUrl, ScenarioPageUrl,
ScenarioScheduleConfigDeleteUrl, ScenarioScheduleConfigDeleteUrl,
ScenarioScheduleConfigUrl, ScenarioScheduleConfigUrl,
ScenarioStatisticsUrl,
ScenarioStepTransferFileUrl, ScenarioStepTransferFileUrl,
ScenarioTransferFileUrl, ScenarioTransferFileUrl,
ScenarioTransferModuleOptionsUrl, ScenarioTransferModuleOptionsUrl,
@ -77,6 +78,7 @@ import {
ScenarioDetail, ScenarioDetail,
ScenarioHistoryItem, ScenarioHistoryItem,
ScenarioHistoryPageParams, ScenarioHistoryPageParams,
type ScenarioStatisticsItem,
ScenarioStepResourceInfo, ScenarioStepResourceInfo,
} from '@/models/apiTest/scenario'; } from '@/models/apiTest/scenario';
import { import {
@ -369,3 +371,8 @@ export function getScenarioDownloadFile(projectId: string, fileId: string) {
export function scenarioBatchEditSchedule(data: ApiScenarioBatchScheduleConfig) { export function scenarioBatchEditSchedule(data: ApiScenarioBatchScheduleConfig) {
return MSR.post({ url: ScenarioBatchEditScheduleUrl, data }); return MSR.post({ url: ScenarioBatchEditScheduleUrl, data });
} }
// 场景执行率统计
export function getScenarioStatistics(data: string[]) {
return MSR.post<ScenarioStatisticsItem[]>({ url: ScenarioStatisticsUrl, data });
}

View File

@ -99,6 +99,7 @@ export const GetCaseReportDetailUrl = '/api/report/case/get/detail/'; // 接口
export const CaseExportLogUrl = '/api/report/case/export'; // 接口用例导出报告日志记录 export const CaseExportLogUrl = '/api/report/case/export'; // 接口用例导出报告日志记录
export const CaseBatchExportLogUrl = '/api/report/case/batch-export'; // 接口用例批量导出报告日志记录 export const CaseBatchExportLogUrl = '/api/report/case/batch-export'; // 接口用例批量导出报告日志记录
export const GetCaseBatchExportParamsUrl = '/api/report/case/batch-param'; // 接口用例批量导出报告id集合 export const GetCaseBatchExportParamsUrl = '/api/report/case/batch-param'; // 接口用例批量导出报告id集合
export const CaseStatisticsUrl = '/api/case/statistics'; // 用例执行率统计
/** /**
* *

View File

@ -28,6 +28,8 @@ export const BatchEditScenarioUrl = '/api/scenario/batch-operation/edit'; // 批
export const BatchRunScenarioUrl = '/api/scenario/batch-operation/run'; // 批量执行接口场景 export const BatchRunScenarioUrl = '/api/scenario/batch-operation/run'; // 批量执行接口场景
export const UpdateScenarioPriorityUrl = '/api/scenario/update-priority'; // 场景更新等级 export const UpdateScenarioPriorityUrl = '/api/scenario/update-priority'; // 场景更新等级
export const UpdateScenarioStatusUrl = '/api/scenario/update-status'; // 场景更新状态 export const UpdateScenarioStatusUrl = '/api/scenario/update-status'; // 场景更新状态
export const ScenarioStatisticsUrl = '/api/scenario/statistics'; // 场景执行率统计
// 场景导入导出相关 // 场景导入导出相关
export const ImportScenarioUrl = '/api/scenario/import'; // 导入场景 export const ImportScenarioUrl = '/api/scenario/import'; // 导入场景
export const ExportScenarioUrl = '/api/scenario/export'; // 导出场景 export const ExportScenarioUrl = '/api/scenario/export'; // 导出场景

View File

@ -475,3 +475,8 @@ export interface ShareDetailType {
isPrivate: boolean; isPrivate: boolean;
projectName?: string; projectName?: string;
} }
// 接口用例统计项
export interface ApiCaseStatisticsItem {
id: string;
passRate: string;
}

View File

@ -558,3 +558,9 @@ export interface ExportScenarioParams extends BatchActionQueryParams {
exportAllRelatedData: boolean; exportAllRelatedData: boolean;
fileId: string; fileId: string;
} }
// 场景统计项
export interface ScenarioStatisticsItem {
id: string;
execPassRate: string;
}

View File

@ -345,6 +345,7 @@
dragSort, dragSort,
getCaseDetail, getCaseDetail,
getCasePage, getCasePage,
getCaseStatistics,
updateCasePriority, updateCasePriority,
updateCaseStatus, updateCaseStatus,
} from '@/api/modules/api-test/management'; } from '@/api/modules/api-test/management';
@ -635,6 +636,22 @@
} }
return moduleIds; 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() { async function loadCaseList() {
const selectModules = await getModuleIds(); const selectModules = await getModuleIds();
const params = { const params = {
@ -648,7 +665,8 @@
combineSearch: advanceFilter, combineSearch: advanceFilter,
}; };
setLoadListParams(params); setLoadListParams(params);
loadList(); await loadList();
initStatistics();
} }
function loadCaseListAndResetSelector() { function loadCaseListAndResetSelector() {
resetSelector(); resetSelector();

View File

@ -528,6 +528,7 @@
deleteScheduleConfig, deleteScheduleConfig,
dragSort, dragSort,
getScenarioPage, getScenarioPage,
getScenarioStatistics,
recycleScenario, recycleScenario,
scenarioBatchEditSchedule, scenarioBatchEditSchedule,
scenarioScheduleConfig, scenarioScheduleConfig,
@ -748,8 +749,8 @@
}, },
{ {
title: 'apiScenario.table.columns.passRate', title: 'apiScenario.table.columns.passRate',
dataIndex: 'requestPassRate', dataIndex: 'execPassRate',
slotName: 'requestPassRate', slotName: 'execPassRate',
titleSlotName: 'requestPassRateColumn', titleSlotName: 'requestPassRateColumn',
showDrag: true, showDrag: true,
showInTable: false, showInTable: false,
@ -847,7 +848,7 @@
}, },
(item) => ({ (item) => ({
...item, ...item,
requestPassRate: item.requestPassRate ? `${item.requestPassRate}%` : '-', execPassRate: item.execPassRate ? `${item.execPassRate}%` : '-',
createTime: dayjs(item.createTime).format('YYYY-MM-DD HH:mm:ss'), createTime: dayjs(item.createTime).format('YYYY-MM-DD HH:mm:ss'),
updateTime: dayjs(item.updateTime).format('YYYY-MM-DD HH:mm:ss'), updateTime: dayjs(item.updateTime).format('YYYY-MM-DD HH:mm:ss'),
}) })
@ -960,6 +961,22 @@
} }
return moduleIds; 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) { async function loadScenarioList(refreshTreeCount?: boolean) {
const moduleIds = await getModuleIds(); const moduleIds = await getModuleIds();
const params = { const params = {
@ -969,6 +986,7 @@
}; };
setLoadListParams({ ...params, viewId: viewId.value, combineSearch: advanceFilter }); setLoadListParams({ ...params, viewId: viewId.value, combineSearch: advanceFilter });
await loadList(); await loadList();
initStatistics();
if (refreshTreeCount && !isAdvancedSearchMode.value) { if (refreshTreeCount && !isAdvancedSearchMode.value) {
emit('refreshModuleTree', params); emit('refreshModuleTree', params);
} }