salix/e2e/paths/claim-module/01_edit_basic_data.spec.js

113 lines
4.2 KiB
JavaScript

import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/helpers.js';
describe('Claim edit basic data path', () => {
const nightmare = createNightmare();
beforeAll(() => {
return nightmare
.waitForLogin('salesAssistant');
});
it('should click on the Claims button of the top bar menu', done => {
return nightmare
.waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible)
.waitToClick(selectors.globalItems.claimsButton)
.wait(selectors.claimsIndex.searchClaimInput)
.parsedUrl()
.then(url => {
expect(url.hash).toEqual('#!/claim/index');
done();
}).catch(done.fail);
});
it('should search for the claim with id 1', done => {
return nightmare
.wait(selectors.claimsIndex.searchResult)
.type(selectors.claimsIndex.searchClaimInput, '1')
.click(selectors.claimsIndex.searchButton)
.waitForNumberOfElements(selectors.claimsIndex.searchResult, 1)
.countElement(selectors.claimsIndex.searchResult)
.then(result => {
expect(result).toEqual(1);
done();
}).catch(done.fail);
});
it(`should click on the search result to access to the claim Basic Data`, done => {
return nightmare
.waitToClick(selectors.claimsIndex.searchResult)
.waitToClick(selectors.claimBasicData.basicDataButton)
.waitForURL('basic-data')
.url()
.then(url => {
expect(url).toContain('basic-data');
done();
}).catch(done.fail);
});
it(`should edit claim state, is paid with mana and observation fields`, done => {
return nightmare
.waitToClick(selectors.claimBasicData.claimStateSelect)
.waitToClick(selectors.claimBasicData.claimStateSelectThirdOption)
.waitToClick(selectors.claimBasicData.isPaidWithManaCheckbox)
.clearInput(selectors.claimBasicData.observationInput)
.type(selectors.claimBasicData.observationInput, 'edited observation')
.click(selectors.claimBasicData.saveButton)
.waitForSnackbar()
.then(result => {
expect(result).toEqual(jasmine.arrayContaining(['Data saved!']));
done();
}).catch(done.fail);
});
it('should confirm the claim state was edited', done => {
return nightmare
.click(selectors.claimDetails.detailsButton)
.wait(selectors.claimDetails.addItemButton)
.click(selectors.claimBasicData.basicDataButton)
.wait(selectors.claimBasicData.claimStateSelect)
.getInputValue(selectors.claimBasicData.claimStateSelect)
.then(result => {
expect(result).toEqual('Gestionado');
done();
}).catch(done.fail);
});
it('should confirm the Is paid with mana checkbox is checked', done => {
return nightmare
.evaluate(selector => {
return document.querySelector(selector).checked;
}, selectors.claimBasicData.isPaidWithManaCheckbox)
.then(value => {
expect(value).toBeTruthy();
done();
}).catch(done.fail);
});
it('should confirm the claim observation was edited', done => {
return nightmare
.getInputValue(selectors.claimBasicData.observationInput)
.then(result => {
expect(result).toEqual('edited observation');
done();
}).catch(done.fail);
});
it(`should edit the claim to leave it untainted`, done => {
return nightmare
.waitToClick(selectors.claimBasicData.claimStateSelect)
.waitToClick(selectors.claimBasicData.claimStateSelectFourthOption)
.waitToClick(selectors.claimBasicData.isPaidWithManaCheckbox)
.clearInput(selectors.claimBasicData.observationInput)
.type(selectors.claimBasicData.observationInput, 'Observation one')
.click(selectors.claimBasicData.saveButton)
.waitForSnackbar()
.then(result => {
expect(result).toEqual(jasmine.arrayContaining(['Data saved!']));
done();
}).catch(done.fail);
});
});