2018-11-13 15:30:19 +00:00
|
|
|
import selectors from '../../helpers/selectors.js';
|
2020-01-23 15:01:29 +00:00
|
|
|
import getBrowser from '../../helpers/puppeteer';
|
2018-11-13 15:30:19 +00:00
|
|
|
|
2018-11-21 13:09:22 +00:00
|
|
|
describe('Ticket purchase request path', () => {
|
2020-01-23 15:01:29 +00:00
|
|
|
let browser;
|
|
|
|
let page;
|
|
|
|
|
|
|
|
beforeAll(async() => {
|
|
|
|
browser = await getBrowser();
|
|
|
|
page = browser.page;
|
|
|
|
await page.loginAndModule('salesPerson', 'ticket');
|
2020-02-27 06:17:09 +00:00
|
|
|
await page.accessToSearchResult('1');
|
2020-01-23 15:01:29 +00:00
|
|
|
await page.accessToSection('ticket.card.request.index');
|
|
|
|
});
|
2018-11-13 15:30:19 +00:00
|
|
|
|
2020-01-23 15:01:29 +00:00
|
|
|
afterAll(async() => {
|
|
|
|
await browser.close();
|
2018-11-13 15:30:19 +00:00
|
|
|
});
|
|
|
|
|
2020-02-27 06:17:09 +00:00
|
|
|
it('should add a new request', async() => {
|
2020-08-28 17:52:54 +00:00
|
|
|
await page.waitFor(500);
|
2020-01-23 15:01:29 +00:00
|
|
|
await page.waitToClick(selectors.ticketRequests.addRequestButton);
|
|
|
|
await page.write(selectors.ticketRequests.descriptionInput, 'New stuff');
|
2020-02-27 06:17:09 +00:00
|
|
|
await page.write(selectors.ticketRequests.quantity, '9');
|
2020-02-03 14:55:11 +00:00
|
|
|
await page.autocompleteSearch(selectors.ticketRequests.atender, 'buyerNick');
|
|
|
|
await page.write(selectors.ticketRequests.price, '999');
|
2020-01-23 15:01:29 +00:00
|
|
|
await page.waitToClick(selectors.ticketRequests.saveButton);
|
2020-04-08 09:24:40 +00:00
|
|
|
const message = await page.waitForSnackbar();
|
2018-11-13 15:30:19 +00:00
|
|
|
|
2020-10-30 16:09:11 +00:00
|
|
|
expect(message.text).toBe('Data saved!');
|
2018-11-13 15:30:19 +00:00
|
|
|
});
|
|
|
|
|
2020-02-27 06:17:09 +00:00
|
|
|
it('should have been redirected to the request index', async() => {
|
2020-03-24 15:49:36 +00:00
|
|
|
await page.waitForState('ticket.card.request.index');
|
2018-11-13 15:30:19 +00:00
|
|
|
});
|
|
|
|
|
2020-02-27 06:17:09 +00:00
|
|
|
it(`should edit the third request quantity as it's state is still new`, async() => {
|
|
|
|
await page.write(selectors.ticketRequests.thirdRequestQuantity, '9');
|
|
|
|
await page.keyboard.press('Enter');
|
2020-04-08 09:24:40 +00:00
|
|
|
const message = await page.waitForSnackbar();
|
2020-02-27 06:17:09 +00:00
|
|
|
|
2020-10-30 16:09:11 +00:00
|
|
|
expect(message.text).toBe('Data saved!');
|
2020-02-27 06:17:09 +00:00
|
|
|
});
|
|
|
|
|
2020-10-30 09:45:55 +00:00
|
|
|
it('should check the new request was added', async() => {
|
2020-01-23 15:01:29 +00:00
|
|
|
await page.reloadSection('ticket.card.request.index');
|
2020-02-27 06:17:09 +00:00
|
|
|
const result = await page.waitToGetProperty(selectors.ticketRequests.thirdRequestQuantity, 'value');
|
|
|
|
|
|
|
|
expect(result).toEqual('99');
|
|
|
|
});
|
|
|
|
|
2020-10-30 09:45:55 +00:00
|
|
|
it(`should check the first request can't be edited as its state is different to new`, async() => {
|
2020-02-27 06:17:09 +00:00
|
|
|
await page.waitForClassPresent(selectors.ticketRequests.firstRequestQuantity, 'disabled');
|
|
|
|
const result = await page.isDisabled(selectors.ticketRequests.firstRequestQuantity);
|
|
|
|
|
|
|
|
expect(result).toBe(true);
|
|
|
|
});
|
|
|
|
|
2020-10-30 09:45:55 +00:00
|
|
|
it(`should check the second request can't be edited as its state is different to new`, async() => {
|
2020-02-27 06:17:09 +00:00
|
|
|
await page.waitForClassPresent(selectors.ticketRequests.secondRequestQuantity, 'disabled');
|
|
|
|
const result = await page.isDisabled(selectors.ticketRequests.secondRequestQuantity);
|
2018-11-13 15:30:19 +00:00
|
|
|
|
2020-02-27 06:17:09 +00:00
|
|
|
expect(result).toBe(true);
|
2018-11-13 15:30:19 +00:00
|
|
|
});
|
|
|
|
|
2020-02-27 06:17:09 +00:00
|
|
|
it('should delete the added request', async() => {
|
|
|
|
await page.waitToClick(selectors.ticketRequests.thirdRemoveRequestButton);
|
2020-04-08 09:24:40 +00:00
|
|
|
const message = await page.waitForSnackbar();
|
2018-11-13 15:30:19 +00:00
|
|
|
|
2020-10-30 16:09:11 +00:00
|
|
|
expect(message.text).toBe('Data saved!');
|
2018-11-13 15:30:19 +00:00
|
|
|
});
|
|
|
|
|
2020-10-30 09:45:55 +00:00
|
|
|
it('should check the request was deleted', async() => {
|
2020-01-23 15:01:29 +00:00
|
|
|
await page.reloadSection('ticket.card.request.index');
|
|
|
|
await page.wait(selectors.ticketRequests.addRequestButton);
|
2020-02-27 06:17:09 +00:00
|
|
|
await page.waitForSelector(selectors.ticketRequests.thirdDescription, {hidden: true});
|
2018-11-13 15:30:19 +00:00
|
|
|
});
|
|
|
|
});
|