Skip to content

Commit

Permalink
add UserPreferences page test and page object (#22734)
Browse files Browse the repository at this point in the history
  • Loading branch information
SkorikSergey authored Dec 19, 2023
1 parent 1c9b84e commit 93348b5
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 1 deletion.
2 changes: 2 additions & 0 deletions tests/e2e/configs/inversify.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import { DevfilesRegistryHelper } from '../utils/DevfilesRegistryHelper';
import { Main as Generator } from '@eclipse-che/che-devworkspace-generator/lib/main';
import { ContainerTerminal, KubernetesCommandLineToolsExecutor } from '../utils/KubernetesCommandLineToolsExecutor';
import { ShellExecutor } from '../utils/ShellExecutor';
import { UserPreferences } from '../pageobjects/dashboard/UserPreferences';

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

Expand Down Expand Up @@ -84,6 +85,7 @@ e2eContainer.bind<DevfilesRegistryHelper>(CLASSES.DevfilesRegistryHelper).to(Dev
e2eContainer.bind<KubernetesCommandLineToolsExecutor>(CLASSES.KubernetesCommandLineToolsExecutor).to(KubernetesCommandLineToolsExecutor);
e2eContainer.bind<ShellExecutor>(CLASSES.ShellExecutor).to(ShellExecutor);
e2eContainer.bind<ContainerTerminal>(CLASSES.ContainerTerminal).to(ContainerTerminal);
e2eContainer.bind<UserPreferences>(CLASSES.UserPreferences).to(UserPreferences);

e2eContainer.bind<Generator>(EXTERNAL_CLASSES.Generator).to(Generator);
e2eContainer.bind<LocatorLoader>(EXTERNAL_CLASSES.LocatorLoader).to(LocatorLoader);
Expand Down
3 changes: 2 additions & 1 deletion tests/e2e/configs/inversify.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ const CLASSES: any = {
DevfilesRegistryHelper: 'DevfilesRegistryHelper',
KubernetesCommandLineToolsExecutor: 'KubernetesCommandLineToolsExecutor',
ShellExecutor: 'ShellExecutor',
ContainerTerminal: 'ContainerTerminal'
ContainerTerminal: 'ContainerTerminal',
UserPreferences: 'UserPreferences'
};

const EXTERNAL_CLASSES: any = {
Expand Down
89 changes: 89 additions & 0 deletions tests/e2e/pageobjects/dashboard/UserPreferences.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/** *******************************************************************
* 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 { inject, injectable } from 'inversify';
import 'reflect-metadata';
import { CLASSES } from '../../configs/inversify.types';
import { By } from 'selenium-webdriver';
import { DriverHelper } from '../../utils/DriverHelper';
import { Logger } from '../../utils/Logger';

@injectable()
export class UserPreferences {
private static readonly USER_SETTINGS_DROPDOWN: By = By.xpath('//header//button/span[text()!=""]//parent::button');
private static readonly USER_PREFERENCES_BUTTON: By = By.xpath('//button[text()="User Preferences"]');
private static readonly USER_PREFERENCES_PAGE: By = By.xpath('//h1[text()="User Preferences"]');

private static readonly CONTAINER_REGISTRIES_TAB: By = By.xpath('//button[text()="Container Registries"]');
private static readonly GIT_SERVICES_TAB: By = By.xpath('//button[text()="Git Services"]');

private static readonly PAT_TAB: By = By.xpath('//button[text()="Personal Access Tokens"]');
private static readonly ADD_NEW_PAT_BUTTON: By = By.xpath('//button[text()="Add Personal Access Token"]');

private static readonly GIT_CONFIG_PAGE: By = By.xpath('//button[text()="Gitconfig"]');

private static readonly SSH_KEY_TAB: By = By.xpath('//button[text()="SSH Keys"]');
private static readonly ADD_NEW_SSH_KEY_BUTTON: By = By.xpath('//button[text()="Add SSH Key"]');

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

async openUserPreferencesPage(): Promise<void> {
Logger.debug();

await this.driverHelper.waitAndClick(UserPreferences.USER_SETTINGS_DROPDOWN);
await this.driverHelper.waitAndClick(UserPreferences.USER_PREFERENCES_BUTTON);

await this.driverHelper.waitVisibility(UserPreferences.USER_PREFERENCES_PAGE);
}

async checkTabsAvailability(): Promise<void> {
Logger.debug();

await this.openContainerRegistriesTab();
await this.openGitServicesTab();
await this.openPatTab();
await this.openGitConfigPage();
await this.openSshKeyTab();
}

async openContainerRegistriesTab(): Promise<void> {
Logger.debug();

await this.driverHelper.waitAndClick(UserPreferences.CONTAINER_REGISTRIES_TAB);
}

async openGitServicesTab(): Promise<void> {
Logger.debug();

await this.driverHelper.waitAndClick(UserPreferences.GIT_SERVICES_TAB);
}

async openPatTab(): Promise<void> {
Logger.debug();

await this.driverHelper.waitAndClick(UserPreferences.PAT_TAB);
await this.driverHelper.waitVisibility(UserPreferences.ADD_NEW_PAT_BUTTON);
}

async openGitConfigPage(): Promise<void> {
Logger.debug();

await this.driverHelper.waitAndClick(UserPreferences.GIT_CONFIG_PAGE);
}

async openSshKeyTab(): Promise<void> {
Logger.debug();

await this.driverHelper.waitAndClick(UserPreferences.SSH_KEY_TAB);
await this.driverHelper.waitVisibility(UserPreferences.ADD_NEW_SSH_KEY_BUTTON);
}
}
30 changes: 30 additions & 0 deletions tests/e2e/specs/miscellaneous/UserPreferencesTest.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/** *******************************************************************
* copyright (c) 2020-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 { e2eContainer } from '../../configs/inversify.config';
import { CLASSES } from '../../configs/inversify.types';
import { LoginTests } from '../../tests-library/LoginTests';
import { BASE_TEST_CONSTANTS } from '../../constants/BASE_TEST_CONSTANTS';
import { UserPreferences } from '../../pageobjects/dashboard/UserPreferences';


suite(`"Check User Preferences page" test ${BASE_TEST_CONSTANTS.TEST_ENVIRONMENT}`, function (): void {
const loginTests: LoginTests = e2eContainer.get(CLASSES.LoginTests);
const userPreferences: UserPreferences = e2eContainer.get(CLASSES.UserPreferences);

suiteSetup('Login', async function (): Promise<void> {
await loginTests.loginIntoChe();
});

test(`Check user preferences page`, async function (): Promise<void> {
await userPreferences.openUserPreferencesPage();
await userPreferences.checkTabsAvailability();
});

});

0 comments on commit 93348b5

Please sign in to comment.