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

79 lines
3.0 KiB
JavaScript
Raw Normal View History

import getBrowser from '../../helpers/puppeteer';
2018-04-04 14:41:06 +00:00
2023-05-05 06:12:38 +00:00
const $ = {
firstPackage: 'vn-autocomplete[label="Package"]',
firstQuantity: 'vn-ticket-package vn-horizontal:nth-child(1) vn-input-number[ng-model="package.quantity"]',
firstRemovePackageButton: 'vn-icon-button[vn-tooltip="Remove package"]',
addPackageButton: 'vn-icon-button[vn-tooltip="Add package"]',
savePackagesButton: `button[type=submit]`
};
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() => {
2023-05-05 06:12:38 +00:00
await page.waitToClick($.firstRemovePackageButton);
await page.waitToClick($.addPackageButton);
await page.write($.firstQuantity, '99');
await page.waitToClick($.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() => {
2023-05-05 06:12:38 +00:00
await page.clearInput($.firstQuantity);
await page.autocompleteSearch($.firstPackage, 'Container medical box 100cm');
2023-05-05 06:12:38 +00:00
await page.waitToClick($.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();
2023-05-05 06:12:38 +00:00
}, $.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() => {
2023-05-05 06:12:38 +00:00
await page.clearInput($.firstQuantity);
await page.write($.firstQuantity, '-99');
await page.waitToClick($.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');
await page.waitForTextInField($.firstPackage, 'Container medical box 100cm');
2023-05-05 06:12:38 +00:00
const result = await page.waitToGetProperty($.firstPackage, 'value');
expect(result).toEqual('Container medical box 100cm');
});
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() => {
2023-05-05 06:12:38 +00:00
await page.waitForTextInField($.firstQuantity, '-99');
const result = await page.waitToGetProperty($.firstQuantity, 'value');
expect(result).toEqual('-99');
});
});