feat: refs #5919 back test

This commit is contained in:
Jorge Penadés 2024-05-13 13:19:28 +02:00
parent 29e3f934af
commit e16e5e3db3
2 changed files with 59 additions and 1 deletions

View File

@ -3789,4 +3789,6 @@ INSERT INTO vn.workerTeam(id, team, workerFk)
(8, 1, 19);
INSERT INTO vn.workCenter (id, name, payrollCenterFk, counter, warehouseFk, street, geoFk, deliveryManAdjustment)
VALUES(100, 'workCenterOne', 1, NULL, 1, 'gotham', NULL, NULL);
VALUES(100, 'workCenterOne', 1, NULL, 1, 'gotham', NULL, NULL);
UPDATE vn.locker SET workerFk = 1110 WHERE id = 147;

View File

@ -0,0 +1,56 @@
const {models} = require('vn-loopback/server/server');
fdescribe('locker model ', () => {
const productionBossId = 50;
const hrBuyerId = 124;
const hrId = 37;
const jessicaJonesId = 1110;
const bruceBannerId = 1109;
const lockerMaleId = 1;
const lockerFemaleId = 147;
let ctx;
let options;
let tx;
beforeEach(async() => {
ctx = {
req: {
accessToken: {userId: hrId},
headers: {origin: 'http://localhost'}
},
};
options = {transaction: tx};
tx = await models.Locker.beginTransaction({});
options.transaction = tx;
});
afterEach(async() => {
await tx.rollback();
});
it('should allocate a locker', async() => {
ctx.req.accessToken.userId = productionBossId;
const locker = await models.Locker.findById(lockerMaleId, null, options);
await locker.updateAttributes({workerFk: bruceBannerId}, options);
expect(locker.workerFk).toEqual(bruceBannerId);
});
it('should take away a locker', async() => {
ctx.req.accessToken.userId = hrBuyerId;
const locker = await models.Locker.findById(lockerFemaleId, null, options);
await locker.updateAttributes({workerFk: null}, options);
expect(locker.workerFk).toEqual(null);
});
it('should change a locker', async() => {
const locker = await models.Locker.findById(148, null, options);
await locker.updateAttributes({workerFk: jessicaJonesId}, options);
const oldLocker = await models.Locker.findById(lockerFemaleId, null, options);
expect(locker.workerFk).toEqual(jessicaJonesId);
expect(oldLocker.workerFk).toEqual(null);
});
});