110 lines
4.7 KiB
JavaScript
110 lines
4.7 KiB
JavaScript
import selectors from '../../helpers/selectors.js';
|
|
import getBrowser from '../../helpers/puppeteer';
|
|
|
|
describe('Order edit basic data path', () => {
|
|
let browser;
|
|
let page;
|
|
|
|
beforeAll(async() => {
|
|
browser = await getBrowser();
|
|
page = browser.page;
|
|
|
|
await page.loginAndModule('employee', 'order');
|
|
await page.accessToSearchResult('1');
|
|
await page.accessToSection('order.card.basicData');
|
|
});
|
|
|
|
afterAll(async() => {
|
|
await browser.close();
|
|
});
|
|
|
|
describe('when confirmed order', () => {
|
|
it('should not be able to change the client', async() => {
|
|
await page.autocompleteSearch(selectors.orderBasicData.client, 'Tony Stark');
|
|
await page.autocompleteSearch(selectors.orderBasicData.address, 'Tony Stark');
|
|
await page.waitToClick(selectors.orderBasicData.saveButton);
|
|
const message = await page.waitForSnackbar();
|
|
|
|
expect(message.text).toContain(`You can't make changes on the basic data of an confirmed order or with rows`);
|
|
});
|
|
});
|
|
|
|
describe('when order with rows', () => {
|
|
it('should now navigate to order index', async() => {
|
|
const orderId = '16';
|
|
|
|
await page.waitToClick(selectors.orderDescriptor.returnToModuleIndexButton);
|
|
await page.waitToClick(selectors.globalItems.acceptButton);
|
|
await page.waitForContentLoaded();
|
|
await page.accessToSearchResult(orderId);
|
|
await page.accessToSection('order.card.basicData');
|
|
await page.waitForSelector(selectors.orderBasicData.observation, {visible: true});
|
|
await page.waitForState('order.card.basicData');
|
|
});
|
|
|
|
it('should not be able to change anything', async() => {
|
|
await page.write(selectors.orderBasicData.observation, 'observation');
|
|
await page.waitToClick(selectors.orderBasicData.saveButton);
|
|
const message = await page.waitForSnackbar();
|
|
|
|
expect(message.text).toContain(`You can't make changes on the basic data of an confirmed order or with rows`);
|
|
});
|
|
});
|
|
|
|
describe('when new order', () => {
|
|
it('should navigate to the order index and click the new order button', async() => {
|
|
await page.waitToClick(selectors.globalItems.returnToModuleIndexButton);
|
|
await page.waitToClick(selectors.orderBasicData.acceptButton);
|
|
await page.waitForContentLoaded();
|
|
await page.waitToClick(selectors.ordersIndex.createOrderButton);
|
|
await page.waitForState('order.create');
|
|
});
|
|
|
|
it('should now create a new one', async() => {
|
|
await page.autocompleteSearch(selectors.createOrderView.client, 'Jessica Jones');
|
|
await page.pickDate(selectors.createOrderView.landedDatePicker);
|
|
await page.autocompleteSearch(selectors.createOrderView.agency, 'Other agency');
|
|
await page.waitToClick(selectors.createOrderView.createButton);
|
|
await page.waitForState('order.card.catalog');
|
|
});
|
|
|
|
it('should navigate to the basic data section of the new order', async() => {
|
|
await page.accessToSection('order.card.basicData');
|
|
await page.waitForState('order.card.basicData');
|
|
});
|
|
|
|
it('should be able to modify all the properties', async() => {
|
|
await page.autocompleteSearch(selectors.orderBasicData.client, 'Tony Stark');
|
|
await page.autocompleteSearch(selectors.orderBasicData.address, 'Tony Stark');
|
|
await page.autocompleteSearch(selectors.orderBasicData.agency, 'Silla247');
|
|
await page.write(selectors.orderBasicData.observation, 'my observation');
|
|
await page.waitToClick(selectors.orderBasicData.saveButton);
|
|
const message = await page.waitForSnackbar();
|
|
|
|
expect(message.text).toContain('Data saved!');
|
|
});
|
|
|
|
it('should now confirm the client have been edited', async() => {
|
|
await page.reloadSection('order.card.basicData');
|
|
const result = await page
|
|
.waitToGetProperty(selectors.orderBasicData.client, 'value');
|
|
|
|
expect(result).toEqual('1104: Tony Stark');
|
|
});
|
|
|
|
it('should now confirm the agency have been edited', async() => {
|
|
const result = await page
|
|
.waitToGetProperty(selectors.orderBasicData.agency, 'value');
|
|
|
|
expect(result).toEqual('7: Silla247');
|
|
});
|
|
|
|
it('should now confirm the observations have been edited', async() => {
|
|
const result = await page
|
|
.waitToGetProperty(selectors.orderBasicData.observation, 'value');
|
|
|
|
expect(result).toEqual('my observation');
|
|
});
|
|
});
|
|
});
|