feat(通知): 四级严重度与严重度/时间双排序,客户端与后台管理同步
通知表新增 severity(紧急/高危/中危/低危,V161),由 scene + level 推导且 不回改 level:老客户端配色不受影响,secret_balance 的余量偏低与欠费也能分档。 列表与聚合接口默认按严重度倒序(同档按时间倒序),sort=time 切纯时间排序; 聚合组取组内最高严重度。两端铃铛加彩色等级标签与排序切换,展开明细沿用 同一排序,严重度排序下隐藏会跨天误导的日期头。
This commit is contained in:
@@ -25,6 +25,7 @@ import { NOTIFICATION_POLL_INTERVAL_MS } from '@/layout/notification-bell-model'
|
||||
|
||||
const feedback = vi.hoisted(() => ({ showAdminFeedback: vi.fn(), runBusy: vi.fn() }))
|
||||
const api = vi.hoisted(() => ({
|
||||
ADMIN_NOTIFICATION_SEVERITY_LABELS: { urgent: '紧急', high: '高危', medium: '中危', low: '低危' },
|
||||
fetchNotificationSummary: vi.fn(),
|
||||
fetchNotificationGroups: vi.fn(),
|
||||
fetchNotificationList: vi.fn(),
|
||||
@@ -260,4 +261,47 @@ describe('NotificationBell:两处失败必须可见', () => {
|
||||
})
|
||||
expect(api.fetchNotificationList.mock.calls[0][0].subjectUnlabelled).toBe(false)
|
||||
})
|
||||
|
||||
it('默认展示四级严重度并按严重度请求;切「时间」后带 sort=time 重查并恢复日期头', async () => {
|
||||
api.fetchNotificationGroups.mockResolvedValue(
|
||||
groupPage([
|
||||
group({ latestId: 51, severity: 'urgent', level: 'error', day: '2026-09-13' }),
|
||||
group({ latestId: 50, subjectUserId: 1196, severity: 'low', level: 'info', day: '2026-09-12' }),
|
||||
]),
|
||||
)
|
||||
|
||||
const bell = mountBell()
|
||||
await flushPromises()
|
||||
await bell.find('button.bell-trigger').trigger('click')
|
||||
await flushPromises()
|
||||
|
||||
expect(Array.from(document.querySelectorAll('.bell-severity-tag')).map((el) => el.textContent?.trim()))
|
||||
.toEqual(['紧急', '低危'])
|
||||
expect(api.fetchNotificationGroups.mock.calls[0][0].sort).toBe('severity')
|
||||
// 严重度排序会跨天交错,不挂日期头
|
||||
expect(document.querySelectorAll('.bell-day-head')).toHaveLength(0)
|
||||
|
||||
// 展开明细也要带同一种排序,否则会出现「列表按严重度、明细又按时间」
|
||||
api.fetchNotificationList.mockResolvedValue({
|
||||
items: [notification({ id: 51, severity: 'urgent' })],
|
||||
total: 1,
|
||||
page: 1,
|
||||
pageSize: 50,
|
||||
unreadCount: 1,
|
||||
})
|
||||
await expandFirstGroup()
|
||||
expect(api.fetchNotificationList.mock.calls.at(-1)?.[0].sort).toBe('severity')
|
||||
|
||||
const timeButton = Array.from(document.querySelectorAll<HTMLElement>('.bell-sort-chips button'))
|
||||
.find((button) => button.textContent?.includes('时间'))
|
||||
expect(timeButton).toBeTruthy()
|
||||
timeButton!.click()
|
||||
await flushPromises()
|
||||
|
||||
expect(api.fetchNotificationGroups.mock.calls.at(-1)?.[0].sort).toBe('time')
|
||||
expect(document.querySelectorAll('.bell-day-head')).toHaveLength(2)
|
||||
|
||||
await expandFirstGroup()
|
||||
expect(api.fetchNotificationList.mock.calls.at(-1)?.[0].sort).toBe('time')
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user