feat(v2.7): 接入协作治理前端体验

This commit is contained in:
2026-07-08 16:31:06 +08:00
parent bcbe84bb6e
commit 9ba9449c1a
23 changed files with 987 additions and 2 deletions

View File

@@ -0,0 +1,20 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { countUnreadNotifications, sortNotificationsNewestFirst } from './notification';
test('countUnreadNotifications counts only rows without readAt', () => {
assert.equal(countUnreadNotifications([
{ id: 'n-1', readAt: null } as any,
{ id: 'n-2', readAt: '2026-07-08T08:00:00.000Z' } as any,
{ id: 'n-3' } as any,
]), 2);
});
test('sortNotificationsNewestFirst keeps newest createdAt first', () => {
const sorted = sortNotificationsNewestFirst([
{ id: 'old', createdAt: '2026-07-07T08:00:00.000Z' } as any,
{ id: 'new', createdAt: '2026-07-08T08:00:00.000Z' } as any,
]);
assert.deepEqual(sorted.map((item) => item.id), ['new', 'old']);
});