feat(测试用例): xmind导入

This commit is contained in:
teukkk 2024-08-08 18:59:28 +08:00 committed by Craftsman
parent 158409ac5a
commit 3c08ffeb9c
8 changed files with 88 additions and 50 deletions

View File

@ -29,9 +29,11 @@ import {
DetailCaseUrl, DetailCaseUrl,
DownloadExcelTemplateUrl, DownloadExcelTemplateUrl,
DownloadFileUrl, DownloadFileUrl,
DownloadXMindTemplateUrl,
dragSortUrl, dragSortUrl,
EditorUploadFileUrl, EditorUploadFileUrl,
exportExcelCheckUrl, exportExcelCheckUrl,
exportXMindCheckUrl,
FollowerCaseUrl, FollowerCaseUrl,
GetAssociatedCaseIdsUrl, GetAssociatedCaseIdsUrl,
GetAssociatedDebuggerUrl, GetAssociatedDebuggerUrl,
@ -64,6 +66,7 @@ import {
getTransferTreeUrl, getTransferTreeUrl,
GetTrashCaseModuleTreeUrl, GetTrashCaseModuleTreeUrl,
importExcelCaseUrl, importExcelCaseUrl,
importXMindCaseUrl,
MoveCaseModuleTreeUrl, MoveCaseModuleTreeUrl,
PreviewEditorImageUrl, PreviewEditorImageUrl,
PreviewFileUrl, PreviewFileUrl,
@ -404,23 +407,27 @@ export function getAssociatedCaseIds(caseId: string) {
return MSR.get<string[]>({ url: `${GetAssociatedCaseIdsUrl}/${caseId}` }); return MSR.get<string[]>({ url: `${GetAssociatedCaseIdsUrl}/${caseId}` });
} }
// 下载导入excel模板 // 下载导入excel或xmind模板
export function downloadTemplate(projectId: string, type: 'Excel' | 'Xmind') { export function downloadTemplate(projectId: string, type: 'Excel' | 'Xmind') {
if (type === 'Excel') {
return MSR.get( return MSR.get(
{ url: `${DownloadExcelTemplateUrl}/${projectId}`, responseType: 'blob' }, {
{ isTransformResponse: false } url: `${type === 'Excel' ? DownloadExcelTemplateUrl : DownloadXMindTemplateUrl}/${projectId}`,
); responseType: 'blob',
} },
return MSR.get(
{ url: `${DownloadExcelTemplateUrl}/${projectId}`, responseType: 'blob' },
{ isTransformResponse: false } { isTransformResponse: false }
); );
} }
// 导入excel文件检查 // 导入excel或xmind文件检查
export function importExcelChecked(data: { request: ImportExcelType; fileList: File[] }) { export function importExcelOrXMindChecked(
return MSR.uploadFile({ url: exportExcelCheckUrl }, { request: data.request, fileList: data.fileList }, ''); data: { request: ImportExcelType; fileList: File[] },
type: 'Excel' | 'Xmind'
) {
return MSR.uploadFile(
{ url: type === 'Excel' ? exportExcelCheckUrl : exportXMindCheckUrl },
{ request: data.request, fileList: data.fileList },
''
);
} }
// 富文本编辑器上传图片文件 // 富文本编辑器上传图片文件
@ -432,8 +439,12 @@ export function editorPreviewImages(data: PreviewImages) {
return MSR.post({ url: PreviewEditorImageUrl, data }); return MSR.post({ url: PreviewEditorImageUrl, data });
} }
// 导入excel // 导入excel
export function importExcelCase(data: { request: ImportExcelType; fileList: File[] }) { export function importExcelOrXMindCase(data: { request: ImportExcelType; fileList: File[] }, type: 'Excel' | 'Xmind') {
return MSR.uploadFile({ url: importExcelCaseUrl }, { request: data.request, fileList: data.fileList }, ''); return MSR.uploadFile(
{ url: type === 'Excel' ? importExcelCaseUrl : importXMindCaseUrl },
{ request: data.request, fileList: data.fileList },
''
);
} }
// 拖拽排序 // 拖拽排序

View File

@ -138,14 +138,20 @@ export const GetAssociatedCaseIdsUrl = '/functional/case/relationship/get-ids';
// 导入功能 // 导入功能
// 功能用例导入excel下载模板 // 功能用例导入excel下载模板
export const DownloadExcelTemplateUrl = '/functional/case/download/excel/template'; export const DownloadExcelTemplateUrl = '/functional/case/download/excel/template';
// 功能用例导入xmind下载模板
export const DownloadXMindTemplateUrl = '/functional/case/download/xmind/template';
// 富文本所需资源上传 // 富文本所需资源上传
export const EditorUploadFileUrl = '/attachment/upload/temp/file'; export const EditorUploadFileUrl = '/attachment/upload/temp/file';
// 富文本资源详情预览压缩图 // 富文本资源详情预览压缩图
export const PreviewEditorImageUrl = '/attachment/download/file'; export const PreviewEditorImageUrl = '/attachment/download/file';
// 导入excel文件检查 // 导入excel文件检查
export const exportExcelCheckUrl = '/functional/case/pre-check/excel'; export const exportExcelCheckUrl = '/functional/case/pre-check/excel';
// 导入xmind文件检查
export const exportXMindCheckUrl = '/functional/case/pre-check/xmind';
// 导入excel文件 // 导入excel文件
export const importExcelCaseUrl = '/functional/case/import/excel'; export const importExcelCaseUrl = '/functional/case/import/excel';
// 导入xmind文件
export const importXMindCaseUrl = '/functional/case/import/xmind';
// 用例拖拽排序 // 用例拖拽排序
export const dragSortUrl = '/functional/case/edit/pos'; export const dragSortUrl = '/functional/case/edit/pos';
// 获取变更历史 // 获取变更历史

View File

@ -15,16 +15,16 @@
}} }}
</template> </template>
<div> <div>
<a-alert class="mb-4" <a-alert class="mb-4">
><div class="flex items-center"> <div class="flex items-center">
{{ t('caseManagement.featureCase.beforeUploadTip', { type: props.validateType }) }} {{ t('caseManagement.featureCase.beforeUploadTip', { type: props.validateType }) }}
<MsIcon <MsIcon
:type="props.validateType === 'Excel' ? 'icon-icon_file-excel_colorful1' : 'icon-icon_file-xmind_colorful1'" :type="props.validateType === 'Excel' ? 'icon-icon_file-excel_colorful1' : 'icon-icon_file-xmind_colorful1'"
class="mx-1 cursor-pointer text-[rgb(var(--primary-6))]" class="mx-1 cursor-pointer text-[rgb(var(--primary-6))]"
></MsIcon> ></MsIcon>
<MsButton @click="downloadExcelTemplate">{{ <MsButton @click="downloadExcelTemplate">
t('caseManagement.featureCase.downloadTemplate', { type: props.validateType }) {{ t('caseManagement.featureCase.downloadTemplate', { type: props.validateType }) }}
}}</MsButton> </MsButton>
</div> </div>
</a-alert> </a-alert>
<MsUpload <MsUpload
@ -78,8 +78,13 @@
:loading="props.confirmLoading" :loading="props.confirmLoading"
:disabled="fileList.length < 1" :disabled="fileList.length < 1"
@click="saveConfirm" @click="saveConfirm"
>{{ t('caseManagement.featureCase.checkImportFile') }}</a-button
> >
{{
props.validateType === 'Excel'
? t('caseManagement.featureCase.checkImportFile')
: t('caseManagement.featureCase.checkTemplate')
}}
</a-button>
</div> </div>
</div> </div>
</template> </template>
@ -138,7 +143,7 @@
async function downloadExcelTemplate() { async function downloadExcelTemplate() {
try { try {
const res = await downloadTemplate(currentProjectId.value, props.validateType); const res = await downloadTemplate(currentProjectId.value, props.validateType);
downloadByteFile(res, 'excel_case.xlsx'); downloadByteFile(res, props.validateType === 'Excel' ? 'excel_case.xlsx' : 'xmind_case.xmind');
} catch (error) { } catch (error) {
console.log(error); console.log(error);
} }

View File

@ -17,7 +17,11 @@
/></div> /></div>
<div class="flex w-[92%] flex-col"> <div class="flex w-[92%] flex-col">
<span class="text-[var(--color-text-1)]">{{ t('caseManagement.featureCase.verifyingTemplate') }}</span> <span class="text-[var(--color-text-1)]">{{
props.validateType === 'Excel'
? t('caseManagement.featureCase.verifyingFile')
: t('caseManagement.featureCase.verifyingTemplate')
}}</span>
<a-progress :percent="props.percent" size="large" /> <a-progress :percent="props.percent" size="large" />
</div> </div>
</div> </div>

View File

@ -17,11 +17,14 @@
}}<span class="mx-1 text-[rgb(var(--success-6))]"> {{ validateResultInfo.successCount }}</span }}<span class="mx-1 text-[rgb(var(--success-6))]"> {{ validateResultInfo.successCount }}</span
>{{ t('caseManagement.featureCase.caseCount') }}</span >{{ t('caseManagement.featureCase.caseCount') }}</span
> >
<span <span v-if="props.validateType === 'Excel'">
>{{ t('caseManagement.featureCase.failCheck') {{ t('caseManagement.featureCase.failCheck') }}
}}<span class="mx-1 font-medium text-[rgb(var(--danger-6))]">{{ validateResultInfo.failCount }}</span <span class="mx-1 font-medium text-[rgb(var(--danger-6))]">{{ validateResultInfo.failCount }}</span>
>{{ t('caseManagement.featureCase.caseCount') }}</span {{ t('caseManagement.featureCase.caseCount') }}
> </span>
<span v-else>
{{ t('caseManagement.featureCase.partialCaseVerificationFailed') }}
</span>
<a-popover <a-popover
position="bottom" position="bottom"
:content-style="{ :content-style="{

View File

@ -29,18 +29,15 @@
> >
{{ t('caseManagement.featureCase.importExcel') }} {{ t('caseManagement.featureCase.importExcel') }}
</a-doption> </a-doption>
<a-doption
v-permission="['FUNCTIONAL_CASE:READ+IMPORT']"
value="Xmind"
@click="handleSelect('import', 'Xmind')"
>
{{ t('caseManagement.featureCase.importXmind') }}
</a-doption>
</template> </template>
</a-dropdown-button> </a-dropdown-button>
<a-button
v-else-if="
!hasAnyPermission(['FUNCTIONAL_CASE:READ+ADD']) && hasAnyPermission(['FUNCTIONAL_CASE:READ+IMPORT'])
"
class="ml-2"
type="primary"
@click="handleSelect('import', 'Excel')"
>
{{ t('caseManagement.featureCase.importExcel') }}
</a-button>
<a-button <a-button
v-else v-else
v-permission="['FUNCTIONAL_CASE:READ+ADD']" v-permission="['FUNCTIONAL_CASE:READ+ADD']"
@ -176,7 +173,11 @@
import ValidateModal from './components/export/validateModal.vue'; import ValidateModal from './components/export/validateModal.vue';
import ValidateResult from './components/export/validateResult.vue'; import ValidateResult from './components/export/validateResult.vue';
import { createCaseModuleTree, importExcelCase, importExcelChecked } from '@/api/modules/case-management/featureCase'; import {
createCaseModuleTree,
importExcelOrXMindCase,
importExcelOrXMindChecked,
} from '@/api/modules/case-management/featureCase';
import { useI18n } from '@/hooks/useI18n'; import { useI18n } from '@/hooks/useI18n';
import useAppStore from '@/store/modules/app'; import useAppStore from '@/store/modules/app';
import useFeatureCaseStore from '@/store/modules/case/featureCase'; import useFeatureCaseStore from '@/store/modules/case/featureCase';
@ -376,11 +377,12 @@
versionId: '', versionId: '',
cover, cover,
}; };
if (validateType.value === 'Excel') { const result = await importExcelOrXMindChecked(
const result = await importExcelChecked({ request: params, fileList: files.map((item: any) => item.file) }); { request: params, fileList: files.map((item: any) => item.file) },
validateType.value
);
finish(); finish();
validateInfo.value = result.data; validateInfo.value = result.data;
}
} catch (error) { } catch (error) {
validateModal.value = false; validateModal.value = false;
console.log(error); console.log(error);
@ -413,7 +415,10 @@
cover: isCover.value, cover: isCover.value,
count: validateInfo.value.successCount, count: validateInfo.value.successCount,
}; };
await importExcelCase({ request: params, fileList: fileList.value.map((item: any) => item.file) }); await importExcelOrXMindCase(
{ request: params, fileList: fileList.value.map((item: any) => item.file) },
validateType.value
);
Message.success(t('caseManagement.featureCase.importSuccess')); Message.success(t('caseManagement.featureCase.importSuccess'));
validateResultModal.value = false; validateResultModal.value = false;
showExcelModal.value = false; showExcelModal.value = false;

View File

@ -219,7 +219,7 @@ export default {
'caseManagement.featureCase.dragOrClick': 'Drag or click this area to select a file', 'caseManagement.featureCase.dragOrClick': 'Drag or click this area to select a file',
'caseManagement.featureCase.onlyEXcelTip': 'caseManagement.featureCase.onlyEXcelTip':
'Only xls and xlsx are supported, and the size of each device cannot exceed 100 MB', 'Only xls and xlsx are supported, and the size of each device cannot exceed 100 MB',
'caseManagement.featureCase.onlyXmindTip': 'Only xmind/ type single size up to 100M is supported', 'caseManagement.featureCase.onlyXmindTip': 'Only supports xmind, with a single size not exceeding 50M',
'caseManagement.featureCase.checkTemplate': 'Check template', 'caseManagement.featureCase.checkTemplate': 'Check template',
'caseManagement.featureCase.checkImportFile': 'Check file', 'caseManagement.featureCase.checkImportFile': 'Check file',
'caseManagement.featureCase.selectedRecoverCase': 'caseManagement.featureCase.selectedRecoverCase':
@ -235,7 +235,8 @@ export default {
'caseManagement.featureCase.defaultSelectNewVersion': 'The latest version is selected by default', 'caseManagement.featureCase.defaultSelectNewVersion': 'The latest version is selected by default',
'caseManagement.featureCase.isRecoverOriginCase': 'Whether or not covered', 'caseManagement.featureCase.isRecoverOriginCase': 'Whether or not covered',
'caseManagement.featureCase.importingUseCase': 'Importing a use case', 'caseManagement.featureCase.importingUseCase': 'Importing a use case',
'caseManagement.featureCase.verifyingTemplate': 'The file is being verified', 'caseManagement.featureCase.verifyingTemplate': 'Verifying the correctness of the template',
'caseManagement.featureCase.verifyingFile': 'Verifying file correctness',
'caseManagement.featureCase.successfulCheck': 'Successful check', 'caseManagement.featureCase.successfulCheck': 'Successful check',
'caseManagement.featureCase.failCheck': 'Check failure', 'caseManagement.featureCase.failCheck': 'Check failure',
'caseManagement.featureCase.caseCount': 'Strip use cases', 'caseManagement.featureCase.caseCount': 'Strip use cases',
@ -247,6 +248,7 @@ export default {
'caseManagement.featureCase.backToUploadPage': 'Back to upload page', 'caseManagement.featureCase.backToUploadPage': 'Back to upload page',
'caseManagement.featureCase.ignoreErrorContinueImporting': 'Ignore&continue', 'caseManagement.featureCase.ignoreErrorContinueImporting': 'Ignore&continue',
'caseManagement.featureCase.partialCheckFailure': 'Partial check failure', 'caseManagement.featureCase.partialCheckFailure': 'Partial check failure',
'caseManagement.featureCase.partialCaseVerificationFailed': 'Partial case verification failed',
'caseManagement.featureCase.CheckFailure': 'Check failure', 'caseManagement.featureCase.CheckFailure': 'Check failure',
'caseManagement.featureCase.CheckSuccess': 'Check success', 'caseManagement.featureCase.CheckSuccess': 'Check success',
'caseManagement.featureCase.tableNoData': 'No data available', 'caseManagement.featureCase.tableNoData': 'No data available',

View File

@ -1,8 +1,8 @@
export default { export default {
'caseManagement.featureCase.creatingCase': '创建用例', 'caseManagement.featureCase.creatingCase': '创建用例',
'caseManagement.featureCase.importCase': '导入用例', 'caseManagement.featureCase.importCase': '导入用例',
'caseManagement.featureCase.importExcel': 'Excel导入', 'caseManagement.featureCase.importExcel': 'Excel 导入',
'caseManagement.featureCase.importXmind': 'Xmind导入', 'caseManagement.featureCase.importXmind': 'Xmind 导入',
'caseManagement.featureCase.importSuccess': '导入成功', 'caseManagement.featureCase.importSuccess': '导入成功',
'caseManagement.featureCase.publicCase': '公共用例库', 'caseManagement.featureCase.publicCase': '公共用例库',
'caseManagement.featureCase.allCase': '全部用例', 'caseManagement.featureCase.allCase': '全部用例',
@ -217,7 +217,7 @@ export default {
'caseManagement.featureCase.formXMindExport': '从 Xmind 文件导入用例', 'caseManagement.featureCase.formXMindExport': '从 Xmind 文件导入用例',
'caseManagement.featureCase.dragOrClick': '拖拽或点击此区域选择文件', 'caseManagement.featureCase.dragOrClick': '拖拽或点击此区域选择文件',
'caseManagement.featureCase.onlyEXcelTip': '仅支持 xls/xlsx单个大小不超过 100M', 'caseManagement.featureCase.onlyEXcelTip': '仅支持 xls/xlsx单个大小不超过 100M',
'caseManagement.featureCase.onlyXmindTip': '仅支持 xmind/类型 单个大小不超过 100M', 'caseManagement.featureCase.onlyXmindTip': '仅支持 xmind,单个大小不超过 50M',
'caseManagement.featureCase.checkTemplate': '校验模板', 'caseManagement.featureCase.checkTemplate': '校验模板',
'caseManagement.featureCase.checkImportFile': '校验文件', 'caseManagement.featureCase.checkImportFile': '校验文件',
'caseManagement.featureCase.selectedRecoverCase': '勾选ID相同时覆盖原用例', 'caseManagement.featureCase.selectedRecoverCase': '勾选ID相同时覆盖原用例',
@ -231,18 +231,20 @@ export default {
'caseManagement.featureCase.defaultSelectNewVersion': '默认选择最新版本', 'caseManagement.featureCase.defaultSelectNewVersion': '默认选择最新版本',
'caseManagement.featureCase.isRecoverOriginCase': '用例 ID 相同时覆盖原用例', 'caseManagement.featureCase.isRecoverOriginCase': '用例 ID 相同时覆盖原用例',
'caseManagement.featureCase.importingUseCase': '正在导入用例', 'caseManagement.featureCase.importingUseCase': '正在导入用例',
'caseManagement.featureCase.verifyingTemplate': '正在校验文件正确性', 'caseManagement.featureCase.verifyingTemplate': '正在校验模版正确性',
'caseManagement.featureCase.verifyingFile': '正在校验文件正确性',
'caseManagement.featureCase.successfulCheck': '成功校验', 'caseManagement.featureCase.successfulCheck': '成功校验',
'caseManagement.featureCase.failCheck': '校验失败', 'caseManagement.featureCase.failCheck': '校验失败',
'caseManagement.featureCase.caseCount': '条用例;', 'caseManagement.featureCase.caseCount': '条用例;',
'caseManagement.featureCase.viewErrorDetail': '查看错误详情', 'caseManagement.featureCase.viewErrorDetail': '查看错误详情',
'caseManagement.featureCase.someCaseImportFailed': '部分用例导入失败', 'caseManagement.featureCase.someCaseImportFailed': '部分用例导入失败',
'caseManagement.featureCase.ViewMore': '查看更多', 'caseManagement.featureCase.ViewMore': '查看更多',
'caseManagement.featureCase.afterFailingToModify': '失败用例在{ type }中修改后重新导入', 'caseManagement.featureCase.afterFailingToModify': '失败用例在 { type } 中修改后重新导入',
'caseManagement.featureCase.import': '导入', 'caseManagement.featureCase.import': '导入',
'caseManagement.featureCase.backToUploadPage': '返回上传页', 'caseManagement.featureCase.backToUploadPage': '返回上传页',
'caseManagement.featureCase.ignoreErrorContinueImporting': '忽略错误继续导入', 'caseManagement.featureCase.ignoreErrorContinueImporting': '忽略错误继续导入',
'caseManagement.featureCase.partialCheckFailure': '部分校验失败', 'caseManagement.featureCase.partialCheckFailure': '部分校验失败',
'caseManagement.featureCase.partialCaseVerificationFailed': '部分用例检验失败',
'caseManagement.featureCase.CheckFailure': '校验失败', 'caseManagement.featureCase.CheckFailure': '校验失败',
'caseManagement.featureCase.CheckSuccess': '校验成功', 'caseManagement.featureCase.CheckSuccess': '校验成功',
'caseManagement.featureCase.tableNoData': '暂无数据', 'caseManagement.featureCase.tableNoData': '暂无数据',