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();
|
2019-06-19 07:03:45 +00:00
|
|
|
const today = new Date().getDate();
|
|
|
|
|
2019-01-08 11:02:38 +00:00
|
|
|
describe('when confirmed order', () => {
|
|
|
|
beforeAll(() => {
|
|
|
|
nightmare
|
|
|
|
.loginAndModule('employee', 'order')
|
2019-06-14 10:27:41 +00:00
|
|
|
.accessToSearchResult(1)
|
2019-01-08 11:02:38 +00:00
|
|
|
.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() => {
|
2019-06-14 10:27:41 +00:00
|
|
|
const orderId = 16;
|
2019-01-08 11:02:38 +00:00
|
|
|
const url = await nightmare
|
|
|
|
.waitToClick(selectors.globalItems.returnToModuleIndexButton)
|
2019-06-19 07:03:45 +00:00
|
|
|
.waitToClick(selectors.globalItems.acceptButton)
|
2019-01-08 11:02:38 +00:00
|
|
|
.wait(selectors.ordersIndex.createOrderButton)
|
2019-06-14 10:27:41 +00:00
|
|
|
.accessToSearchResult(orderId)
|
2019-01-08 11:02:38 +00:00
|
|
|
.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();
|
|
|
|
|
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() => {
|
2019-01-08 11:02:38 +00:00
|
|
|
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-06-19 07:03:45 +00:00
|
|
|
it('should navigate to the order index and click the new order button', async() => {
|
2019-01-23 14:34:16 +00:00
|
|
|
const url = await nightmare
|
|
|
|
.waitToClick(selectors.globalItems.returnToModuleIndexButton)
|
2019-06-19 07:03:45 +00:00
|
|
|
.waitToClick(selectors.globalItems.acceptButton)
|
2019-06-14 10:27:41 +00:00
|
|
|
.waitToClick(selectors.ordersIndex.createOrderButton)
|
2019-06-19 07:03:45 +00:00
|
|
|
.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')
|
2019-06-14 10:27:41 +00:00
|
|
|
.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
|
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();
|
|
|
|
|
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() => {
|
|
|
|
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-06-19 07:03:45 +00:00
|
|
|
.write(selectors.orderBasicData.observationInput, 'my 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('Data saved!');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should now confirm the client have been edited', async() => {
|
|
|
|
const result = await nightmare
|
2019-01-27 20:09:54 +00:00
|
|
|
.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');
|
|
|
|
|
2019-06-19 07:03:45 +00:00
|
|
|
expect(result).toEqual('my observation');
|
2019-01-08 11:02:38 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|