test(ticket_basic-data): test and fixtures
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Alex Moreno 2021-12-21 20:58:58 +01:00
parent 7a7bcf217a
commit 18b6efe8f1
11 changed files with 103 additions and 20 deletions

View File

@ -622,6 +622,7 @@ INSERT INTO `vn`.`ticket`(`id`, `priority`, `agencyModeFk`,`warehouseFk`,`routeF
(25 ,NULL, 8, 1, NULL, CURDATE(), CURDATE(), 1101, 'Bruce Wayne', 1, NULL, 0, 1, 5, 1, CURDATE()),
(26 ,NULL, 8, 1, NULL, CURDATE(), CURDATE(), 1101, 'An incredibly long alias for testing purposes', 1, NULL, 0, 1, 5, 1, CURDATE()),
(27 ,NULL, 8, 1, NULL, CURDATE(), CURDATE(), 1101, 'Wolverine', 1, NULL, 0, 1, 5, 1, CURDATE());
INSERT INTO `vn`.`ticketObservation`(`id`, `ticketFk`, `observationTypeFk`, `description`)
VALUES
(1, 11, 1, 'ready'),
@ -665,7 +666,9 @@ INSERT INTO `vn`.`ticketTracking`(`ticketFk`, `stateFk`, `workerFk`, `created`)
(21, 1, 19, DATE_ADD(NOW(), INTERVAL +1 MONTH)),
(22, 1, 19, DATE_ADD(NOW(), INTERVAL +1 MONTH)),
(23, 16, 21, NOW()),
(24, 16, 21, NOW());
(24, 16, 21, NOW()),
(27, 3, 21, NOW());
INSERT INTO `vn`.`stowaway`(`id`, `shipFk`, `created`)
VALUES
@ -896,7 +899,9 @@ INSERT INTO `vn`.`sale`(`id`, `itemFk`, `ticketFk`, `concept`, `quantity`, `pric
(29, 4, 17, 'Melee weapon heavy shield 1x0.5m', 20, 1.72, 0, 0, 0, CURDATE()),
(30, 4, 18, 'Melee weapon heavy shield 1x0.5m', 20, 1.72, 0, 0, 0, CURDATE()),
(31, 2, 23, 'Melee weapon combat fist 15cm', -5, 7.08, 0, 0, 0, CURDATE()),
(32, 1, 24, 'Ranged weapon longbow 2m', -1, 8.07, 0, 0, 0, CURDATE());
(32, 1, 24, 'Ranged weapon longbow 2m', -1, 8.07, 0, 0, 0, CURDATE()),
(33, 4, 27, 'Melee weapon combat fist 15cm', 1, 8.07, 0, 0, 0, CURDATE()),
(34, 5, 27, 'Ranged weapon pistol 9mm', 50, 1.79, 0, 0, 0, CURDATE());
INSERT INTO `vn`.`saleChecked`(`saleFk`, `isChecked`)
VALUES

View File

@ -525,6 +525,7 @@ export default {
acceptDialog: '.vn-dialog.shown button[response="accept"]',
acceptChangeHourButton: '.vn-dialog.shown button[response="accept"]',
descriptorDeliveryDate: 'vn-ticket-descriptor slot-body > .attributes > vn-label-value:nth-child(4) > section > span',
descriptorDeliveryAgency: 'vn-ticket-descriptor slot-body > .attributes > vn-label-value:nth-child(5) > section > span',
acceptInvoiceOutButton: '.vn-confirm.shown button[response="accept"]',
acceptDeleteStowawayButton: '.vn-dialog.shown button[response="accept"]'
},
@ -562,6 +563,7 @@ export default {
transferQuantityInput: '.vn-popover.shown vn-table > div > vn-tbody > vn-tr > vn-td-editable > span > text',
transferQuantityCell: '.vn-popover.shown vn-table > div > vn-tbody > vn-tr > vn-td-editable',
firstSaleId: 'vn-ticket-sale vn-tbody > vn-tr:nth-child(1) > vn-td:nth-child(6) > span',
firstSaleText: 'vn-table div > vn-tbody > vn-tr:nth-child(1)',
firstSaleClaimIcon: 'vn-ticket-sale vn-table vn-tbody > vn-tr:nth-child(1) vn-icon[icon="icon-claims"]',
firstSaleDescriptorImage: '.vn-popover.shown vn-item-descriptor img',
firstSaleThumbnailImage: 'vn-ticket-sale:nth-child(1) vn-tr:nth-child(1) vn-td:nth-child(3) > img',
@ -601,10 +603,12 @@ export default {
ticketBasicData: {
agency: 'vn-autocomplete[ng-model="$ctrl.agencyModeId"]',
zone: 'vn-autocomplete[ng-model="$ctrl.zoneId"]',
shipped: 'vn-date-picker[ng-model="$ctrl.shipped"]',
nextStepButton: 'vn-step-control .buttons > section:last-child vn-button',
finalizeButton: 'vn-step-control .buttons > section:last-child button[type=submit]',
stepTwoTotalPriceDif: 'vn-ticket-basic-data-step-two > vn-side-menu div:nth-child(4)',
chargesReason: 'vn-ticket-basic-data-step-two div:nth-child(3) > vn-radio',
withoutNegatives: 'vn-check[ng-model="$ctrl.ticket.withoutNegatives"]',
},
ticketComponents: {
base: 'vn-ticket-components > vn-side-menu div:nth-child(1) > div:nth-child(2)'

View File

@ -83,4 +83,65 @@ describe('Ticket Edit basic data path', () => {
await page.waitToClick(selectors.ticketBasicData.finalizeButton);
await page.waitForState('ticket.card.summary');
});
it(`should not find ticket`, async() => {
await page.doSearch('28');
const count = await page.countElement(selectors.ticketsIndex.searchResult);
expect(count).toEqual(0);
});
it(`should split ticket without negatives`, async() => {
const tomorrow = new Date();
tomorrow.setDate(tomorrow.getDate() + 1);
await page.accessToSearchResult('14');
await page.accessToSection('ticket.card.basicData.stepOne');
const originalDate = await page
.waitToGetProperty(selectors.ticketDescriptor.descriptorDeliveryDate, 'innerText');
const originalAgency = await page
.waitToGetProperty(selectors.ticketDescriptor.descriptorDeliveryAgency, 'innerText');
await page.autocompleteSearch(selectors.ticketBasicData.agency, 'Silla247');
await page.pickDate(selectors.ticketBasicData.shipped, tomorrow);
await page.waitToClick(selectors.ticketBasicData.nextStepButton);
await page.waitToClick(selectors.ticketBasicData.withoutNegatives);
await page.waitToClick(selectors.ticketBasicData.finalizeButton);
const resultDate = await page
.waitToGetProperty(selectors.ticketDescriptor.descriptorDeliveryDate, 'innerText');
const resultAgency = await page
.waitToGetProperty(selectors.ticketDescriptor.descriptorDeliveryAgency, 'innerText');
expect(resultDate).toEqual(originalDate);
expect(resultAgency).toEqual(originalAgency);
});
it(`should new ticket have one line from splited ticket`, async() => {
const tomorrow = new Date();
tomorrow.setDate(tomorrow.getDate() + 1);
const expectedDay = tomorrow.getDate();
const expectedMonth = tomorrow.getMonth() + 1;
const expectedYear = tomorrow.getFullYear();
await page.accessToSearchResult('28');
await page.accessToSection('ticket.card.sale');
const item = await page.waitToGetProperty(selectors.ticketSales.firstSaleId, 'innerText');
const agency = await page
.waitToGetProperty(selectors.ticketDescriptor.descriptorDeliveryAgency, 'innerText');
let date = await page
.waitToGetProperty(selectors.ticketDescriptor.descriptorDeliveryDate, 'innerText');
date = date.split(' ');
date = date[0].split('/');
expect(item).toEqual('4');
expect(agency).toEqual('Silla247');
expect(date[0]).toContain(expectedDay);
expect(date[1]).toContain(expectedMonth);
expect(date[2]).toContain(expectedYear);
});
});

View File

@ -119,5 +119,6 @@
"The PDF document does not exists": "The PDF document does not exists. Try regenerating it from 'Regenerate invoice PDF' option",
"This item is not available": "This item is not available",
"Deny buy request": "Purchase request for ticket id [{{ticketId}}]({{{url}}}) has been rejected. Reason: {{observation}}",
"The type of business must be filled in basic data": "The type of business must be filled in basic data"
"The type of business must be filled in basic data": "The type of business must be filled in basic data",
"isWithoutNegatives": "isWithoutNegatives"
}

View File

@ -118,15 +118,14 @@ module.exports = Self => {
const isProductionBoss = await models.Account.hasRole(userId, 'productionBoss', myOptions);
if (!isProductionBoss) {
const params = [args.landed, args.addressFk, args.agencyModeFk, args.warehouseFk];
const zoneShipped = await models.Agency.getShipped(params, myOptions);
const zoneShipped = await models.Agency.getShipped(args.landed, args.addressFk, args.agencyModeFk, args.warehouseFk, myOptions);
if (!zoneShipped || zoneShipped.zoneFk != args.zoneFk)
throw new UserError(`You don't have privileges to change the zone`);
}
if (args.isWithoutNegatives) {
let query = `CALL ticket_getVisibleAvailable(?,?)`;
let params = [args.id, args.shipped];
const query = `CALL ticket_getVisibleAvailable(?,?)`;
const params = [args.id, args.shipped];
const [salesAvailable] = await Self.rawSql(query, params, myOptions);
let salesNewTicket = [];

View File

@ -45,7 +45,8 @@ describe('ticket componentUpdate()', () => {
shipped: today,
landed: tomorrow,
isDeleted: false,
option: 1
option: 1,
isWithoutNegatives: false
};
let ctx = {
@ -94,7 +95,8 @@ describe('ticket componentUpdate()', () => {
shipped: today,
landed: tomorrow,
isDeleted: false,
option: 1
option: 1,
isWithoutNegatives: false
};
const ctx = {

View File

@ -60,7 +60,7 @@ describe('sale priceDifference()', () => {
expect(error).toEqual(new UserError(`The sales of this ticket can't be modified`));
});
it('should return ticket visible', async() => {
it('should return ticket available', async() => {
const tx = await models.Ticket.beginTransaction({});
try {
@ -83,8 +83,8 @@ describe('sale priceDifference()', () => {
const firstItem = result.items[0];
const secondtItem = result.items[1];
expect(firstItem.visible).toEqual(445);
expect(secondtItem.visible).toEqual(1980);
expect(firstItem.available).toEqual(410);
expect(secondtItem.available).toEqual(1870);
await tx.rollback();
} catch (e) {

View File

@ -77,7 +77,8 @@
<div class="totalBox align-left" ng-show="::$ctrl.haveNegatives">
<vn-check
ng-model="$ctrl.ticket.withoutNegatives"
label="Without create negatives">
label="Without create negatives"
info="Clone this ticket with the changes and only sales availables">
</vn-check>
</div>
</div>

View File

@ -75,6 +75,7 @@ class Controller extends Component {
haveNotNegatives = true;
});
this.ticket.withoutNegatives = false;
this.haveNegatives = (haveNegatives && haveNotNegatives);
}

View File

@ -65,14 +65,22 @@ describe('Ticket', () => {
});
});
fdescribe('ticketHaveNegatives()', () => {
it('should show if ticket have any negative', () => {
describe('ticketHaveNegatives()', () => {
it('should show if ticket have any negative and any not negative', () => {
controller.ticket = {
sale: {
items: [{
quantity: 2,
visible: 1
}]
items: [
{
item: 1,
quantity: 2,
available: 1
},
{
item: 2,
quantity: 1,
available: 5
}
]
}
};

View File

@ -6,4 +6,5 @@ The ticket has been unrouted: El ticket ha sido desenrutado
Price: Precio
New price: Nuevo precio
Price difference: Diferencia de precio
Without create negatives: Sin crear negativos
Without create negatives: Sin crear negativos
Clone this ticket with the changes and only sales availables: Clona este ticket con los cambios y solo las ventas disponibles.