8713-testToMaster #3523
|
@ -77,8 +77,8 @@ INSERT INTO `vn`.`agency` (`name`, `warehouseFk`, `isOwn`, `isAnyVolumeAllowed`)
|
||||||
('Otra agencia ', '1', '0', '0');
|
('Otra agencia ', '1', '0', '0');
|
||||||
|
|
||||||
INSERT INTO `vn`.`expedition` (`agencyModeFk`, `ticketFk`, `isBox`, `counter`, `workerFk`, `externalId`, `packagingFk`, `hostFk`, `itemPackingTypeFk`, `hasNewRoute`) VALUES
|
INSERT INTO `vn`.`expedition` (`agencyModeFk`, `ticketFk`, `isBox`, `counter`, `workerFk`, `externalId`, `packagingFk`, `hostFk`, `itemPackingTypeFk`, `hasNewRoute`) VALUES
|
||||||
('1', '1', 1, '1', '1', '1', '1', 'pc00', 'F', 0),
|
('1', '1', 1, '1', '1', '1', '1', 'pc1', 'F', 0),
|
||||||
('1', '1', 1, '2', '1', '1', '1', 'pc00', 'F', 0);
|
('1', '1', 1, '2', '1', '1', '1', 'pc1', 'F', 0);
|
||||||
|
|
||||||
INSERT INTO vn.client (id,name,defaultAddressFk,street,fi,email,dueDay,isTaxDataChecked,accountingAccount,city,provinceFk,postcode,socialName,contact,credit,countryFk,quality,riskCalculated) VALUES
|
INSERT INTO vn.client (id,name,defaultAddressFk,street,fi,email,dueDay,isTaxDataChecked,accountingAccount,city,provinceFk,postcode,socialName,contact,credit,countryFk,quality,riskCalculated) VALUES
|
||||||
(100,'root',110,'Valle de la muerte','74974747G','root@mydomain.com',0,1,'4300000078','ALGEMESI',1,'46680','rootSocial','rootContact',500.0,1,10,'2025-01-01');
|
(100,'root',110,'Valle de la muerte','74974747G','root@mydomain.com',0,1,'4300000078','ALGEMESI',1,'46680','rootSocial','rootContact',500.0,1,10,'2025-01-01');
|
||||||
|
|
|
@ -47,9 +47,11 @@ module.exports = Self => {
|
||||||
JOIN host h ON Convert(h.code USING utf8mb3) COLLATE utf8mb3_unicode_ci = e.hostFk
|
JOIN host h ON Convert(h.code USING utf8mb3) COLLATE utf8mb3_unicode_ci = e.hostFk
|
||||||
JOIN packingSite ps ON ps.hostFk = h.id
|
JOIN packingSite ps ON ps.hostFk = h.id
|
||||||
WHERE e.id = ?;`;
|
WHERE e.id = ?;`;
|
||||||
const [expedition] = await models.PackingSiteConfig.rawSql(query, [id]);
|
|
||||||
|
const [expedition] = await models.PackingSiteConfig.rawSql(query, [id], myOptions);
|
||||||
|
|
||||||
if (!from && !expedition) return [];
|
if (!from && !expedition) return [];
|
||||||
|
|
||||||
let start = new Date(expedition.created);
|
let start = new Date(expedition.created);
|
||||||
let end = new Date(start.getTime() + (packingSiteConfig.avgBoxingTime * 1000));
|
let end = new Date(start.getTime() + (packingSiteConfig.avgBoxingTime * 1000));
|
||||||
|
|
||||||
|
@ -57,9 +59,13 @@ module.exports = Self => {
|
||||||
start.setHours(from, 0, 0);
|
start.setHours(from, 0, 0);
|
||||||
end.setHours(to, 0, 0);
|
end.setHours(to, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
const offset = start.getTimezoneOffset();
|
const offset = start.getTimezoneOffset();
|
||||||
start = new Date(start.getTime() - (offset * 60 * 1000));
|
start = new Date(start.getTime() - (offset * 60 * 1000));
|
||||||
end = new Date(end.getTime() - (offset * 60 * 1000));
|
end = new Date(end.getTime() - (offset * 60 * 1000));
|
||||||
|
const minutes = start.getMinutes();
|
||||||
|
const roundedMinutes = minutes - (minutes % 15);
|
||||||
|
start.setMinutes(roundedMinutes, 0, 0);
|
||||||
|
|
||||||
const videoUrl =
|
const videoUrl =
|
||||||
`/${packingSiteConfig.shinobiToken}/videos/${packingSiteConfig.shinobiGroupKey}/${expedition.monitorId}`;
|
`/${packingSiteConfig.shinobiToken}/videos/${packingSiteConfig.shinobiGroupKey}/${expedition.monitorId}`;
|
||||||
|
@ -73,6 +79,7 @@ module.exports = Self => {
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
return response.data.videos.map(video => video.filename);
|
return response.data.videos.map(video => video.filename);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,35 +2,28 @@ const models = require('vn-loopback/server/server').models;
|
||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
|
|
||||||
describe('boxing getVideoList()', () => {
|
describe('boxing getVideoList()', () => {
|
||||||
it('should return video list', async() => {
|
let tx;
|
||||||
const tx = await models.PackingSiteConfig.beginTransaction({});
|
let options;
|
||||||
|
|
||||||
try {
|
beforeEach(async() => {
|
||||||
const options = {transaction: tx};
|
tx = await models.PackingSiteConfig.beginTransaction({});
|
||||||
|
options = {transaction: tx};
|
||||||
const id = 1;
|
});
|
||||||
const from = 1;
|
|
||||||
const to = 2;
|
|
||||||
|
|
||||||
const response = {
|
|
||||||
data: {
|
|
||||||
videos: [{
|
|
||||||
id: 1,
|
|
||||||
filename: 'video1.mp4'
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
spyOn(axios, 'get').and.returnValue(new Promise(resolve => resolve(response)));
|
|
||||||
|
|
||||||
const result = await models.Boxing.getVideoList(id, from, to, options);
|
|
||||||
|
|
||||||
expect(result[0]).toEqual(response.data.videos[0].filename);
|
|
||||||
|
|
||||||
|
afterEach(async() => {
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
} catch (e) {
|
});
|
||||||
await tx.rollback();
|
|
||||||
throw e;
|
it('should make the correct API call', async() => {
|
||||||
}
|
const expedition = await models.Expedition.findById(15, null, options);
|
||||||
|
await expedition.updateAttribute('created', '2000-12-01 07:07:00', options);
|
||||||
|
|
||||||
|
const axiosSpy = spyOn(axios, 'get').and.callThrough();
|
||||||
|
await models.Boxing.getVideoList(expedition.id, undefined, undefined, options);
|
||||||
|
|
||||||
|
const expectedStartTime = '2000-12-01T07:00:00';
|
||||||
|
const calledUrl = axiosSpy.calls.mostRecent().args[0];
|
||||||
|
|
||||||
|
expect(calledUrl).toContain(`start=${expectedStartTime}`);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue