2018-09-10 08:23:26 +00:00
|
|
|
import selectors from '../../helpers/selectors.js';
|
2018-10-24 08:57:14 +00:00
|
|
|
import createNightmare from '../../helpers/nightmare';
|
2018-04-04 14:41:06 +00:00
|
|
|
|
2018-11-07 12:32:09 +00:00
|
|
|
describe('Ticket Create packages path', () => {
|
2018-09-10 08:23:26 +00:00
|
|
|
const nightmare = createNightmare();
|
2018-04-04 14:41:06 +00:00
|
|
|
|
2018-09-10 08:23:26 +00:00
|
|
|
beforeAll(() => {
|
|
|
|
return nightmare
|
2018-12-02 23:45:34 +00:00
|
|
|
.loginAndModule('employee', 'ticket')
|
|
|
|
.accessToSearchResult('id:1')
|
|
|
|
.accessToSection('ticket.card.package.index');
|
2018-09-10 08:23:26 +00:00
|
|
|
});
|
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() => {
|
2018-10-31 10:58:10 +00:00
|
|
|
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)
|
2018-10-30 12:58:02 +00:00
|
|
|
.waitForLastSnackbar();
|
|
|
|
|
|
|
|
expect(result).toEqual('Some fields are invalid');
|
2018-09-10 08:23:26 +00:00
|
|
|
});
|
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() => {
|
2018-10-31 10:58:10 +00:00
|
|
|
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)
|
2018-10-30 12:58:02 +00:00
|
|
|
.waitForLastSnackbar();
|
|
|
|
|
|
|
|
expect(result).toEqual('Some fields are invalid');
|
2018-09-10 08:23:26 +00:00
|
|
|
});
|
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() => {
|
2018-10-31 10:58:10 +00:00
|
|
|
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)
|
2018-10-30 12:58:02 +00:00
|
|
|
.waitForLastSnackbar();
|
|
|
|
|
|
|
|
expect(result).toEqual('Package cannot be blank');
|
2018-09-10 08:23:26 +00:00
|
|
|
});
|
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() => {
|
2018-10-31 10:58:10 +00:00
|
|
|
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)
|
2018-10-30 12:58:02 +00:00
|
|
|
.waitForLastSnackbar();
|
|
|
|
|
|
|
|
expect(result).toEqual('Data saved!');
|
2018-09-10 08:23:26 +00:00
|
|
|
});
|
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() => {
|
2018-10-31 10:58:10 +00:00
|
|
|
const result = await nightmare
|
2019-01-27 20:09:54 +00:00
|
|
|
.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');
|
2018-10-30 12:58:02 +00:00
|
|
|
|
2019-03-27 07:44:15 +00:00
|
|
|
expect(result).toEqual('7 : Container medical box 1m');
|
2018-09-10 08:23:26 +00:00
|
|
|
});
|
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() => {
|
2018-10-31 10:58:10 +00:00
|
|
|
const result = await nightmare
|
2018-10-25 14:44:03 +00:00
|
|
|
.waitForTextInInput(selectors.ticketPackages.firstQuantityInput, '99')
|
2018-11-22 14:44:33 +00:00
|
|
|
.waitToGetProperty(selectors.ticketPackages.firstQuantityInput, 'value');
|
2018-10-30 12:58:02 +00:00
|
|
|
|
|
|
|
expect(result).toEqual('99');
|
2018-09-10 08:23:26 +00:00
|
|
|
});
|
|
|
|
});
|