salix/e2e/paths/07-order-module/01_edit_basic_data.spec.js

120 lines
5.1 KiB
JavaScript

import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
describe('Order edit basic data path', () => {
const nightmare = createNightmare();
const today = new Date().getDate();
describe('when confirmed order', () => {
beforeAll(() => {
nightmare
.loginAndModule('employee', 'order')
.accessToSearchResult(1)
.accessToSection('order.card.basicData');
});
it('should not be able to change the client', async() => {
const result = await nightmare
.autocompleteSearch(selectors.orderBasicData.clientAutocomplete, 'Tony Stark')
.autocompleteSearch(selectors.orderBasicData.addressAutocomplete, 'Tony Stark')
.waitToClick(selectors.orderBasicData.saveButton)
.waitForLastSnackbar();
expect(result).toEqual(`You can't make changes on the basic data of an confirmed order or with rows`);
}, 15000);
});
describe('when order with rows', () => {
it('should now navigate to order index', async() => {
const orderId = 16;
const url = await nightmare
.waitToClick(selectors.orderDescriptor.returnToModuleIndexButton)
.waitToClick(selectors.orderDescriptor.acceptNavigationButton)
.wait(selectors.ordersIndex.createOrderButton)
.accessToSearchResult(orderId)
.accessToSection('order.card.basicData')
.wait(selectors.orderBasicData.observationInput)
.parsedUrl();
expect(url.hash).toEqual(`#!/order/${orderId}/basic-data`);
});
it('should not be able to change anything', async() => {
const result = await nightmare
.write(selectors.orderBasicData.observationInput, 'observation')
.waitToClick(selectors.orderBasicData.saveButton)
.waitForLastSnackbar();
expect(result).toEqual(`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() => {
const url = await nightmare
.waitToClick(selectors.globalItems.returnToModuleIndexButton)
.waitToClick(selectors.globalItems.acceptButton)
.waitToClick(selectors.ordersIndex.createOrderButton)
.waitForURL('#!/order/create')
.parsedUrl();
expect(url.hash).toContain('#!/order/create');
});
it('should now create a new one', async() => {
const url = await nightmare
.autocompleteSearch(selectors.createOrderView.clientAutocomplete, 'Jessica Jones')
.datePicker(selectors.createOrderView.landedDatePicker, 0, today)
.autocompleteSearch(selectors.createOrderView.agencyAutocomplete, 'inhouse pickup')
.waitToClick(selectors.createOrderView.createButton)
.waitForURL('/catalog')
.parsedUrl();
expect(url.hash).toContain('/catalog');
});
it('should navigate to the basic data section of the new order', async() => {
const url = await nightmare
.accessToSection('order.card.basicData')
.wait(selectors.orderBasicData.observationInput)
.parsedUrl();
expect(url.hash).toContain('/basic-data');
});
it('should be able to modify all the properties', async() => {
const result = await nightmare
.autocompleteSearch(selectors.orderBasicData.clientAutocomplete, 'Tony Stark')
.autocompleteSearch(selectors.orderBasicData.addressAutocomplete, 'Tony Stark')
.autocompleteSearch(selectors.orderBasicData.agencyAutocomplete, 'Silla247')
.write(selectors.orderBasicData.observationInput, 'my observation')
.waitToClick(selectors.orderBasicData.saveButton)
.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it('should now confirm the client have been edited', async() => {
const result = await nightmare
.reloadSection('order.card.basicData')
.waitToGetProperty(`${selectors.orderBasicData.clientAutocomplete} input`, 'value');
expect(result).toEqual('104: Tony Stark');
});
it('should now confirm the agency have been edited', async() => {
const result = await nightmare
.waitToGetProperty(`${selectors.orderBasicData.agencyAutocomplete} input`, 'value');
expect(result).toEqual('7: Silla247');
});
it('should now confirm the observations have been edited', async() => {
const result = await nightmare
.waitToGetProperty(selectors.orderBasicData.observationInput, 'value');
expect(result).toEqual('my observation');
});
});
});