Merge pull request 'fix test updateVolume' (#525) from 2735-test_route_updateVolume into dev
gitea/salix/pipeline/head This commit looks good Details

Reviewed-on: #525
Reviewed-by: Joan Sanchez <joan@verdnatura.es>
This commit is contained in:
Joan Sanchez 2021-01-27 06:25:12 +00:00
commit 7b85b968f2
1 changed files with 3 additions and 4 deletions

View File

@ -1,8 +1,7 @@
const app = require('vn-loopback/server/server'); const app = require('vn-loopback/server/server');
const LoopBackContext = require('loopback-context'); const LoopBackContext = require('loopback-context');
// #2735 route updateVolume() returns inconsistent values describe('route updateVolume()', () => {
xdescribe('route updateVolume()', () => {
const routeId = 1; const routeId = 1;
const userId = 50; const userId = 50;
const activeCtx = { const activeCtx = {
@ -19,7 +18,6 @@ xdescribe('route updateVolume()', () => {
expect(route.m3).toEqual(1.8); expect(route.m3).toEqual(1.8);
const ticket = await app.models.Ticket.findById(14); const ticket = await app.models.Ticket.findById(14);
await ticket.updateAttributes({routeFk: routeId}); await ticket.updateAttributes({routeFk: routeId});
await app.models.Route.updateVolume(ctx, routeId); await app.models.Route.updateVolume(ctx, routeId);
@ -30,7 +28,8 @@ xdescribe('route updateVolume()', () => {
const logs = await app.models.RouteLog.find({fields: ['id', 'newInstance']}); const logs = await app.models.RouteLog.find({fields: ['id', 'newInstance']});
const m3Log = logs.filter(log => { const m3Log = logs.filter(log => {
return log.newInstance.m3 === updatedRoute.m3; if (log.newInstance)
return log.newInstance.m3 === updatedRoute.m3;
}); });
const logIdToDestroy = m3Log[0].id; const logIdToDestroy = m3Log[0].id;