salix/e2e/paths/06-claim-module/06_descriptor.spec.js

72 lines
2.5 KiB
JavaScript

import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
describe('claim Descriptor path', () => {
const nightmare = createNightmare();
const claimId = 1;
it('should navigate to the target claim summary section', async() => {
let url = await nightmare
.loginAndModule('employee', 'claim')
.accessToSearchResult(claimId)
.waitForURL('/summary')
.parsedUrl();
expect(url.hash).toContain('/summary');
});
it(`should not be able to see the delete claim button of the descriptor more menu`, async() => {
let exists = await nightmare
.waitToClick(selectors.claimDescriptor.moreMenu)
.exists(selectors.claimDescriptor.moreMenuDeleteClaim);
expect(exists).toBeFalsy();
});
it(`should log in as salesAssistant and navigate to the target claim`, async() => {
let url = await nightmare
.loginAndModule('salesAssistant', 'claim')
.accessToSearchResult(claimId)
.waitForURL('/summary')
.parsedUrl();
expect(url.hash).toContain('/summary');
});
it(`should be able to see the delete claim button of the descriptor more menu`, async() => {
let exists = await nightmare
.waitToClick(selectors.claimDescriptor.moreMenu)
.wait(selectors.claimDescriptor.moreMenuDeleteClaim)
.exists(selectors.claimDescriptor.moreMenuDeleteClaim);
expect(exists).toBeTruthy();
});
it(`should delete the claim`, async() => {
let result = await nightmare
.waitToClick(selectors.claimDescriptor.moreMenuDeleteClaim)
.waitToClick(selectors.claimDescriptor.acceptDeleteClaim)
.waitForLastSnackbar();
expect(result).toEqual('Claim deleted!');
});
it(`should have been relocated to the claim index`, async() => {
let url = await nightmare
.waitForURL('/claim/index')
.parsedUrl();
expect(url.hash).toContain('/claim/index');
});
it(`should search for the deleted claim to find no results`, async() => {
const result = await nightmare
.write(selectors.claimsIndex.searchClaimInput, claimId)
.waitToClick(selectors.claimsIndex.searchButton)
.waitForNumberOfElements(selectors.claimsIndex.searchResult, 0)
.countElement(selectors.claimsIndex.searchResult);
expect(result).toEqual(0);
});
});