diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index da9aa3112..c941d80a2 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -494,6 +494,11 @@ export default { searchResult: 'vn-claim-index vn-card > div > vn-table > div > vn-tbody > a', searchButton: 'vn-claim-index vn-searchbar vn-icon[icon="search"]' }, + claimDescriptor: { + moreMenu: 'vn-claim-descriptor vn-icon-menu[vn-id="more-button"]', + moreMenuDeleteClaim: 'vn-claim-descriptor vn-icon-menu vn-drop-down li[name="Delete claim"]', + acceptDeleteClaim: 'vn-claim-descriptor > vn-confirm[vn-id="confirm-delete-claim"] button[response="ACCEPT"]' + }, claimSummary: { header: 'vn-claim-summary > vn-card > div > h5', state: 'vn-claim-summary vn-label-value[label="State"] > section > span', diff --git a/e2e/paths/06-claim-module/06_descriptor.spec.js b/e2e/paths/06-claim-module/06_descriptor.spec.js new file mode 100644 index 000000000..f43440129 --- /dev/null +++ b/e2e/paths/06-claim-module/06_descriptor.spec.js @@ -0,0 +1,70 @@ +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) + .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); + }); +});