8713-testToMaster #3523

Merged
alexm merged 383 commits from 8713-testToMaster into master 2025-03-04 06:52:15 +00:00
3 changed files with 28 additions and 28 deletions
Showing only changes of commit 1c8ad94ab8 - Show all commits

View File

@ -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');

View File

@ -45,11 +45,13 @@ module.exports = Self => {
e.created e.created
FROM expedition e FROM expedition e
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);
}; };
}; };

View File

@ -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; afterEach(async() => {
const from = 1; await tx.rollback();
const to = 2; });
const response = { it('should make the correct API call', async() => {
data: { const expedition = await models.Expedition.findById(15, null, options);
videos: [{ await expedition.updateAttribute('created', '2000-12-01 07:07:00', options);
id: 1,
filename: 'video1.mp4'
}]
}
};
spyOn(axios, 'get').and.returnValue(new Promise(resolve => resolve(response))); const axiosSpy = spyOn(axios, 'get').and.callThrough();
await models.Boxing.getVideoList(expedition.id, undefined, undefined, options);
const result = await models.Boxing.getVideoList(id, from, to, options); const expectedStartTime = '2000-12-01T07:00:00';
const calledUrl = axiosSpy.calls.mostRecent().args[0];
expect(result[0]).toEqual(response.data.videos[0].filename); expect(calledUrl).toContain(`start=${expectedStartTime}`);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
}); });
}); });