Updated back unit test
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
052c51cee5
commit
1e4f36b775
|
@ -112,7 +112,7 @@ module.exports = Self => {
|
||||||
otherTicketId = ticket.ship().id;
|
otherTicketId = ticket.ship().id;
|
||||||
|
|
||||||
if (otherTicketId) {
|
if (otherTicketId) {
|
||||||
models.TicketTracking.changeState(ctx, {
|
await models.TicketTracking.changeState(ctx, {
|
||||||
ticketFk: otherTicketId,
|
ticketFk: otherTicketId,
|
||||||
code: 'FIXING'
|
code: 'FIXING'
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,6 +4,7 @@ const models = app.models;
|
||||||
describe('ticket deleted()', () => {
|
describe('ticket deleted()', () => {
|
||||||
let ticket;
|
let ticket;
|
||||||
let sale;
|
let sale;
|
||||||
|
let deletedClaim;
|
||||||
|
|
||||||
beforeAll(async done => {
|
beforeAll(async done => {
|
||||||
let originalTicket = await models.Ticket.findOne({where: {id: 16}});
|
let originalTicket = await models.Ticket.findOne({where: {id: 16}});
|
||||||
|
@ -27,8 +28,36 @@ describe('ticket deleted()', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
afterAll(async done => {
|
afterAll(async done => {
|
||||||
|
const ticketId = 16;
|
||||||
|
const stowawayTicketId = 17;
|
||||||
|
const ctx = {
|
||||||
|
req: {
|
||||||
|
accessToken: {userId: 106},
|
||||||
|
headers: {
|
||||||
|
origin: 'http://localhost:5000'
|
||||||
|
},
|
||||||
|
__: () => {}
|
||||||
|
}
|
||||||
|
};
|
||||||
await models.Ticket.destroyById(ticket.id);
|
await models.Ticket.destroyById(ticket.id);
|
||||||
|
const stowaway = await models.Stowaway.findOne({
|
||||||
|
where: {
|
||||||
|
id: stowawayTicketId,
|
||||||
|
shipFk: ticketId
|
||||||
|
}
|
||||||
|
});
|
||||||
|
await stowaway.destroy();
|
||||||
|
await models.Claim.create(deletedClaim);
|
||||||
|
await models.TicketTracking.changeState(ctx, {
|
||||||
|
ticketFk: ticketId,
|
||||||
|
code: 'OK'
|
||||||
|
});
|
||||||
|
await models.TicketTracking.changeState(ctx, {
|
||||||
|
ticketFk: stowawayTicketId,
|
||||||
|
code: 'OK'
|
||||||
|
});
|
||||||
|
const orgTicket = await models.Ticket.findById(ticketId);
|
||||||
|
await orgTicket.updateAttribute('isDeleted', false);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -104,8 +133,10 @@ describe('ticket deleted()', () => {
|
||||||
expect(error.message).toEqual('You must delete the claim id %d first');
|
expect(error.message).toEqual('You must delete the claim id %d first');
|
||||||
});
|
});
|
||||||
|
|
||||||
fit('should delete the ticket and change the state to "FIXING" to the stowaway ticket', async() => {
|
it('should delete the ticket and change the state to "FIXING" to the stowaway ticket', async() => {
|
||||||
const ticketId = 16;
|
const ticketId = 16;
|
||||||
|
const claimIdToRemove = 2;
|
||||||
|
const stowawayTicketId = 17;
|
||||||
const ctx = {
|
const ctx = {
|
||||||
req: {
|
req: {
|
||||||
accessToken: {userId: 106},
|
accessToken: {userId: 106},
|
||||||
|
@ -115,15 +146,21 @@ describe('ticket deleted()', () => {
|
||||||
__: () => {}
|
__: () => {}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let error;
|
|
||||||
|
|
||||||
try {
|
await app.models.Stowaway.rawSql(`
|
||||||
await app.models.Ticket.setDeleted(ctx, ticketId);
|
INSERT INTO vn.stowaway(id, shipFk)
|
||||||
} catch (e) {
|
VALUES (?, ?)`, [stowawayTicketId, ticketId]);
|
||||||
error = e;
|
|
||||||
}
|
|
||||||
|
|
||||||
expect(error.translateArgs[0]).toEqual(2);
|
deletedClaim = await app.models.Claim.findById(claimIdToRemove);
|
||||||
expect(error.message).toEqual('You must delete the claim id %d first');
|
await app.models.Claim.destroyById(claimIdToRemove);
|
||||||
|
await app.models.Ticket.setDeleted(ctx, ticketId);
|
||||||
|
|
||||||
|
const stowawayTicket = await app.models.TicketState.findOne({
|
||||||
|
where: {
|
||||||
|
ticketFk: stowawayTicketId
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(stowawayTicket.code).toEqual('FIXING');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -17,6 +17,9 @@
|
||||||
},
|
},
|
||||||
"alertLevel": {
|
"alertLevel": {
|
||||||
"type": "Number"
|
"type": "Number"
|
||||||
|
},
|
||||||
|
"code": {
|
||||||
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"relations": {
|
"relations": {
|
||||||
|
|
Loading…
Reference in New Issue