diff --git a/tests/e2e/configs/inversify.config.ts b/tests/e2e/configs/inversify.config.ts index 4bb89cf6e52..0847de699ba 100644 --- a/tests/e2e/configs/inversify.config.ts +++ b/tests/e2e/configs/inversify.config.ts @@ -54,6 +54,7 @@ import { ShellExecutor } from '../utils/ShellExecutor'; import { UserPreferences } from '../pageobjects/dashboard/UserPreferences'; import { WebTerminalPage } from '../pageobjects/webterminal/WebTerminalPage'; import { TrustAuthorPopup } from '../pageobjects/dashboard/TrustAuthorPopup'; +import { ViewsMoreActionsButton } from '../pageobjects/ide/ViewsMoreActionsButton'; const e2eContainer: Container = new Container({ defaultScope: 'Transient', skipBaseClassChecks: true }); @@ -93,6 +94,7 @@ e2eContainer.bind(EXTERNAL_CLASSES.Generator).to(Generator); e2eContainer.bind(EXTERNAL_CLASSES.LocatorLoader).to(LocatorLoader); e2eContainer.bind(EXTERNAL_CLASSES.LocatorLoader).to(LocatorLoader); e2eContainer.bind(CLASSES.TrustAuthorPopup).to(TrustAuthorPopup); +e2eContainer.bind(CLASSES.ViewsMoreActionsButton).to(ViewsMoreActionsButton); if (BASE_TEST_CONSTANTS.TS_PLATFORM === Platform.OPENSHIFT) { if (OAUTH_CONSTANTS.TS_SELENIUM_VALUE_OPENSHIFT_OAUTH) { diff --git a/tests/e2e/configs/inversify.types.ts b/tests/e2e/configs/inversify.types.ts index ab89535896f..7abce8b702d 100644 --- a/tests/e2e/configs/inversify.types.ts +++ b/tests/e2e/configs/inversify.types.ts @@ -51,7 +51,8 @@ const CLASSES: any = { UserPreferences: 'UserPreferences', WebTerminalPage: 'WebTerminalPage', RevokeOauthPage: 'RevokeOauthPage', - TrustAuthorPopup: 'TrustAuthorPopup' + TrustAuthorPopup: 'TrustAuthorPopup', + ViewsMoreActionsButton: 'ViewsMoreActionsButton' }; const EXTERNAL_CLASSES: any = { diff --git a/tests/e2e/index.ts b/tests/e2e/index.ts index 9f91e26cd3e..44027982124 100644 --- a/tests/e2e/index.ts +++ b/tests/e2e/index.ts @@ -30,6 +30,7 @@ export * from './pageobjects/dashboard/workspace-details/WorkspaceDetails'; export * from './pageobjects/dashboard/Workspaces'; export * from './pageobjects/git-providers/OauthPage'; export * from './pageobjects/ide/CheCodeLocatorLoader'; +export * from './pageobjects/ide/ViewsMoreActionsButton'; export * from './pageobjects/login/interfaces/ICheLoginPage'; export * from './pageobjects/login/interfaces/IOcpLoginPage'; export * from './pageobjects/login/kubernetes/DexLoginPage'; diff --git a/tests/e2e/pageobjects/ide/ViewsMoreActionsButton.ts b/tests/e2e/pageobjects/ide/ViewsMoreActionsButton.ts new file mode 100644 index 00000000000..6ede53a9034 --- /dev/null +++ b/tests/e2e/pageobjects/ide/ViewsMoreActionsButton.ts @@ -0,0 +1,56 @@ +/** ******************************************************************* + * copyright (c) 2024 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 { e2eContainer } from '../../configs/inversify.config'; +import { CLASSES } from '../../configs/inversify.types'; +import { By } from 'selenium-webdriver'; +import { DriverHelper } from '../../utils/DriverHelper'; +import { Logger } from '../../utils/Logger'; +import { TIMEOUT_CONSTANTS } from '../../constants/TIMEOUT_CONSTANTS'; +import { CheCodeLocatorLoader } from './CheCodeLocatorLoader'; +import { ContextMenu, NewScmView, SingleScmProvider, Locators } from 'monaco-page-objects'; + +@injectable() +export class ViewsMoreActionsButton { + private static readonly VIEWS_AND_MORE_ACTIONS_BUTTON: By = By.xpath('//a[@role="button" and @aria-label="Views and More Actions..."]'); + + constructor( + @inject(CLASSES.DriverHelper) + readonly driverHelper: DriverHelper + ) {} + + async closeSourceControlGraph(): Promise { + Logger.debug(); + + const cheCodeLocatorLoader: CheCodeLocatorLoader = e2eContainer.get(CLASSES.CheCodeLocatorLoader); + const webCheCodeLocators: Locators = cheCodeLocatorLoader.webCheCodeLocators; + + const scmView: NewScmView = new NewScmView(); + const [scmProvider]: SingleScmProvider[] = await scmView.getProviders(); + + Logger.debug('scmProvider.openMoreActions'); + const scmContextMenu: ContextMenu = await scmProvider.openMoreActions(); + await this.driverHelper.waitVisibility(webCheCodeLocators.ContextMenu.contextView); + Logger.debug('scmContextMenu.select: "Source Control Graph"'); + await scmContextMenu.select('Source Control Graph'); + } + + async viewsAndMoreActionsButtonIsVisible(timeout: number = TIMEOUT_CONSTANTS.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise { + Logger.debug(); + + const viewsActionsButton: boolean = await this.driverHelper.waitVisibilityBoolean( + ViewsMoreActionsButton.VIEWS_AND_MORE_ACTIONS_BUTTON, + timeout + ); + + return viewsActionsButton; + } +} diff --git a/tests/e2e/specs/factory/Factory.spec.ts b/tests/e2e/specs/factory/Factory.spec.ts index 0443e634995..dd9546f00d9 100644 --- a/tests/e2e/specs/factory/Factory.spec.ts +++ b/tests/e2e/specs/factory/Factory.spec.ts @@ -1,5 +1,5 @@ /** ******************************************************************* - * copyright (c) 2021 Red Hat, Inc. + * copyright (c) 2021-2024 Red Hat, Inc. * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 @@ -40,6 +40,7 @@ import { FACTORY_TEST_CONSTANTS } from '../../constants/FACTORY_TEST_CONSTANTS'; import { ITestWorkspaceUtil } from '../../utils/workspace/ITestWorkspaceUtil'; import { Dashboard } from '../../pageobjects/dashboard/Dashboard'; import { CreateWorkspace } from '../../pageobjects/dashboard/CreateWorkspace'; +import { ViewsMoreActionsButton } from '../../pageobjects/ide/ViewsMoreActionsButton'; suite( `Create a workspace via launching a factory from the ${FACTORY_TEST_CONSTANTS.TS_SELENIUM_FACTORY_GIT_PROVIDER} repository ${BASE_TEST_CONSTANTS.TEST_ENVIRONMENT}`, @@ -55,11 +56,13 @@ suite( const testWorkspaceUtil: ITestWorkspaceUtil = e2eContainer.get(TYPES.WorkspaceUtil); const dashboard: Dashboard = e2eContainer.get(CLASSES.Dashboard); const createWorkspace: CreateWorkspace = e2eContainer.get(CLASSES.CreateWorkspace); + const viewsMoreActionsButton: ViewsMoreActionsButton = e2eContainer.get(CLASSES.ViewsMoreActionsButton); let projectSection: ViewSection; let scmProvider: SingleScmProvider; let rest: SingleScmProvider[]; let scmContextMenu: ContextMenu; + let viewsActionsButton: boolean; // test specific data const timeToRefresh: number = 1500; @@ -154,6 +157,10 @@ suite( test('Stage the changes', async function (): Promise { await driverHelper.waitVisibility(webCheCodeLocators.ScmView.more); + viewsActionsButton = await viewsMoreActionsButton.viewsAndMoreActionsButtonIsVisible(); + if (viewsActionsButton) { + await viewsMoreActionsButton.closeSourceControlGraph(); + } Logger.debug('scmProvider.openMoreActions'); scmContextMenu = await scmProvider.openMoreActions(); await driverHelper.waitVisibility(webCheCodeLocators.ContextMenu.contextView); diff --git a/tests/e2e/specs/factory/NoSetupRepoFactory.spec.ts b/tests/e2e/specs/factory/NoSetupRepoFactory.spec.ts index cc4eb8ecb62..a09c09a9212 100644 --- a/tests/e2e/specs/factory/NoSetupRepoFactory.spec.ts +++ b/tests/e2e/specs/factory/NoSetupRepoFactory.spec.ts @@ -1,5 +1,5 @@ /** ******************************************************************* - * copyright (c) 2021 Red Hat, Inc. + * copyright (c) 2021-2024 Red Hat, Inc. * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 @@ -41,6 +41,7 @@ import { OAUTH_CONSTANTS } from '../../constants/OAUTH_CONSTANTS'; import { BASE_TEST_CONSTANTS } from '../../constants/BASE_TEST_CONSTANTS'; import { ITestWorkspaceUtil } from '../../utils/workspace/ITestWorkspaceUtil'; import { CreateWorkspace } from '../../pageobjects/dashboard/CreateWorkspace'; +import { ViewsMoreActionsButton } from '../../pageobjects/ide/ViewsMoreActionsButton'; suite( `Create a workspace via launching a factory from the ${FACTORY_TEST_CONSTANTS.TS_SELENIUM_FACTORY_GIT_PROVIDER} repository without PAT/OAuth setup ${BASE_TEST_CONSTANTS.TEST_ENVIRONMENT}`, @@ -56,10 +57,12 @@ suite( const loginTests: LoginTests = e2eContainer.get(CLASSES.LoginTests); const testWorkspaceUtil: ITestWorkspaceUtil = e2eContainer.get(TYPES.WorkspaceUtil); const createWorkspace: CreateWorkspace = e2eContainer.get(CLASSES.CreateWorkspace); + const viewsMoreActionsButton: ViewsMoreActionsButton = e2eContainer.get(CLASSES.ViewsMoreActionsButton); let projectSection: ViewSection; let scmProvider: SingleScmProvider; let scmContextMenu: ContextMenu; + let viewsActionsButton: boolean; // test specific data let numberOfCreatedWorkspaces: number = 0; @@ -172,7 +175,10 @@ suite( test('Stage the changes', async function (): Promise { await driverHelper.waitVisibility(webCheCodeLocators.ScmView.more); - Logger.debug('scmProvider.openMoreActions'); + viewsActionsButton = await viewsMoreActionsButton.viewsAndMoreActionsButtonIsVisible(); + if (viewsActionsButton) { + await viewsMoreActionsButton.closeSourceControlGraph(); + } scmContextMenu = await scmProvider.openMoreActions(); await driverHelper.waitVisibility(webCheCodeLocators.ContextMenu.contextView); Logger.debug('scmContextMenu.select: "Changes" -> "Stage All Changes"'); diff --git a/tests/e2e/specs/factory/RefusedOAuthFactory.spec.ts b/tests/e2e/specs/factory/RefusedOAuthFactory.spec.ts index defa44c0b9a..ea1fb1b992d 100644 --- a/tests/e2e/specs/factory/RefusedOAuthFactory.spec.ts +++ b/tests/e2e/specs/factory/RefusedOAuthFactory.spec.ts @@ -1,5 +1,5 @@ /** ******************************************************************* - * copyright (c) 2021 Red Hat, Inc. + * copyright (c) 2021-2024 Red Hat, Inc. * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 @@ -40,6 +40,7 @@ import { FACTORY_TEST_CONSTANTS, GitProviderType } from '../../constants/FACTORY import { ITestWorkspaceUtil } from '../../utils/workspace/ITestWorkspaceUtil'; import { Dashboard } from '../../pageobjects/dashboard/Dashboard'; import { CreateWorkspace } from '../../pageobjects/dashboard/CreateWorkspace'; +import { ViewsMoreActionsButton } from '../../pageobjects/ide/ViewsMoreActionsButton'; suite( `Create a workspace via launching a factory from the ${FACTORY_TEST_CONSTANTS.TS_SELENIUM_FACTORY_GIT_PROVIDER} repository and deny the access ${BASE_TEST_CONSTANTS.TEST_ENVIRONMENT}`, @@ -55,11 +56,13 @@ suite( const testWorkspaceUtil: ITestWorkspaceUtil = e2eContainer.get(TYPES.WorkspaceUtil); const dashboard: Dashboard = e2eContainer.get(CLASSES.Dashboard); const createWorkspace: CreateWorkspace = e2eContainer.get(CLASSES.CreateWorkspace); + const viewsMoreActionsButton: ViewsMoreActionsButton = e2eContainer.get(CLASSES.ViewsMoreActionsButton); let projectSection: ViewSection; let scmProvider: SingleScmProvider; let rest: SingleScmProvider[]; let scmContextMenu: ContextMenu; + let viewsActionsButton: boolean; // test specific data const timeToRefresh: number = 1500; @@ -171,6 +174,10 @@ suite( test('Stage the changes', async function (): Promise { await driverHelper.waitVisibility(webCheCodeLocators.ScmView.more); + viewsActionsButton = await viewsMoreActionsButton.viewsAndMoreActionsButtonIsVisible(); + if (viewsActionsButton) { + await viewsMoreActionsButton.closeSourceControlGraph(); + } Logger.debug('scmProvider.openMoreActions'); scmContextMenu = await scmProvider.openMoreActions(); await driverHelper.waitVisibility(webCheCodeLocators.ContextMenu.contextView);