salix/e2e/paths/06-claim-module/02_create_development.spec.js

132 lines
6.2 KiB
JavaScript

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, 'deliveryNick')
.autocompleteSearch(selectors.claimDevelopment.secondClaimRedeliveryAutocomplete, 'Reparto')
.waitToClick(selectors.claimDevelopment.saveDevelopmentButton)
.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
}, 15000);
it(`should redirect to the next section of claims as the role is salesAssistant`, async() => {
const url = await nightmare
.waitForURL('/action')
.parsedUrl();
expect(url.hash).toContain('/action');
});
it('should edit a development', async() => {
const result = await nightmare
.reloadSection('claim.card.development')
.autocompleteSearch(selectors.claimDevelopment.firstClaimReasonAutocomplete, 'Calor')
.autocompleteSearch(selectors.claimDevelopment.firstClaimResultAutocomplete, 'Cocido')
.autocompleteSearch(selectors.claimDevelopment.firstClaimResponsibleAutocomplete, 'Calidad general')
.autocompleteSearch(selectors.claimDevelopment.firstClaimWorkerAutocomplete, 'adminAssistantNick')
.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('adminAssistantNick');
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('deliveryNick');
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
.reloadSection('claim.card.development')
.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('managerNick');
expect(redelivery).toEqual('Cliente');
});
});