diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 83b6f446f..bc81fba5d 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -444,6 +444,22 @@ export default { detailsButton: `vn-left-menu a[ui-sref="claim.card.detail"]`, addItemButton: `vn-claim-detail a vn-float-button` }, + claimDevelopment: { + developmentButton: 'vn-left-menu a[ui-sref="claim.card.development"]', + addDevelopmentButton: 'vn-claim-development > vn-vertical > vn-card > div > vn-vertical > vn-one > vn-icon-button > button > vn-icon', + firstDeleteDevelopmentButton: 'vn-claim-development > vn-vertical > vn-card > div > vn-vertical > form > vn-horizontal:nth-child(2) > vn-icon-button > button > vn-icon', + firstClaimReasonAutocomplete: 'vn-claim-development vn-horizontal:nth-child(2) vn-autocomplete[field="claimDevelopment.claimReasonFk"]', + firstClaimResultAutocomplete: 'vn-claim-development vn-horizontal:nth-child(2) vn-autocomplete[field="claimDevelopment.claimResultFk"]', + firstClaimResponsibleAutocomplete: 'vn-claim-development vn-horizontal:nth-child(2) vn-autocomplete[field="claimDevelopment.claimResponsibleFk"]', + firstClaimWorkerAutocomplete: 'vn-claim-development vn-horizontal:nth-child(2) vn-autocomplete[field="claimDevelopment.workerFk"]', + firstClaimRedeliveryAutocomplete: 'vn-claim-development vn-horizontal:nth-child(2) vn-autocomplete[field="claimDevelopment.claimRedeliveryFk"]', + secondClaimReasonAutocomplete: 'vn-claim-development vn-horizontal:nth-child(3) vn-autocomplete[field="claimDevelopment.claimReasonFk"]', + secondClaimResultAutocomplete: 'vn-claim-development vn-horizontal:nth-child(3) vn-autocomplete[field="claimDevelopment.claimResultFk"]', + secondClaimResponsibleAutocomplete: 'vn-claim-development vn-horizontal:nth-child(3) vn-autocomplete[field="claimDevelopment.claimResponsibleFk"]', + secondClaimWorkerAutocomplete: 'vn-claim-development vn-horizontal:nth-child(3) vn-autocomplete[field="claimDevelopment.workerFk"]', + secondClaimRedeliveryAutocomplete: 'vn-claim-development vn-horizontal:nth-child(3) vn-autocomplete[field="claimDevelopment.claimRedeliveryFk"]', + saveDevelopmentButton: `${components.vnSubmit}` + }, ordersIndex: { searchResult: `vn-order-index vn-card > div > vn-table > div > vn-tbody > a.vn-tr`, searchResultDate: `vn-order-index vn-table vn-tbody > a:nth-child(1) > vn-td:nth-child(4)`, diff --git a/e2e/paths/claim-module/02_create_development.spec.js b/e2e/paths/claim-module/02_create_development.spec.js new file mode 100644 index 000000000..a856586a2 --- /dev/null +++ b/e2e/paths/claim-module/02_create_development.spec.js @@ -0,0 +1,123 @@ +import selectors from '../../helpers/selectors.js'; +import createNightmare from '../../helpers/nightmare'; + +describe('Claim development', () => { + const nightmare = createNightmare(); + + beforeAll(() => { + nightmare + .loginAndModule('developer', 'claim') + .accessToSearchResult('1') + .accessToSection('claim.card.development'); + }); + + it('should delete a development and create a new one', async() => { + const result = await nightmare + .waitToClick(selectors.claimDevelopment.firstDeleteDevelopmentButton) + .waitToClick(selectors.claimDevelopment.addDevelopmentButton) + .autocompleteSearch(selectors.claimDevelopment.secondClaimReasonAutocomplete, 'Baja calidad') + .autocompleteSearch(selectors.claimDevelopment.secondClaimResultAutocomplete, 'Deshidratacion') + .autocompleteSearch(selectors.claimDevelopment.secondClaimResponsibleAutocomplete, 'Calidad general') + .autocompleteSearch(selectors.claimDevelopment.secondClaimWorkerAutocomplete, 'delivery') + .autocompleteSearch(selectors.claimDevelopment.secondClaimRedeliveryAutocomplete, 'Reparto') + .waitToClick(selectors.claimDevelopment.saveDevelopmentButton) + .waitForLastSnackbar(); + + expect(result).toEqual('Data saved!'); + }); + + it('should edit a development', async() => { + const result = await nightmare + .autocompleteSearch(selectors.claimDevelopment.firstClaimReasonAutocomplete, 'Calor') + .autocompleteSearch(selectors.claimDevelopment.firstClaimResultAutocomplete, 'Cocido') + .autocompleteSearch(selectors.claimDevelopment.firstClaimResponsibleAutocomplete, 'Calidad general') + .autocompleteSearch(selectors.claimDevelopment.firstClaimWorkerAutocomplete, 'adminAssistant') + .autocompleteSearch(selectors.claimDevelopment.firstClaimRedeliveryAutocomplete, 'Cliente') + .waitToClick(selectors.claimDevelopment.saveDevelopmentButton) + .waitForLastSnackbar(); + + expect(result).toEqual('Data saved!'); + }); + + it('should confirm the first development is the expected one', async() => { + const reason = await nightmare + .waitToClick(selectors.claimBasicData.basicDataButton) + .wait(selectors.claimBasicData.claimStateAutocomplete) + .click(selectors.claimDevelopment.developmentButton) + .waitToGetProperty(`${selectors.claimDevelopment.firstClaimReasonAutocomplete} input`, 'value'); + + const result = await nightmare + .waitToGetProperty(`${selectors.claimDevelopment.firstClaimResultAutocomplete} input`, 'value'); + + const responsible = await nightmare + .waitToGetProperty(`${selectors.claimDevelopment.firstClaimResponsibleAutocomplete} input`, 'value'); + + const worker = await nightmare + .waitToGetProperty(`${selectors.claimDevelopment.firstClaimWorkerAutocomplete} input`, 'value'); + + const redelivery = await nightmare + .waitToGetProperty(`${selectors.claimDevelopment.firstClaimRedeliveryAutocomplete} input`, 'value'); + + expect(reason).toEqual('Calor'); + expect(result).toEqual('Cocido'); + expect(responsible).toEqual('Calidad general'); + expect(worker).toEqual('adminAssistant adminAssistant'); + expect(redelivery).toEqual('Cliente'); + }); + + it('should confirm the second development is the expected one', async() => { + const reason = await nightmare + .waitToGetProperty(`${selectors.claimDevelopment.secondClaimReasonAutocomplete} input`, 'value'); + + const result = await nightmare + .waitToGetProperty(`${selectors.claimDevelopment.secondClaimResultAutocomplete} input`, 'value'); + + const responsible = await nightmare + .waitToGetProperty(`${selectors.claimDevelopment.secondClaimResponsibleAutocomplete} input`, 'value'); + + const worker = await nightmare + .waitToGetProperty(`${selectors.claimDevelopment.secondClaimWorkerAutocomplete} input`, 'value'); + + const redelivery = await nightmare + .waitToGetProperty(`${selectors.claimDevelopment.secondClaimRedeliveryAutocomplete} input`, 'value'); + + expect(reason).toEqual('Baja calidad'); + expect(result).toEqual('Deshidratacion'); + expect(responsible).toEqual('Calidad general'); + expect(worker).toEqual('delivery delivery'); + expect(redelivery).toEqual('Reparto'); + }); + + it('should delete the first development, add an empty one and save it', async() => { + const result = await nightmare + .waitToClick(selectors.claimDevelopment.firstDeleteDevelopmentButton) + .waitToClick(selectors.claimDevelopment.addDevelopmentButton) + .waitToClick(selectors.claimDevelopment.saveDevelopmentButton) + .waitForLastSnackbar(); + + expect(result).toEqual('Data saved!'); + }); + + it('should confirm the second development was auto filled', async() => { + const reason = await nightmare + .waitToGetProperty(`${selectors.claimDevelopment.secondClaimReasonAutocomplete} input`, 'value'); + + const result = await nightmare + .waitToGetProperty(`${selectors.claimDevelopment.secondClaimResultAutocomplete} input`, 'value'); + + const responsible = await nightmare + .waitToGetProperty(`${selectors.claimDevelopment.secondClaimResponsibleAutocomplete} input`, 'value'); + + const worker = await nightmare + .waitToGetProperty(`${selectors.claimDevelopment.secondClaimWorkerAutocomplete} input`, 'value'); + + const redelivery = await nightmare + .waitToGetProperty(`${selectors.claimDevelopment.secondClaimRedeliveryAutocomplete} input`, 'value'); + + expect(reason).toEqual('Prisas'); + expect(result).toEqual('Otros daƱos'); + expect(responsible).toEqual('Compradores'); + expect(worker).toEqual('manager manager'); + expect(redelivery).toEqual('Cliente'); + }); +});