From 4e2ab537ee287c0c81f435464ed8b4bf311dcc12 Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Fri, 14 Feb 2020 14:52:47 +0100 Subject: [PATCH] unstable with the rest of tests --- e2e/helpers/extensions.js | 23 ++++++------- e2e/helpers/selectors.js | 10 ++++++ e2e/paths/04-item/13_request.spec.js | 48 +++++++++++++++++++++++++++ modules/item/front/request/index.html | 2 +- 4 files changed, 70 insertions(+), 13 deletions(-) create mode 100644 e2e/paths/04-item/13_request.spec.js diff --git a/e2e/helpers/extensions.js b/e2e/helpers/extensions.js index 816eea064..32c531f7c 100644 --- a/e2e/helpers/extensions.js +++ b/e2e/helpers/extensions.js @@ -179,6 +179,13 @@ let actions = { await this.click(selector); }, + writeOnEditableTD: async function(selector, text) { + let builtSelector = await this.selectorFormater(selector); + await this.waitToClick(selector); + await this.type(builtSelector, text); + await this.keyboard.press('Enter'); + }, + focusElement: async function(selector) { await this.wait(selector); return await this.evaluate(selector => { @@ -284,22 +291,14 @@ let actions = { }, {}, selector, text); }, - selectorFormater: async function(selector) { - let builtSelector = `${selector} input`; - - if (selector.includes('vn-autocomplete')) - return builtSelector = `${selector} input`; - + selectorFormater: function(selector) { if (selector.includes('vn-textarea')) - return builtSelector = `${selector} textarea`; - - if (selector.includes('vn-textfield')) - return builtSelector = `${selector} input`; + return `${selector} textarea`; if (selector.includes('vn-input-file')) - return builtSelector = `${selector} section`; + return `${selector} section`; - return builtSelector; + return `${selector} input`; }, waitForTextInField: async function(selector, text) { diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 63d40f9d5..16a9bb399 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -250,6 +250,16 @@ export default { inactiveIcon: 'vn-item-descriptor vn-icon[icon="icon-unavailable"]', navigateBackToIndex: 'vn-item-descriptor vn-icon[icon="chevron_left"]' }, + itemRequest: { + firstRequestItemID: 'vn-item-request vn-tbody > vn-tr:nth-child(1) > vn-td-editable:nth-child(7)', + firstRequestQuantity: 'vn-item-request vn-tbody > vn-tr:nth-child(1) > vn-td-editable:nth-child(8)', + firstRequestConcept: 'vn-item-request vn-tbody > vn-tr:nth-child(1) > vn-td:nth-child(9)', + firstRequestStatus: 'vn-item-request vn-tbody > vn-tr:nth-child(1) > vn-td:nth-child(10)', + firstRequestDecline: 'vn-item-request vn-tbody > vn-tr:nth-child(1) vn-icon-button[icon="thumb_down"]', + declineReason: 'vn-textarea[ng-model="$ctrl.denyObservation"]', + acceptDeclineReason: 'button[response="accept"]', + + }, itemBasicData: { basicDataButton: 'vn-left-menu a[ui-sref="item.card.basicData"]', goToItemIndexButton: 'vn-item-descriptor [ui-sref="item.index"]', diff --git a/e2e/paths/04-item/13_request.spec.js b/e2e/paths/04-item/13_request.spec.js new file mode 100644 index 000000000..9e53e300a --- /dev/null +++ b/e2e/paths/04-item/13_request.spec.js @@ -0,0 +1,48 @@ +import selectors from '../../helpers/selectors.js'; +import getBrowser from '../../helpers/puppeteer'; + +describe('Item request path', () => { + let browser; + let page; + beforeAll(async() => { + browser = await getBrowser(); + page = browser.page; + await page.loginAndModule('buyer', 'item'); + await page.accessToSection('item.request'); + }); + + afterAll(async() => { + await browser.close(); + }); + + it('should reach the item request section', async() => { + const result = await page.expectURL('/item/request'); + + expect(result).toBe(true); + }); + + it('should fill the id and quantity then check the concept was updated', async() => { + await page.writeOnEditableTD(selectors.itemRequest.firstRequestItemID, '4'); + await page.writeOnEditableTD(selectors.itemRequest.firstRequestQuantity, '10'); + await page.waitForTextInElement(selectors.itemRequest.firstRequestConcept, 'Melee weapon heavy shield 1x0.5m'); + let filledConcept = await page.waitToGetProperty(selectors.itemRequest.firstRequestConcept, 'innerText'); + + expect(filledConcept).toContain('Melee weapon heavy shield 1x0.5m'); + }); + + it('should the status of the request should now be accepted', async() => { + let status = await page.waitToGetProperty(selectors.itemRequest.firstRequestStatus, 'innerText'); + + expect(status).toContain('Aceptada'); + }); + + it('should now click on the first declain request icon then type the reason', async() => { + await page.waitToClick(selectors.itemRequest.firstRequestDecline); + await page.write(selectors.itemRequest.declineReason, 'not quite as expected'); + await page.waitToClick(selectors.itemRequest.acceptDeclineReason); + await page.waitForContentLoaded(); + let status = await page.waitToGetProperty(selectors.itemRequest.firstRequestStatus, 'innerText'); + + expect(status).toContain('Denegada'); + }); +}); diff --git a/modules/item/front/request/index.html b/modules/item/front/request/index.html index e0cf05107..3216e05e1 100644 --- a/modules/item/front/request/index.html +++ b/modules/item/front/request/index.html @@ -85,7 +85,7 @@