72 lines
3.0 KiB
JavaScript
72 lines
3.0 KiB
JavaScript
import selectors from '../../helpers/selectors.js';
|
|
import getBrowser from '../../helpers/puppeteer';
|
|
|
|
describe('Ticket Create packages path', () => {
|
|
let browser;
|
|
let page;
|
|
|
|
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();
|
|
});
|
|
|
|
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);
|
|
await page.write(selectors.ticketPackages.firstQuantity, '99');
|
|
await page.waitToClick(selectors.ticketPackages.savePackagesButton);
|
|
const message = await page.waitForSnackbar();
|
|
|
|
expect(message.text).toContain('Package cannot be blank');
|
|
});
|
|
|
|
it(`should delete the first package and receive and error to save a new one with blank quantity`, async() => {
|
|
await page.clearInput(selectors.ticketPackages.firstQuantity);
|
|
await page.autocompleteSearch(selectors.ticketPackages.firstPackage, 'Container medical box 1m');
|
|
await page.waitToClick(selectors.ticketPackages.savePackagesButton);
|
|
const message = await page.waitForSnackbar();
|
|
|
|
expect(message.text).toContain('Some fields are invalid');
|
|
});
|
|
|
|
it(`should confirm the quantity input isn't invalid yet`, async() => {
|
|
const result = await page
|
|
.evaluate(selector => {
|
|
return document.querySelector(`${selector} input`).checkValidity();
|
|
}, selectors.ticketPackages.firstQuantity);
|
|
|
|
expect(result).toBeTruthy();
|
|
});
|
|
|
|
it(`should create a new package with correct data`, async() => {
|
|
await page.clearInput(selectors.ticketPackages.firstQuantity);
|
|
await page.write(selectors.ticketPackages.firstQuantity, '-99');
|
|
await page.waitToClick(selectors.ticketPackages.savePackagesButton);
|
|
const message = await page.waitForSnackbar();
|
|
|
|
expect(message.text).toContain('Data saved!');
|
|
});
|
|
|
|
it(`should confirm the first select is the expected one`, async() => {
|
|
await page.reloadSection('ticket.card.package');
|
|
await page.waitForTextInField(selectors.ticketPackages.firstPackage, 'Container medical box 1m');
|
|
const result = await page.waitToGetProperty(selectors.ticketPackages.firstPackage, 'value');
|
|
|
|
expect(result).toEqual('7 : Container medical box 1m');
|
|
});
|
|
|
|
it(`should confirm quantity is just a number and the string part was ignored by the imput number`, async() => {
|
|
await page.waitForTextInField(selectors.ticketPackages.firstQuantity, '-99');
|
|
const result = await page.waitToGetProperty(selectors.ticketPackages.firstQuantity, 'value');
|
|
|
|
expect(result).toEqual('-99');
|
|
});
|
|
});
|