fix(接口测试): 修复断言&补充报告hover卡片交互

This commit is contained in:
xinxin.wu 2024-04-03 13:12:01 +08:00 committed by Craftsman
parent 2beebe8fbc
commit 033157169d
7 changed files with 126 additions and 55 deletions

View File

@ -45,7 +45,7 @@
@change="() => handleExpressionChange(rowIndex)" @change="() => handleExpressionChange(rowIndex)"
> >
<template #suffix> <template #suffix>
<a-tooltip :disabled="!disabledExpressionSuffix"> <a-tooltip :disabled="props.disabled || !!props.response">
<template #content> <template #content>
<div>{{ t('apiTestDebug.expressionTip1') }}</div> <div>{{ t('apiTestDebug.expressionTip1') }}</div>
<div>{{ t('apiTestDebug.expressionTip2') }}</div> <div>{{ t('apiTestDebug.expressionTip2') }}</div>
@ -57,7 +57,7 @@
type="icon-icon_flashlamp" type="icon-icon_flashlamp"
:size="15" :size="15"
:class=" :class="
disabledExpressionSuffix || props.disabled props.disabled || !props.response
? 'ms-params-input-suffix-icon--disabled' ? 'ms-params-input-suffix-icon--disabled'
: 'ms-params-input-suffix-icon' : 'ms-params-input-suffix-icon'
" "
@ -141,7 +141,7 @@
@change="() => handleExpressionChange(rowIndex)" @change="() => handleExpressionChange(rowIndex)"
> >
<template #suffix> <template #suffix>
<a-tooltip :disabled="!disabledExpressionSuffix"> <a-tooltip :disabled="props.disabled || !!props.response">
<template #content> <template #content>
<div>{{ t('apiTestDebug.expressionTip1') }}</div> <div>{{ t('apiTestDebug.expressionTip1') }}</div>
<div>{{ t('apiTestDebug.expressionTip2') }}</div> <div>{{ t('apiTestDebug.expressionTip2') }}</div>
@ -150,10 +150,9 @@
<MsIcon <MsIcon
v-if="props.showExtraction" v-if="props.showExtraction"
type="icon-icon_flashlamp" type="icon-icon_flashlamp"
:disabled="props.disabled"
:size="15" :size="15"
:class=" :class="
disabledExpressionSuffix || props.disabled props.disabled || !props.response
? 'ms-params-input-suffix-icon--disabled' ? 'ms-params-input-suffix-icon--disabled'
: 'ms-params-input-suffix-icon' : 'ms-params-input-suffix-icon'
" "
@ -290,7 +289,7 @@
@change="() => handleExpressionChange(rowIndex)" @change="() => handleExpressionChange(rowIndex)"
> >
<template #suffix> <template #suffix>
<a-tooltip :disabled="disabledExpressionSuffix || props.disabled"> <a-tooltip :disabled="props.disabled || !!props.response">
<template #content> <template #content>
<div>{{ t('apiTestDebug.expressionTip1') }}</div> <div>{{ t('apiTestDebug.expressionTip1') }}</div>
<div>{{ t('apiTestDebug.expressionTip2') }}</div> <div>{{ t('apiTestDebug.expressionTip2') }}</div>
@ -301,9 +300,9 @@
type="icon-icon_flashlamp" type="icon-icon_flashlamp"
:size="15" :size="15"
:class=" :class="
disabledExpressionSuffix || props.disabled props.disabled || !props.response
? 'ms-params-input-suffix-icon' ? 'ms-params-input-suffix-icon--disabled'
: 'ms-params-input-suffix-icon--disabled' : 'ms-params-input-suffix-icon'
" "
@click.stop="() => showFastExtraction(record, RequestExtractExpressionEnum.REGEX)" @click.stop="() => showFastExtraction(record, RequestExtractExpressionEnum.REGEX)"
/> />
@ -430,7 +429,7 @@
const extractParamsTableRef = ref<InstanceType<typeof paramsTable>>(); const extractParamsTableRef = ref<InstanceType<typeof paramsTable>>();
const fastExtractionVisible = ref(false); const fastExtractionVisible = ref(false);
const disabledExpressionSuffix = ref(false); // const disabledExpressionSuffix = ref(false);
export type ExpressionConfig = (RegexExtract | JSONPathExtract | XPathExtract) & Record<string, any>; export type ExpressionConfig = (RegexExtract | JSONPathExtract | XPathExtract) & Record<string, any>;
const defaultExtractParamItem: ExpressionConfig = { const defaultExtractParamItem: ExpressionConfig = {
@ -780,7 +779,7 @@
function deleteListItem(id: string | number) {} function deleteListItem(id: string | number) {}
function showFastExtraction(record: ExpressionConfig, type: ExpressionType) { function showFastExtraction(record: ExpressionConfig, type: ExpressionType) {
if (!props.disabled) return; if (props.disabled || !props.response) return;
activeRecord.value = { ...record, extractType: type }; activeRecord.value = { ...record, extractType: type };
fastExtractionVisible.value = true; fastExtractionVisible.value = true;
} }

View File

@ -126,6 +126,7 @@
<ScriptTab <ScriptTab
v-if="getCurrentItemState.assertionType === ResponseAssertionType.SCRIPT" v-if="getCurrentItemState.assertionType === ResponseAssertionType.SCRIPT"
v-model:data="getCurrentItemState" v-model:data="getCurrentItemState"
:disabled="props.disabled"
@change="handleChange" @change="handleChange"
/> />
</a-scrollbar> </a-scrollbar>
@ -176,7 +177,7 @@
isDefinition?: boolean; // isDefinition?: boolean; //
assertionConfig?: ExecuteAssertionConfig; // assertionConfig?: ExecuteAssertionConfig; //
response?: string; // response?: string; //
disabled?: boolean; disabled?: boolean; //
showExtraction?: boolean; // showExtraction?: boolean; //
}>(); }>();

View File

@ -107,11 +107,19 @@
showPagination: false, showPagination: false,
}); });
async function initEnvironment(envId: string) {
try {
const res = await getEnvironment(envId);
propsRes.value.data = cloneDeep(res.dataSources) as any[];
} catch (error) {
console.log(error);
}
}
watch( watch(
() => currentEnvConfig?.value, () => currentEnvConfig?.value,
(config) => { (config) => {
if (config && config.id) { if (config && config.id) {
// eslint-disable-next-line no-use-before-define
initEnvironment(config.id); initEnvironment(config.id);
} }
}, },
@ -119,15 +127,15 @@
immediate: true, immediate: true,
} }
); );
async function initEnvironment(envId: string) {
try { watch(
const res = await getEnvironment(envId); () => innerVisible.value,
propsRes.value.data = cloneDeep(res.dataSources) as any[]; (val) => {
} catch (error) { if (val && currentEnvConfig?.value.id) {
// eslint-disable-next-line no-console initEnvironment(currentEnvConfig.value.id);
console.log(error); }
} }
} );
function searchDataSource() { function searchDataSource() {
propsRes.value.data = cloneDeep(currentEnvConfig?.value.dataSources) as any[]; propsRes.value.data = cloneDeep(currentEnvConfig?.value.dataSources) as any[];

View File

@ -452,6 +452,7 @@
dataIndex: 'createUserName', dataIndex: 'createUserName',
width: 180, width: 180,
showDrag: true, showDrag: true,
showTooltip: true,
}, },
{ {
title: hasOperationPermission.value ? 'common.operation' : '', title: hasOperationPermission.value ? 'common.operation' : '',

View File

@ -16,18 +16,47 @@
<div class="time-card-item flex h-full"> <div class="time-card-item flex h-full">
<MsIcon type="icon-icon_time_outlined" class="mr-[4px] text-[var(--color-text-4)]" size="16" /> <MsIcon type="icon-icon_time_outlined" class="mr-[4px] text-[var(--color-text-4)]" size="16" />
<span class="time-card-item-title">{{ t('report.detail.api.totalTime') }}</span> <span class="time-card-item-title">{{ t('report.detail.api.totalTime') }}</span>
<span class="count">{{ getTotalTime.split('-')[0] || 0 }}</span <a-popover position="bottom" content-class="response-popover-content">
><span class="time-card-item-title">{{ getTotalTime.split('-')[1] || 'ms' }}</span> <span class="count">{{ getTotalTime.split('-')[0] || 0 }}</span
><span class="time-card-item-title">{{ getTotalTime.split('-')[1] || 'ms' }}</span>
<template #content>
<div class="min-w-[140px] max-w-[400px] p-4 text-[14px]">
<div class="text-[var(--color-text-4)]">{{ t('report.detail.api.totalTime') }}</div>
<div class="mt-2 text-[var(--color-text-1)]">
<span class="text-[18px] font-medium">{{ getTotalTime.split('-')[0] || '-' }}</span
>{{ getTotalTime.split('-')[1] || 'ms' }}</div
>
</div>
</template>
</a-popover>
</div> </div>
<div class="time-card-item h-full"> <div class="time-card-item h-full">
<MsIcon type="icon-icon_time_outlined" class="mr-[4px] text-[var(--color-text-4)]" size="16" /> <MsIcon type="icon-icon_time_outlined" class="mr-[4px] text-[var(--color-text-4)]" size="16" />
<span class="time-card-item-title"> {{ t('report.detail.api.requestTotalTime') }}</span> <span class="time-card-item-title"> {{ t('report.detail.api.requestTotalTime') }}</span>
<span class="count">{{ <a-popover position="bottom" content-class="response-popover-content">
detail.requestDuration !== null ? formatDuration(detail.requestDuration).split('-')[0] : '-' <div class="flex items-center">
}}</span <div class="count">{{
><span class="time-card-item-title">{{ detail.requestDuration !== null ? formatDuration(detail.requestDuration).split('-')[0] : '-'
detail.requestDuration !== null ? formatDuration(detail.requestDuration).split('-')[1] : 'ms' }}</div
}}</span> ><div class="time-card-item-title">{{
detail.requestDuration !== null ? formatDuration(detail.requestDuration).split('-')[1] : 'ms'
}}</div>
</div>
<template #content>
<div class="min-w-[140px] max-w-[400px] p-4 text-[14px]">
<div class="text-[var(--color-text-4)]">{{ t('report.detail.api.requestTotalTime') }}</div>
<div class="mt-2 text-[var(--color-text-1)]">
<span class="text-[18px] font-medium">{{
detail.requestDuration !== null ? formatDuration(detail.requestDuration).split('-')[0] : '-'
}}</span
>{{
detail.requestDuration !== null ? formatDuration(detail.requestDuration).split('-')[1] : 'ms'
}}</div
>
</div>
</template>
</a-popover>
</div> </div>
</div> </div>
@ -50,22 +79,54 @@
<MsIcon type="icon-icon_yes_outlined" class="mr-[4px] text-[var(--color-text-4)]" size="16" /> <MsIcon type="icon-icon_yes_outlined" class="mr-[4px] text-[var(--color-text-4)]" size="16" />
{{ t('report.detail.api.assertPass') }} {{ t('report.detail.api.assertPass') }}
</div> </div>
<div class="flex items-center"> <div class="flex items-center">
<span class="count" <a-popover position="bottom" content-class="response-popover-content">
>{{ detail.assertionPassRate === 'Calculating' ? '-' : detail.assertionPassRate || '0.00' }}%</span <div class="flex items-center">
> <div class="count one-line-text max-w-[80px]">{{
<a-divider direction="vertical" class="!h-[16px]" :margin="8"></a-divider> detail.assertionPassRate === 'Calculating' ? '-' : detail.assertionPassRate || '0.00'
<span>{{ }}</div
getIndicators(detail.assertionSuccessCount) === '-' >%
? '-' <a-divider direction="vertical" class="!h-[16px]" :margin="8"></a-divider>
: addCommasToNumber(detail.assertionSuccessCount || 0) <div class="one-line-text max-w-[80px]">{{
}}</span> getIndicators(detail.assertionSuccessCount) === '-'
<span class="mx-1 text-[var(--color-text-4)]" ? '-'
>/ : addCommasToNumber(detail.assertionSuccessCount || 0)
{{ }}</div>
getIndicators(detail.assertionCount) === '-' ? '-' : addCommasToNumber(detail.assertionCount) || 0 <span class="mx-1 text-[var(--color-text-4)]">/</span>
}}</span <div class="one-line-text max-w-[80px]">
> {{
getIndicators(detail.assertionCount) === '-' ? '-' : addCommasToNumber(detail.assertionCount) || 0
}}</div
>
</div>
<template #content>
<div class="min-w-[190px] max-w-[400px] p-4 text-[14px]">
<div class="text-[var(--color-text-4)]">{{ t('report.detail.api.assertPass') }}</div>
<div class="mt-2 flex items-center justify-between">
<div class="text-[18px] font-medium text-[var(--color-text-1)]"
>{{ getIndicators(detail.assertionPassRate) }} <span>%</span></div
>
<div>
<span class="text-[var(--color-text-1)]">{{
getIndicators(detail.assertionSuccessCount) === '-'
? '-'
: addCommasToNumber(detail.assertionSuccessCount || 0)
}}</span>
<span class="text-[var(--color-text-4)]"
><span class="mx-1">/</span>
{{
getIndicators(detail.assertionCount) === '-'
? '-'
: addCommasToNumber(detail.assertionCount) || 0
}}</span
>
</div>
</div>
</div>
</template>
</a-popover>
</div> </div>
</div> </div>
</div> </div>

View File

@ -91,27 +91,28 @@
</a-popover> </a-popover>
</div> </div>
</div> </div>
<div class="timer-card min-w-[200px]"> <div class="timer-card min-w-[40%]">
<div class="text-[var(--color-text-4)]"> <div class="text-[var(--color-text-4)]">
<MsIcon type="icon-icon_yes_outlined" class="mr-[4px] text-[var(--color-text-4)]" size="16" /> <MsIcon type="icon-icon_yes_outlined" class="mr-[4px] text-[var(--color-text-4)]" size="16" />
{{ t('report.detail.api.assertPass') }} {{ t('report.detail.api.assertPass') }}
</div> </div>
<a-popover position="bottom" content-class="response-popover-content"> <a-popover position="bottom" content-class="response-popover-content">
<div class="flex items-center"> <div class="flex flex-nowrap items-center">
<span class="text-[18px] font-medium text-[var(--color-text-1)]" <div class="one-line-text max-w-[80px] text-[18px] font-medium text-[var(--color-text-1)]"
>{{ getIndicators(detail.assertionPassRate) }} <span>%</span></span >{{ getIndicators(detail.assertionPassRate) }}
> </div>
<span>%</span>
<a-divider direction="vertical" :margin="0" class="!mx-2 h-[16px]"></a-divider> <a-divider direction="vertical" :margin="0" class="!mx-2 h-[16px]"></a-divider>
<span class="text-[var(--color-text-1)]">{{ <div class="one-line-text max-w-[80px] text-[var(--color-text-1)]">{{
getIndicators(detail.assertionSuccessCount) === '-' getIndicators(detail.assertionSuccessCount) === '-'
? '-' ? '-'
: addCommasToNumber(detail.assertionSuccessCount || 0) : addCommasToNumber(detail.assertionSuccessCount || 0)
}}</span> }}</div>
<span class="text-[var(--color-text-4)]" <span class="mx-1">/</span>
><span class="mx-1">/</span> <div class="one-line-text max-w-[80px] text-[var(--color-text-4)]">
{{ {{
getIndicators(detail.assertionCount) === '-' ? '-' : addCommasToNumber(detail.assertionCount) || 0 getIndicators(detail.assertionCount) === '-' ? '-' : addCommasToNumber(detail.assertionCount) || 0
}}</span }}</div
> >
</div> </div>
<template #content> <template #content>

View File

@ -1,5 +1,5 @@
<template> <template>
<MsAssertion v-model:params="params" :show-extraction="false" /> <MsAssertion v-model:params="params" :show-extraction="false" :disabled="false" />
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>