feat: add notification category filters
فشلت بعض الفحوصات
Deploy To Ghaymah / deploy (push) Has been cancelled
فشلت بعض الفحوصات
Deploy To Ghaymah / deploy (push) Has been cancelled
هذا الالتزام موجود في:
@@ -107,6 +107,80 @@ describe('NotificationsService', () => {
|
||||
expect(notificationsRepository.countUnread).toHaveBeenCalledWith('507f1f77bcf86cd799439011');
|
||||
});
|
||||
|
||||
it('filters notifications by interactions category', async () => {
|
||||
const notificationsRepository = {
|
||||
findMine: jest.fn().mockResolvedValue([]),
|
||||
countMine: jest.fn().mockResolvedValue(0),
|
||||
countUnread: jest.fn().mockResolvedValue(0),
|
||||
};
|
||||
const notificationsGateway = {
|
||||
emitUnreadCount: jest.fn(),
|
||||
};
|
||||
|
||||
const service = new NotificationsService(
|
||||
notificationsRepository as any,
|
||||
notificationsGateway as any,
|
||||
);
|
||||
|
||||
await service.getMine('507f1f77bcf86cd799439011', {
|
||||
page: 1,
|
||||
limit: 20,
|
||||
category: 'interactions',
|
||||
});
|
||||
|
||||
expect(notificationsRepository.findMine).toHaveBeenCalledWith(
|
||||
'507f1f77bcf86cd799439011',
|
||||
{
|
||||
type: {
|
||||
$in: [
|
||||
'like',
|
||||
'comment',
|
||||
'reply',
|
||||
'mention',
|
||||
'save',
|
||||
'share',
|
||||
'collaboration_request',
|
||||
'system',
|
||||
],
|
||||
},
|
||||
},
|
||||
0,
|
||||
20,
|
||||
{ createdAt: -1 },
|
||||
);
|
||||
});
|
||||
|
||||
it('keeps type filter priority over category for backward compatibility', async () => {
|
||||
const notificationsRepository = {
|
||||
findMine: jest.fn().mockResolvedValue([]),
|
||||
countMine: jest.fn().mockResolvedValue(0),
|
||||
countUnread: jest.fn().mockResolvedValue(0),
|
||||
};
|
||||
const notificationsGateway = {
|
||||
emitUnreadCount: jest.fn(),
|
||||
};
|
||||
|
||||
const service = new NotificationsService(
|
||||
notificationsRepository as any,
|
||||
notificationsGateway as any,
|
||||
);
|
||||
|
||||
await service.getMine('507f1f77bcf86cd799439011', {
|
||||
page: 1,
|
||||
limit: 20,
|
||||
type: 'message',
|
||||
category: 'interactions',
|
||||
});
|
||||
|
||||
expect(notificationsRepository.findMine).toHaveBeenCalledWith(
|
||||
'507f1f77bcf86cd799439011',
|
||||
{ type: 'message' },
|
||||
0,
|
||||
20,
|
||||
{ createdAt: -1 },
|
||||
);
|
||||
});
|
||||
|
||||
it('creates system notifications with system resource mapping when requested', async () => {
|
||||
const notificationsRepository = {
|
||||
create: jest.fn().mockResolvedValue({ toJSON: () => ({ _id: 'notification-1' }) }),
|
||||
|
||||
المرجع في مشكلة جديدة
حظر مستخدم