148 lines
5.8 KiB
JavaScript
148 lines
5.8 KiB
JavaScript
import selectors from '../../helpers/selectors.js';
|
|
import getBrowser from '../../helpers/puppeteer';
|
|
|
|
describe('Ticket Edit basic data path', () => {
|
|
let browser;
|
|
let page;
|
|
|
|
beforeAll(async() => {
|
|
browser = await getBrowser();
|
|
page = browser.page;
|
|
await page.loginAndModule('employee', 'ticket');
|
|
await page.accessToSearchResult('11');
|
|
await page.accessToSection('ticket.card.basicData.stepOne');
|
|
});
|
|
|
|
afterAll(async() => {
|
|
await browser.close();
|
|
});
|
|
|
|
it(`should confirm the zone autocomplete is disabled unless your role is productionBoss`, async() => {
|
|
await page.waitForSelector(selectors.ticketBasicData.zone, {});
|
|
const disabled = await page.evaluate(selector => {
|
|
return document.querySelector(selector).disabled;
|
|
}, `${selectors.ticketBasicData.zone} input`);
|
|
|
|
expect(disabled).toBeTruthy();
|
|
});
|
|
|
|
it(`should now log as productionBoss to perform the rest of the tests`, async() => {
|
|
await page.loginAndModule('productionBoss', 'ticket');
|
|
await page.accessToSearchResult('11');
|
|
await page.accessToSection('ticket.card.basicData.stepOne');
|
|
});
|
|
|
|
it(`should confirm the zone autocomplete is enabled for the role productionBoss`, async() => {
|
|
await page.waitForSpinnerLoad();
|
|
await page.waitForSelector(selectors.ticketBasicData.zone);
|
|
const disabled = await page.evaluate(selector => {
|
|
return document.querySelector(selector).disabled;
|
|
}, `${selectors.ticketBasicData.zone} input`);
|
|
|
|
expect(disabled).toBeFalsy();
|
|
});
|
|
|
|
it(`should check the zone is for Silla247`, async() => {
|
|
let zone = await page
|
|
.waitToGetProperty(selectors.ticketBasicData.zone, 'value');
|
|
|
|
expect(zone).toContain('Zone 247 A');
|
|
});
|
|
|
|
it(`should edit the ticket agency then check there are no zones for it`, async() => {
|
|
await page.autocompleteSearch(selectors.ticketBasicData.agency, 'Super-Man delivery');
|
|
let emptyZone = await page
|
|
.expectPropertyValue(selectors.ticketBasicData.zone, 'value', '');
|
|
|
|
expect(emptyZone).toBeTruthy();
|
|
});
|
|
|
|
it(`should edit the ticket zone then check the agency is for the new zone`, async() => {
|
|
await page.clearInput(selectors.ticketBasicData.agency);
|
|
await page.autocompleteSearch(selectors.ticketBasicData.zone, 'Zone expensive A');
|
|
let zone = await page
|
|
.waitToGetProperty(selectors.ticketBasicData.agency, 'value');
|
|
|
|
expect(zone).toContain('Silla247Expensive');
|
|
});
|
|
|
|
it(`should click next`, async() => {
|
|
await page.waitToClick(selectors.ticketBasicData.nextStepButton);
|
|
await page.waitForState('ticket.card.basicData.stepTwo');
|
|
});
|
|
|
|
it(`should have a price diference`, async() => {
|
|
const result = await page
|
|
.waitToGetProperty(selectors.ticketBasicData.stepTwoTotalPriceDif, 'innerText');
|
|
|
|
expect(result).toContain('-€232.75');
|
|
});
|
|
|
|
it(`should select a new reason for the changes made then click on finalize`, async() => {
|
|
await page.waitToClick(selectors.ticketBasicData.chargesReason);
|
|
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);
|
|
});
|
|
});
|