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

82 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-04-09 11:20:08 +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
.waitToClick(selectors.ticketPackages.firstRemovePackageButton)
.waitToClick(selectors.ticketPackages.addPackageButton)
2019-04-09 11:20:08 +00:00
.write(selectors.ticketPackages.firstQuantityInput, 99)
2019-01-23 15:00:56 +00:00
.waitToClick(selectors.ticketPackages.savePackagesButton)
.waitForLastSnackbar();
2019-04-09 11:20:08 +00:00
expect(result).toEqual('Package cannot be blank');
});
2018-04-04 14:41:06 +00:00
2019-04-09 11:20:08 +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
.clearInput(selectors.ticketPackages.firstQuantityInput)
2019-04-09 11:20:08 +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-04-09 11:20:08 +00:00
it(`should confirm the quantity input isn't invalid yet`, async() => {
const result = await nightmare
2019-04-09 11:20:08 +00:00
.evaluate(selector => {
return document.querySelector(selector).checkValidity();
}, selectors.ticketPackages.firstQuantityInput);
expect(result).toBeTruthy();
});
it(`should attempt create a new package but receive an error if the quantity is invalid`, async() => {
const result = await nightmare
.write(selectors.ticketPackages.firstQuantityInput, -99)
2019-01-23 15:00:56 +00:00
.waitToClick(selectors.ticketPackages.savePackagesButton)
2019-04-09 11:20:08 +00:00
.evaluate(selector => {
return document.querySelector(selector).checkValidity();
}, selectors.ticketPackages.firstQuantityInput);
2019-04-09 11:20:08 +00:00
expect(result).toBeFalsy();
});
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-04-09 11:20:08 +00:00
.clearInput(selectors.ticketPackages.firstQuantityInput)
.write(selectors.ticketPackages.firstQuantityInput, 99)
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');
});
});