feat: refs #6276 WIP test sectorCollection_getSales
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Jorge Penadés 2024-01-23 15:58:09 +01:00
parent 08dd37e9e4
commit ae89d59bde
2 changed files with 38 additions and 14 deletions

View File

@ -1,6 +1,6 @@
const {models} = require('vn-loopback/server/server'); const {models} = require('vn-loopback/server/server');
fdescribe('collection getSalesFromTicketOrCollection()', () => { describe('collection getSalesFromTicketOrCollection()', () => {
const collectionOrTicketFk = 999999; const collectionOrTicketFk = 999999;
const print = true; const print = true;
const source = 'CHECKER'; const source = 'CHECKER';
@ -15,21 +15,45 @@ fdescribe('collection getSalesFromTicketOrCollection()', () => {
}); });
it('should return a collection with tickets, placements and barcodes settled correctly', async() => { it('should return a collection with tickets, placements and barcodes settled correctly', async() => {
const options = {}; const tx = await models.Collection.beginTransaction({});
const collection = await models.Collection.getSalesFromTicketOrCollection(ctx, const options = {transaction: tx};
collectionOrTicketFk, print, source, options); try {
const collection = await models.Collection.getSalesFromTicketOrCollection(ctx,
collectionOrTicketFk, print, source, options);
const [firstTicket] = collection.tickets; const [firstTicket] = collection.tickets;
const [firstSale] = firstTicket.sales; const [firstSale] = firstTicket.sales;
const [firstPlacement] = firstSale.placements; const [firstPlacement] = firstSale.placements;
expect(collection.tickets.length).toBeGreaterThan(0); expect(collection.tickets.length).toBeTruthy();
expect(collection.collectionFk).toEqual(firstTicket.ticketFk); expect(collection.collectionFk).toEqual(firstTicket.ticketFk);
expect(firstSale.ticketFk).toEqual(firstTicket.ticketFk); expect(firstSale.ticketFk).toEqual(firstTicket.ticketFk);
expect(firstSale.placements.length).toBeGreaterThan(0); expect(firstSale.placements.length).toBeTruthy();
expect(firstSale.barcodes.length).toBeGreaterThan(0); expect(firstSale.barcodes.length).toBeTruthy();
expect(firstSale.saleFk).toEqual(firstPlacement.saleFk); expect(firstSale.saleFk).toEqual(firstPlacement.saleFk);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
it('should print a sticker', async() => {
const tx = await models.Collection.beginTransaction({});
const options = {transaction: tx};
try {
const printQueueBefore = await models.Collection.rawSql('SELECT * FROM printQueue', [], options);
await models.Collection.getSalesFromTicketOrCollection(ctx,
collectionOrTicketFk, print, source, options);
const printQueueAfter = await models.Collection.rawSql('SELECT * FROM printQueue', [], options);
expect(printQueueAfter.length).toEqual(printQueueBefore.length + 1);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
}); });
}); });

View File

@ -3713,4 +3713,4 @@ UPDATE vn.buy SET itemOriginalFk = 1 WHERE id = 1;
UPDATE vn.saleTracking SET stateFk = 26 WHERE id = 5; UPDATE vn.saleTracking SET stateFk = 26 WHERE id = 5;
INSERT INTO vn.report (name) VALUES ('LabelCollection') INSERT INTO vn.report (name) VALUES ('LabelCollection');