unstable with the rest of tests
gitea/salix/1835-e2e-item-request This commit looks good Details

This commit is contained in:
Carlos Jimenez Ruiz 2020-02-14 14:52:47 +01:00
parent fe91ca080e
commit 4e2ab537ee
4 changed files with 70 additions and 13 deletions

View File

@ -179,6 +179,13 @@ let actions = {
await this.click(selector); 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) { focusElement: async function(selector) {
await this.wait(selector); await this.wait(selector);
return await this.evaluate(selector => { return await this.evaluate(selector => {
@ -284,22 +291,14 @@ let actions = {
}, {}, selector, text); }, {}, selector, text);
}, },
selectorFormater: async function(selector) { selectorFormater: function(selector) {
let builtSelector = `${selector} input`;
if (selector.includes('vn-autocomplete'))
return builtSelector = `${selector} input`;
if (selector.includes('vn-textarea')) if (selector.includes('vn-textarea'))
return builtSelector = `${selector} textarea`; return `${selector} textarea`;
if (selector.includes('vn-textfield'))
return builtSelector = `${selector} input`;
if (selector.includes('vn-input-file')) if (selector.includes('vn-input-file'))
return builtSelector = `${selector} section`; return `${selector} section`;
return builtSelector; return `${selector} input`;
}, },
waitForTextInField: async function(selector, text) { waitForTextInField: async function(selector, text) {

View File

@ -250,6 +250,16 @@ export default {
inactiveIcon: 'vn-item-descriptor vn-icon[icon="icon-unavailable"]', inactiveIcon: 'vn-item-descriptor vn-icon[icon="icon-unavailable"]',
navigateBackToIndex: 'vn-item-descriptor vn-icon[icon="chevron_left"]' 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: { itemBasicData: {
basicDataButton: 'vn-left-menu a[ui-sref="item.card.basicData"]', basicDataButton: 'vn-left-menu a[ui-sref="item.card.basicData"]',
goToItemIndexButton: 'vn-item-descriptor [ui-sref="item.index"]', goToItemIndexButton: 'vn-item-descriptor [ui-sref="item.index"]',

View File

@ -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');
});
});

View File

@ -85,7 +85,7 @@
<vn-td> <vn-td>
<vn-icon <vn-icon
ng-if="request.response.length" ng-if="request.response.length"
ranslate-attr="{title: request.response}" translate-attr="{title: request.response}"
icon="insert_drive_file"> icon="insert_drive_file">
</vn-icon> </vn-icon>
<vn-icon-button <vn-icon-button