salix/e2e/paths/05-ticket/04_packages.spec.js

72 lines
3.0 KiB
JavaScript
Raw Normal View History

import selectors from '../../helpers/selectors.js';
import getBrowser from '../../helpers/puppeteer';
2018-04-04 14:41:06 +00:00
describe('Ticket Create packages path', () => {
let browser;
let page;
2018-04-04 14:41:06 +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-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() => {
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');
await page.waitToClick(selectors.ticketPackages.savePackagesButton);
2020-04-08 09:24:40 +00:00
const message = await page.waitForSnackbar();
2020-11-10 11:06:21 +00:00
expect(message.text).toContain('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() => {
2020-02-03 14:55:11 +00:00
await page.clearInput(selectors.ticketPackages.firstQuantity);
await page.autocompleteSearch(selectors.ticketPackages.firstPackage, 'Container medical box 1m');
await page.waitToClick(selectors.ticketPackages.savePackagesButton);
2020-04-08 09:24:40 +00:00
const message = await page.waitForSnackbar();
2020-11-10 11:06:21 +00:00
expect(message.text).toContain('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 page
2019-04-09 11:20:08 +00:00
.evaluate(selector => {
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');
await page.waitToClick(selectors.ticketPackages.savePackagesButton);
2020-04-08 09:24:40 +00:00
const message = await page.waitForSnackbar();
2020-11-10 11:06:21 +00:00
expect(message.text).toContain('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() => {
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');
2019-03-27 07:44:15 +00:00
expect(result).toEqual('7 : Container medical box 1m');
});
2018-04-04 14:41:06 +00:00
it(`should confirm 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');
expect(result).toEqual('-99');
});
});