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');
|
|
|
|
await page.accessToSearchResult('16');
|
|
|
|
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
|
|
|
});
|
|
|
|
|
2019-01-07 09:55:23 +00:00
|
|
|
it(`should add a new request`, async() => {
|
2020-01-23 15:01:29 +00:00
|
|
|
await page.waitToClick(selectors.ticketRequests.addRequestButton);
|
|
|
|
await page.write(selectors.ticketRequests.descriptionInput, 'New stuff');
|
|
|
|
await page.write(selectors.ticketRequests.quantityInput, '99');
|
|
|
|
await page.autocompleteSearch(selectors.ticketRequests.atenderAutocomplete, 'buyerNick');
|
|
|
|
await page.write(selectors.ticketRequests.priceInput, '999');
|
|
|
|
await page.waitToClick(selectors.ticketRequests.saveButton);
|
|
|
|
const result = await page.waitForLastSnackbar();
|
2018-11-13 15:30:19 +00:00
|
|
|
|
|
|
|
expect(result).toEqual('Data saved!');
|
|
|
|
});
|
|
|
|
|
2019-01-07 09:55:23 +00:00
|
|
|
it(`should have been redirected to the request index`, async() => {
|
2020-01-23 15:01:29 +00:00
|
|
|
await page.waitForURL('/request');
|
|
|
|
const url = await page.parsedUrl();
|
2018-11-13 15:30:19 +00:00
|
|
|
|
2018-11-22 14:44:33 +00:00
|
|
|
expect(url.hash).toContain('/request');
|
2018-11-13 15:30:19 +00:00
|
|
|
});
|
|
|
|
|
2019-01-07 09:55:23 +00:00
|
|
|
it(`should confirm the new request was added`, async() => {
|
2020-01-23 15:01:29 +00:00
|
|
|
await page.reloadSection('ticket.card.request.index');
|
|
|
|
const result = await page.waitToGetProperty(selectors.ticketRequests.firstDescription, 'innerText');
|
2018-11-13 15:30:19 +00:00
|
|
|
|
2018-11-21 13:09:22 +00:00
|
|
|
expect(result).toEqual('New stuff');
|
2018-11-13 15:30:19 +00:00
|
|
|
});
|
|
|
|
|
2019-01-07 09:55:23 +00:00
|
|
|
it(`should delete the added request`, async() => {
|
2020-01-23 15:01:29 +00:00
|
|
|
await page.waitToClick(selectors.ticketRequests.firstRemoveRequestButton);
|
|
|
|
const result = await page.waitForLastSnackbar();
|
2018-11-13 15:30:19 +00:00
|
|
|
|
|
|
|
expect(result).toEqual('Data saved!');
|
|
|
|
});
|
|
|
|
|
2019-01-07 09:55:23 +00:00
|
|
|
it(`should confirm 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);
|
|
|
|
await page.waitForSelector(selectors.ticketRequests.request, {hidden: true});
|
2018-11-13 15:30:19 +00:00
|
|
|
});
|
|
|
|
});
|