Test improve (#6146)

* fix

* fix datatable wait method

* slow down isEmpty check

* fix

* fix

* fix
This commit is contained in:
Eugenio Romano
2020-09-23 13:32:27 +01:00
committed by GitHub
parent 98742e898e
commit 3f1a9f4853
12 changed files with 89 additions and 29 deletions

View File

@@ -5,7 +5,7 @@ git:
language: node_js language: node_js
dist: bionic dist: bionic
node_js: node_js:
- '12.16.3' - '12.18.4'
before_install: . ./scripts/ci/job_hooks/before_install.sh before_install: . ./scripts/ci/job_hooks/before_install.sh
install: install:
@@ -46,8 +46,6 @@ stages:
addons: addons:
chrome: stable chrome: stable
before_script: before_script:
- "sudo chown root /opt/google/chrome/chrome-sandbox"
- "sudo chmod 4755 /opt/google/chrome/chrome-sandbox"
- export GIT_HASH=`git rev-parse HEAD` - export GIT_HASH=`git rev-parse HEAD`
services: services:
- xvfb - xvfb

View File

@@ -141,7 +141,7 @@ describe('Favorite directive', () => {
await customSourcesPage.checkRowIsNotDisplayed(testFile.entry.name); await customSourcesPage.checkRowIsNotDisplayed(testFile.entry.name);
await navigationBarPage.clickTrashcanButton(); await navigationBarPage.clickTrashcanButton();
await trashcanPage.waitForTableBody(); await trashcanPage.contentList.dataTablePage().waitTillContentLoaded();
await expect(await trashcanPage.numberOfResultsDisplayed()).toBe(1); await expect(await trashcanPage.numberOfResultsDisplayed()).toBe(1);
await trashcanPage.getDocumentList().dataTablePage().clickRowByContent(testFile.entry.name); await trashcanPage.getDocumentList().dataTablePage().clickRowByContent(testFile.entry.name);
await trashcanPage.getDocumentList().dataTablePage().checkRowByContentIsSelected(testFile.entry.name); await trashcanPage.getDocumentList().dataTablePage().checkRowByContentIsSelected(testFile.entry.name);

View File

@@ -92,6 +92,10 @@ export class LoginShellPage {
return BrowserActions.getText(this.loginError); return BrowserActions.getText(this.loginError);
} }
async checkLoginErrorIsDisplayed(loginError: string): Promise<void> {
await BrowserVisibility.waitUntilElementHasText(this.loginError, loginError);
}
async checkLoginImgURL(): Promise<string> { async checkLoginImgURL(): Promise<string> {
await BrowserVisibility.waitUntilElementIsVisible(this.logoImg); await BrowserVisibility.waitUntilElementIsVisible(this.logoImg);
return this.logoImg.getAttribute('src'); return this.logoImg.getAttribute('src');

View File

@@ -55,7 +55,7 @@ export class NotificationDemoPage {
} }
async waitForSnackBarToClose(): Promise<void> { async waitForSnackBarToClose(): Promise<void> {
await this.snackbarPage.waitForSnackBarToClose(); await this.snackbarPage.waitForSnackBarToClose(15000);
} }
async enterMessageField(text: string): Promise<void> { async enterMessageField(text: string): Promise<void> {

View File

@@ -82,7 +82,7 @@ describe('Settings component', () => {
await loginPage.enterUsername(browser.params.testConfig.admin.email); await loginPage.enterUsername(browser.params.testConfig.admin.email);
await loginPage.enterPassword(browser.params.testConfig.admin.password); await loginPage.enterPassword(browser.params.testConfig.admin.password);
await loginPage.clickSignInButton(); await loginPage.clickSignInButton();
await expect(await loginPage.getLoginError()).toMatch(loginError); await loginPage.checkLoginErrorIsDisplayed(loginError);
}); });
it('[C291952] Should not be able to sign in with invalid Process Services Url', async () => { it('[C291952] Should not be able to sign in with invalid Process Services Url', async () => {
@@ -93,7 +93,7 @@ describe('Settings component', () => {
await loginPage.enterUsername(browser.params.testConfig.admin.email); await loginPage.enterUsername(browser.params.testConfig.admin.email);
await loginPage.enterPassword(browser.params.testConfig.admin.password); await loginPage.enterPassword(browser.params.testConfig.admin.password);
await loginPage.clickSignInButton(); await loginPage.clickSignInButton();
await expect(await loginPage.getLoginError()).toMatch(loginError); await loginPage.checkLoginErrorIsDisplayed(loginError);
}); });
}); });

View File

@@ -99,6 +99,7 @@ describe('Edit task filters and task list properties', () => {
}); });
describe('Edit task filters and task list properties - filter properties', () => { describe('Edit task filters and task list properties - filter properties', () => {
beforeEach(async () => { beforeEach(async () => {
await navigationBarPage.navigateToProcessServicesCloudPage(); await navigationBarPage.navigateToProcessServicesCloudPage();
await appListCloudComponent.checkApsContainer(); await appListCloudComponent.checkApsContainer();

View File

@@ -259,23 +259,34 @@ describe('Start Task - Custom App', () => {
it('[C286404] Navigate using page field', async () => { it('[C286404] Navigate using page field', async () => {
currentPage = 1; currentPage = 1;
await taskListSinglePage.typeItemsPerPage(itemsPerPage.fiveValue); await taskListSinglePage.typeItemsPerPage(itemsPerPage.fiveValue);
await taskListSinglePage.taskList().getDataTable().waitTillContentLoaded();
await taskListSinglePage.typePage(currentPage); await taskListSinglePage.typePage(currentPage);
await taskListSinglePage.taskList().getDataTable().waitTillContentLoaded(); await taskListSinglePage.taskList().getDataTable().waitTillContentLoaded();
await expect(await paginationPage.getCurrentPage()).toEqual('Page ' + currentPage); await expect(await paginationPage.getCurrentPage()).toEqual('Page ' + currentPage);
await expect(await paginationPage.getTotalPages()).toEqual(totalNrOfPages); await expect(await paginationPage.getTotalPages()).toEqual(totalNrOfPages);
await paginationPage.checkPageSelectorIsDisplayed(); await paginationPage.checkPageSelectorIsDisplayed();
await expect(await taskListSinglePage.taskList().getDataTable().numberOfRows()).toBe(itemsPerPage.fiveValue); await expect(await taskListSinglePage.taskList().getDataTable().numberOfRows()).toBe(itemsPerPage.fiveValue);
await taskListSinglePage.taskList().getAllRowsNameColumn().then(async (list) => { await taskListSinglePage.taskList().getAllRowsNameColumn().then(async (list) => {
await expect(ArrayUtil.arrayContainsArray(list, allTasksName.slice(0, 5))).toEqual(true); await expect(ArrayUtil.arrayContainsArray(list, allTasksName.slice(0, 5))).toEqual(true);
}); });
currentPage++; currentPage++;
await taskListSinglePage.typePage(currentPage); await taskListSinglePage.typePage(currentPage);
await taskListSinglePage.taskList().getDataTable().waitTillContentLoaded(); await taskListSinglePage.taskList().getDataTable().waitTillContentLoaded();
await expect(await paginationPage.getCurrentPage()).toEqual('Page ' + currentPage); await expect(await paginationPage.getCurrentPage()).toEqual('Page ' + currentPage);
await expect(await paginationPage.getTotalPages()).toEqual(totalNrOfPages); await expect(await paginationPage.getTotalPages()).toEqual(totalNrOfPages);
await paginationPage.checkPageSelectorIsDisplayed(); await paginationPage.checkPageSelectorIsDisplayed();
await expect(await taskListSinglePage.taskList().getDataTable().numberOfRows()).toBe(itemsPerPage.fiveValue); await expect(await taskListSinglePage.taskList().getDataTable().numberOfRows()).toBe(itemsPerPage.fiveValue);
await taskListSinglePage.taskList().getAllRowsNameColumn().then(async (list) => { await taskListSinglePage.taskList().getAllRowsNameColumn().then(async (list) => {
await expect(ArrayUtil.arrayContainsArray(list, allTasksName.slice(5, 10))).toEqual(true); await expect(ArrayUtil.arrayContainsArray(list, allTasksName.slice(5, 10))).toEqual(true);
}); });
@@ -283,9 +294,12 @@ describe('Start Task - Custom App', () => {
currentPage++; currentPage++;
await taskListSinglePage.typePage(currentPage); await taskListSinglePage.typePage(currentPage);
await taskListSinglePage.taskList().getDataTable().waitTillContentLoaded(); await taskListSinglePage.taskList().getDataTable().waitTillContentLoaded();
await expect(await paginationPage.getCurrentPage()).toEqual('Page ' + currentPage); await expect(await paginationPage.getCurrentPage()).toEqual('Page ' + currentPage);
await expect(await paginationPage.getTotalPages()).toEqual(totalNrOfPages); await expect(await paginationPage.getTotalPages()).toEqual(totalNrOfPages);
await paginationPage.checkPageSelectorIsDisplayed(); await paginationPage.checkPageSelectorIsDisplayed();
await expect(await taskListSinglePage.taskList().getDataTable().numberOfRows()).toBe(itemsPerPage.fiveValue); await expect(await taskListSinglePage.taskList().getDataTable().numberOfRows()).toBe(itemsPerPage.fiveValue);
await taskListSinglePage.taskList().getAllRowsNameColumn().then(async (list) => { await taskListSinglePage.taskList().getAllRowsNameColumn().then(async (list) => {
await expect(ArrayUtil.arrayContainsArray(list, allTasksName.slice(10, 15))).toEqual(true); await expect(ArrayUtil.arrayContainsArray(list, allTasksName.slice(10, 15))).toEqual(true);
@@ -294,10 +308,14 @@ describe('Start Task - Custom App', () => {
currentPage++; currentPage++;
await taskListSinglePage.typePage(currentPage); await taskListSinglePage.typePage(currentPage);
await taskListSinglePage.taskList().getDataTable().waitTillContentLoaded(); await taskListSinglePage.taskList().getDataTable().waitTillContentLoaded();
await expect(await paginationPage.getCurrentPage()).toEqual('Page ' + currentPage); await expect(await paginationPage.getCurrentPage()).toEqual('Page ' + currentPage);
await expect(await paginationPage.getTotalPages()).toEqual(totalNrOfPages); await expect(await paginationPage.getTotalPages()).toEqual(totalNrOfPages);
await paginationPage.checkPageSelectorIsDisplayed(); await paginationPage.checkPageSelectorIsDisplayed();
await expect(await taskListSinglePage.taskList().getDataTable().numberOfRows()).toBe(itemsPerPage.fiveValue); await expect(await taskListSinglePage.taskList().getDataTable().numberOfRows()).toBe(itemsPerPage.fiveValue);
await taskListSinglePage.taskList().getAllRowsNameColumn().then(async (list) => { await taskListSinglePage.taskList().getAllRowsNameColumn().then(async (list) => {
await expect(ArrayUtil.arrayContainsArray(list, allTasksName.slice(15, 20))).toEqual(true); await expect(ArrayUtil.arrayContainsArray(list, allTasksName.slice(15, 20))).toEqual(true);
}); });

View File

@@ -17,7 +17,6 @@
import { import {
ApiService, ApiService,
BrowserActions,
LocalStorageUtil, LocalStorageUtil,
LoginPage, LoginPage,
StringUtil, StringUtil,
@@ -83,7 +82,10 @@ describe('Search Checklist Component', () => {
beforeEach(async () => { beforeEach(async () => {
await navigationBarPage.clickContentServicesButton(); await navigationBarPage.clickContentServicesButton();
await BrowserActions.getUrl(`${browser.baseUrl}/search;q=${randomName}`); await searchBarPage.checkSearchIconIsVisible();
await searchBarPage.clickOnSearchIcon();
await searchBarPage.enterTextAndPressEnter(randomName);
await searchResults.dataTable.waitTillContentLoaded();
}); });
afterAll(async () => { afterAll(async () => {

View File

@@ -257,15 +257,32 @@ export class DataTableComponentPage {
} }
} }
async checkContentIsDisplayed(columnName: string, columnValue: string): Promise<void> { async checkContentIsDisplayed(columnName: string, columnValue: string, retry = 0): Promise<void> {
Logger.log(`Wait content is displayed ${columnName} ${columnValue}`); Logger.log(`Wait content is displayed ${columnName} ${columnValue} retry: ${retry}`);
const row = this.getCellElementByValue(columnName, columnValue); const row = this.getCellElementByValue(columnName, columnValue);
await BrowserVisibility.waitUntilElementIsVisible(row);
try {
await BrowserVisibility.waitUntilElementIsVisible(row);
} catch (error) {
if (retry < 3) {
retry++;
await this.checkContentIsDisplayed(columnName, columnValue, retry);
}
}
} }
async checkContentIsNotDisplayed(columnName: string, columnValue: string): Promise<void> { async checkContentIsNotDisplayed(columnName: string, columnValue: string, retry = 0): Promise<void> {
Logger.log(`Wait content is displayed ${columnName} ${columnValue} retry: ${retry}`);
const row = this.getCellElementByValue(columnName, columnValue); const row = this.getCellElementByValue(columnName, columnValue);
await BrowserVisibility.waitUntilElementIsNotVisible(row);
try {
await BrowserVisibility.waitUntilElementIsNotVisible(row);
} catch (error) {
if (retry < 3) {
retry++;
await this.checkContentIsNotDisplayed(columnName, columnValue, retry);
}
}
} }
getRow(columnName: string, columnValue: string): ElementFinder { getRow(columnName: string, columnValue: string): ElementFinder {
@@ -292,11 +309,11 @@ export class DataTableComponentPage {
async waitTillContentLoaded(): Promise<void> { async waitTillContentLoaded(): Promise<void> {
await browser.sleep(500); await browser.sleep(500);
if (this.isSpinnerPresent()) { if (await this.isSpinnerPresent()) {
Logger.log('wait datatable loading spinner disappear'); Logger.log('wait datatable loading spinner disappear');
await BrowserVisibility.waitUntilElementIsNotVisible(element(by.tagName('mat-spinner'))); await BrowserVisibility.waitUntilElementIsNotVisible(element(by.tagName('mat-spinner')));
if (this.isEmpty()) { if (await this.isEmpty()) {
Logger.log('empty page'); Logger.log('empty page');
} else { } else {
await this.waitFirstElementPresent(); await this.waitFirstElementPresent();
@@ -304,10 +321,11 @@ export class DataTableComponentPage {
} else { } else {
try { try {
Logger.log('wait datatable loading spinner is present'); Logger.log('wait datatable loading spinner is present');
await BrowserVisibility.waitUntilElementIsVisible(element(by.tagName('mat-spinner'))); await BrowserVisibility.waitUntilElementIsVisible(element(by.tagName('mat-spinner')), 2000);
} catch (error) { } catch (error) {
} }
if (this.isEmpty()) {
if (await this.isEmpty()) {
Logger.log('empty page'); Logger.log('empty page');
} else { } else {
await this.waitFirstElementPresent(); await this.waitFirstElementPresent();
@@ -327,6 +345,18 @@ export class DataTableComponentPage {
return isSpinnerPresent; return isSpinnerPresent;
} }
private async isInfiniteSpinnerPresent(): Promise<boolean> {
let isSpinnerPresent;
try {
isSpinnerPresent = await element(by.tagName('mat-progress-bar')).isDisplayed();
} catch (error) {
isSpinnerPresent = false;
}
return isSpinnerPresent;
}
private async waitFirstElementPresent(): Promise<void> { private async waitFirstElementPresent(): Promise<void> {
try { try {
Logger.log('wait first element is present'); Logger.log('wait first element is present');
@@ -339,11 +369,11 @@ export class DataTableComponentPage {
async waitTillContentLoadedInfinitePagination(): Promise<void> { async waitTillContentLoadedInfinitePagination(): Promise<void> {
await browser.sleep(500); await browser.sleep(500);
if (this.isSpinnerPresent()) { if (await this.isInfiniteSpinnerPresent()) {
Logger.log('wait datatable loading spinner disappear'); Logger.log('wait datatable loading spinner disappear');
await BrowserVisibility.waitUntilElementIsNotVisible(element(by.tagName('mat-progress-bar'))); await BrowserVisibility.waitUntilElementIsNotVisible(element(by.tagName('mat-progress-bar')));
if (this.isEmpty()) { if (await this.isEmpty()) {
Logger.log('empty page'); Logger.log('empty page');
} else { } else {
await this.waitFirstElementPresent(); await this.waitFirstElementPresent();
@@ -351,15 +381,16 @@ export class DataTableComponentPage {
} else { } else {
try { try {
Logger.log('wait datatable loading spinner is present'); Logger.log('wait datatable loading spinner is present');
await BrowserVisibility.waitUntilElementIsVisible(element(by.tagName('mat-progress-bar'))); await BrowserVisibility.waitUntilElementIsVisible(element(by.tagName('mat-progress-bar')), 2000);
} catch (error) { } catch (error) {
} }
if (this.isEmpty()) { if (await this.isEmpty()) {
Logger.log('empty page'); Logger.log('empty page');
} else { } else {
await this.waitFirstElementPresent(); await this.waitFirstElementPresent();
} }
} } }
}
async checkColumnIsDisplayed(column: string): Promise<void> { async checkColumnIsDisplayed(column: string): Promise<void> {
await BrowserVisibility.waitUntilElementIsVisible(element(by.css(`div[data-automation-id="auto_id_entry.${column}"]`))); await BrowserVisibility.waitUntilElementIsVisible(element(by.css(`div[data-automation-id="auto_id_entry.${column}"]`)));
@@ -478,6 +509,8 @@ export class DataTableComponentPage {
} }
async isEmpty(): Promise<boolean> { async isEmpty(): Promise<boolean> {
await browser.sleep(500);
let isDisplayed; let isDisplayed;
try { try {
@@ -485,6 +518,9 @@ export class DataTableComponentPage {
} catch (error) { } catch (error) {
isDisplayed = false; isDisplayed = false;
} }
Logger.log(`empty page isDisplayed ${isDisplayed}`);
return isDisplayed; return isDisplayed;
} }

View File

@@ -57,8 +57,9 @@ export class LoginPage {
Logger.log('Login With ' + username); Logger.log('Login With ' + username);
const authType = await LocalStorageUtil.getConfigField('authType'); const authType = await LocalStorageUtil.getConfigField('authType');
const oauth: any = await LocalStorageUtil.getConfigField('oauth2');
if (!authType || authType === 'OAUTH') { if ((!authType || authType === 'OAUTH') && oauth.implicitFlow) {
await this.loginSSOIdentityService(username, password); await this.loginSSOIdentityService(username, password);
} else { } else {
await this.loginBasicAuth(username, password); await this.loginBasicAuth(username, password);

View File

@@ -25,14 +25,14 @@ export class SnackbarPage {
snackBarAction = element(by.css('simple-snack-bar button span')); snackBarAction = element(by.css('simple-snack-bar button span'));
snackBarContainerCss: Locator = by.css('.mat-snack-bar-container'); snackBarContainerCss: Locator = by.css('.mat-snack-bar-container');
async waitForSnackBarToAppear() { async waitForSnackBarToAppear(timeout = 5000) {
return BrowserVisibility.waitUntilElementIsVisible(element.all(this.snackBarContainerCss).first(), 5000, return BrowserVisibility.waitUntilElementIsVisible(element.all(this.snackBarContainerCss).first(), timeout,
'snackbar did not appear' 'snackbar did not appear'
); );
} }
async waitForSnackBarToClose() { async waitForSnackBarToClose(timeout = 5000) {
return BrowserVisibility.waitUntilElementIsNotVisible(element.all(this.snackBarContainerCss).first(), 5000); return BrowserVisibility.waitUntilElementIsNotVisible(element.all(this.snackBarContainerCss).first(), timeout);
} }
async getSnackBarMessage(): Promise<string> { async getSnackBarMessage(): Promise<string> {

View File

@@ -191,7 +191,7 @@ export class EditTaskFilterCloudComponentPage {
async clearAssignee(): Promise<void> { async clearAssignee(): Promise<void> {
await BrowserActions.clearWithBackSpace(this.assignee, 250); await BrowserActions.clearWithBackSpace(this.assignee, 250);
await browser.driver.sleep(1000); await this.dataTable.waitTillContentLoaded();
} }
async clearField(locator: ElementFinder): Promise<void> { async clearField(locator: ElementFinder): Promise<void> {