This commit is contained in:
2026-08-14 16:06:30 +08:00
parent 1c1c48f8d3
commit d1b4a4d3f3
26 changed files with 187 additions and 29 deletions
@@ -4,6 +4,7 @@ import {
cancelTask,
changeTemplateStatus,
createNotification,
getTask,
listTasks,
listTemplates,
retryTask,
@@ -18,6 +19,7 @@ vi.mock('@/shared/api/http', () => ({
const envelope = <T>(data: T) => ({ code: '200', data })
const template = { id: 12, templateCode: 'ORDER_SENT', templateName: '订单已发货', category: 'ORDER', channel: 'IN_APP' as const, titleTemplate: '已发货', bodyTemplate: '正文', variableWhitelist: [], status: 'DRAFT' as const, version: 1 }
const task = { id: 13, taskNo: 'NT-13', category: 'ORDER', title: '已发货', status: 'CREATED' as const, recipientCount: 2, scheduledAt: null, sentAt: null, duplicated: false }
const taskDetail = { id: 13, taskNo: 'NT-13', category: 'ORDER', title: '已发货', status: 'DEAD' as const, recipientCount: 1, attemptCount: 3, scheduledAt: null, sentAt: null, lastError: 'gateway timeout', recipients: [{ id: 21, displayName: '客户成员', appCode: 'MERCHANT', status: 'FAILED', failureReason: 'gateway timeout', deliveredAt: null }] }
describe('notificationCenter API', () => {
beforeEach(() => vi.clearAllMocks())
@@ -51,4 +53,13 @@ describe('notificationCenter API', () => {
expect(http.put).toHaveBeenNthCalledWith(1, '/platform/v1/notification-tasks/13/cancel')
expect(http.put).toHaveBeenNthCalledWith(2, '/platform/v1/notification-tasks/13/retry')
})
it('loads task failure evidence and normalizes nested long ids', async () => {
vi.mocked(http.get).mockResolvedValueOnce(envelope(taskDetail))
const result = await getTask('13')
expect(http.get).toHaveBeenCalledWith('/platform/v1/notification-tasks/13')
expect(result.id).toBe('13')
expect(result.recipients[0]?.id).toBe('21')
expect(result.lastError).toBe('gateway timeout')
})
})