mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-01 03:27:52 +00:00
feat: Inbox list filter (#8880)
* feat: Inbox list filter * fix: routes after delete/unread * fix: Specs * feat: Handle sort in frontend * chore: Minor fixes * chore: Minor fix --------- Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
This commit is contained in:
@@ -6,8 +6,15 @@ class NotificationsAPI extends ApiClient {
|
||||
super('notifications', { accountScoped: true });
|
||||
}
|
||||
|
||||
get(page) {
|
||||
return axios.get(`${this.url}?page=${page}`);
|
||||
get({ page, status, type, sortOrder }) {
|
||||
return axios.get(this.url, {
|
||||
params: {
|
||||
page,
|
||||
status,
|
||||
type,
|
||||
sort_order: sortOrder,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
getNotifications(contactId) {
|
||||
|
||||
@@ -28,10 +28,20 @@ describe('#NotificationAPI', () => {
|
||||
});
|
||||
|
||||
it('#get', () => {
|
||||
notificationsAPI.get(1);
|
||||
expect(axiosMock.get).toHaveBeenCalledWith(
|
||||
'/api/v1/notifications?page=1'
|
||||
);
|
||||
notificationsAPI.get({
|
||||
page: 1,
|
||||
status: 'read',
|
||||
type: 'Conversation',
|
||||
sortOrder: 'desc',
|
||||
});
|
||||
expect(axiosMock.get).toHaveBeenCalledWith('/api/v1/notifications', {
|
||||
params: {
|
||||
page: 1,
|
||||
status: 'read',
|
||||
type: 'Conversation',
|
||||
sort_order: 'desc',
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it('#getNotifications', () => {
|
||||
@@ -65,5 +75,30 @@ describe('#NotificationAPI', () => {
|
||||
'/api/v1/notifications/read_all'
|
||||
);
|
||||
});
|
||||
|
||||
it('#snooze', () => {
|
||||
notificationsAPI.snooze({ id: 1, snoozedUntil: 12332211 });
|
||||
expect(axiosMock.post).toHaveBeenCalledWith(
|
||||
'/api/v1/notifications/1/snooze',
|
||||
{
|
||||
snoozed_until: 12332211,
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('#delete', () => {
|
||||
notificationsAPI.delete(1);
|
||||
expect(axiosMock.delete).toHaveBeenCalledWith('/api/v1/notifications/1');
|
||||
});
|
||||
|
||||
it('#deleteAll', () => {
|
||||
notificationsAPI.deleteAll({ type: 'all' });
|
||||
expect(axiosMock.post).toHaveBeenCalledWith(
|
||||
'/api/v1/notifications/destroy_all',
|
||||
{
|
||||
type: 'all',
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user