2018-09-10 08:23:26 +00:00
|
|
|
import selectors from '../../helpers/selectors.js';
|
2020-01-23 15:01:29 +00:00
|
|
|
import getBrowser from '../../helpers/puppeteer';
|
2018-04-04 14:41:06 +00:00
|
|
|
|
2018-11-07 12:32:09 +00:00
|
|
|
describe('Ticket Create packages path', () => {
|
2020-01-23 15:01:29 +00:00
|
|
|
let browser;
|
|
|
|
let page;
|
2018-04-04 14:41:06 +00:00
|
|
|
|
2020-01-23 15:01:29 +00:00
|
|
|
beforeAll(async() => {
|
|
|
|
browser = await getBrowser();
|
|
|
|
page = browser.page;
|
|
|
|
await page.loginAndModule('employee', 'ticket');
|
|
|
|
await page.accessToSearchResult('1');
|
|
|
|
await page.accessToSection('ticket.card.package');
|
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(async() => {
|
|
|
|
await browser.close();
|
2018-09-10 08:23:26 +00:00
|
|
|
});
|
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() => {
|
2020-01-23 15:01:29 +00:00
|
|
|
await page.waitToClick(selectors.ticketPackages.firstRemovePackageButton);
|
|
|
|
await page.waitToClick(selectors.ticketPackages.addPackageButton);
|
2020-02-03 14:55:11 +00:00
|
|
|
await page.write(selectors.ticketPackages.firstQuantity, '99');
|
2020-01-23 15:01:29 +00:00
|
|
|
await page.waitToClick(selectors.ticketPackages.savePackagesButton);
|
|
|
|
const result = await page.waitForLastSnackbar();
|
2018-10-30 12:58:02 +00:00
|
|
|
|
2019-04-09 11:20:08 +00:00
|
|
|
expect(result).toEqual('Package cannot be blank');
|
2018-09-10 08:23:26 +00:00
|
|
|
});
|
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() => {
|
2020-02-03 14:55:11 +00:00
|
|
|
await page.clearInput(selectors.ticketPackages.firstQuantity);
|
|
|
|
await page.autocompleteSearch(selectors.ticketPackages.firstPackage, 'Container medical box 1m');
|
2020-01-23 15:01:29 +00:00
|
|
|
await page.waitToClick(selectors.ticketPackages.savePackagesButton);
|
|
|
|
const result = await page.waitForLastSnackbar();
|
2018-10-30 12:58:02 +00:00
|
|
|
|
|
|
|
expect(result).toEqual('Some fields are invalid');
|
2018-09-10 08:23:26 +00:00
|
|
|
});
|
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() => {
|
2020-01-23 15:01:29 +00:00
|
|
|
const result = await page
|
2019-04-09 11:20:08 +00:00
|
|
|
.evaluate(selector => {
|
2020-01-23 15:01:29 +00:00
|
|
|
return document.querySelector(`${selector} input`).checkValidity();
|
2020-02-03 14:55:11 +00:00
|
|
|
}, selectors.ticketPackages.firstQuantity);
|
2019-04-09 11:20:08 +00:00
|
|
|
|
|
|
|
expect(result).toBeTruthy();
|
|
|
|
});
|
|
|
|
|
2019-01-07 08:33:07 +00:00
|
|
|
it(`should create a new package with correct data`, async() => {
|
2020-02-03 14:55:11 +00:00
|
|
|
await page.clearInput(selectors.ticketPackages.firstQuantity);
|
|
|
|
await page.write(selectors.ticketPackages.firstQuantity, '-99');
|
2020-01-23 15:01:29 +00:00
|
|
|
await page.waitToClick(selectors.ticketPackages.savePackagesButton);
|
|
|
|
const result = await page.waitForLastSnackbar();
|
2018-10-30 12:58:02 +00:00
|
|
|
|
|
|
|
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() => {
|
2020-01-23 15:01:29 +00:00
|
|
|
await page.reloadSection('ticket.card.package');
|
2020-02-03 14:55:11 +00:00
|
|
|
await page.waitForTextInField(selectors.ticketPackages.firstPackage, 'Container medical box 1m');
|
|
|
|
const result = await page.waitToGetProperty(selectors.ticketPackages.firstPackage, '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() => {
|
2020-02-03 14:55:11 +00:00
|
|
|
await page.waitForTextInField(selectors.ticketPackages.firstQuantity, '-99');
|
|
|
|
const result = await page.waitToGetProperty(selectors.ticketPackages.firstQuantity, 'value');
|
2018-10-30 12:58:02 +00:00
|
|
|
|
2019-04-24 09:36:13 +00:00
|
|
|
expect(result).toEqual('-99');
|
2018-09-10 08:23:26 +00:00
|
|
|
});
|
|
|
|
});
|