|
| 1 | +/** ******************************************************************* |
| 2 | + * copyright (c) 2024 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 { e2eContainer } from '../../configs/inversify.config'; |
| 13 | +import { CLASSES } from '../../configs/inversify.types'; |
| 14 | +import { By } from 'selenium-webdriver'; |
| 15 | +import { DriverHelper } from '../../utils/DriverHelper'; |
| 16 | +import { Logger } from '../../utils/Logger'; |
| 17 | +import { TIMEOUT_CONSTANTS } from '../../constants/TIMEOUT_CONSTANTS'; |
| 18 | +import { CheCodeLocatorLoader } from './CheCodeLocatorLoader'; |
| 19 | +import { ContextMenu, NewScmView, SingleScmProvider, Locators } from 'monaco-page-objects'; |
| 20 | + |
| 21 | +@injectable() |
| 22 | +export class ViewsMoreActionsButton { |
| 23 | + private static readonly VIEWS_AND_MORE_ACTIONS_BUTTON: By = By.xpath('//a[@role="button" and @aria-label="Views and More Actions..."]'); |
| 24 | + |
| 25 | + constructor( |
| 26 | + @inject(CLASSES.DriverHelper) |
| 27 | + readonly driverHelper: DriverHelper |
| 28 | + ) {} |
| 29 | + |
| 30 | + async closeSourceControlGraph(): Promise<void> { |
| 31 | + Logger.debug(); |
| 32 | + |
| 33 | + const cheCodeLocatorLoader: CheCodeLocatorLoader = e2eContainer.get(CLASSES.CheCodeLocatorLoader); |
| 34 | + const webCheCodeLocators: Locators = cheCodeLocatorLoader.webCheCodeLocators; |
| 35 | + |
| 36 | + const scmView: NewScmView = new NewScmView(); |
| 37 | + const [scmProvider]: SingleScmProvider[] = await scmView.getProviders(); |
| 38 | + |
| 39 | + Logger.debug('scmProvider.openMoreActions'); |
| 40 | + const scmContextMenu: ContextMenu = await scmProvider.openMoreActions(); |
| 41 | + await this.driverHelper.waitVisibility(webCheCodeLocators.ContextMenu.contextView); |
| 42 | + Logger.debug('scmContextMenu.select: "Source Control Graph"'); |
| 43 | + await scmContextMenu.select('Source Control Graph'); |
| 44 | + } |
| 45 | + |
| 46 | + async viewsAndMoreActionsButtonIsVisible(timeout: number = TIMEOUT_CONSTANTS.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<boolean> { |
| 47 | + Logger.debug(); |
| 48 | + |
| 49 | + const viewsActionsButton: boolean = await this.driverHelper.waitVisibilityBoolean( |
| 50 | + ViewsMoreActionsButton.VIEWS_AND_MORE_ACTIONS_BUTTON, |
| 51 | + timeout |
| 52 | + ); |
| 53 | + |
| 54 | + return viewsActionsButton; |
| 55 | + } |
| 56 | +} |
0 commit comments