#2137 e2e adaptados a Snackbar con contador

This commit is contained in:
Carlos Jimenez Ruiz 2020-02-21 10:26:40 +01:00
parent bb66f35f2f
commit 5c4d7bda18
6 changed files with 21 additions and 25 deletions

View File

@ -40,16 +40,12 @@ let actions = {
}, },
login: async function(userName) { login: async function(userName) {
try { await this.goto(`${defaultURL}/#!/login`);
await this.expectURL('#!/login'); let dialog = await this.evaluate(() => {
} catch (e) { return document.querySelector('button[response="accept"]');
await this.goto(`${defaultURL}/#!/login`); });
let dialog = await this.evaluate(() => { if (dialog)
return document.querySelector('button[response="accept"]'); await this.waitToClick('button[response="accept"]');
});
if (dialog)
await this.waitToClick('button[response="accept"]');
}
await this.doLogin(userName); await this.doLogin(userName);
await this.waitForFunction(() => { await this.waitForFunction(() => {
@ -175,7 +171,7 @@ let actions = {
}, },
waitToClick: async function(selector) { waitToClick: async function(selector) {
await this.waitForSelector(selector, {}); await this.waitForSelector(selector);
await this.click(selector); await this.click(selector);
}, },
@ -327,11 +323,17 @@ let actions = {
}, },
hideSnackbar: async function() { hideSnackbar: async function() {
await this.waitToClick('#shapes .shown button'); await this.evaluate(() => {
let hideButton = document.querySelector('#shapes .shown button');
if (hideButton)
return document.querySelector('#shapes .shown button').click();
});
}, },
waitForLastShape: async function(selector) { waitForLastSnackbar: async function() {
await this.wait(selector); const selector = 'vn-snackbar .shown .text';
await this.waitForSelector(selector);
let snackBarText = await this.evaluate(selector => { let snackBarText = await this.evaluate(selector => {
const shape = document.querySelector(selector); const shape = document.querySelector(selector);
@ -341,12 +343,6 @@ let actions = {
return snackBarText; return snackBarText;
}, },
waitForLastSnackbar: async function() {
await this.waitFor(1000); // this needs a refactor to be somehow dynamic ie: page.waitForResponse(urlOrPredicate[, options]) or something to fire waitForLastShape once the request is completed
await this.waitForSpinnerLoad();
return await this.waitForLastShape('vn-snackbar .shown .text');
},
accessToSearchResult: async function(searchValue) { accessToSearchResult: async function(searchValue) {
await this.clearInput('vn-searchbar'); await this.clearInput('vn-searchbar');
await this.write('vn-searchbar', searchValue); await this.write('vn-searchbar', searchValue);

View File

@ -28,7 +28,7 @@ export async function getBrowser() {
}); });
}); });
page = extendPage(page); page = extendPage(page);
page.setDefaultTimeout(5000); page.setDefaultTimeout(10000);
await page.goto(defaultURL, {waitUntil: 'networkidle0'}); await page.goto(defaultURL, {waitUntil: 'networkidle0'});
return {page, close: browser.close.bind(browser)}; return {page, close: browser.close.bind(browser)};
} }

View File

@ -101,7 +101,6 @@ describe('Client create path', async() => {
}); });
it('should click on the Clients button of the top bar menu', async() => { it('should click on the Clients button of the top bar menu', async() => {
await page.waitFor(500);
await page.waitToClick(selectors.globalItems.applicationsMenuButton); await page.waitToClick(selectors.globalItems.applicationsMenuButton);
await page.wait(selectors.globalItems.applicationsMenuVisible); await page.wait(selectors.globalItems.applicationsMenuVisible);
await page.waitToClick(selectors.globalItems.clientsButton); await page.waitToClick(selectors.globalItems.clientsButton);

View File

@ -63,14 +63,16 @@ describe('Client Add address path', () => {
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
}); });
it(`should click on the first address button to confirm the new address exists and it's the default one`, async() => { it(`should confirm the new address exists and it's the default one`, async() => {
const result = await page.waitToGetProperty(selectors.clientAddresses.defaultAddress, 'innerText'); const result = await page.waitToGetProperty(selectors.clientAddresses.defaultAddress, 'innerText');
expect(result).toContain('320 Park Avenue New York'); expect(result).toContain('320 Park Avenue New York');
}); });
it(`should click on the make default icon of the second address`, async() => { it(`should click on the make default icon of the second address`, async() => {
await page.waitForContentLoaded();
await page.waitToClick(selectors.clientAddresses.secondMakeDefaultStar); await page.waitToClick(selectors.clientAddresses.secondMakeDefaultStar);
await page.waitForContentLoaded();
const result = await page.waitForLastSnackbar(); const result = await page.waitForLastSnackbar();
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');

View File

@ -51,7 +51,6 @@ describe('Item Edit basic data path', () => {
}); });
it(`should save with the new intrastat`, async() => { it(`should save with the new intrastat`, async() => {
await page.waitFor(250);
await page.waitForTextInField(selectors.itemBasicData.intrastat, 'Tropical Flowers'); await page.waitForTextInField(selectors.itemBasicData.intrastat, 'Tropical Flowers');
await page.waitToClick(selectors.itemBasicData.submitBasicDataButton); await page.waitToClick(selectors.itemBasicData.submitBasicDataButton);
const result = await page.waitForLastSnackbar(); const result = await page.waitForLastSnackbar();

View File

@ -105,7 +105,7 @@ export default class Controller extends Component {
this.hideTimeout = setTimeout(() => { this.hideTimeout = setTimeout(() => {
this.hide(shape); this.hide(shape);
this.lastShape = null; this.lastShape = null;
}, data.timeout || 9000); }, data.timeout || 3000);
this.lastShape = { this.lastShape = {
data: data, data: data,