fix(测试计划): 修复测试计划报告接口用例&场景用例切换数据问题&测试计划执行

This commit is contained in:
xinxin.wu 2024-06-17 13:05:59 +08:00 committed by Craftsman
parent b869df8428
commit a9b35ccdcb
4 changed files with 69 additions and 70 deletions

View File

@ -87,17 +87,23 @@ export function getShareValidity(id: string) {
} }
// 测试计划-独立报告-接口用例 // 测试计划-独立报告-接口用例
export function getApiPage(data: TableQueryParams) { export function getApiPage(data: TableQueryParams) {
if (data.shareId) {
return MSR.post<CommonList<ApiOrScenarioCaseItem>>({ url: reportUrl.ReportShareApiUrl, data });
}
return MSR.post<CommonList<ApiOrScenarioCaseItem>>({ url: reportUrl.ReportIndependentApiUrl, data }); return MSR.post<CommonList<ApiOrScenarioCaseItem>>({ url: reportUrl.ReportIndependentApiUrl, data });
} }
// 测试计划-报告-获取分享链接时效 // 测试计划-报告-获取分享链接时效
export function getScenarioPage(data: TableQueryParams) { export function getScenarioPage(data: TableQueryParams) {
if (data.shareId) {
return MSR.post<CommonList<ApiOrScenarioCaseItem>>({ url: reportUrl.ReportShareScenarioUrl, data });
}
return MSR.post<CommonList<ApiOrScenarioCaseItem>>({ url: reportUrl.ReportIndependentScenarioUrl, data }); return MSR.post<CommonList<ApiOrScenarioCaseItem>>({ url: reportUrl.ReportIndependentScenarioUrl, data });
} }
// 测试计划-独立报告-接口用例 // 测试计划-独立报告-接口用例
export function getShareApiPage(data: TableQueryParams) { export function getShareApiPage(data: TableQueryParams) {
return MSR.post<CommonList<ApiOrScenarioCaseItem>>({ url: reportUrl.ReportShareApiUrl, data }); return MSR.post<CommonList<ApiOrScenarioCaseItem>>({ url: reportUrl.ReportShareApiUrl, data });
} }
// 测试计划-报告-获取分享链接时效 // 测试计划-报告-场景用例
export function getShareScenarioPage(data: TableQueryParams) { export function getShareScenarioPage(data: TableQueryParams) {
return MSR.post<CommonList<ApiOrScenarioCaseItem>>({ url: reportUrl.ReportShareScenarioUrl, data }); return MSR.post<CommonList<ApiOrScenarioCaseItem>>({ url: reportUrl.ReportShareScenarioUrl, data });
} }

View File

@ -25,7 +25,6 @@
:disabled="!contentEditAble" :disabled="!contentEditAble"
:placeholder="t('editor.placeholder')" :placeholder="t('editor.placeholder')"
:upload-image="handleUploadImage" :upload-image="handleUploadImage"
:auto-height="false"
:preview-url="EditorPreviewFileUrl" :preview-url="EditorPreviewFileUrl"
/> />
<div v-else v-dompurify-html="form?.description || '-'" class="markdown-body"></div> <div v-else v-dompurify-html="form?.description || '-'" class="markdown-body"></div>

View File

@ -1,5 +1,5 @@
<template> <template>
<MsBaseTable v-bind="propsRes" v-on="propsEvent"> <MsBaseTable v-bind="currentCaseTable.propsRes.value" v-on="currentCaseTable.propsEvent.value">
<template #num="{ record }"> <template #num="{ record }">
<MsButton type="text" @click="showReport(record)">{{ record.num }}</MsButton> <MsButton type="text" @click="showReport(record)">{{ record.num }}</MsButton>
</template> </template>
@ -32,7 +32,7 @@
/> />
</template> </template>
<script setup lang="ts"> <script setup lang="ts" async>
import MsButton from '@/components/pure/ms-button/index.vue'; import MsButton from '@/components/pure/ms-button/index.vue';
import MsBaseTable from '@/components/pure/ms-table/base-table.vue'; import MsBaseTable from '@/components/pure/ms-table/base-table.vue';
import type { MsTableColumn } from '@/components/pure/ms-table/type'; import type { MsTableColumn } from '@/components/pure/ms-table/type';
@ -41,7 +41,7 @@
import ExecuteResult from '@/components/business/ms-case-associate/executeResult.vue'; import ExecuteResult from '@/components/business/ms-case-associate/executeResult.vue';
import CaseAndScenarioReportDrawer from '@/views/api-test/components/caseAndScenarioReportDrawer.vue'; import CaseAndScenarioReportDrawer from '@/views/api-test/components/caseAndScenarioReportDrawer.vue';
import { getApiPage, getScenarioPage, getShareApiPage, getShareScenarioPage } from '@/api/modules/test-plan/report'; import { getApiPage, getScenarioPage } from '@/api/modules/test-plan/report';
import { ApiOrScenarioCaseItem } from '@/models/testPlan/report'; import { ApiOrScenarioCaseItem } from '@/models/testPlan/report';
import { FilterSlotNameEnum } from '@/enums/tableFilterEnum'; import { FilterSlotNameEnum } from '@/enums/tableFilterEnum';
@ -117,32 +117,36 @@
showDrag: true, showDrag: true,
}, },
]; ];
const reportApiList = () => {
if (props.activeTab === 'scenarioCase') { const getReportApiList = () => {
return !props.shareId ? getScenarioPage : getShareScenarioPage; if (props.activeTab === 'apiCase') {
return getApiPage;
} }
return !props.shareId ? getApiPage : getShareApiPage; return getScenarioPage;
}; };
const { propsRes, propsEvent, loadList, setLoadListParams, resetFilterParams, resetPagination } = useTable(
reportApiList(), const useApiTable = useTable(getApiPage, {
{
scroll: { x: '100%' }, scroll: { x: '100%' },
columns, columns,
showSelectorAll: false, showSelectorAll: false,
} showSetting: false,
); });
const useScenarioTable = useTable(getScenarioPage, {
scroll: { x: '100%' },
columns,
showSelectorAll: false,
showSetting: false,
});
const currentCaseTable = computed(() => {
return props.activeTab === 'apiCase' ? useApiTable : useScenarioTable;
});
async function loadCaseList() { async function loadCaseList() {
setLoadListParams({ reportId: props.reportId, shareId: props.shareId ?? undefined }); currentCaseTable.value.setLoadListParams({ reportId: props.reportId, shareId: props.shareId ?? undefined });
loadList(); currentCaseTable.value.loadList();
} }
watchEffect(() => {
if (props.reportId) {
loadCaseList();
}
});
// //
const reportVisible = ref(false); const reportVisible = ref(false);
@ -156,9 +160,24 @@
watch( watch(
() => props.activeTab, () => props.activeTab,
() => { () => {
resetFilterParams(); currentCaseTable.value.resetFilterParams();
resetPagination(); currentCaseTable.value.resetPagination();
loadCaseList(); loadCaseList();
} }
); );
// onBeforeMount(() => {
// if (props.reportId) {
// loadCaseList();
// }
// });
watch(
() => props.reportId,
(val) => {
if (val) {
loadCaseList();
}
}
);
</script> </script>

View File

@ -239,27 +239,10 @@
<template #operation="{ record }"> <template #operation="{ record }">
<div class="flex items-center"> <div class="flex items-center">
<!-- TODO 测试计划组手动生成报告 --> <MsButton v-if="isShowExecuteButton(record)" class="!mx-0" @click="executePlan(record)">{{
<!-- <MsButton class="mr-2" @click="handleGenerateReport(record.id)">生成报告</MsButton> --> t('testPlan.testPlanIndex.execution')
<MsButton }}</MsButton>
v-if=" <a-divider v-if="isShowExecuteButton(record)" direction="vertical" :margin="8"></a-divider>
getFunctionalCount(record.id) > 0 &&
hasAnyPermission(['PROJECT_TEST_PLAN:READ+EXECUTE']) &&
record.status !== 'ARCHIVED'
"
class="!mx-0"
@click="executePlan(record)"
>{{ t('testPlan.testPlanIndex.execution') }}</MsButton
>
<a-divider
v-if="
getFunctionalCount(record.id) > 0 &&
hasAnyPermission(['PROJECT_TEST_PLAN:READ+EXECUTE']) &&
record.status !== 'ARCHIVED'
"
direction="vertical"
:margin="8"
></a-divider>
<MsButton <MsButton
v-if="hasAnyPermission(['PROJECT_TEST_PLAN:READ+UPDATE']) && record.status !== 'ARCHIVED'" v-if="hasAnyPermission(['PROJECT_TEST_PLAN:READ+UPDATE']) && record.status !== 'ARCHIVED'"
@ -273,25 +256,10 @@
:margin="8" :margin="8"
></a-divider> ></a-divider>
<MsButton <MsButton v-if="!isShowExecuteButton(record)" class="!mx-0" @click="copyTestPlanOrGroup(record.id)">{{
v-if=" t('common.copy')
hasAnyPermission(['PROJECT_TEST_PLAN:READ+ADD']) && }}</MsButton>
getFunctionalCount(record.id) < 1 && <a-divider v-if="!isShowExecuteButton(record)" direction="vertical" :margin="8"></a-divider>
record.status !== 'ARCHIVED'
"
class="!mx-0"
@click="copyTestPlanOrGroup(record.id)"
>{{ t('common.copy') }}</MsButton
>
<a-divider
v-if="
hasAnyPermission(['PROJECT_TEST_PLAN:READ+ADD']) &&
getFunctionalCount(record.id) < 1 &&
record.status !== 'ARCHIVED'
"
direction="vertical"
:margin="8"
></a-divider>
<MsTableMoreAction :list="getMoreActions(record)" @select="handleMoreActionSelect($event, record)" /> <MsTableMoreAction :list="getMoreActions(record)" @select="handleMoreActionSelect($event, record)" />
</div> </div>
</template> </template>
@ -727,13 +695,20 @@
return defaultCountDetailMap.value[id].scheduleConfig.enable; return defaultCountDetailMap.value[id].scheduleConfig.enable;
} }
function isShowExecuteButton(record: TestPlanItem) {
return (
((record.type === testPlanTypeEnum.TEST_PLAN && getFunctionalCount(record.id) > 0) ||
(record.type === testPlanTypeEnum.GROUP && record.childrenCount)) &&
hasAnyPermission(['PROJECT_TEST_PLAN:READ+EXECUTE']) &&
record.status !== 'ARCHIVED'
);
}
function getMoreActions(record: TestPlanItem) { function getMoreActions(record: TestPlanItem) {
const { status: planStatus } = record; const { status: planStatus } = record;
const useCount = defaultCountDetailMap.value[record.id]?.caseTotal ?? 0;
// //
const copyAction = const copyAction = isShowExecuteButton(record) ? copyActions : [];
useCount > 0 && hasAnyPermission(['PROJECT_TEST_PLAN:READ+ADD']) && planStatus !== 'ARCHIVED' ? copyActions : [];
let scheduledTaskAction: ActionsItem[] = []; let scheduledTaskAction: ActionsItem[] = [];
if (planStatus !== 'ARCHIVED' && record.groupId && record.groupId === 'NONE') { if (planStatus !== 'ARCHIVED' && record.groupId && record.groupId === 'NONE') {