fix(e2e): 修复对话框关闭问题,完善 E2E 测试
- 修复 TDesign Dialog onConfirm 不自动关闭的问题 - 使用 useEffect 监听 mutation 状态自动关闭对话框 - 测试使用 waitForResponse 等待 API 响应 - 添加 clearDatabase 函数确保测试隔离 - 归档 e2e-real-backend 变更到 archive/2026-04-22 - 同步 e2e-testing spec 到主 specs
This commit is contained in:
@@ -30,11 +30,9 @@ export function ProviderForm({
|
||||
const [form] = Form.useForm();
|
||||
const isEdit = !!provider;
|
||||
|
||||
// 当弹窗打开或provider变化时,设置表单值
|
||||
useEffect(() => {
|
||||
if (open && form) {
|
||||
if (provider) {
|
||||
// 编辑模式:设置现有值
|
||||
form.setFieldsValue({
|
||||
id: provider.id,
|
||||
name: provider.name,
|
||||
@@ -44,12 +42,11 @@ export function ProviderForm({
|
||||
enabled: provider.enabled,
|
||||
});
|
||||
} else {
|
||||
// 新增模式:重置表单
|
||||
form.reset();
|
||||
form.setFieldsValue({ enabled: true, protocol: 'openai' });
|
||||
}
|
||||
}
|
||||
}, [open, provider]); // 移除form依赖,避免循环
|
||||
}, [open, provider]);
|
||||
|
||||
const handleSubmit = (context: SubmitContext) => {
|
||||
if (context.validateResult === true && form) {
|
||||
@@ -67,7 +64,6 @@ export function ProviderForm({
|
||||
confirmLoading={loading}
|
||||
confirmBtn="保存"
|
||||
cancelBtn="取消"
|
||||
destroyOnClose
|
||||
>
|
||||
<Form form={form} layout="vertical" onSubmit={handleSubmit}>
|
||||
<Form.FormItem label="ID" name="id" rules={[{ required: true, message: '请输入供应商 ID' }]}>
|
||||
|
||||
Reference in New Issue
Block a user