diff --git a/e2e/paths/order-module/02_edit_basic_data.spec.js b/e2e/paths/order-module/02_edit_basic_data.spec.js new file mode 100644 index 000000000..834503ab7 --- /dev/null +++ b/e2e/paths/order-module/02_edit_basic_data.spec.js @@ -0,0 +1,92 @@ +import selectors from '../../helpers/selectors.js'; +import createNightmare from '../../helpers/nightmare'; + +fdescribe('Order Edit basicData path', () => { + 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') + .click(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 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') + .wait(selectors.orderBasicData.companyAutocomplete) + .parsedUrl(); + + expect(url.hash).toEqual('#!/order/16/basic-data'); + }); + + it('should not be able to change the company', async() => { + const result = await nightmare + .autocompleteSearch(selectors.orderBasicData.companyAutocomplete, 'CCs') + .click(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', () => { + beforeAll(() => { + nightmare + .loginAndModule('employee', 'order') + .accessToSearchResult('18') + .accessToSection('order.card.basicData'); + }); + + it('should be able to modify all the properties', async() => { + const result = await nightmare + .autocompleteSearch(selectors.orderBasicData.clientAutocomplete, 'Tony Stark') + .autocompleteSearch(selectors.orderBasicData.companyAutocomplete, 'CCs') + .clearInput(selectors.orderBasicData.observationInput) + .type(selectors.orderBasicData.observationInput, 'Observation modified') + .click(selectors.orderBasicData.saveButton) + .waitForLastSnackbar(); + + expect(result).toEqual('Data saved!'); + }); + + it('should now confirm the client have been edited', async() => { + const result = await nightmare + .click(selectors.orderCatalog.catalogButton) + .wait(selectors.orderCatalog.orderByAutocomplete) + .click(selectors.orderBasicData.basicDataButton) + .waitToGetProperty(`${selectors.orderBasicData.clientAutocomplete} input`, 'value'); + + expect(result).toEqual('104: Tony Stark'); + }); + + it('should now confirm the comany have been edited', async() => { + const result = await nightmare + .waitToGetProperty(`${selectors.orderBasicData.companyAutocomplete} input`, 'value'); + + expect(result).toEqual('CCs'); + }); + + it('should now confirm the observations have been edited', async() => { + const result = await nightmare + .waitToGetProperty(selectors.orderBasicData.observationInput, 'value'); + + expect(result).toEqual('Observation modified'); + }); + }); +});