Keep routine events out of notifications

This commit is contained in:
Jamie Brunton committed 2026-08-14 09:13:36 +01:00
1 parent 79c508be2b
commit 3bb1dda6bb
2 files changed
+41 -68

No files matched your search

+25 -6
View File
@@ -11,7 +11,6 @@ import {
NotificationProvider,
NotificationViewport,
notificationForEvent,
shouldToastForEvent,
} from '../../apps/dashboard/src/app/notifications.js';
class FakeRealtime {
@@ -54,6 +53,27 @@ describe('dashboard notifications', () => {
type: 'log.created',
payload: { level: 'info', message: 'Routine detail' },
})).toBeNull();
expect(notificationForEvent({
id: 'sent-1',
occurredAt: '2026-08-09T09:30:00.000Z',
type: 'message.sent',
payload: { messageId: 'message-2', recipient: 'alice', conversationId: 'room/one' },
})).toBeNull();
expect(notificationForEvent({
id: 'running-1',
occurredAt: '2026-08-09T09:30:00.000Z',
type: 'bot.status.changed',
payload: { status: 'running', dryRun: false },
})).toBeNull();
expect(notificationForEvent({
id: 'rate-clear-1',
occurredAt: '2026-08-09T09:30:00.000Z',
type: 'rate-limit.changed',
payload: { limited: false },
})).toBeNull();
});
it('shows new events as toasts and keeps them in a readable notification centre', async () => {
@@ -94,9 +114,8 @@ describe('dashboard notifications', () => {
expect(within(centre).getByText('All quiet')).toBeInTheDocument();
});
it('keeps routine sync completions in the notification centre without showing a toast', async () => {
it('ignores routine sync completions entirely', () => {
const realtime = new FakeRealtime();
const user = userEvent.setup();
render(
<MemoryRouter>
<NotificationProvider realtime={realtime}>
@@ -112,12 +131,12 @@ describe('dashboard notifications', () => {
type: 'sync.completed',
payload: { syncId: 'conversation-sync-1', kind: 'conversations', processed: 12 },
};
expect(shouldToastForEvent(syncEvent)).toBe(false);
expect(notificationForEvent(syncEvent)).toBeNull();
act(() => realtime.emit(syncEvent));
expect(screen.queryByRole('status')).not.toBeInTheDocument();
await user.click(screen.getByRole('button', { name: 'Notifications, 1 unread' }));
expect(within(screen.getByLabelText('Notifications', { selector: 'aside' })).getByText('Conversations sync complete'))
expect(screen.getByRole('button', { name: 'Notifications' })).toBeInTheDocument();
expect(within(screen.getByLabelText('Notifications', { selector: 'aside' })).getByText('All quiet'))
.toBeInTheDocument();
});