refactor(接口测试): 添加断言组件是否启用全局
This commit is contained in:
parent
d6f93ca8e1
commit
941ebbb7b9
|
@ -1,5 +1,6 @@
|
|||
<template>
|
||||
<div class="ms-assertion">
|
||||
<div class="mb-[8px] flex items-center justify-between">
|
||||
<a-dropdown trigger="hover" @select="handleSelect">
|
||||
<a-button class="w-[84px]" type="outline">
|
||||
<div class="flex flex-row items-center gap-[8px]">
|
||||
|
@ -8,10 +9,22 @@
|
|||
</div>
|
||||
</a-button>
|
||||
<template #content>
|
||||
<a-doption v-for="item in assertOptionSource" :key="item.value" :value="item.value">{{ item.label }}</a-doption>
|
||||
<a-doption v-for="item in assertOptionSource" :key="item.value" :value="item.value">{{
|
||||
item.label
|
||||
}}</a-doption>
|
||||
</template>
|
||||
</a-dropdown>
|
||||
|
||||
<div v-if="props.isDefinition && innerConfig" class="flex items-center">
|
||||
<a-switch v-model:model-value="innerConfig.enableGlobal" size="small" type="line" />
|
||||
<div class="ml-[8px] text-[var(--color-text-1)]">{{ t('ms.assertion.openGlobal') }}</div>
|
||||
<a-tooltip :content="t('ms.assertion.openGlobalTip')" position="left">
|
||||
<icon-question-circle
|
||||
class="ml-[4px] text-[var(--color-text-brand)] hover:text-[rgb(var(--primary-5))]"
|
||||
size="16"
|
||||
/>
|
||||
</a-tooltip>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="showBody" class="ms-assertion-body w-full">
|
||||
<a-scrollbar
|
||||
:style="{
|
||||
|
@ -114,6 +127,7 @@
|
|||
|
||||
<script lang="ts" setup>
|
||||
import { defineModel } from 'vue';
|
||||
import { useVModel } from '@vueuse/core';
|
||||
import { cloneDeep } from 'lodash-es';
|
||||
import { VueDraggable } from 'vue-draggable-plus';
|
||||
|
||||
|
@ -131,7 +145,7 @@
|
|||
|
||||
import { useI18n } from '@/hooks/useI18n';
|
||||
|
||||
import { ExecuteConditionProcessor } from '@/models/apiTest/common';
|
||||
import { ExecuteAssertionConfig , ExecuteConditionProcessor} from '@/models/apiTest/common';
|
||||
import { RequestConditionScriptLanguage, ResponseAssertionType, ResponseBodyAssertionType } from '@/enums/apiEnum';
|
||||
|
||||
import { ExecuteAssertion, MsAssertionItem } from './type';
|
||||
|
@ -145,6 +159,19 @@
|
|||
const focusKey = ref<string>('');
|
||||
// 所有的断言列表参数
|
||||
const assertions = defineModel<any[]>('params', { default: [] });
|
||||
|
||||
const props = defineProps<{
|
||||
isDefinition?: boolean; // 是否是定义页面
|
||||
assertionConfig?: ExecuteAssertionConfig; // 是否开启全局
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:assertionConfig', params: ExecuteAssertionConfig): void;
|
||||
(e: 'change'): void;
|
||||
}>();
|
||||
|
||||
const innerConfig = useVModel(props, 'assertionConfig', emit);
|
||||
|
||||
const activeIds = ref('');
|
||||
// Item点击的key
|
||||
const activeKey = ref<string>('');
|
||||
|
|
|
@ -5,4 +5,7 @@ export default {
|
|||
'ms.assertion.document': 'Document',
|
||||
'ms.assertion.regular': 'Regular',
|
||||
'ms.assertion.script': 'Script',
|
||||
'ms.assertion.openGlobal': 'Implement the Global Declaration',
|
||||
'ms.assertion.openGlobalTip':
|
||||
'It is enabled by default. If it is disabled, the global assertion will not be executed when running this interface.',
|
||||
};
|
||||
|
|
|
@ -22,4 +22,6 @@ export default {
|
|||
'ms.assertion.typeChecking': '类型校验',
|
||||
'ms.assertion.addChild': '添加子字段',
|
||||
'ms.assertion.validateChild': '添加子校验',
|
||||
'ms.assertion.openGlobal': '启用全局断言',
|
||||
'ms.assertion.openGlobalTip': '默认开启,关闭则运行该接口时不执行全局断言',
|
||||
};
|
||||
|
|
|
@ -245,6 +245,8 @@
|
|||
<assertion
|
||||
v-else-if="requestVModel.activeTab === RequestComposition.ASSERTION"
|
||||
v-model:params="requestVModel.children[0].assertionConfig.assertions"
|
||||
:is-definition="props.isDefinition"
|
||||
:assertion-config="requestVModel.children[0].assertionConfig"
|
||||
/>
|
||||
<auth
|
||||
v-else-if="requestVModel.activeTab === RequestComposition.AUTH"
|
||||
|
|
Loading…
Reference in New Issue