mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-30 19:52:20 +01:00
(test) add small front-end test for notifications list
This commit is contained in:
parent
94c3e3effd
commit
fb0b32e0d2
@ -0,0 +1,9 @@
|
||||
import { NotificationType } from '../../../app/frontend/src/javascript/models/notification-type';
|
||||
|
||||
const notificationTypes: Array<NotificationType> = [
|
||||
{ id: 1, name: 'notify_admin_when_project_published', category: 'projects', is_configurable: true },
|
||||
{ id: 2, name: 'notify_project_collaborator_to_valid', category: 'projects', is_configurable: true },
|
||||
{ id: 3, name: 'notify_project_author_when_collaborator_valid', category: 'projects', is_configurable: true }
|
||||
];
|
||||
|
||||
export default notificationTypes;
|
47
test/frontend/__fixtures__/notifications.ts
Normal file
47
test/frontend/__fixtures__/notifications.ts
Normal file
@ -0,0 +1,47 @@
|
||||
import { Notification, NotificationsIndex } from '../../../app/frontend/src/javascript/models/notification';
|
||||
|
||||
const newNotifications: Array<Notification> = [
|
||||
{
|
||||
id: 1,
|
||||
notification_type: 'notify_admin_when_project_published',
|
||||
notification_type_id: 1,
|
||||
created_at: '2023-02-03T14:42:34.678Z',
|
||||
is_read: false,
|
||||
message: {
|
||||
title: '',
|
||||
description: 'Decription of the first notification'
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
notification_type: 'notify_project_collaborator_to_valid',
|
||||
notification_type_id: 2,
|
||||
created_at: '2023-02-03T14:42:34.678Z',
|
||||
is_read: false,
|
||||
message: {
|
||||
title: '',
|
||||
description: 'Decription of the second notification'
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
notification_type: 'notify_project_author_when_collaborator_valid',
|
||||
notification_type_id: 3,
|
||||
created_at: '2023-02-03T14:42:34.678Z',
|
||||
is_read: false,
|
||||
message: {
|
||||
title: '',
|
||||
description: 'Decription of the third notification'
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
const notificationsIndex: NotificationsIndex = {
|
||||
notifications: newNotifications,
|
||||
totals: {
|
||||
total: 3,
|
||||
unread: 3
|
||||
}
|
||||
};
|
||||
|
||||
export default notificationsIndex;
|
@ -11,6 +11,8 @@ import providers from '../__fixtures__/auth_providers';
|
||||
import profileCustomFields from '../__fixtures__/profile_custom_fields';
|
||||
import spaces from '../__fixtures__/spaces';
|
||||
import statuses from '../__fixtures__/statuses';
|
||||
import notificationTypes from '../__fixtures__/notification_types';
|
||||
import notifications from '../__fixtures__/notifications';
|
||||
|
||||
const FixturesLib = {
|
||||
init: () => {
|
||||
@ -29,7 +31,9 @@ const FixturesLib = {
|
||||
providers: JSON.parse(JSON.stringify(providers)),
|
||||
profileCustomFields: JSON.parse(JSON.stringify(profileCustomFields)),
|
||||
spaces: JSON.parse(JSON.stringify(spaces)),
|
||||
statuses: JSON.parse(JSON.stringify(statuses))
|
||||
statuses: JSON.parse(JSON.stringify(statuses)),
|
||||
notificationTypes: JSON.parse(JSON.stringify(notificationTypes)),
|
||||
notifications: JSON.parse(JSON.stringify(notifications))
|
||||
};
|
||||
}
|
||||
};
|
||||
|
@ -111,6 +111,12 @@ export const server = setupServer(
|
||||
status.id = fixtures.statuses.length + 1;
|
||||
fixtures.statuses.push(status);
|
||||
return res(ctx.json({ status }));
|
||||
}),
|
||||
rest.get('/api/notification_types', (req, res, ctx) => {
|
||||
return res(ctx.json(fixtures.notification_types));
|
||||
}),
|
||||
rest.get('/api/notifications', (req, res, ctx) => {
|
||||
return res(ctx.json(fixtures.notifications));
|
||||
})
|
||||
);
|
||||
|
||||
|
@ -8,5 +8,8 @@ describe('Notifications list', () => {
|
||||
|
||||
render(<NotificationsList onError={onError} />);
|
||||
await waitFor(() => screen.getByTestId('notifications-list'));
|
||||
expect(screen.getByText('Decription of the first notification')).toBeDefined();
|
||||
expect(screen.getByText('Decription of the second notification')).toBeDefined();
|
||||
expect(screen.getByText('Decription of the third notification')).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user