补齐通知Hook渠道SMTP错误测试
This commit is contained in:
1 parent
c698b4df5e
commit
0eeaf57e5b
2 files changed
+49
No files matched your search
@@ -664,3 +664,4 @@ npm --prefix frontend run build
|
||||
| 2026-08-15 | 完成业务测试覆盖切片“账号自动化 Hook 失败与重试” | 补充任务设置读取失败、任务执行失败和失败重试测试,覆盖业务错误提示、重试动作和状态清理;不触发真实账号任务;前端 Hook 测试、类型和注释门禁通过 | 下一步:补齐 Accounts/Items/Notifications 等 Hook 的未覆盖错误分支 |
|
||||
| 2026-08-15 | 完成业务测试覆盖切片“商品批量发布 Hook 异常与轮询” | 补充类目推荐、批量预检、启动、取消、重试、最近结果和预检清理失败测试,并覆盖轮询完成后刷新商品/发货规则列表;使用 API 替身验证状态机,不触发真实商品文件或外部平台;前端 Hook 测试、类型和注释门禁通过 | 下一步:补齐 Accounts 子模块与 Notifications Hook 的未覆盖错误分支 |
|
||||
| 2026-08-15 | 完成业务测试覆盖切片“账号子模块保存与密码登录异常” | 补充长期登录、AI、账号编辑、暂停保存失败,以及密码登录启动失败和状态查询失败测试;覆盖错误提示、状态收口和重试前置条件,不触发真实账号凭证或平台登录;前端 Hook 测试、类型和注释门禁通过 | 下一步:补齐 Notifications/Chat/Settings 等 Hook 的未覆盖错误分支 |
|
||||
| 2026-08-15 | 完成业务测试覆盖切片“Notifications Hook 渠道与 SMTP 错误” | 补充通知渠道加载、编辑保存、启用切换和系统 SMTP 保存失败测试;验证错误提示、请求状态收口和管理员边界,不触发真实推送服务或邮件服务器;前端 Hook 测试、类型和注释门禁通过 | 下一步:补齐 Chat/Settings/Orders 等 Hook 的未覆盖错误分支 |
|
||||
@@ -145,4 +145,52 @@ describe('useNotifications', /* 当前回调处理通知渠道、SMTP 和动作
|
||||
expect(hook.result.current.testingId).toBe('');
|
||||
expect(hook.result.current.toast).toEqual({ type: 'error', text: '通知服务失败' });
|
||||
});
|
||||
|
||||
test('渠道加载、保存、切换和 SMTP 保存失败时展示错误', /* 当前回调验证通知 Hook 的业务错误分支。 */ async () => {
|
||||
// hook 是管理员通知错误场景的 Hook 渲染结果。
|
||||
const hook = renderHook(
|
||||
// errorHookFactory 创建管理员通知错误场景的 Hook。
|
||||
() => useNotifications(true),
|
||||
);
|
||||
await waitFor(
|
||||
// loadingAssertion 等待首次通知渠道加载完成。
|
||||
() => expect(hook.result.current.loading).toBe(false),
|
||||
);
|
||||
|
||||
getChannelsMock.mockRejectedValueOnce(new Error('渠道读取失败'));
|
||||
await act(
|
||||
// loadErrorAction 触发通知渠道读取错误。
|
||||
async () => hook.result.current.loadChannels(),
|
||||
);
|
||||
|
||||
await act(
|
||||
// openEditAction 打开已有渠道编辑表单。
|
||||
() => hook.result.current.openEdit(channelFixture),
|
||||
);
|
||||
await act(
|
||||
// formAction 写入编辑渠道表单。
|
||||
() => hook.result.current.setForm({ name: '修改渠道', type: 'bark', enabled: true, config: { server_url: 'https://api.day.app', device_key: 'key' }, event_types: [] }),
|
||||
);
|
||||
updateChannelMock.mockRejectedValueOnce(new Error('渠道保存失败'));
|
||||
await act(
|
||||
// saveErrorAction 触发渠道保存错误。
|
||||
async () => hook.result.current.handleSave(),
|
||||
);
|
||||
expect(hook.result.current.toast).toEqual({ type: 'error', text: '渠道保存失败' });
|
||||
|
||||
updateChannelMock.mockRejectedValueOnce(new Error('切换失败'));
|
||||
await act(
|
||||
// toggleErrorAction 触发渠道状态切换错误。
|
||||
async () => hook.result.current.handleToggleEnabled(channelFixture),
|
||||
);
|
||||
expect(hook.result.current.toast).toEqual({ type: 'error', text: '切换失败' });
|
||||
|
||||
updateSmtpMock.mockRejectedValueOnce(new Error('SMTP保存失败'));
|
||||
await act(
|
||||
// smtpErrorAction 触发系统 SMTP 保存错误。
|
||||
async () => hook.result.current.handleSaveSmtp(),
|
||||
);
|
||||
expect(hook.result.current.toast).toEqual({ type: 'error', text: 'SMTP保存失败' });
|
||||
hook.unmount();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user