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

132 lines
6.2 KiB
JavaScript
Raw Normal View History

2019-01-15 07:33:19 +00:00
import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
2019-01-15 07:40:16 +00:00
describe('Claim development', () => {
2019-01-15 07:33:19 +00:00
const nightmare = createNightmare();
beforeAll(() => {
nightmare
2019-01-15 07:39:42 +00:00
.loginAndModule('salesAssistant', 'claim')
2019-01-15 07:33:19 +00:00
.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')
2019-01-15 07:33:19 +00:00
.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');
2019-01-15 07:33:19 +00:00
});
it('should edit a development', async() => {
const result = await nightmare
.reloadSection('claim.card.development')
2019-01-15 07:33:19 +00:00
.autocompleteSearch(selectors.claimDevelopment.firstClaimReasonAutocomplete, 'Calor')
.autocompleteSearch(selectors.claimDevelopment.firstClaimResultAutocomplete, 'Cocido')
.autocompleteSearch(selectors.claimDevelopment.firstClaimResponsibleAutocomplete, 'Calidad general')
.autocompleteSearch(selectors.claimDevelopment.firstClaimWorkerAutocomplete, 'adminAssistantNick')
2019-01-15 07:33:19 +00:00
.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')
2019-01-15 07:33:19 +00:00
.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');
2019-01-15 07:33:19 +00:00
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');
2019-01-15 07:33:19 +00:00
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')
2019-01-15 07:33:19 +00:00
.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');
2019-01-15 07:33:19 +00:00
expect(redelivery).toEqual('Cliente');
});
});