feat(接口测试): 接口&用例复制文件

This commit is contained in:
baiqi 2024-12-10 10:41:10 +08:00 committed by Craftsman
parent 91321faa07
commit 0457508be6
5 changed files with 80 additions and 26 deletions

View File

@ -22,6 +22,7 @@ import {
BatchUpdateDefinitionUrl, BatchUpdateDefinitionUrl,
CaseBatchExportLogUrl, CaseBatchExportLogUrl,
CaseExportLogUrl, CaseExportLogUrl,
CaseFileCopyUrl,
CasePageUrl, CasePageUrl,
CaseStatisticsUrl, CaseStatisticsUrl,
caseTableBatchSyncUrl, caseTableBatchSyncUrl,
@ -32,6 +33,7 @@ import {
CopyMockUrl, CopyMockUrl,
DebugCaseUrl, DebugCaseUrl,
DebugDefinitionUrl, DebugDefinitionUrl,
DefinitionFileCopyUrl,
DefinitionMockPageUrl, DefinitionMockPageUrl,
DefinitionPageUrl, DefinitionPageUrl,
DefinitionReferenceUrl, DefinitionReferenceUrl,
@ -144,6 +146,7 @@ import {
CheckScheduleParams, CheckScheduleParams,
CheckSharePsdType, CheckSharePsdType,
CreateImportApiDefinitionScheduleParams, CreateImportApiDefinitionScheduleParams,
type DefinitionFileCopyParams,
DefinitionHistoryItem, DefinitionHistoryItem,
DefinitionHistoryPageParams, DefinitionHistoryPageParams,
DefinitionReferencePageParams, DefinitionReferencePageParams,
@ -364,25 +367,10 @@ export function convertJsonSchemaToJson(data: JsonSchema) {
export function jsonSchemaAutoGenerate(data: JsonSchema) { export function jsonSchemaAutoGenerate(data: JsonSchema) {
return MSR.post({ url: JsonSchemaAutoGenerateUrl, data }); return MSR.post({ url: JsonSchemaAutoGenerateUrl, data });
} }
// 接口定义-用例接口对比-清除本次变更
export function clearThisChange(id: string) { // 接口定义-文件复制
return MSR.get({ url: `${clearThisChangeUrl}/${id}` }); export function definitionFileCopy(data: DefinitionFileCopyParams) {
} return MSR.post({ url: DefinitionFileCopyUrl, data });
// 接口定义-用例接口对比-忽略每次变更
export function ignoreEveryTimeChange(id: string, ignore: boolean) {
return MSR.get({ url: `${ignoreEveryTimeApiChangeUrl}/${id}`, params: { ignore } });
}
// 接口测试-接口管理-接口用例-批量同步编辑
export function caseTableBatchSync(data: TableQueryParams) {
return MSR.post({ url: caseTableBatchSyncUrl, data });
}
// 接口测试-接口用例-定义对比用例
export function diffDataRequest(id: string) {
return MSR.get({ url: `${diffDataUrl}/${id}` });
}
// 接口测试-接口用例-定义对比用例-同步-获取同步后的用例详情
export function getSyncedCaseDetail(data: diffSyncParams) {
return MSR.post({ url: getSyncedCaseDetailUrl, data });
} }
/** /**
@ -566,6 +554,36 @@ export function runCase(data: ExecuteRequestParams) {
return MSR.post({ url: RunCaseUrl, data }); return MSR.post({ url: RunCaseUrl, data });
} }
// 接口定义-用例接口对比-清除本次变更
export function clearThisChange(id: string) {
return MSR.get({ url: `${clearThisChangeUrl}/${id}` });
}
// 接口定义-用例接口对比-忽略每次变更
export function ignoreEveryTimeChange(id: string, ignore: boolean) {
return MSR.get({ url: `${ignoreEveryTimeApiChangeUrl}/${id}`, params: { ignore } });
}
// 接口测试-接口管理-接口用例-批量同步编辑
export function caseTableBatchSync(data: TableQueryParams) {
return MSR.post({ url: caseTableBatchSyncUrl, data });
}
// 接口测试-接口用例-定义对比用例
export function diffDataRequest(id: string) {
return MSR.get({ url: `${diffDataUrl}/${id}` });
}
// 接口测试-接口用例-定义对比用例-同步-获取同步后的用例详情
export function getSyncedCaseDetail(data: diffSyncParams) {
return MSR.post({ url: getSyncedCaseDetailUrl, data });
}
// 接口用例-文件复制
export function caseFileCopy(data: DefinitionFileCopyParams) {
return MSR.post({ url: CaseFileCopyUrl, data });
}
/** /**
* *
*/ */

View File

@ -40,11 +40,7 @@ export const RecoverOperationHistoryUrl = '/api/definition/operation-history/rec
export const DefinitionReferenceUrl = '/api/definition/get-reference'; // 获取接口引用关系 export const DefinitionReferenceUrl = '/api/definition/get-reference'; // 获取接口引用关系
export const ConvertJsonSchemaToJsonUrl = '/api/definition/json-schema/preview'; // 将json-schema转换为 json 数据 export const ConvertJsonSchemaToJsonUrl = '/api/definition/json-schema/preview'; // 将json-schema转换为 json 数据
export const JsonSchemaAutoGenerateUrl = '/api/definition/json-schema/auto-generate'; // 将json-schema转换为 json 数据 export const JsonSchemaAutoGenerateUrl = '/api/definition/json-schema/auto-generate'; // 将json-schema转换为 json 数据
export const clearThisChangeUrl = '/api/case/api-change/clear'; // 接口定义-变更对比-清除本次变更 export const DefinitionFileCopyUrl = '/api/definition/file/copy'; // 接口文件复制
export const caseTableBatchSyncUrl = '/api/case/batch/api-change/sync'; // 接口测试-接口管理-接口用例-批量同步
export const ignoreEveryTimeApiChangeUrl = '/api/case/api-change/ignore'; // 接口测试-接口用例-忽略每次接口变更
export const diffDataUrl = '/api/case/api/compare'; // 接口测试-接口用例-定义对比用例
export const getSyncedCaseDetailUrl = '/api/case/api-change/sync'; // 接口测试-接口用例-定义对比用例-同步-获取同步后的用例详情
/** /**
* Mock * Mock
@ -101,6 +97,12 @@ 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'; // 用例执行率统计 export const CaseStatisticsUrl = '/api/case/statistics'; // 用例执行率统计
export const getSyncedCaseDetailUrl = '/api/case/api-change/sync'; // 接口测试-接口用例-定义对比用例-同步-获取同步后的用例详情
export const clearThisChangeUrl = '/api/case/api-change/clear'; // 接口定义-变更对比-清除本次变更
export const caseTableBatchSyncUrl = '/api/case/batch/api-change/sync'; // 接口测试-接口管理-接口用例-批量同步
export const ignoreEveryTimeApiChangeUrl = '/api/case/api-change/ignore'; // 接口测试-接口用例-忽略每次接口变更
export const diffDataUrl = '/api/case/api/compare'; // 接口测试-接口用例-定义对比用例
export const CaseFileCopyUrl = '/api/case/file/copy'; // 接口用例文件复制
/** /**
* *

View File

@ -288,6 +288,12 @@ export interface DefinitionReferencePageParams extends TableQueryParams {
resourceId: string; resourceId: string;
} }
// 定义-复制文件参数
export interface DefinitionFileCopyParams {
resourceId: string;
fileIds: string[];
}
// 回收站-恢复接口定义参数 // 回收站-恢复接口定义参数
export interface ApiDefinitionDeleteParams { export interface ApiDefinitionDeleteParams {
id: string; id: string;

View File

@ -123,6 +123,7 @@
import { import {
addDefinition, addDefinition,
debugDefinition, debugDefinition,
definitionFileCopy,
deleteDefinition, deleteDefinition,
getDefinitionDetail, getDefinitionDetail,
getTransferOptions, getTransferOptions,
@ -376,7 +377,16 @@
} }
let parseRequestBodyResult; let parseRequestBodyResult;
if (res.protocol === 'HTTP') { if (res.protocol === 'HTTP') {
parseRequestBodyResult = parseRequestBodyFiles(res.request.body, res.response); // id //
let copyFilesMap: Record<string, any> = {};
const fileIds = parseRequestBodyFiles(res.request.body, [], [], []).uploadFileIds;
if (fileIds.length > 0) {
copyFilesMap = await definitionFileCopy({
resourceId: typeof apiInfo === 'string' ? apiInfo : apiInfo.id,
fileIds,
});
}
parseRequestBodyResult = parseRequestBodyFiles(res.request.body, [], [], [], copyFilesMap); // id
} }
let { request } = res; let { request } = res;
if (isDebugMock) { if (isDebugMock) {

View File

@ -116,6 +116,7 @@
import { localExecuteApiDebug } from '@/api/modules/api-test/common'; import { localExecuteApiDebug } from '@/api/modules/api-test/common';
import { import {
addCase, addCase,
caseFileCopy,
debugCase, debugCase,
getDefinitionDetail, getDefinitionDetail,
getTransferOptionsCase, getTransferOptionsCase,
@ -134,6 +135,7 @@
import { RequestCaseStatus, RequestMethods } from '@/enums/apiEnum'; import { RequestCaseStatus, RequestMethods } from '@/enums/apiEnum';
import { casePriorityOptions, defaultResponse } from '@/views/api-test/components/config'; import { casePriorityOptions, defaultResponse } from '@/views/api-test/components/config';
import { parseRequestBodyFiles } from '@/views/api-test/components/utils';
const props = defineProps<{ const props = defineProps<{
apiDetail?: RequestParam | ApiDefinitionDetail; apiDetail?: RequestParam | ApiDefinitionDetail;
@ -236,9 +238,25 @@
: apiDetailInfo.value), : apiDetailInfo.value),
children: apiDetailInfo.value.children ?? apiDetailInfo.value.request.children, children: apiDetailInfo.value.children ?? apiDetailInfo.value.request.children,
}; };
let parseRequestBodyResult;
// //
if (isCopy) { if (isCopy) {
detailForm.value = cloneDeep(record as RequestParam); if (record?.protocol === 'HTTP') {
//
let copyFilesMap: Record<string, any> = {};
const fileIds = parseRequestBodyFiles(record.request.body, [], [], []).uploadFileIds;
if (fileIds.length > 0) {
copyFilesMap = await caseFileCopy({
resourceId: record.id as string,
fileIds,
});
}
parseRequestBodyResult = parseRequestBodyFiles(record.request.body, [], [], [], copyFilesMap); // id
detailForm.value = {
...cloneDeep(record as RequestParam),
...parseRequestBodyResult,
};
}
detailForm.value.name = `copy_${record?.name}`; detailForm.value.name = `copy_${record?.name}`;
detailForm.value.isCopy = true; detailForm.value.isCopy = true;
environmentId.value = record?.environmentId ?? environmentId.value; environmentId.value = record?.environmentId ?? environmentId.value;