Skip to content

Commit

Permalink
"DevConsole integration" regression test case automation (#22181)
Browse files Browse the repository at this point in the history
Signed-off-by: mdolhalo <mdolhalo@redhat.com>
  • Loading branch information
nallikaea committed May 3, 2023
1 parent 008f7d6 commit 2c79499
Show file tree
Hide file tree
Showing 16 changed files with 420 additions and 31 deletions.
14 changes: 10 additions & 4 deletions tests/e2e/configs/inversify.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ import { ProjectAndFileTests } from '../tests-library/ProjectAndFileTests';
import { LoginTests } from '../tests-library/LoginTests';
import { RedHatLoginPage } from '../pageobjects/login/RedHatLoginPage';
import { OcpRedHatLoginPage } from '../pageobjects/login/OcpRedHatLoginPage';
import { OcpMainPage } from '../pageobjects/openshift/OcpMainPage';
import { OcpImportFromGitPage } from '../pageobjects/openshift/OcpImportFromGitPage';
import { OcpApplicationPage } from '../pageobjects/openshift/OcpApplicationPage';

const e2eContainer: Container = new Container({defaultScope: 'Transient'});

Expand All @@ -53,6 +56,12 @@ e2eContainer.bind<Workspaces>(CLASSES.Workspaces).to(Workspaces);
e2eContainer.bind<WorkspaceDetails>(CLASSES.WorkspaceDetails).to(WorkspaceDetails);
e2eContainer.bind<ScreenCatcher>(CLASSES.ScreenCatcher).to(ScreenCatcher);
e2eContainer.bind<OcpLoginPage>(CLASSES.OcpLoginPage).to(OcpLoginPage);

e2eContainer.bind<OcpMainPage>(CLASSES.OcpMainPage).to(OcpMainPage);
e2eContainer.bind<OcpImportFromGitPage>(CLASSES.OcpImportFromGitPage).to(OcpImportFromGitPage);
e2eContainer.bind<OcpApplicationPage>(CLASSES.OcpApplicationPage).to(OcpApplicationPage);


e2eContainer.bind<CheLoginPage>(CLASSES.CheLoginPage).to(CheLoginPage);
e2eContainer.bind<CheApiRequestHandler>(CLASSES.CheApiRequestHandler).to(CheApiRequestHandler);
e2eContainer.bind<CreateWorkspace>(CLASSES.CreateWorkspace).to(CreateWorkspace);
Expand All @@ -61,13 +70,10 @@ e2eContainer.bind<LoginTests>(CLASSES.LoginTests).to(LoginTests);
e2eContainer.bind<Sanitizer>(CLASSES.Sanitizer).to(Sanitizer);
e2eContainer.bind<ApiUrlResolver>(CLASSES.ApiUrlResolver).to(ApiUrlResolver);
e2eContainer.bind<WorkspaceHandlingTests>(CLASSES.WorkspaceHandlingTests).to(WorkspaceHandlingTests);
e2eContainer.bind<RedHatLoginPage>(CLASSES.RedHatLoginPage).to(RedHatLoginPage);

TestConstants.TS_SELENIUM_VALUE_OPENSHIFT_OAUTH ?
e2eContainer.bind<ICheLoginPage>(TYPES.CheLogin).to(RegularUserOcpCheLoginPage) :
e2eContainer.bind<ICheLoginPage>(TYPES.CheLogin).to(OcpRedHatLoginPage);

if (TestConstants.TS_OCP_LOGIN_PAGE_PROVIDER_TITLE === 'DevSandbox') {
e2eContainer.bind<RedHatLoginPage>(CLASSES.RedHatLoginPage).to(RedHatLoginPage);
}

export { e2eContainer };
3 changes: 3 additions & 0 deletions tests/e2e/configs/inversify.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ const CLASSES: any = {
WorkspaceHandlingTests: 'WorkspaceHandlingTests',
RedHatLoginPage: 'RedHatLoginPage',
OcpRedHatLoginPage: 'OcpRedHatLoginPage',
OcpApplicationPage: 'OcpApplicationPage',
OcpMainPage: 'OcpMainPage',
OcpImportFromGitPage: 'OcpImportFromGitPage'
};

export { TYPES, CLASSES };
3 changes: 3 additions & 0 deletions tests/e2e/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ export * from './pageobjects/login/OcpUserLoginPage';
export * from './pageobjects/login/RedHatLoginPage';
export * from './pageobjects/login/RegularUserOcpCheLoginPage';
export * from './pageobjects/openshift/CheLoginPage';
export * from './pageobjects/openshift/OcpApplicationPage';
export * from './pageobjects/openshift/OcpImportFromGitPage';
export * from './pageobjects/openshift/OcpLoginPage';
export * from './pageobjects/openshift/OcpMainPage';
export * from './tests-library/LoginTests';
export * from './tests-library/ProjectAndFileTests';
export * from './tests-library/WorkspaceHandlingTests';
42 changes: 42 additions & 0 deletions tests/e2e/pageobjects/openshift/OcpApplicationPage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*********************************************************************
* Copyright (c) 2019-2023 Red Hat, Inc.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
import 'reflect-metadata';
import { inject, injectable } from 'inversify';
import { DriverHelper } from '../../utils/DriverHelper';
import { CLASSES } from '../../configs/inversify.types';
import { By } from 'selenium-webdriver';
import { Logger } from '../../utils/Logger';
import { TimeoutConstants } from '../../constants/TimeoutConstants';
import { BrowserTabsUtil } from '../../utils/BrowserTabsUtil';

@injectable()
export class OcpApplicationPage {

private static readonly APPLICATION_ICON_LOCATOR: By = By.xpath('//*[@data-test-id="base-node-handler"]');
private static readonly EDIT_SOURCE_CODE_ICON_LOCATOR: By = By.xpath('//*[@aria-label="Edit source code"]');

constructor(
@inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper,
@inject(CLASSES.BrowserTabsUtil) private readonly browserTabsUtil: BrowserTabsUtil) {
}

async waitApplicationIcon(): Promise<void> {
Logger.debug(`${this.constructor.name}.${this.waitApplicationIcon.name}`);

await this.driverHelper.waitPresence(OcpApplicationPage.APPLICATION_ICON_LOCATOR, TimeoutConstants.TS_SELENIUM_LOAD_PAGE_TIMEOUT);
}

async waitAndOpenEditSourceCodeIcon(): Promise<void> {
Logger.debug(`${this.constructor.name}.${this.waitAndOpenEditSourceCodeIcon.name}`);
const parentGUID: string = await this.browserTabsUtil.getCurrentWindowHandle();
await this.driverHelper.waitAndClick(OcpApplicationPage.EDIT_SOURCE_CODE_ICON_LOCATOR);
await this.browserTabsUtil.waitAndSwitchToAnotherWindow(parentGUID, TimeoutConstants.TS_SELENIUM_LOAD_PAGE_TIMEOUT);
}
}
87 changes: 87 additions & 0 deletions tests/e2e/pageobjects/openshift/OcpImportFromGitPage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/*********************************************************************
* Copyright (c) 2019-2023 Red Hat, Inc.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
import 'reflect-metadata';
import { inject, injectable } from 'inversify';
import { DriverHelper } from '../../utils/DriverHelper';
import { CLASSES } from '../../configs/inversify.types';
import { By } from 'selenium-webdriver';
import { Logger } from '../../utils/Logger';
import { OcpApplicationPage } from './OcpApplicationPage';
import { e2eContainer } from '../../configs/inversify.config';

@injectable()
export class OcpImportFromGitPage {

private static readonly GIT_URL_INPUT_LOCATOR: By = By.id('form-input-git-url-field');
private static readonly SHOW_ADVANCED_GIT_OPTIONS_LINK_LOCATOR: By = By.xpath('//*[text()="Show advanced Git options"]//ancestor::button');
private static readonly HIDE_ADVANCED_GIT_OPTIONS_LOCATOR: By = By.xpath('//*[text()="Hide advanced Git options"]');
private static readonly GIT_REFERENCE_INPUT_LOCATOR: By = By.id('form-input-git-ref-field');
private static readonly EDIT_IMPORT_STRATEGY_LINK_LOCATOR: By = By.xpath('//*[text()="Edit Import Strategy"]//ancestor::button');
private static readonly BUILDER_IMAGE_STRATEGY_ITEM_LOCATOR: By = By.xpath('//*[text()="Builder Image"]//parent::div//parent::div');
private static readonly ADD_LABEL_LINK_LOCATOR: By = By.xpath('//button[text()="Labels"]');
private static readonly ADD_LABEL_INPUT_LOCATOR: By = By.id('form-selector-labels-field');
private static readonly SUBMIT_BUTTON_LOCATOR: By = By.xpath('//*[@data-test-id="submit-button"]');

constructor(
@inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper) {
}

async enterGitRepoUrl(gitRepoUrl: string): Promise<void> {
Logger.debug(`${this.constructor.name}.${this.enterGitRepoUrl.name} "${gitRepoUrl}"`);

await this.driverHelper.enterValue(OcpImportFromGitPage.GIT_URL_INPUT_LOCATOR, gitRepoUrl);
}

async clickOnAdvancedOptionsButton(): Promise<void> {
Logger.debug(`${this.constructor.name}.${this.clickOnAdvancedOptionsButton.name}`);

if (!(await this.driverHelper.isVisible(OcpImportFromGitPage.HIDE_ADVANCED_GIT_OPTIONS_LOCATOR))) {
await this.driverHelper.waitAndClick(OcpImportFromGitPage.SHOW_ADVANCED_GIT_OPTIONS_LINK_LOCATOR);
}
}

async enterGitReference(gitReference: string): Promise<void> {
Logger.debug(`${this.constructor.name}.${this.enterGitReference.name} "${gitReference}"`);

await this.driverHelper.enterValue(OcpImportFromGitPage.GIT_REFERENCE_INPUT_LOCATOR, gitReference);
}

async selectBuilderImageImportStrategy(): Promise<void> {
Logger.debug(`${this.constructor.name}.${this.selectBuilderImageImportStrategy.name}`);

await this.driverHelper.scrollToAndClick(OcpImportFromGitPage.EDIT_IMPORT_STRATEGY_LINK_LOCATOR);
await this.driverHelper.scrollToAndClick(OcpImportFromGitPage.BUILDER_IMAGE_STRATEGY_ITEM_LOCATOR);
}

async addLabel(label: string): Promise<void> {
Logger.debug(`${this.constructor.name}.${this.addLabel.name} "${label}"`);

await this.driverHelper.scrollToAndClick(OcpImportFromGitPage.ADD_LABEL_LINK_LOCATOR);
await this.driverHelper.scrollToAndEnterValue(OcpImportFromGitPage.ADD_LABEL_INPUT_LOCATOR, label);
}

async submitConfiguration(): Promise<OcpApplicationPage> {
Logger.debug(`${this.constructor.name}.${this.submitConfiguration.name}`);

await this.driverHelper.waitAndClick(OcpImportFromGitPage.SUBMIT_BUTTON_LOCATOR);
return e2eContainer.get(CLASSES.OcpApplicationPage);
}

async fitAndSubmitConfiguration(gitRepoUrl: string, gitReference: string, label: string): Promise<OcpApplicationPage> {
Logger.debug(`${this.constructor.name}.${this.fitAndSubmitConfiguration.name}`);

await this.enterGitRepoUrl(gitRepoUrl);
await this.clickOnAdvancedOptionsButton();
await this.enterGitReference(gitReference);
await this.selectBuilderImageImportStrategy();
await this.addLabel(label);
return await this.submitConfiguration();
}
}
6 changes: 3 additions & 3 deletions tests/e2e/pageobjects/openshift/OcpLoginPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class OcpLoginPage {
Logger.debug('OcpLoginPage.clickOnLoginProviderTitle');

const loginProviderTitleLocator: By = By.xpath(`//a[text()=\'${TestConstants.TS_OCP_LOGIN_PAGE_PROVIDER_TITLE}\']`);
await this.driverHelper.waitAndClick(loginProviderTitleLocator);
await this.driverHelper.waitAndClick(loginProviderTitleLocator, TimeoutConstants.TS_SELENIUM_WAIT_FOR_URL);
}

async isIdentityProviderLinkVisible(): Promise<boolean> {
Expand Down Expand Up @@ -80,8 +80,8 @@ export class OcpLoginPage {
async clickOnLoginButton(): Promise<void> {
Logger.debug('OcpLoginPage.clickOnLoginButton');

const loginButtonlocator: By = By.css('button[type=submit]');
await this.driverHelper.waitAndClick(loginButtonlocator);
const loginButtonLocator: By = By.css('button[type=submit]');
await this.driverHelper.waitAndClick(loginButtonLocator);
}

async waitDisappearanceOpenShiftLoginWelcomePage(): Promise<void> {
Expand Down
87 changes: 87 additions & 0 deletions tests/e2e/pageobjects/openshift/OcpMainPage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/*********************************************************************
* Copyright (c) 2019-2023 Red Hat, Inc.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
import 'reflect-metadata';
import { inject, injectable } from 'inversify';
import { DriverHelper } from '../../utils/DriverHelper';
import { CLASSES } from '../../configs/inversify.types';
import { By } from 'selenium-webdriver';
import { Logger } from '../../utils/Logger';
import { TimeoutConstants } from '../../constants/TimeoutConstants';
import { OcpImportFromGitPage } from './OcpImportFromGitPage';
import { e2eContainer } from '../../configs/inversify.config';

@injectable()
export class OcpMainPage {

private static readonly MAIN_PAGE_HEADER_LOCATOR: By = By.id('page-main-header');
private static readonly SELECT_ROLE_BUTTON_LOCATOR: By = By.xpath('//*[@data-test-id="perspective-switcher-toggle"]');
private static readonly ADD_BUTTON_LOCATOR: By = By.xpath('//*[@data-test-id="+Add-header"]');
private static readonly IMPORT_FROM_GIT_ITEM_LOCATOR: By = By.xpath('//*[@data-test="item import-from-git"]');
private static readonly SELECT_PROJECT_DROPDOWN_LOCATOR: By = By.xpath('//div[@class="co-namespace-dropdown"]//button');
private static readonly PROJECT_FILTER_INPUT_LOCATOR: By = By.xpath('//*[@data-test="dropdown-text-filter"]');

private static getRoleLocator(role: string): By {
return By.xpath(`//a//*[text()="${role}"]`);
}

private static getProjectDropdownItemLocator(projectName: string): By {
return By.xpath(`//button//*[text()="${projectName}"]`);
}

constructor(
@inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper) { }

async waitOpenMainPage(): Promise<void> {
Logger.debug(`${this.constructor.name}.${this.waitOpenMainPage.name}`);

await this.driverHelper.waitVisibility(OcpMainPage.MAIN_PAGE_HEADER_LOCATOR, TimeoutConstants.TS_SELENIUM_LOAD_PAGE_TIMEOUT);
}

async clickOnSelectRoleButton(): Promise<void> {
Logger.debug(`${this.constructor.name}.${this.clickOnSelectRoleButton.name}`);

await this.driverHelper.waitAndClick(OcpMainPage.SELECT_ROLE_BUTTON_LOCATOR);
}

async clickAddToProjectButton(): Promise<void> {
Logger.debug(`${this.constructor.name}.${this.clickAddToProjectButton.name}`);

await this.driverHelper.waitAndClick(OcpMainPage.ADD_BUTTON_LOCATOR);
}

async selectDeveloperRole(): Promise<void> {
Logger.debug(`${this.constructor.name}.${this.selectDeveloperRole.name}`);

await this.driverHelper.waitAndClick(OcpMainPage.getRoleLocator('Developer'));
}

async selectImportFromGitMethod(): Promise<OcpImportFromGitPage> {
Logger.debug(`${this.constructor.name}.${this.selectImportFromGitMethod.name}`);

await this.driverHelper.waitAndClick(OcpMainPage.IMPORT_FROM_GIT_ITEM_LOCATOR);
return e2eContainer.get(CLASSES.OcpImportFromGitPage);
}

async openImportFromGitPage(): Promise<OcpImportFromGitPage> {
await this.waitOpenMainPage();
await this.clickOnSelectRoleButton();
await this.selectDeveloperRole();
await this.clickAddToProjectButton();
return await this.selectImportFromGitMethod();
}

async selectProject(projectName: string): Promise<void> {
Logger.debug(`${this.constructor.name}.${this.selectProject.name}`);

await this.driverHelper.waitAndClick(OcpMainPage.SELECT_PROJECT_DROPDOWN_LOCATOR);
await this.driverHelper.enterValue(OcpMainPage.PROJECT_FILTER_INPUT_LOCATOR, projectName);
await this.driverHelper.waitAndClick(OcpMainPage.getProjectDropdownItemLocator(projectName));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ suite(`Check if recommended extensions installed for ${samples}`, async function
test(`Let extensions complete installation`, async function (): Promise<void> {
Logger.info(`Time for extensions installation TimeoutConstants.TS_COMMON_PLUGIN_TEST_TIMEOUT=${TimeoutConstants.TS_COMMON_PLUGIN_TEST_TIMEOUT}`);
await driverHelper.wait(TimeoutConstants.TS_COMMON_PLUGIN_TEST_TIMEOUT);
browserTabsUtil.refreshPage();
await browserTabsUtil.refreshPage();
await projectAndFileTests.waitWorkspaceReadinessForCheCodeEditor();
});

Expand Down
Loading

0 comments on commit 2c79499

Please sign in to comment.