fix(测试计划): 修改测试计划规划关联测试集参数调整

This commit is contained in:
xinxin.wu 2024-08-16 16:01:20 +08:00 committed by 刘瑞斌
parent 149b233f9c
commit 2820fdf6ec
6 changed files with 59 additions and 37 deletions

View File

@ -297,7 +297,7 @@
children: 'children', children: 'children',
}" }"
class="w-[200px]" class="w-[200px]"
:data="apiSetTree" :data="nodeApiTestSet"
allow-clear allow-clear
> >
<template #prefix> <template #prefix>
@ -319,7 +319,7 @@
}" }"
class="ml-[12px] w-[200px]" class="ml-[12px] w-[200px]"
allow-clear allow-clear
:data="scenarioSetTree" :data="nodeScenarioTestSet"
> >
<template #prefix> <template #prefix>
<div class="text-[var(--color-text-brand)]">{{ t('ms.case.associate.scenario') }}</div> <div class="text-[var(--color-text-brand)]">{{ t('ms.case.associate.scenario') }}</div>
@ -350,6 +350,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref } from 'vue'; import { ref } from 'vue';
import { useVModel } from '@vueuse/core'; import { useVModel } from '@vueuse/core';
import { type SelectOptionData } from '@arco-design/web-vue';
import { isEqual } from 'lodash-es'; import { isEqual } from 'lodash-es';
import { MsAdvanceFilter } from '@/components/pure/ms-advance-filter'; import { MsAdvanceFilter } from '@/components/pure/ms-advance-filter';
@ -362,14 +363,13 @@
import TotalCount from './totalCount.vue'; import TotalCount from './totalCount.vue';
import { getAssociatedProjectOptions } from '@/api/modules/case-management/featureCase'; import { getAssociatedProjectOptions } from '@/api/modules/case-management/featureCase';
import { getApiCaseModule, getApiScenarioModule } from '@/api/modules/test-plan/testPlan';
import { useI18n } from '@/hooks/useI18n'; import { useI18n } from '@/hooks/useI18n';
import useVisit from '@/hooks/useVisit'; import useVisit from '@/hooks/useVisit';
import useAppStore from '@/store/modules/app'; import useAppStore from '@/store/modules/app';
import type { ModuleTreeNode, TableQueryParams } from '@/models/common'; import type { ModuleTreeNode, TableQueryParams } from '@/models/common';
import type { ProjectListItem } from '@/models/setting/project'; import type { ProjectListItem } from '@/models/setting/project';
import type { AssociateCaseRequestParams, PlanDetailApiCaseTreeParams } from '@/models/testPlan/testPlan'; import type { AssociateCaseRequestParams } from '@/models/testPlan/testPlan';
import { CaseModulesApiTypeEnum, CasePageApiTypeEnum } from '@/enums/associateCaseEnum'; import { CaseModulesApiTypeEnum, CasePageApiTypeEnum } from '@/enums/associateCaseEnum';
import { CaseLinkEnum } from '@/enums/caseEnum'; import { CaseLinkEnum } from '@/enums/caseEnum';
@ -400,6 +400,8 @@
hideProjectSelect?: boolean; // hideProjectSelect?: boolean; //
associatedType: keyof typeof CaseLinkEnum; // associatedType: keyof typeof CaseLinkEnum; //
protocols?: string[]; // protocols?: string[]; //
nodeApiTestSet?: SelectOptionData[]; //
nodeScenarioTestSet?: SelectOptionData[]; //
}>(); }>();
const emit = defineEmits<{ const emit = defineEmits<{
@ -635,35 +637,12 @@
selectedProtocols.value = _protocols || []; selectedProtocols.value = _protocols || [];
} }
const apiSetTree = ref<ModuleTreeNode[]>();
const scenarioSetTree = ref<ModuleTreeNode[]>();
async function initTestSet() {
if (props.extraTableParams?.testPlanId) {
const params: PlanDetailApiCaseTreeParams = {
testPlanId: props.extraTableParams.testPlanId,
treeType: 'COLLECTION',
};
try {
const [apiSetTreeResult, scenarioSetTreeResult] = await Promise.all([
getApiCaseModule(params),
getApiScenarioModule(params),
]);
apiSetTree.value = apiSetTreeResult;
scenarioSetTree.value = scenarioSetTreeResult;
apiCaseCollectionId.value = apiSetTree.value[0].id;
apiScenarioCollectionId.value = scenarioSetTree.value[0].id;
} catch (error) {
// eslint-disable-next-line no-console
console.log(error);
}
}
}
function changeSyncCase(value: string | number | boolean, ev: Event) { function changeSyncCase(value: string | number | boolean, ev: Event) {
if (value) { if (value) {
initTestSet(); if (props.nodeApiTestSet && props.nodeScenarioTestSet) {
apiCaseCollectionId.value = props.nodeApiTestSet?.[0]?.id ?? '';
apiScenarioCollectionId.value = props.nodeScenarioTestSet?.[0]?.id ?? '';
}
} else { } else {
apiCaseCollectionId.value = ''; apiCaseCollectionId.value = '';
apiScenarioCollectionId.value = ''; apiScenarioCollectionId.value = '';

View File

@ -14,12 +14,16 @@
}" }"
:modules-maps="props.modulesMaps" :modules-maps="props.modulesMaps"
:associated-type="associationType" :associated-type="associationType"
:node-api-test-set="nodeApiTestSet"
:node-scenario-test-set="nodeScenarioTestSet"
@save="saveHandler" @save="saveHandler"
> >
</MsCaseAssociate> </MsCaseAssociate>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { type SelectOptionData } from '@arco-design/web-vue';
import MsCaseAssociate from '@/components/business/ms-associate-case/index.vue'; import MsCaseAssociate from '@/components/business/ms-associate-case/index.vue';
import type { saveParams } from '@/components/business/ms-associate-case/types'; import type { saveParams } from '@/components/business/ms-associate-case/types';
@ -33,6 +37,8 @@
associationType: CaseLinkEnum; associationType: CaseLinkEnum;
modulesMaps?: Record<string, saveParams>; modulesMaps?: Record<string, saveParams>;
testPlanId?: string; testPlanId?: string;
nodeApiTestSet?: SelectOptionData[];
nodeScenarioTestSet?: SelectOptionData[];
}>(); }>();
const innerVisible = defineModel<boolean>('visible', { const innerVisible = defineModel<boolean>('visible', {
required: true, required: true,

View File

@ -227,6 +227,8 @@
:test-plan-id="props.planId" :test-plan-id="props.planId"
:modules-maps="selectedAssociateCasesParams.moduleMaps" :modules-maps="selectedAssociateCasesParams.moduleMaps"
:protocols="selectedAssociateCasesParams.protocols" :protocols="selectedAssociateCasesParams.protocols"
:node-api-test-set="nodeApiTestSet"
:node-scenario-test-set="nodeScenarioTestSet"
@success="writeAssociateCases" @success="writeAssociateCases"
/> />
</template> </template>
@ -369,6 +371,29 @@
} }
} }
const nodeApiTestSet = ref<SelectOptionData[]>([]);
const nodeScenarioTestSet = ref<SelectOptionData[]>([]);
function getTestNodeSet(nodeSet: PlanMinderNode[] = []): { name: string; id: string }[] {
return nodeSet.map((node) => ({
name: node.data?.text ?? '',
id: node.data?.id ?? '',
}));
}
function setCaseSelectedSet() {
const minderJson = window.minder.exportJson()?.root;
if (minderJson) {
const testApiNode =
minderJson?.children?.find((item: PlanMinderNode) => item.data.type === 'API')?.children ?? [];
const testScenarioNode =
minderJson?.children?.find((item: PlanMinderNode) => item.data.type === 'SCENARIO')?.children ?? [];
nodeApiTestSet.value = getTestNodeSet(testApiNode);
nodeScenarioTestSet.value = getTestNodeSet(testScenarioNode);
}
}
/** /**
* 插入节点 * 插入节点
* @param node 目标节点 * @param node 目标节点
@ -581,7 +606,7 @@
selectedAssociateCasesParams.value = { ...param }; selectedAssociateCasesParams.value = { ...param };
const node: PlanMinderNode = window.minder.getSelectedNode(); const node: PlanMinderNode = window.minder.getSelectedNode();
let associateType: string = ''; let associateType: string = '';
if (node.data.type === PlanMinderCollectionType.SCENARIO) { if (node && node.data?.type === PlanMinderCollectionType.SCENARIO) {
associateType = PlanMinderAssociateType.SCENARIO_CASE; associateType = PlanMinderAssociateType.SCENARIO_CASE;
} else { } else {
associateType = param?.associateType ?? node.data.type; associateType = param?.associateType ?? node.data.type;
@ -623,6 +648,7 @@
configForm.value = cloneDeep(activePlanSet.value?.data); configForm.value = cloneDeep(activePlanSet.value?.data);
extraVisible.value = true; extraVisible.value = true;
currentSelectCase.value = (activePlanSet.value?.data.type as unknown as CaseLinkEnum) || CaseLinkEnum.FUNCTIONAL; currentSelectCase.value = (activePlanSet.value?.data.type as unknown as CaseLinkEnum) || CaseLinkEnum.FUNCTIONAL;
setCaseSelectedSet();
caseAssociateVisible.value = true; caseAssociateVisible.value = true;
nextTick(() => { nextTick(() => {
switchingConfigFormData.value = false; switchingConfigFormData.value = false;
@ -631,6 +657,7 @@
function openCaseAssociateDrawer() { function openCaseAssociateDrawer() {
currentSelectCase.value = (activePlanSet.value?.data?.type as unknown as CaseLinkEnum) || CaseLinkEnum.FUNCTIONAL; currentSelectCase.value = (activePlanSet.value?.data?.type as unknown as CaseLinkEnum) || CaseLinkEnum.FUNCTIONAL;
setCaseSelectedSet();
caseAssociateVisible.value = true; caseAssociateVisible.value = true;
} }
@ -878,9 +905,9 @@
if (node.data.isNew) { if (node.data.isNew) {
tempMinderParams.value.editList.push({ tempMinderParams.value.editList.push({
...node.data, ...node.data,
id: undefined,
num: nodeIndex, num: nodeIndex,
executeMethod: getExecuteMethod(node.data), executeMethod: getExecuteMethod(node.data),
tempCollectionNode: true,
}); });
} else { } else {
tempMinderParams.value.editList.push({ tempMinderParams.value.editList.push({

View File

@ -109,7 +109,7 @@
<MsIcon <MsIcon
type="icon-icon_full_screen_one" type="icon-icon_full_screen_one"
class="input-suffix-icon ml-[8px]" class="input-suffix-icon ml-[8px]"
@click.stop="emit('quickInput', 'conditionValue')" @click.stop="handleQuickInput"
/> />
</template> </template>
</a-input> </a-input>
@ -245,6 +245,15 @@
}, },
]; ];
function handleQuickInput() {
emit(
'quickInput',
innerData.value.whileController.conditionType === WhileConditionType.CONDITION
? 'msWhileVariableValue'
: 'msWhileVariableScriptValue'
);
}
watchEffect(() => { watchEffect(() => {
innerData.value = props.data; innerData.value = props.data;
}); });

View File

@ -91,7 +91,7 @@ export default {
'testPlan.planForm.enableAutomaticStatusTip': 'testPlan.planForm.enableAutomaticStatusTip':
'Enable: function case execution successful cases associated interface, function of the use case status automatically updated to success', 'Enable: function case execution successful cases associated interface, function of the use case status automatically updated to success',
'testPlan.planForm.closeAutomaticStatusTip': 'testPlan.planForm.closeAutomaticStatusTip':
'Close: The result of execution of a functional use case is not affected by the interface', 'Close: Function of use case execution result is not affected by the interface use case/scenario use case',
'testPlan.planForm.passThresholdTip': 'If the pass rate reaches the specified pass threshold, the result is passed', 'testPlan.planForm.passThresholdTip': 'If the pass rate reaches the specified pass threshold, the result is passed',
'testPlan.planForm.pickCases': 'Select cases', 'testPlan.planForm.pickCases': 'Select cases',
'testPlan.testPlanDetail.executed': 'Executed', 'testPlan.testPlanDetail.executed': 'Executed',

View File

@ -85,8 +85,9 @@ export default {
'testPlan.planForm.selectPlanGroup': '选择计划组', 'testPlan.planForm.selectPlanGroup': '选择计划组',
'testPlan.planForm.repeatCaseTip1': '开启:可重复关联同一个用例', 'testPlan.planForm.repeatCaseTip1': '开启:可重复关联同一个用例',
'testPlan.planForm.repeatCaseTip2': '关闭:不可重复关联同一用例', 'testPlan.planForm.repeatCaseTip2': '关闭:不可重复关联同一用例',
'testPlan.planForm.enableAutomaticStatusTip': '开启:功能用例关联的接口用例执行成功,功能用例的状态自动更新为成功', 'testPlan.planForm.enableAutomaticStatusTip':
'testPlan.planForm.closeAutomaticStatusTip': '关闭:功能用例的执行结果不受接口的影响', '开启Function cases the interface associated use case/scenario use case implementation success, function of the use case status automatically updated to success',
'testPlan.planForm.closeAutomaticStatusTip': '关闭:功能用例的执行结果不受接口用例/场景用例的影响',
'testPlan.planForm.passThresholdTip': '通过率达到设置的通过阈值时,报告结果为通过', 'testPlan.planForm.passThresholdTip': '通过率达到设置的通过阈值时,报告结果为通过',
'testPlan.planForm.pickCases': '选择用例', 'testPlan.planForm.pickCases': '选择用例',
'testPlan.testPlanDetail.executed': '已执行', 'testPlan.testPlanDetail.executed': '已执行',