2020-01-23 15:01:29 +00:00
|
|
|
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]`
|
|
|
|
};
|
|
|
|
|
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() => {
|
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();
|
2018-10-30 12:58:02 +00:00
|
|
|
|
2020-11-10 11:06:21 +00:00
|
|
|
expect(message.text).toContain('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() => {
|
2023-05-05 06:12:38 +00:00
|
|
|
await page.clearInput($.firstQuantity);
|
2023-09-01 09:52:48 +00:00
|
|
|
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();
|
2018-10-30 12:58:02 +00:00
|
|
|
|
2020-11-10 11:06:21 +00:00
|
|
|
expect(message.text).toContain('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();
|
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();
|
2018-10-30 12:58:02 +00:00
|
|
|
|
2020-11-10 11:06:21 +00:00
|
|
|
expect(message.text).toContain('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');
|
2023-09-01 09:52:48 +00:00
|
|
|
await page.waitForTextInField($.firstPackage, 'Container medical box 100cm');
|
2023-05-05 06:12:38 +00:00
|
|
|
const result = await page.waitToGetProperty($.firstPackage, 'value');
|
2018-10-30 12:58:02 +00:00
|
|
|
|
2023-09-01 09:52:48 +00:00
|
|
|
expect(result).toEqual('Container medical box 100cm');
|
2018-09-10 08:23:26 +00:00
|
|
|
});
|
2018-04-04 14:41:06 +00:00
|
|
|
|
2021-11-12 14:17:09 +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');
|
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
|
|
|
});
|
|
|
|
});
|