From 9c021dc1bd7cc835aa8976ed44a16954c0a7927e Mon Sep 17 00:00:00 2001 From: sreekanthpuligadda <52752138+sreekanthpuligadda@users.noreply.github.com> Date: Fri, 24 Jan 2020 09:28:13 +0000 Subject: [PATCH] Tests/eui 1002 test coverage (#357) * Refactor and fix existing functional tests * New browser to handle user registration email on mailinator domain * Functional tests invite user and validate after successful registration * End to end scenarios added * common run config to separet file * Fixed config import/require * minor fix to use chai-promised * Fixed minor issues. added jenkins nightly file for nightly functional test build. * Fixed step definition mapping issue. * Include invite suer scenario to functional test group * config update * added retry page load on blank or service error. * Applied fixes to make tests robust * locator fix * Added scenario to validate MC login for invited user * Fixes to improve robustness of tests. * merge conflict fixes * Added retry actions to handle scenario robustness * Ret login added to get to login page * fix missing async keyword for function * Fixes to screenshot util and Invite user retries * Fixed world param reference in step definition * Replaced page refresh with get url to overcome service error page. * Fixed by adding async function * Disabled flakey tests on pipeline * Fix to wait for spinner to disappear * Handing spinner to improve test stability. * fix to use screenshot util in step def. --- test/e2e/features/pageObjects/headerPage.js | 7 +++++++ test/e2e/features/step_definitions/loginLogout.steps.js | 4 +++- .../features/step_definitions/viewOrganisation.steps.js | 7 +++++-- test/e2e/features/step_definitions/viewUser.steps.js | 5 ++++- test/e2e/support/customWaits.js | 4 ++-- 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/test/e2e/features/pageObjects/headerPage.js b/test/e2e/features/pageObjects/headerPage.js index d55b31553..7dbedbef6 100644 --- a/test/e2e/features/pageObjects/headerPage.js +++ b/test/e2e/features/pageObjects/headerPage.js @@ -43,6 +43,7 @@ class HeaderPage { } async clickUser(){ + await this.waitForSpinnerNotPresent(); await BrowserWaits.waitForElementNotVisible(this.spinner); await BrowserWaits.waitForElement(this.user); await BrowserWaits.waitForElementClickable(this.user); @@ -51,6 +52,7 @@ class HeaderPage { } async clickOrganisation() { + await this.waitForSpinnerNotPresent(); await BrowserWaits.waitForElementNotVisible(this.spinner); await BrowserWaits.waitForElement(this.organisation); await BrowserWaits.waitForElementClickable(this.organisation); @@ -58,6 +60,11 @@ class HeaderPage { // browser.sleep(AMAZING_DELAY); } + async waitForSpinnerNotPresent(){ + await BrowserWaits.waitForElementNotVisible(element(by.css('div.spinner-wrapper')), 60000); + + } + } diff --git a/test/e2e/features/step_definitions/loginLogout.steps.js b/test/e2e/features/step_definitions/loginLogout.steps.js index cf2fcd0ef..4b159e129 100644 --- a/test/e2e/features/step_definitions/loginLogout.steps.js +++ b/test/e2e/features/step_definitions/loginLogout.steps.js @@ -11,7 +11,8 @@ const browserWaits = require('../../support/customWaits'); const mailinatorService = require('../pageObjects/mailinatorService'); const manageCasesService = require('../pageObjects/manageCasesService'); - +const HeaderPage = require('../pageObjects/headerPage'); +const headerPage = new HeaderPage(); async function waitForElement(el) { await browser.wait(result => { @@ -113,6 +114,7 @@ defineSupportCode(function ({ Given, When, Then }) { browser.sleep(SHORT_DELAY); await expect(loginPage.signOutlink.isDisplayed()).to.eventually.be.true; browser.sleep(SHORT_DELAY); + await headerPage.waitForSpinnerNotPresent(); await loginPage.signOutlink.click(); browser.sleep(SHORT_DELAY); }); diff --git a/test/e2e/features/step_definitions/viewOrganisation.steps.js b/test/e2e/features/step_definitions/viewOrganisation.steps.js index d87eb3f93..e0556b409 100644 --- a/test/e2e/features/step_definitions/viewOrganisation.steps.js +++ b/test/e2e/features/step_definitions/viewOrganisation.steps.js @@ -4,6 +4,7 @@ const loginPage = require('../pageObjects/loginLogoutObjects'); const { AMAZING_DELAY, SHORT_DELAY, MID_DELAY, LONG_DELAY } = require('../../support/constants'); const EC = protractor.ExpectedConditions; const browserWaits = require('../../support/customWaits'); +const { config } = require('../../config/common.conf.js'); var {defineSupportCode} = require('cucumber'); @@ -20,8 +21,10 @@ defineSupportCode(function ({And, But, Given, Then, When}) { .then(stream => { const decodedImage = new Buffer(stream.replace(/^data:image\/(png|gif|jpeg);base64,/, ''), 'base64'); world.attach(decodedImage, 'image/png'); - }) - await headerPage.clickOrganisation(); + }); + await browser.get(config.config.baseUrl + '/organisation'); + + // await headerPage.clickOrganisation(); }); }); diff --git a/test/e2e/features/step_definitions/viewUser.steps.js b/test/e2e/features/step_definitions/viewUser.steps.js index ff5272eae..4b711950b 100644 --- a/test/e2e/features/step_definitions/viewUser.steps.js +++ b/test/e2e/features/step_definitions/viewUser.steps.js @@ -4,6 +4,7 @@ const loginPage = require('../pageObjects/loginLogoutObjects'); const { AMAZING_DELAY, SHORT_DELAY, MID_DELAY, LONG_DELAY } = require('../../support/constants'); const EC = protractor.ExpectedConditions; +const { config } = require('../../config/common.conf.js'); var {defineSupportCode} = require('cucumber'); const browserWaits = require('../../support/customWaits'); @@ -27,8 +28,10 @@ defineSupportCode(function ({And, But, Given, Then, When}) { const decodedImage = new Buffer(stream.replace(/^data:image\/(png|gif|jpeg);base64,/, ''), 'base64'); world.attach(decodedImage, 'image/png'); }) - await headerPage.clickUser(); + await browser.get(config.config.baseUrl+'/users'); + // await headerPage.clickUser(); }); + await viewUserPage.amOnPage(); // browser.sleep(AMAZING_DELAY); diff --git a/test/e2e/support/customWaits.js b/test/e2e/support/customWaits.js index a08da68ec..13a7bf380 100644 --- a/test/e2e/support/customWaits.js +++ b/test/e2e/support/customWaits.js @@ -13,8 +13,8 @@ class BrowserWaits { await browser.wait(EC.visibilityOf(waitelement), this.waitTime, "Error : " + waitelement.locator().toString()); } - async waitForElementNotVisible(element) { - await browser.wait(EC.not(EC.presenceOf(element), this.waitTime, "Error : " + element.locator().toString())); + async waitForElementNotVisible(element,customWait) { + await browser.wait(EC.not(EC.presenceOf(element), customWait ? customWait : this.waitTime, "Error : " + element.locator().toString())); } async waitForPresenceOfElement(element) {