salix/e2e/paths/ticket-module/04_create_ticket_packages.s...

129 lines
5.3 KiB
JavaScript
Raw Normal View History

2018-04-04 14:41:06 +00:00
import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/helpers';
describe('Ticket', () => {
describe('Create packages path', () => {
const nightmare = createNightmare();
2018-04-04 14:41:06 +00:00
beforeAll(() => {
return nightmare
.waitForLogin('developer');
});
2018-04-04 14:41:06 +00:00
it('should click on the Tickets button of the top bar menu', () => {
return nightmare
.waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible)
.waitToClick(selectors.globalItems.ticketsButton)
.wait(selectors.ticketsIndex.createTicketButton)
.parsedUrl()
.then(url => {
expect(url.hash).toEqual('#!/ticket/list');
});
2018-04-04 14:41:06 +00:00
});
it('should search for the ticket 1', () => {
return nightmare
.wait(selectors.ticketsIndex.searchResult)
.type(selectors.ticketsIndex.searchTicketInput, 1)
.click(selectors.ticketsIndex.searchButton)
.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1)
.countSearchResults(selectors.ticketsIndex.searchResult)
.then(result => {
expect(result).toEqual(1);
});
2018-04-04 14:41:06 +00:00
});
it(`should click on the search result to access to the ticket packages`, () => {
return nightmare
.waitForTextInElement(selectors.ticketsIndex.searchResult, 'Batman')
.waitToClick(selectors.ticketsIndex.searchResult)
.waitToClick(selectors.ticketPackages.packagesButton)
.waitForURL('package/index')
.url()
.then(url => {
expect(url).toContain('package/index');
});
2018-04-04 14:41:06 +00:00
});
it(`should delete the first package and receive and error to save a new one with blank quantity`, () => {
return nightmare
.waitToClick(selectors.ticketPackages.firstRemovePackageButton)
.waitToClick(selectors.ticketPackages.addPackageButton)
.waitToClick(selectors.ticketPackages.firstPackageSelect)
.waitToClick(selectors.ticketPackages.firstPackageSelectOptionThree)
.click(selectors.ticketPackages.savePackagesButton)
.waitForSnackbar()
.then(result => {
expect(result).toContain('Some fields are invalid');
});
2018-04-04 14:41:06 +00:00
});
it(`should attempt create a new package but receive an error if quantity is a string`, () => {
return nightmare
.type(selectors.ticketPackages.firstQuantityInput, 'ninety 9')
.click(selectors.ticketPackages.savePackagesButton)
.waitForSnackbar()
.then(result => {
expect(result).toContain('Some fields are invalid');
});
2018-04-04 14:41:06 +00:00
});
it(`should attempt create a new package but receive an error if quantity is 0`, () => {
return nightmare
.clearInput(selectors.ticketPackages.firstQuantityInput)
.type(selectors.ticketPackages.firstQuantityInput, '0')
.click(selectors.ticketPackages.savePackagesButton)
.waitForSnackbar()
.then(result => {
expect(result).toContain('Some fields are invalid');
});
2018-04-04 14:41:06 +00:00
});
it(`should attempt create a new package but receive an error if package is blank`, () => {
return nightmare
.clearInput(selectors.ticketPackages.firstQuantityInput)
.type(selectors.ticketPackages.firstQuantityInput, '99')
.click(selectors.ticketPackages.clearPackageSelectButton)
.click(selectors.ticketPackages.savePackagesButton)
.waitForSnackbar()
.then(result => {
expect(result).toContain('Package cannot be blank');
});
2018-04-04 14:41:06 +00:00
});
it(`should create a new package with correct data`, () => {
return nightmare
.waitToClick(selectors.ticketPackages.firstPackageSelect)
.waitToClick(selectors.ticketPackages.firstPackageSelectOptionThree)
.waitForTextInInput(selectors.ticketPackages.firstPackageSelect, 'Iron Patriot')
.click(selectors.ticketPackages.savePackagesButton)
.waitForSnackbar()
.then(result => {
expect(result).toContain('Data saved!');
});
2018-04-04 14:41:06 +00:00
});
it(`should confirm the first select is the expected one`, () => {
return nightmare
.click(selectors.ticketSales.saleButton)
.wait(selectors.ticketSales.firstPackageSelect)
.click(selectors.ticketPackages.packagesButton)
.waitForTextInInput(selectors.ticketPackages.firstPackageSelect, 'Iron Patriot')
.getInputValue(selectors.ticketPackages.firstPackageSelect)
.then(result => {
expect(result).toEqual('Iron Patriot');
});
2018-04-04 14:41:06 +00:00
});
it(`should confirm the first quantity is the expected one`, () => {
return nightmare
.waitForTextInInput(selectors.ticketPackages.firstQuantityInput, '99')
.getInputValue(selectors.ticketPackages.firstQuantityInput)
.then(result => {
expect(result).toEqual('99');
});
2018-04-04 14:41:06 +00:00
});
});
});