补齐商品通知API归一化测试
This commit is contained in:
1 parent
2c626413a5
commit
620a565c44
2 files changed
+27
No files matched your search
@@ -676,3 +676,4 @@ npm --prefix frontend run build
|
||||
| 2026-08-15 | 完成业务测试覆盖切片“账号子模块通知与密码登录中间状态” | 补充通知渠道独立失败、AI 弹窗关闭、密码登录处理中和编辑弹窗关闭取消测试;覆盖子模块请求隔离与生命周期清理,不触发真实账号凭证或平台登录;前端 Hook 测试、类型和注释门禁通过 | 下一步:继续补齐剩余可控业务分支并分类外部依赖分支 |
|
||||
| 2026-08-15 | 完成阶段性业务覆盖率审计 | 前端全量测试 50 个文件、268 个用例通过;业务代码 V8 覆盖率达到语句 92.47%、分支 73.48%、函数 93.41%、行 96.46%;纯 UI 组件按用户要求排除,剩余未覆盖项集中在 API 适配器未调用接口、请求取消/过期保护和真实平台生命周期分支,下一轮继续按可控性补测并保留外部依赖跳过说明 | 下一步:继续补齐剩余可控业务分支,最终形成业务覆盖率验收清单 |
|
||||
| 2026-08-15 | 完成业务测试覆盖切片“通知 API 序列化与绑定响应” | 补充通知渠道更新配置/事件序列化和消息通知数组展开、非法绑定值忽略测试;覆盖 API 适配层确定性响应归一化,不触发推送服务;前端 API 测试、类型和注释门禁通过 | 下一步:继续补齐剩余 API 适配器与请求取消分支 |
|
||||
| 2026-08-15 | 完成业务测试覆盖切片“商品发布与通知事件 API 归一化” | 补充商品发布 multipart 图片/地点字段序列化,以及通知事件 JSON/分隔符兼容解析测试;覆盖 API 适配层剩余确定性分支,不触发真实商品发布或推送服务;前端 API 测试、类型和注释门禁通过 | 下一步:继续补齐剩余 API 适配器与请求取消分支 |
|
||||
@@ -763,6 +763,32 @@ test('getMessageNotifications 展开数组并忽略非法绑定值', /* 当前
|
||||
await expect(getMessageNotifications()).resolves.toEqual({ success: true, data: [{ cookie_id: 'account-1', channel_id: 1, channel_name: '邮件', enabled: true }] });
|
||||
});
|
||||
|
||||
test('publishItem 序列化图片和地点字段', /* 当前回调验证商品发布 multipart 请求体。 */ async () => {
|
||||
// fetchMock 是商品发布上传接口的网络替身。
|
||||
const fetchMock = vi.fn().mockResolvedValue(jsonResponse({ success: true }));
|
||||
vi.stubGlobal('fetch', fetchMock);
|
||||
// image 是待上传的商品图片文件。
|
||||
const image = new File(['image'], 'item.png', { type: 'image/png' });
|
||||
await publishItem({ cookie_id: 'account-1', title: '商品', description: '描述', price: '10', quantity: 2, postage_mode: 'free', images: [image], location: { area: '区域', city: '城市', division_id: '1', longitude: 120, latitude: 30, poi_id: 'poi-1', poi_name: '地点', province: '省' } });
|
||||
// body 是商品发布 multipart 请求体。
|
||||
const body = fetchMock.mock.calls[0][1].body as FormData;
|
||||
expect(body.get('location')).toContain('poi-1');
|
||||
expect(body.getAll('images')).toHaveLength(1);
|
||||
});
|
||||
|
||||
test('通知事件字段支持 JSON 数组和分隔符格式', /* 当前回调验证通知事件响应解析兼容性。 */ async () => {
|
||||
// fetchMock 是返回多种通知事件编码的网络替身。
|
||||
const fetchMock = vi.fn().mockResolvedValue(jsonResponse([
|
||||
{ id: 1, name: 'JSON', type: 'bark', config: '{}', event_types: '["system_error", "order_paid"]', enabled: true },
|
||||
{ id: 2, name: '分隔符', type: 'bark', config: '{}', event_types: 'system_error, order_paid; buyer_reviewed', enabled: true },
|
||||
]));
|
||||
vi.stubGlobal('fetch', fetchMock);
|
||||
// result 是通知事件字段解析后的渠道列表。
|
||||
const result = await getNotificationChannels();
|
||||
expect(result.data?.[0].event_types).toEqual(['system_error', 'order_paid']);
|
||||
expect(result.data?.[1].event_types).toEqual(['system_error', 'order_paid', 'buyer_reviewed']);
|
||||
});
|
||||
|
||||
test('updateShippingRule posts buyer reviewed gift payload to automation-rules', async () => {
|
||||
const fetchMock = vi.fn().mockResolvedValue(jsonResponse({ success: true, id: 1 })); /* fetchMock 表示fetchMock。 */
|
||||
vi.stubGlobal('fetch', fetchMock);
|
||||
|
||||
Reference in new issue
Block a user