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

137 lines
5.6 KiB
JavaScript
Raw Normal View History

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