4797-lilium-worker-notifications #1229

Merged
pau merged 37 commits from 4797-lilium-worker-notifications into dev 2023-02-02 08:53:29 +00:00
1 changed files with 22 additions and 0 deletions
Showing only changes of commit a425d54bf6 - Show all commits

View File

@ -0,0 +1,22 @@
const app = require('vn-loopback/server/server');
pau marked this conversation as resolved Outdated
Outdated
Review

const models = require('vn-loopback/server/server').models;

const models = require('vn-loopback/server/server').models;
describe('loopback model NotificationSubscription', () => {
it('Should fail to delete a notification if the user is not editing itself or a subordinate', async() => {
pau marked this conversation as resolved
Review

Poner un caso en el que te deje si eres tu mismo y otro que te deje si es tu jefe, te hará falta transaccionar la ruta para poder deshacer el delete

Poner un caso en el que te deje si eres tu mismo y otro que te deje si es tu jefe, te hará falta transaccionar la ruta para poder deshacer el delete
const user = 9;
const notificationSubscriptionId = 2;
const ctx = {req: {accessToken: {userId: user}}};
const models = app.models;
const notification = await models.NotificationSubscription.findById(notificationSubscriptionId);
let error;
try {
await models.NotificationSubscription.deleteNotification(ctx, notification.id);
} catch (e) {
error = e;
}
expect(error.message).toContain('You dont have permission to modify this user');
});
});