import selectors from '../../helpers/selectors.js'; import createNightmare from '../../helpers/nightmare'; describe('Claim development', () => { const nightmare = createNightmare(); beforeAll(() => { nightmare .loginAndModule('salesAssistant', '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 .reloadSection('claim.card.development') .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'); }); });