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

72 lines
3.1 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-03-27 07:44:15 +00:00
.autocompleteSearch(selectors.ticketPackages.firstPackageAutocomplete, 'Container medical box 1m')
2019-01-23 15:00:56 +00:00
.waitToClick(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)
2019-01-23 14:33:25 +00:00
.write(selectors.ticketPackages.firstQuantityInput, 0)
2019-01-23 15:00:56 +00:00
.waitToClick(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)
2019-04-05 06:06:03 +00:00
.write(selectors.ticketPackages.firstQuantityInput, 'text and 99')
2019-01-23 15:00:56 +00:00
.waitToClick(selectors.ticketPackages.clearPackageAutocompleteButton)
.waitToClick(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-03-27 07:44:15 +00:00
.autocompleteSearch(selectors.ticketPackages.firstPackageAutocomplete, 'Container medical box 1m')
2019-01-23 15:00:56 +00:00
.waitToClick(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
.reloadSection('ticket.card.package.index')
2019-03-27 07:44:15 +00:00
.waitForTextInInput(`${selectors.ticketPackages.firstPackageAutocomplete} input`, 'Container medical box 1m')
2019-01-07 08:33:07 +00:00
.waitToGetProperty(`${selectors.ticketPackages.firstPackageAutocomplete} input`, 'value');
2019-03-27 07:44:15 +00:00
expect(result).toEqual('7 : Container medical box 1m');
});
2018-04-04 14:41:06 +00:00
2019-04-05 06:06:03 +00:00
it(`should confirm the first quantity is just a number and the string part was ignored by the imput number`, 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');
});
});