refactor(接口测试): 添加断言组件是否启用全局
This commit is contained in:
parent
d6f93ca8e1
commit
941ebbb7b9
|
@ -1,17 +1,30 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="ms-assertion">
|
<div class="ms-assertion">
|
||||||
<a-dropdown trigger="hover" @select="handleSelect">
|
<div class="mb-[8px] flex items-center justify-between">
|
||||||
<a-button class="w-[84px]" type="outline">
|
<a-dropdown trigger="hover" @select="handleSelect">
|
||||||
<div class="flex flex-row items-center gap-[8px]">
|
<a-button class="w-[84px]" type="outline">
|
||||||
<icon-plus />
|
<div class="flex flex-row items-center gap-[8px]">
|
||||||
<span>{{ t('ms.assertion.button') }}</span>
|
<icon-plus />
|
||||||
</div>
|
<span>{{ t('ms.assertion.button') }}</span>
|
||||||
</a-button>
|
</div>
|
||||||
<template #content>
|
</a-button>
|
||||||
<a-doption v-for="item in assertOptionSource" :key="item.value" :value="item.value">{{ item.label }}</a-doption>
|
<template #content>
|
||||||
</template>
|
<a-doption v-for="item in assertOptionSource" :key="item.value" :value="item.value">{{
|
||||||
</a-dropdown>
|
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">
|
<div v-if="showBody" class="ms-assertion-body w-full">
|
||||||
<a-scrollbar
|
<a-scrollbar
|
||||||
:style="{
|
:style="{
|
||||||
|
@ -114,6 +127,7 @@
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { defineModel } from 'vue';
|
import { defineModel } from 'vue';
|
||||||
|
import { useVModel } from '@vueuse/core';
|
||||||
import { cloneDeep } from 'lodash-es';
|
import { cloneDeep } from 'lodash-es';
|
||||||
import { VueDraggable } from 'vue-draggable-plus';
|
import { VueDraggable } from 'vue-draggable-plus';
|
||||||
|
|
||||||
|
@ -131,7 +145,7 @@
|
||||||
|
|
||||||
import { useI18n } from '@/hooks/useI18n';
|
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 { RequestConditionScriptLanguage, ResponseAssertionType, ResponseBodyAssertionType } from '@/enums/apiEnum';
|
||||||
|
|
||||||
import { ExecuteAssertion, MsAssertionItem } from './type';
|
import { ExecuteAssertion, MsAssertionItem } from './type';
|
||||||
|
@ -145,6 +159,19 @@
|
||||||
const focusKey = ref<string>('');
|
const focusKey = ref<string>('');
|
||||||
// 所有的断言列表参数
|
// 所有的断言列表参数
|
||||||
const assertions = defineModel<any[]>('params', { default: [] });
|
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('');
|
const activeIds = ref('');
|
||||||
// Item点击的key
|
// Item点击的key
|
||||||
const activeKey = ref<string>('');
|
const activeKey = ref<string>('');
|
||||||
|
|
|
@ -5,4 +5,7 @@ export default {
|
||||||
'ms.assertion.document': 'Document',
|
'ms.assertion.document': 'Document',
|
||||||
'ms.assertion.regular': 'Regular',
|
'ms.assertion.regular': 'Regular',
|
||||||
'ms.assertion.script': 'Script',
|
'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.typeChecking': '类型校验',
|
||||||
'ms.assertion.addChild': '添加子字段',
|
'ms.assertion.addChild': '添加子字段',
|
||||||
'ms.assertion.validateChild': '添加子校验',
|
'ms.assertion.validateChild': '添加子校验',
|
||||||
|
'ms.assertion.openGlobal': '启用全局断言',
|
||||||
|
'ms.assertion.openGlobalTip': '默认开启,关闭则运行该接口时不执行全局断言',
|
||||||
};
|
};
|
||||||
|
|
|
@ -245,6 +245,8 @@
|
||||||
<assertion
|
<assertion
|
||||||
v-else-if="requestVModel.activeTab === RequestComposition.ASSERTION"
|
v-else-if="requestVModel.activeTab === RequestComposition.ASSERTION"
|
||||||
v-model:params="requestVModel.children[0].assertionConfig.assertions"
|
v-model:params="requestVModel.children[0].assertionConfig.assertions"
|
||||||
|
:is-definition="props.isDefinition"
|
||||||
|
:assertion-config="requestVModel.children[0].assertionConfig"
|
||||||
/>
|
/>
|
||||||
<auth
|
<auth
|
||||||
v-else-if="requestVModel.activeTab === RequestComposition.AUTH"
|
v-else-if="requestVModel.activeTab === RequestComposition.AUTH"
|
||||||
|
|
Loading…
Reference in New Issue