From 84606de1da4184919ac3635ffbad3d7323964e0f Mon Sep 17 00:00:00 2001 From: carlosjr Date: Mon, 27 Jun 2022 17:25:35 +0200 Subject: [PATCH] e2e path for claim notes + refactor --- e2e/helpers/selectors.js | 9 +++-- e2e/paths/06-claim/01_basic_data.spec.js | 11 ------ e2e/paths/06-claim/05_summary.spec.js | 2 +- e2e/paths/06-claim/07_note.spec.js | 46 ++++++++++++++++++++++++ 4 files changed, 54 insertions(+), 14 deletions(-) create mode 100644 e2e/paths/06-claim/07_note.spec.js diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 3638c26e0..0e3fa3b78 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -730,7 +730,7 @@ export default { claimSummary: { header: 'vn-claim-summary > vn-card > h5', state: 'vn-claim-summary vn-label-value[label="State"] > section > span', - observation: 'vn-claim-summary vn-textarea[ng-model="$ctrl.summary.claim.observation"]', + observation: 'vn-claim-summary vn-horizontal.text', firstSaleItemId: 'vn-claim-summary vn-horizontal > vn-auto:nth-child(5) vn-table > div > vn-tbody > vn-tr:nth-child(1) > vn-td:nth-child(1) > span', firstSaleDescriptorImage: '.vn-popover.shown vn-item-descriptor img', itemDescriptorPopover: '.vn-popover.shown vn-item-descriptor', @@ -742,7 +742,6 @@ export default { }, claimBasicData: { claimState: 'vn-claim-basic-data vn-autocomplete[ng-model="$ctrl.claim.claimStateFk"]', - observation: 'vn-textarea[ng-model="$ctrl.claim.observation"]', packages: 'vn-input-number[ng-model="$ctrl.claim.packages"]', hasToPickUpCheckbox: 'vn-claim-basic-data vn-check[ng-model="$ctrl.claim.hasToPickUp"]', saveButton: `button[type=submit]` @@ -772,6 +771,12 @@ export default { secondClaimRedelivery: 'vn-claim-development vn-horizontal:nth-child(2) vn-autocomplete[ng-model="claimDevelopment.claimRedeliveryFk"]', saveDevelopmentButton: 'button[type=submit]' }, + claimNote: { + addNoteFloatButton: 'vn-float-button', + note: 'vn-textarea[ng-model="$ctrl.note.text"]', + saveButton: 'button[type=submit]', + firstNoteText: 'vn-claim-note .text' + }, claimAction: { importClaimButton: 'vn-claim-action vn-button[label="Import claim"]', anyLine: 'vn-claim-action vn-tbody > vn-tr', diff --git a/e2e/paths/06-claim/01_basic_data.spec.js b/e2e/paths/06-claim/01_basic_data.spec.js index 2e2286939..0a08cad9f 100644 --- a/e2e/paths/06-claim/01_basic_data.spec.js +++ b/e2e/paths/06-claim/01_basic_data.spec.js @@ -22,8 +22,6 @@ describe('Claim edit basic data path', () => { it(`should edit claim state and observation fields`, async() => { await page.autocompleteSearch(selectors.claimBasicData.claimState, 'Gestionado'); - await page.clearTextarea(selectors.claimBasicData.observation); - await page.write(selectors.claimBasicData.observation, 'edited observation'); await page.clearInput(selectors.claimBasicData.packages); await page.write(selectors.claimBasicData.packages, '2'); await page.waitToClick(selectors.claimBasicData.saveButton); @@ -59,13 +57,6 @@ describe('Claim edit basic data path', () => { expect(hasToPickUpCheckbox).toBe('checked'); }); - it('should confirm the claim observation was edited', async() => { - const result = await page - .waitToGetProperty(selectors.claimBasicData.observation, 'value'); - - expect(result).toEqual('edited observation'); - }); - it('should confirm the claim packages was edited', async() => { const result = await page .waitToGetProperty(selectors.claimBasicData.packages, 'value'); @@ -75,8 +66,6 @@ describe('Claim edit basic data path', () => { it(`should edit the claim to leave it untainted`, async() => { await page.autocompleteSearch(selectors.claimBasicData.claimState, 'Pendiente'); - await page.clearTextarea(selectors.claimBasicData.observation); - await page.write(selectors.claimBasicData.observation, 'Observation one'); await page.clearInput(selectors.claimBasicData.packages); await page.write(selectors.claimBasicData.packages, '0'); await page.waitToClick(selectors.claimBasicData.saveButton); diff --git a/e2e/paths/06-claim/05_summary.spec.js b/e2e/paths/06-claim/05_summary.spec.js index 589b3b6cb..00b021f88 100644 --- a/e2e/paths/06-claim/05_summary.spec.js +++ b/e2e/paths/06-claim/05_summary.spec.js @@ -37,7 +37,7 @@ describe('Claim summary path', () => { }); it('should display the observation', async() => { - const result = await page.waitToGetProperty(selectors.claimSummary.observation, 'value'); + const result = await page.waitToGetProperty(selectors.claimSummary.observation, 'innerText'); expect(result).toContain('Wisi forensibus mnesarchum in cum. Per id impetus abhorreant'); }); diff --git a/e2e/paths/06-claim/07_note.spec.js b/e2e/paths/06-claim/07_note.spec.js new file mode 100644 index 000000000..830f77cbe --- /dev/null +++ b/e2e/paths/06-claim/07_note.spec.js @@ -0,0 +1,46 @@ +import selectors from '../../helpers/selectors'; +import getBrowser from '../../helpers/puppeteer'; + +describe('Claim Add note path', () => { + let browser; + let page; + beforeAll(async() => { + browser = await getBrowser(); + page = browser.page; + await page.loginAndModule('salesPerson', 'claim'); + await page.accessToSearchResult('2'); + await page.accessToSection('claim.card.note.index'); + }); + + afterAll(async() => { + await browser.close(); + }); + + it(`should reach the claim note index`, async() => { + await page.waitForState('claim.card.note.index'); + }); + + it(`should click on the add new note button`, async() => { + await page.waitToClick(selectors.claimNote.addNoteFloatButton); + await page.waitForState('claim.card.note.create'); + }); + + it(`should create a new note`, async() => { + await page.waitForSelector(selectors.claimNote.note); + await page.type(`${selectors.claimNote.note} textarea`, 'The delivery was unsuccessful'); + await page.waitToClick(selectors.claimNote.saveButton); + const message = await page.waitForSnackbar(); + + expect(message.text).toContain('Data saved!'); + }); + + it(`should redirect back to the claim notes page`, async() => { + await page.waitForState('claim.card.note.index'); + }); + + it('should confirm the note was created', async() => { + const result = await page.waitToGetProperty(selectors.claimNote.firstNoteText, 'innerText'); + + expect(result).toEqual('The delivery was unsuccessful'); + }); +});