test(notification_getList): fix
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
0de5bc5109
commit
204323ac69
|
@ -2,30 +2,12 @@ const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
describe('NotificationSubscription getList()', () => {
|
describe('NotificationSubscription getList()', () => {
|
||||||
it('should return a list of available and active notifications of a user', async() => {
|
it('should return a list of available and active notifications of a user', async() => {
|
||||||
const userId = 1109;
|
const userId = 9;
|
||||||
const activeNotifications = await models.NotificationSubscription.find({
|
const {active, available} = await models.NotificationSubscription.getList(userId);
|
||||||
where: {userFk: userId}
|
const notifications = await models.Notification.find({});
|
||||||
});
|
const totalAvailable = notifications.length - active.length;
|
||||||
const roles = await models.RoleMapping.find({
|
|
||||||
fields: ['roleId'],
|
|
||||||
where: {principalId: userId}
|
|
||||||
});
|
|
||||||
const availableNotifications = await models.NotificationAcl.find({
|
|
||||||
where: {
|
|
||||||
roleFk: {
|
|
||||||
inq: roles.map(role => {
|
|
||||||
return role.roleId;
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const result = await models.NotificationSubscription.getList(userId);
|
expect(active.length).toEqual(2);
|
||||||
|
expect(available.length).toEqual(totalAvailable);
|
||||||
expect(result.filter(notification => notification.active == true).length)
|
|
||||||
.toEqual(activeNotifications.length);
|
|
||||||
|
|
||||||
expect(result.filter(notification => notification.active == false).length)
|
|
||||||
.toEqual(availableNotifications.length - activeNotifications.length);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -2790,7 +2790,9 @@ INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`)
|
||||||
(1, 9),
|
(1, 9),
|
||||||
(1, 1),
|
(1, 1),
|
||||||
(2, 1),
|
(2, 1),
|
||||||
|
(3, 9),
|
||||||
(4, 1),
|
(4, 1),
|
||||||
|
(5, 9),
|
||||||
(6, 9);
|
(6, 9);
|
||||||
|
|
||||||
INSERT INTO `util`.`notificationQueue` (`id`, `notificationFk`, `params`, `authorFk`, `status`, `created`)
|
INSERT INTO `util`.`notificationQueue` (`id`, `notificationFk`, `params`, `authorFk`, `status`, `created`)
|
||||||
|
|
Loading…
Reference in New Issue