|
| 1 | +/** ******************************************************************* |
| 2 | + * copyright (c) 2019-2023 Red Hat, Inc. |
| 3 | + * |
| 4 | + * This program and the accompanying materials are made |
| 5 | + * available under the terms of the Eclipse Public License 2.0 |
| 6 | + * which is available at https://www.eclipse.org/legal/epl-2.0/ |
| 7 | + * |
| 8 | + * SPDX-License-Identifier: EPL-2.0 |
| 9 | + **********************************************************************/ |
| 10 | +import { inject, injectable } from 'inversify'; |
| 11 | +import 'reflect-metadata'; |
| 12 | +import { CLASSES } from '../../configs/inversify.types'; |
| 13 | +import { By } from 'selenium-webdriver'; |
| 14 | +import { DriverHelper } from '../../utils/DriverHelper'; |
| 15 | +import { Logger } from '../../utils/Logger'; |
| 16 | + |
| 17 | +@injectable() |
| 18 | +export class UserPreferences { |
| 19 | + private static readonly USER_SETTINGS_DROPDOWN: By = By.xpath('//header//button/span[text()!=""]//parent::button'); |
| 20 | + private static readonly USER_PREFERENCES_BUTTON: By = By.xpath('//button[text()="User Preferences"]'); |
| 21 | + private static readonly USER_PREFERENCES_PAGE: By = By.xpath('//h1[text()="User Preferences"]'); |
| 22 | + |
| 23 | + private static readonly CONTAINER_REGISTRIES_TAB: By = By.xpath('//button[text()="Container Registries"]'); |
| 24 | + private static readonly GIT_SERVICES_TAB: By = By.xpath('//button[text()="Git Services"]'); |
| 25 | + |
| 26 | + private static readonly PAT_TAB: By = By.xpath('//button[text()="Personal Access Tokens"]'); |
| 27 | + private static readonly ADD_NEW_PAT_BUTTON: By = By.xpath('//button[text()="Add Personal Access Token"]'); |
| 28 | + |
| 29 | + private static readonly GIT_CONFIG_PAGE: By = By.xpath('//button[text()="Gitconfig"]'); |
| 30 | + |
| 31 | + private static readonly SSH_KEY_TAB: By = By.xpath('//button[text()="SSH Keys"]'); |
| 32 | + private static readonly ADD_NEW_SSH_KEY_BUTTON: By = By.xpath('//button[text()="Add SSH Key"]'); |
| 33 | + |
| 34 | + constructor( |
| 35 | + @inject(CLASSES.DriverHelper) |
| 36 | + readonly driverHelper: DriverHelper |
| 37 | + ) {} |
| 38 | + |
| 39 | + async openUserPreferencesPage(): Promise<void> { |
| 40 | + Logger.debug(); |
| 41 | + |
| 42 | + await this.driverHelper.waitAndClick(UserPreferences.USER_SETTINGS_DROPDOWN); |
| 43 | + await this.driverHelper.waitAndClick(UserPreferences.USER_PREFERENCES_BUTTON); |
| 44 | + |
| 45 | + await this.driverHelper.waitVisibility(UserPreferences.USER_PREFERENCES_PAGE); |
| 46 | + } |
| 47 | + |
| 48 | + async checkTabsAvailability(): Promise<void> { |
| 49 | + Logger.debug(); |
| 50 | + |
| 51 | + await this.openContainerRegistriesTab(); |
| 52 | + await this.openGitServicesTab(); |
| 53 | + await this.openPatTab(); |
| 54 | + await this.openGitConfigPage(); |
| 55 | + await this.openSshKeyTab(); |
| 56 | + } |
| 57 | + |
| 58 | + async openContainerRegistriesTab(): Promise<void> { |
| 59 | + Logger.debug(); |
| 60 | + |
| 61 | + await this.driverHelper.waitAndClick(UserPreferences.CONTAINER_REGISTRIES_TAB); |
| 62 | + } |
| 63 | + |
| 64 | + async openGitServicesTab(): Promise<void> { |
| 65 | + Logger.debug(); |
| 66 | + |
| 67 | + await this.driverHelper.waitAndClick(UserPreferences.GIT_SERVICES_TAB); |
| 68 | + } |
| 69 | + |
| 70 | + async openPatTab(): Promise<void> { |
| 71 | + Logger.debug(); |
| 72 | + |
| 73 | + await this.driverHelper.waitAndClick(UserPreferences.PAT_TAB); |
| 74 | + await this.driverHelper.waitVisibility(UserPreferences.ADD_NEW_PAT_BUTTON); |
| 75 | + } |
| 76 | + |
| 77 | + async openGitConfigPage(): Promise<void> { |
| 78 | + Logger.debug(); |
| 79 | + |
| 80 | + await this.driverHelper.waitAndClick(UserPreferences.GIT_CONFIG_PAGE); |
| 81 | + } |
| 82 | + |
| 83 | + async openSshKeyTab(): Promise<void> { |
| 84 | + Logger.debug(); |
| 85 | + |
| 86 | + await this.driverHelper.waitAndClick(UserPreferences.SSH_KEY_TAB); |
| 87 | + await this.driverHelper.waitVisibility(UserPreferences.ADD_NEW_SSH_KEY_BUTTON); |
| 88 | + } |
| 89 | +} |
0 commit comments