test(ticket): update to advanceable
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
8e1c3e107c
commit
9ddf11c6bc
|
@ -8,7 +8,7 @@ describe('Ticket Edit basic data path', () => {
|
||||||
beforeAll(async() => {
|
beforeAll(async() => {
|
||||||
browser = await getBrowser();
|
browser = await getBrowser();
|
||||||
page = browser.page;
|
page = browser.page;
|
||||||
await page.loginAndModule('employee', 'ticket');
|
await page.loginAndModule('employee', 'ticket');
|
||||||
await page.accessToSearchResult('11');
|
await page.accessToSearchResult('11');
|
||||||
await page.accessToSection('ticket.card.basicData.stepOne');
|
await page.accessToSection('ticket.card.basicData.stepOne');
|
||||||
});
|
});
|
||||||
|
@ -85,7 +85,7 @@ describe('Ticket Edit basic data path', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it(`should not find ticket`, async() => {
|
it(`should not find ticket`, async() => {
|
||||||
await page.doSearch('28');
|
await page.doSearch('29');
|
||||||
const count = await page.countElement(selectors.ticketsIndex.searchResult);
|
const count = await page.countElement(selectors.ticketsIndex.searchResult);
|
||||||
|
|
||||||
expect(count).toEqual(0);
|
expect(count).toEqual(0);
|
||||||
|
@ -128,8 +128,8 @@ describe('Ticket Edit basic data path', () => {
|
||||||
const expectedMonth = tomorrow.getMonth() + 1;
|
const expectedMonth = tomorrow.getMonth() + 1;
|
||||||
const expectedYear = tomorrow.getFullYear();
|
const expectedYear = tomorrow.getFullYear();
|
||||||
|
|
||||||
await page.loginAndModule('employee', 'ticket');
|
await page.loginAndModule('employee', 'ticket');
|
||||||
await page.accessToSearchResult('28');
|
await page.accessToSearchResult('29');
|
||||||
await page.accessToSection('ticket.card.sale');
|
await page.accessToSection('ticket.card.sale');
|
||||||
|
|
||||||
const item = await page.waitToGetProperty(selectors.ticketSales.firstSaleId, 'innerText');
|
const item = await page.waitToGetProperty(selectors.ticketSales.firstSaleId, 'innerText');
|
||||||
|
|
|
@ -136,4 +136,60 @@ describe('ticket componentUpdate()', () => {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should change warehouse and without negatives', async() => {
|
||||||
|
const tx = await models.SaleComponent.beginTransaction({});
|
||||||
|
|
||||||
|
try {
|
||||||
|
const options = {transaction: tx};
|
||||||
|
|
||||||
|
const saleToTransfer = 27;
|
||||||
|
const originDate = today;
|
||||||
|
const newDate = tomorrow;
|
||||||
|
const ticketID = 14;
|
||||||
|
newDate.setHours(0, 0, 0, 0, 0);
|
||||||
|
originDate.setHours(0, 0, 0, 0, 0);
|
||||||
|
|
||||||
|
const args = {
|
||||||
|
id: ticketID,
|
||||||
|
clientFk: 1104,
|
||||||
|
agencyModeFk: 2,
|
||||||
|
addressFk: 4,
|
||||||
|
zoneFk: 9,
|
||||||
|
warehouseFk: 1,
|
||||||
|
companyFk: 442,
|
||||||
|
shipped: newDate,
|
||||||
|
landed: tomorrow,
|
||||||
|
isDeleted: false,
|
||||||
|
option: 1,
|
||||||
|
isWithoutNegatives: true
|
||||||
|
};
|
||||||
|
|
||||||
|
const ctx = {
|
||||||
|
args: args,
|
||||||
|
req: {
|
||||||
|
accessToken: {userId: 9},
|
||||||
|
headers: {origin: 'http://localhost'},
|
||||||
|
__: value => {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
await models.Ticket.componentUpdate(ctx, options);
|
||||||
|
|
||||||
|
const [newTicketID] = await models.Ticket.rawSql('SELECT MAX(id) as id FROM ticket', null, options);
|
||||||
|
const oldTicket = await models.Ticket.findById(ticketID, null, options);
|
||||||
|
const newTicket = await models.Ticket.findById(newTicketID.id, null, options);
|
||||||
|
const newTicketSale = await models.Sale.findOne({where: {ticketFk: args.id}}, options);
|
||||||
|
|
||||||
|
expect(oldTicket.shipped).toEqual(originDate);
|
||||||
|
expect(newTicket.shipped).toEqual(newDate);
|
||||||
|
expect(newTicketSale.id).toEqual(saleToTransfer);
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -60,7 +60,7 @@ describe('sale priceDifference()', () => {
|
||||||
expect(error).toEqual(new UserError(`The sales of this ticket can't be modified`));
|
expect(error).toEqual(new UserError(`The sales of this ticket can't be modified`));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return ticket available', async() => {
|
it('should return ticket advanceable', async() => {
|
||||||
const tx = await models.Ticket.beginTransaction({});
|
const tx = await models.Ticket.beginTransaction({});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue