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

99 lines
4.3 KiB
JavaScript
Raw Normal View History

2019-01-08 11:02:38 +00:00
import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
2019-02-19 15:37:17 +00:00
describe('Order edit basic data path', () => {
2019-01-08 11:02:38 +00:00
const nightmare = createNightmare();
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')
2019-02-19 07:42:36 +00:00
.autocompleteSearch(selectors.orderBasicData.addressAutocomplete, 'Tony Stark')
2019-01-23 15:00:56 +00:00
.waitToClick(selectors.orderBasicData.saveButton)
2019-01-08 11:02:38 +00:00
.waitForLastSnackbar();
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() => {
const url = await nightmare
.waitToClick(selectors.globalItems.returnToModuleIndexButton)
.waitToClick(selectors.globalItems.acceptVnConfirm)
.wait(selectors.ordersIndex.createOrderButton)
.accessToSearchResult('16')
.accessToSection('order.card.basicData')
2019-02-06 15:40:12 +00:00
.wait(selectors.orderBasicData.observationInput)
2019-01-08 11:02:38 +00:00
.parsedUrl();
expect(url.hash).toEqual('#!/order/16/basic-data');
});
it('should not be able to change the company', async() => {
const result = await nightmare
2019-02-06 15:40:12 +00:00
.write(selectors.orderBasicData.observationInput, 'observation')
2019-01-23 15:00:56 +00:00
.waitToClick(selectors.orderBasicData.saveButton)
2019-01-08 11:02:38 +00:00
.waitForLastSnackbar();
expect(result).toEqual(`You can't make changes on the basic data of an confirmed order or with rows`);
});
});
describe('when new order', () => {
2019-01-23 14:34:16 +00:00
it('should once more navigate to order index', async() => {
const url = await nightmare
.waitToClick(selectors.globalItems.returnToModuleIndexButton)
.waitToClick(selectors.globalItems.acceptVnConfirm)
.wait(selectors.ordersIndex.createOrderButton)
2019-01-08 11:02:38 +00:00
.accessToSearchResult('18')
2019-01-23 14:34:16 +00:00
.accessToSection('order.card.basicData')
2019-02-06 15:40:12 +00:00
.wait(selectors.orderBasicData.observationInput)
2019-01-23 14:34:16 +00:00
.parsedUrl();
expect(url.hash).toEqual('#!/order/18/basic-data');
2019-01-08 11:02:38 +00:00
});
it('should be able to modify all the properties', async() => {
const result = await nightmare
.autocompleteSearch(selectors.orderBasicData.clientAutocomplete, 'Tony Stark')
2019-02-19 15:37:17 +00:00
.autocompleteSearch(selectors.orderBasicData.addressAutocomplete, 'Tony Stark')
2019-02-20 07:24:10 +00:00
.autocompleteSearch(selectors.orderBasicData.agencyAutocomplete, 'Silla247')
2019-01-08 11:02:38 +00:00
.clearInput(selectors.orderBasicData.observationInput)
2019-01-23 14:34:16 +00:00
.write(selectors.orderBasicData.observationInput, 'Observation modified')
2019-01-23 15:00:56 +00:00
.waitToClick(selectors.orderBasicData.saveButton)
2019-01-08 11:02:38 +00:00
.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it('should now confirm the client have been edited', async() => {
const result = await nightmare
.reloadSection('order.card.basicData')
2019-01-08 11:02:38 +00:00
.waitToGetProperty(`${selectors.orderBasicData.clientAutocomplete} input`, 'value');
expect(result).toEqual('104: Tony Stark');
});
2019-02-20 07:24:10 +00:00
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');
});
2019-01-08 11:02:38 +00:00
it('should now confirm the observations have been edited', async() => {
const result = await nightmare
.waitToGetProperty(selectors.orderBasicData.observationInput, 'value');
expect(result).toEqual('Observation modified');
});
});
});