🐛 fix(query-editor): 优化事务下拉显示与浮层交互

- 自动提交延迟选项改为多语言完整文案,避免短标签语义不清
- 收窄并校准 V2 工具栏事务下拉宽度,兼顾不截断与紧凑布局
- 事务模式 Select 展开时自动隐藏 DBeaver 参考 Tooltip,避免浮层互相遮挡
- 补充事务设置行为测试和布局守护测试
This commit is contained in:
Syngnat
2026-06-24 17:50:57 +08:00
parent 9da9a36cf3
commit 8a552c4cb3
13 changed files with 144 additions and 23 deletions

View File

@@ -0,0 +1,74 @@
import React from 'react';
import { act, create, type ReactTestRenderer } from 'react-test-renderer';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import QueryEditorTransactionSettings from './QueryEditorTransactionSettings';
const antdState = vi.hoisted(() => ({
selectProps: [] as any[],
tooltipProps: [] as any[],
}));
vi.mock('antd', () => ({
Select: (props: any) => {
antdState.selectProps.push(props);
return <button type="button">{props.value}</button>;
},
Tooltip: (props: any) => {
antdState.tooltipProps.push(props);
return <div>{props.children}</div>;
},
}));
vi.mock('../i18n/provider', () => ({
useOptionalI18n: () => ({
t: (key: string, params?: Record<string, unknown>) => params?.seconds ? `${params.seconds}s后提交` : key,
}),
}));
const latestSelectProps = () => antdState.selectProps[antdState.selectProps.length - 1];
const latestTooltipProps = () => antdState.tooltipProps[antdState.tooltipProps.length - 1];
describe('QueryEditorTransactionSettings', () => {
let renderer: ReactTestRenderer | null = null;
beforeEach(() => {
antdState.selectProps = [];
antdState.tooltipProps = [];
});
afterEach(() => {
renderer?.unmount();
renderer = null;
});
it('hides the DBeaver reference tooltip while the transaction mode select is open', () => {
act(() => {
renderer = create(
<QueryEditorTransactionSettings
isV2Ui
commitMode="manual"
autoCommitDelayMs={0}
onCommitModeChange={vi.fn()}
onAutoCommitDelayMsChange={vi.fn()}
/>,
);
});
act(() => {
latestTooltipProps().onOpenChange(true);
});
expect(latestTooltipProps().open).toBe(true);
act(() => {
latestSelectProps().onOpenChange(true);
});
expect(latestTooltipProps().open).toBe(false);
act(() => {
latestSelectProps().onOpenChange(false);
latestTooltipProps().onOpenChange(true);
});
expect(latestTooltipProps().open).toBe(true);
});
});