Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update 'factory' E2E tests according changes in IDE to 'Source Control' #23153

Merged
merged 6 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions tests/e2e/configs/inversify.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });

Expand Down Expand Up @@ -93,6 +94,7 @@ e2eContainer.bind<Generator>(EXTERNAL_CLASSES.Generator).to(Generator);
e2eContainer.bind<LocatorLoader>(EXTERNAL_CLASSES.LocatorLoader).to(LocatorLoader);
e2eContainer.bind<LocatorLoader>(EXTERNAL_CLASSES.LocatorLoader).to(LocatorLoader);
e2eContainer.bind<TrustAuthorPopup>(CLASSES.TrustAuthorPopup).to(TrustAuthorPopup);
e2eContainer.bind<ViewsMoreActionsButton>(CLASSES.ViewsMoreActionsButton).to(ViewsMoreActionsButton);

if (BASE_TEST_CONSTANTS.TS_PLATFORM === Platform.OPENSHIFT) {
if (OAUTH_CONSTANTS.TS_SELENIUM_VALUE_OPENSHIFT_OAUTH) {
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 @@ -51,7 +51,8 @@ const CLASSES: any = {
UserPreferences: 'UserPreferences',
WebTerminalPage: 'WebTerminalPage',
RevokeOauthPage: 'RevokeOauthPage',
TrustAuthorPopup: 'TrustAuthorPopup'
TrustAuthorPopup: 'TrustAuthorPopup',
ViewsMoreActionsButton: 'ViewsMoreActionsButton'
};

const EXTERNAL_CLASSES: any = {
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
56 changes: 56 additions & 0 deletions tests/e2e/pageobjects/ide/ViewsMoreActionsButton.ts
Original file line number Diff line number Diff line change
@@ -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<void> {
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<boolean> {
Logger.debug();

const viewsActionsButton: boolean = await this.driverHelper.waitVisibilityBoolean(
ViewsMoreActionsButton.VIEWS_AND_MORE_ACTIONS_BUTTON,
timeout
);

return viewsActionsButton;
}
}
9 changes: 8 additions & 1 deletion tests/e2e/specs/factory/Factory.spec.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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}`,
Expand All @@ -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;
Expand Down Expand Up @@ -154,6 +157,10 @@ suite(

test('Stage the changes', async function (): Promise<void> {
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);
Expand Down
10 changes: 8 additions & 2 deletions tests/e2e/specs/factory/NoSetupRepoFactory.spec.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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}`,
Expand All @@ -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;
Expand Down Expand Up @@ -172,7 +175,10 @@ suite(

test('Stage the changes', async function (): Promise<void> {
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"');
Expand Down
9 changes: 8 additions & 1 deletion tests/e2e/specs/factory/RefusedOAuthFactory.spec.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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}`,
Expand All @@ -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;
Expand Down Expand Up @@ -171,6 +174,10 @@ suite(

test('Stage the changes', async function (): Promise<void> {
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);
Expand Down
Loading