1
This commit is contained in:
@@ -4,9 +4,14 @@ import {
|
||||
cancelTask,
|
||||
changeTemplateStatus,
|
||||
createNotification,
|
||||
getMyNotification,
|
||||
getMyUnreadNotificationCount,
|
||||
getTask,
|
||||
listMyNotifications,
|
||||
listTasks,
|
||||
listTemplates,
|
||||
markAllMyNotificationsRead,
|
||||
markMyNotificationRead,
|
||||
retryTask,
|
||||
updateTemplate,
|
||||
} from './notificationCenter'
|
||||
@@ -62,4 +67,24 @@ describe('notificationCenter API', () => {
|
||||
expect(result.recipients[0]?.id).toBe('21')
|
||||
expect(result.lastError).toBe('gateway timeout')
|
||||
})
|
||||
it('uses platform inbox paths and normalizes inbox ids', async () => {
|
||||
const inbox = { id: 14, category: 'ORDER', title: 'order notice', summary: 'summary', status: 'UNREAD' as const, sentAt: '2026-08-27T10:00:00', readAt: null }
|
||||
const detail = { ...inbox, body: 'body', sourceType: null, sourceId: null }
|
||||
vi.mocked(http.get)
|
||||
.mockResolvedValueOnce(envelope({ records: [inbox], page: 1, size: 20, total: 1, pages: 1 }))
|
||||
.mockResolvedValueOnce(envelope(detail))
|
||||
.mockResolvedValueOnce(envelope({ unreadCount: 1 }))
|
||||
vi.mocked(http.put)
|
||||
.mockResolvedValueOnce(envelope(detail))
|
||||
.mockResolvedValueOnce(envelope({ updatedCount: 1 }))
|
||||
const result = await listMyNotifications({ page: 1, size: 20, status: 'UNREAD' })
|
||||
await getMyNotification('14')
|
||||
await markMyNotificationRead('14')
|
||||
await markAllMyNotificationsRead()
|
||||
expect(await getMyUnreadNotificationCount()).toBe(1)
|
||||
expect(result.records[0]?.id).toBe('14')
|
||||
expect(http.get).toHaveBeenNthCalledWith(1, '/platform/v1/notifications', { params: { page: 1, size: 20, status: 'UNREAD' } })
|
||||
expect(http.put).toHaveBeenNthCalledWith(1, '/platform/v1/notifications/14/read')
|
||||
expect(http.put).toHaveBeenNthCalledWith(2, '/platform/v1/notifications/read-all')
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user