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

83 lines
3.5 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
.loginAndModule('employee', 'ticket')
.accessToSearchResult('id:1')
.accessToSection('ticket.card.package.index');
});
2018-04-04 14:41:06 +00:00
2019-01-07 08:33:07 +00:00
it(`should delete the first package and receive and error to save a new one with blank quantity`, async() => {
const result = await nightmare
2018-10-25 14:44:03 +00:00
.waitToClick(selectors.ticketPackages.firstRemovePackageButton)
.waitToClick(selectors.ticketPackages.addPackageButton)
2019-01-07 08:33:07 +00:00
.autocompleteSearch(selectors.ticketPackages.firstPackageAutocomplete, 'Legendary Box')
2018-10-25 14:44:03 +00:00
.click(selectors.ticketPackages.savePackagesButton)
.waitForLastSnackbar();
expect(result).toEqual('Some fields are invalid');
});
2018-04-04 14:41:06 +00:00
2019-01-07 08:33:07 +00:00
it(`should attempt create a new package but receive an error if quantity is a string`, async() => {
const result = await nightmare
2018-10-25 14:44:03 +00:00
.type(selectors.ticketPackages.firstQuantityInput, 'ninety 9')
.click(selectors.ticketPackages.savePackagesButton)
.waitForLastSnackbar();
expect(result).toEqual('Some fields are invalid');
});
2018-04-04 14:41:06 +00:00
2019-01-07 08:33:07 +00:00
it(`should attempt create a new package but receive an error if quantity is 0`, async() => {
const result = await nightmare
2018-10-25 14:44:03 +00:00
.clearInput(selectors.ticketPackages.firstQuantityInput)
.type(selectors.ticketPackages.firstQuantityInput, 0)
.click(selectors.ticketPackages.savePackagesButton)
.waitForLastSnackbar();
expect(result).toEqual('Some fields are invalid');
});
2018-04-04 14:41:06 +00:00
2019-01-07 08:33:07 +00:00
it(`should attempt create a new package but receive an error if package is blank`, async() => {
const result = await nightmare
2018-10-25 14:44:03 +00:00
.clearInput(selectors.ticketPackages.firstQuantityInput)
.type(selectors.ticketPackages.firstQuantityInput, 99)
2019-01-07 09:55:23 +00:00
.click(selectors.ticketPackages.clearPackageAutocompleteButton)
2018-10-25 14:44:03 +00:00
.click(selectors.ticketPackages.savePackagesButton)
.waitForLastSnackbar();
expect(result).toEqual('Package cannot be blank');
});
2018-04-04 14:41:06 +00:00
2019-01-07 08:33:07 +00:00
it(`should create a new package with correct data`, async() => {
const result = await nightmare
2019-01-07 08:33:07 +00:00
.autocompleteSearch(selectors.ticketPackages.firstPackageAutocomplete, 'Legendary Box')
2018-10-25 14:44:03 +00:00
.click(selectors.ticketPackages.savePackagesButton)
.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
2018-04-04 14:41:06 +00:00
2019-01-07 08:33:07 +00:00
it(`should confirm the first select is the expected one`, async() => {
const result = await nightmare
2019-01-07 08:33:07 +00:00
.waitToClick(selectors.ticketSales.saleButton)
.wait(selectors.ticketSales.firstPackageAutocomplete)
.waitToClick(selectors.ticketPackages.packagesButton)
.waitForTextInInput(`${selectors.ticketPackages.firstPackageAutocomplete} input`, 'Legendary Box')
.waitToGetProperty(`${selectors.ticketPackages.firstPackageAutocomplete} input`, 'value');
expect(result).toEqual('7 : Legendary Box');
});
2018-04-04 14:41:06 +00:00
2019-01-07 08:33:07 +00:00
it(`should confirm the first quantity is the expected one`, async() => {
const result = await nightmare
2018-10-25 14:44:03 +00:00
.waitForTextInInput(selectors.ticketPackages.firstQuantityInput, '99')
.waitToGetProperty(selectors.ticketPackages.firstQuantityInput, 'value');
expect(result).toEqual('99');
});
});