diff --git a/tests/e2e/configs/inversify.config.ts b/tests/e2e/configs/inversify.config.ts index 7dce0b5ae32..6aba4125dae 100644 --- a/tests/e2e/configs/inversify.config.ts +++ b/tests/e2e/configs/inversify.config.ts @@ -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 }); @@ -84,6 +85,7 @@ e2eContainer.bind(CLASSES.DevfilesRegistryHelper).to(Dev e2eContainer.bind(CLASSES.KubernetesCommandLineToolsExecutor).to(KubernetesCommandLineToolsExecutor); e2eContainer.bind(CLASSES.ShellExecutor).to(ShellExecutor); e2eContainer.bind(CLASSES.ContainerTerminal).to(ContainerTerminal); +e2eContainer.bind(CLASSES.UserPreferences).to(UserPreferences); e2eContainer.bind(EXTERNAL_CLASSES.Generator).to(Generator); e2eContainer.bind(EXTERNAL_CLASSES.LocatorLoader).to(LocatorLoader); diff --git a/tests/e2e/configs/inversify.types.ts b/tests/e2e/configs/inversify.types.ts index f2d2dff1071..1e040aecb8c 100644 --- a/tests/e2e/configs/inversify.types.ts +++ b/tests/e2e/configs/inversify.types.ts @@ -47,7 +47,8 @@ const CLASSES: any = { DevfilesRegistryHelper: 'DevfilesRegistryHelper', KubernetesCommandLineToolsExecutor: 'KubernetesCommandLineToolsExecutor', ShellExecutor: 'ShellExecutor', - ContainerTerminal: 'ContainerTerminal' + ContainerTerminal: 'ContainerTerminal', + UserPreferences: 'UserPreferences' }; const EXTERNAL_CLASSES: any = { diff --git a/tests/e2e/pageobjects/dashboard/UserPreferences.ts b/tests/e2e/pageobjects/dashboard/UserPreferences.ts new file mode 100644 index 00000000000..d0a5c560748 --- /dev/null +++ b/tests/e2e/pageobjects/dashboard/UserPreferences.ts @@ -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 { + 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 { + Logger.debug(); + + await this.openContainerRegistriesTab(); + await this.openGitServicesTab(); + await this.openPatTab(); + await this.openGitConfigPage(); + await this.openSshKeyTab(); + } + + async openContainerRegistriesTab(): Promise { + Logger.debug(); + + await this.driverHelper.waitAndClick(UserPreferences.CONTAINER_REGISTRIES_TAB); + } + + async openGitServicesTab(): Promise { + Logger.debug(); + + await this.driverHelper.waitAndClick(UserPreferences.GIT_SERVICES_TAB); + } + + async openPatTab(): Promise { + Logger.debug(); + + await this.driverHelper.waitAndClick(UserPreferences.PAT_TAB); + await this.driverHelper.waitVisibility(UserPreferences.ADD_NEW_PAT_BUTTON); + } + + async openGitConfigPage(): Promise { + Logger.debug(); + + await this.driverHelper.waitAndClick(UserPreferences.GIT_CONFIG_PAGE); + } + + async openSshKeyTab(): Promise { + Logger.debug(); + + await this.driverHelper.waitAndClick(UserPreferences.SSH_KEY_TAB); + await this.driverHelper.waitVisibility(UserPreferences.ADD_NEW_SSH_KEY_BUTTON); + } +} diff --git a/tests/e2e/specs/miscellaneous/UserPreferencesTest.spec.ts b/tests/e2e/specs/miscellaneous/UserPreferencesTest.spec.ts new file mode 100644 index 00000000000..90344449303 --- /dev/null +++ b/tests/e2e/specs/miscellaneous/UserPreferencesTest.spec.ts @@ -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 { + await loginTests.loginIntoChe(); + }); + + test(`Check user preferences page`, async function (): Promise { + await userPreferences.openUserPreferencesPage(); + await userPreferences.checkTabsAvailability(); + }); + +});