7642_createNewState #2736

Closed
sergiodt wants to merge 32 commits from 7642_createNewState into dev
2 changed files with 30 additions and 2 deletions
Showing only changes of commit 97fe9debf6 - Show all commits

View File

@ -1,5 +1,5 @@
-- Place your SQL code here
INSERT INTO vn.state ( name, `order`, alertLevel, code, sectorProdPriority, nextStateFk, isPreviousPreparable, isPicked, isPreparable, semaphore, isPrintable, isOK, graphCategory, isNotValidated, classColor) VALUES('Entregado en parte', 13, 3, 'PARTIALLYDELIVERED', NULL, 16, 0, 1, 0, 0, 0, 0, 0, 0, NULL);
INSERT INTO vn.state ( name, `order`, alertLevel, code, sectorProdPriority, nextStateFk, isPreviousPreparable, isPicked, isPreparable, semaphore, isPrintable, isOK, graphCategory, isNotValidated, classColor) VALUES('Entregado en parte', 13, 3, 'PARTIALLY_DELIVERED', NULL, 16, 0, 1, 0, 0, 0, 0, 0, 0, NULL);

View File

@ -8,7 +8,7 @@ describe('Ticket saveSign()', () => {
accessToken: {userId: 9}
}};
it(`should throw error if the ticket's alert level is lower than 2`, async() => {
fit(`should throw error if the ticket's alert level is lower than 2`, async() => {
const tx = await models.TicketDms.beginTransaction({});
const ticketWithOkState = 12;
let error;
@ -26,4 +26,32 @@ describe('Ticket saveSign()', () => {
expect(error).toBeDefined();
});
fit('should change state for ticket', async() => {
const tx = await models.TicketDms.beginTransaction({});
const ticketWithOkState = 12;
const ticketStateId = 16;
const ticketCode = 'PARTIALLY_DELIVERED';
try {
const options = {transaction: tx};
const tickets = [ticketWithOkState];
const state = await models.State.findById(ticketStateId);
await state.updateAttributes({
code: ticketCode
}, options);
const ticketState = await models.TicketTracking.findById(ticketStateId);
await ticketState.updateAttributes({
code: ticketCode
}, options);
await models.Ticket.saveSign(ctx, tickets, options);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
expect(ticket.toEqual('DELIVERED'));
});
});