2019-01-08 11:02:38 +00:00
|
|
|
import selectors from '../../helpers/selectors.js';
|
2020-01-23 15:01:29 +00:00
|
|
|
import getBrowser from '../../helpers/puppeteer';
|
2019-01-08 11:02:38 +00:00
|
|
|
|
2019-02-19 15:37:17 +00:00
|
|
|
describe('Order edit basic data path', () => {
|
2020-01-23 15:01:29 +00:00
|
|
|
let browser;
|
|
|
|
let page;
|
2019-06-19 07:03:45 +00:00
|
|
|
const today = new Date().getDate();
|
|
|
|
|
2020-01-23 15:01:29 +00:00
|
|
|
beforeAll(async() => {
|
|
|
|
browser = await getBrowser();
|
|
|
|
page = browser.page;
|
|
|
|
|
|
|
|
await page.loginAndModule('employee', 'order');
|
|
|
|
await page.accessToSearchResult('1');
|
|
|
|
await page.accessToSection('order.card.basicData');
|
|
|
|
});
|
2019-01-08 11:02:38 +00:00
|
|
|
|
2020-01-23 15:01:29 +00:00
|
|
|
afterAll(async() => {
|
|
|
|
await browser.close();
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when confirmed order', () => {
|
2019-01-08 11:02:38 +00:00
|
|
|
it('should not be able to change the client', async() => {
|
2020-01-23 15:01:29 +00:00
|
|
|
await page.autocompleteSearch(selectors.orderBasicData.clientAutocomplete, 'Tony Stark');
|
|
|
|
await page.autocompleteSearch(selectors.orderBasicData.addressAutocomplete, 'Tony Stark');
|
|
|
|
await page.waitToClick(selectors.orderBasicData.saveButton);
|
|
|
|
const result = await page.waitForLastSnackbar();
|
2019-01-08 11:02:38 +00:00
|
|
|
|
|
|
|
expect(result).toEqual(`You can't make changes on the basic data of an confirmed order or with rows`);
|
2019-02-19 07:42:36 +00:00
|
|
|
}, 15000);
|
2019-01-08 11:02:38 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
describe('when order with rows', () => {
|
|
|
|
it('should now navigate to order index', async() => {
|
2020-01-26 23:48:00 +00:00
|
|
|
const orderId = '16';
|
2020-01-23 15:01:29 +00:00
|
|
|
|
|
|
|
await page.waitToClick(selectors.orderDescriptor.returnToModuleIndexButton);
|
|
|
|
await page.waitToClick(selectors.orderDescriptor.acceptNavigationButton);
|
2020-01-26 23:48:00 +00:00
|
|
|
await page.waitForContentLoaded();
|
2020-01-23 15:01:29 +00:00
|
|
|
await page.accessToSearchResult(orderId);
|
|
|
|
await page.accessToSection('order.card.basicData');
|
2020-01-27 17:35:39 +00:00
|
|
|
await page.waitForContentLoaded();
|
2020-01-26 23:48:00 +00:00
|
|
|
await page.waitForSelector(selectors.orderBasicData.observationInput, {visible: true});
|
|
|
|
await page.waitForURL('basic-data');
|
2020-01-23 15:01:29 +00:00
|
|
|
const url = await page.parsedUrl();
|
2019-01-08 11:02:38 +00:00
|
|
|
|
2019-06-14 10:27:41 +00:00
|
|
|
expect(url.hash).toEqual(`#!/order/${orderId}/basic-data`);
|
2019-01-08 11:02:38 +00:00
|
|
|
});
|
|
|
|
|
2019-06-14 10:27:41 +00:00
|
|
|
it('should not be able to change anything', async() => {
|
2020-01-26 23:48:00 +00:00
|
|
|
await page.type(selectors.orderBasicData.observationInput, 'observation');
|
2020-01-23 15:01:29 +00:00
|
|
|
await page.waitToClick(selectors.orderBasicData.saveButton);
|
|
|
|
const result = await page.waitForLastSnackbar();
|
2019-01-08 11:02:38 +00:00
|
|
|
|
|
|
|
expect(result).toEqual(`You can't make changes on the basic data of an confirmed order or with rows`);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when new order', () => {
|
2019-06-19 07:03:45 +00:00
|
|
|
it('should navigate to the order index and click the new order button', async() => {
|
2020-01-23 15:01:29 +00:00
|
|
|
await page.waitToClick(selectors.globalItems.returnToModuleIndexButton);
|
|
|
|
await page.waitToClick(selectors.orderBasicData.acceptButton);
|
2020-01-26 23:48:00 +00:00
|
|
|
await page.waitForContentLoaded();
|
2020-01-23 15:01:29 +00:00
|
|
|
await page.waitToClick(selectors.ordersIndex.createOrderButton);
|
|
|
|
await page.waitForURL('#!/order/create');
|
|
|
|
const url = await page.parsedUrl();
|
2019-06-19 07:03:45 +00:00
|
|
|
|
|
|
|
expect(url.hash).toContain('#!/order/create');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should now create a new one', async() => {
|
2020-01-23 15:01:29 +00:00
|
|
|
await page.autocompleteSearch(selectors.createOrderView.clientAutocomplete, 'Jessica Jones');
|
|
|
|
await page.datePicker(selectors.createOrderView.landedDatePicker, 0, today);
|
2020-01-26 23:48:00 +00:00
|
|
|
await page.autocompleteSearch(selectors.createOrderView.agencyAutocomplete, 'Other agency');
|
2020-01-23 15:01:29 +00:00
|
|
|
await page.waitToClick(selectors.createOrderView.createButton);
|
|
|
|
await page.waitForURL('/catalog');
|
|
|
|
const url = await page.parsedUrl();
|
2019-06-14 10:27:41 +00:00
|
|
|
|
|
|
|
expect(url.hash).toContain('/catalog');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should navigate to the basic data section of the new order', async() => {
|
2020-01-23 15:01:29 +00:00
|
|
|
await page.accessToSection('order.card.basicData');
|
|
|
|
await page.wait(selectors.orderBasicData.observationInput);
|
|
|
|
const url = await page.parsedUrl();
|
2019-01-23 14:34:16 +00:00
|
|
|
|
2019-06-14 10:27:41 +00:00
|
|
|
expect(url.hash).toContain('/basic-data');
|
2019-01-08 11:02:38 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should be able to modify all the properties', async() => {
|
2020-01-23 15:01:29 +00:00
|
|
|
await page.autocompleteSearch(selectors.orderBasicData.clientAutocomplete, 'Tony Stark');
|
|
|
|
await page.autocompleteSearch(selectors.orderBasicData.addressAutocomplete, 'Tony Stark');
|
|
|
|
await page.autocompleteSearch(selectors.orderBasicData.agencyAutocomplete, 'Silla247');
|
2020-01-26 23:48:00 +00:00
|
|
|
await page.type(selectors.orderBasicData.observationInput, 'my observation');
|
2020-01-23 15:01:29 +00:00
|
|
|
await page.waitToClick(selectors.orderBasicData.saveButton);
|
|
|
|
const result = await page.waitForLastSnackbar();
|
2019-01-08 11:02:38 +00:00
|
|
|
|
|
|
|
expect(result).toEqual('Data saved!');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should now confirm the client have been edited', async() => {
|
2020-01-23 15:01:29 +00:00
|
|
|
await page.reloadSection('order.card.basicData');
|
|
|
|
const result = await page
|
2020-01-29 13:54:07 +00:00
|
|
|
.waitToGetProperty(selectors.orderBasicData.clientAutocomplete, 'value');
|
2019-01-08 11:02:38 +00:00
|
|
|
|
|
|
|
expect(result).toEqual('104: Tony Stark');
|
|
|
|
});
|
|
|
|
|
2019-02-20 07:24:10 +00:00
|
|
|
it('should now confirm the agency have been edited', async() => {
|
2020-01-23 15:01:29 +00:00
|
|
|
const result = await page
|
2020-01-29 13:54:07 +00:00
|
|
|
.waitToGetProperty(selectors.orderBasicData.agencyAutocomplete, 'value');
|
2019-02-20 07:24:10 +00:00
|
|
|
|
|
|
|
expect(result).toEqual('7: Silla247');
|
|
|
|
});
|
|
|
|
|
2019-01-08 11:02:38 +00:00
|
|
|
it('should now confirm the observations have been edited', async() => {
|
2020-01-23 15:01:29 +00:00
|
|
|
const result = await page
|
2019-01-08 11:02:38 +00:00
|
|
|
.waitToGetProperty(selectors.orderBasicData.observationInput, 'value');
|
|
|
|
|
2019-06-19 07:03:45 +00:00
|
|
|
expect(result).toEqual('my observation');
|
2019-01-08 11:02:38 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|