2510-client-address-create-test #418

Merged
jgallego merged 11 commits from 2510-client-address-create-test into dev 2020-11-02 07:53:55 +00:00
2 changed files with 58 additions and 16 deletions
Showing only changes of commit 31b5a140d4 - Show all commits

View File

@ -412,7 +412,8 @@ INSERT INTO `vn`.`addressObservation`(`id`,`addressFk`,`observationTypeFk`,`desc
VALUES VALUES
(1, 121, 1, 'under the floor'), (1, 121, 1, 'under the floor'),
(2, 121, 2, 'wears leather and goes out at night'), (2, 121, 2, 'wears leather and goes out at night'),
(3, 121, 3, 'care with the dog'); (3, 121, 3, 'care with the dog'),
(5, 122, 5, 'Delivery after 10am');
INSERT INTO `vn`.`creditClassification`(`id`, `client`, `dateStart`, `dateEnd`) INSERT INTO `vn`.`creditClassification`(`id`, `client`, `dateStart`, `dateEnd`)
VALUES VALUES
@ -606,7 +607,8 @@ INSERT INTO `vn`.`ticketObservation`(`id`, `ticketFk`, `observationTypeFk`, `des
(8, 23, 2, 'wears leather and goes out at night'), (8, 23, 2, 'wears leather and goes out at night'),
(9, 23, 3, 'care with the dog'), (9, 23, 3, 'care with the dog'),
(10, 23, 4, 'Reclama ticket: 8'), (10, 23, 4, 'Reclama ticket: 8'),
(11, 24, 4, 'Reclama ticket: 7'); (11, 24, 4, 'Reclama ticket: 7'),
(12, 11, 5, 'Delivery after 10am');
-- FIX for state hours on local, inter_afterInsert -- FIX for state hours on local, inter_afterInsert
UPDATE vncontrol.inter SET odbc_date = DATE_ADD(CURDATE(), INTERVAL -10 SECOND); UPDATE vncontrol.inter SET odbc_date = DATE_ADD(CURDATE(), INTERVAL -10 SECOND);

View File

@ -97,11 +97,11 @@ describe('ticket componentUpdate()', () => {
expect(firstvalueBeforeChange).toEqual(firstvalueAfterChange); expect(firstvalueBeforeChange).toEqual(firstvalueAfterChange);
expect(secondvalueBeforeChange).toEqual(secondvalueAfterChange); expect(secondvalueBeforeChange).toEqual(secondvalueAfterChange);
}); });
});
it('should change the addressFk to modify the observations and then undo the changes', async() => { it('should change the addressFk and check that delivery observations have been changed and then undo the changes', async() => {
const clientID = 102; const clientID = 102;
const addressID = 122; const addressID = 122;
const newAddressID = 2;
const agencyModeID = 8; const agencyModeID = 8;
const warehouseID = 1; const warehouseID = 1;
const zoneID = 5; const zoneID = 5;
@ -110,7 +110,47 @@ it('should change the addressFk to modify the observations and then undo the cha
const isDeleted = false; const isDeleted = false;
const landed = tomorrow; const landed = tomorrow;
const option = 1; const option = 1;
const ctx = {
args: {clientFk: clientID,
agencyModeFk: agencyModeID},
req: {
accessToken: {userId: userID},
headers: {origin: 'http://localhost'},
__: value => {
return value;
}
}
};
const observationTypeDelivery = await app.models.ObservationType.findOne({
where: {code: 'delivery'}
});
const ticketObservation = await app.models.TicketObservation.findOne({
where: {
ticketFk: ticketID,
observationTypeFk: observationTypeDelivery.id}
});
carlosjr marked this conversation as resolved
Review

expect ticketObservation toBeDefined

expect ticketObservation toBeDefined
await app.models.Ticket.componentUpdate(ctx, ticketID, clientID, agencyModeID, newAddressID,
zoneID, warehouseID, companyID, shipped, landed, isDeleted, option);
const newTicketObservation = await app.models.TicketObservation.findOne({
where: {
ticketFk: ticketID,
observationTypeFk: observationTypeDelivery.id}
});
expect(newTicketObservation).toBeNull();
// restores
await app.models.Ticket.componentUpdate(ctx, ticketID, clientID, agencyModeID, addressID, await app.models.Ticket.componentUpdate(ctx, ticketID, clientID, agencyModeID, addressID,
zoneID, warehouseID, companyID, shipped, landed, isDeleted, option); zoneID, warehouseID, companyID, shipped, landed, isDeleted, option);
const restoredTicketObservation = await app.models.TicketObservation.findOne({
where: {
ticketFk: ticketID,
observationTypeFk: observationTypeDelivery.id}
});
expect(restoredTicketObservation.description).toEqual(ticketObservation.description);
carlosjr marked this conversation as resolved
Review

originalTicketObervation

originalTicketObervation
});
}); });