Skip to content

Commit dd6c3f2

Browse files
authored
Update 'factory' E2E tests according changes in IDE to 'Source Control' (#23153)
* Create new pageobject 'ViewsMoreActionsButton' * Update service files * Update 'factory' tests
1 parent 71276b8 commit dd6c3f2

7 files changed

+85
-5
lines changed

tests/e2e/configs/inversify.config.ts

+2
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ import { ShellExecutor } from '../utils/ShellExecutor';
5454
import { UserPreferences } from '../pageobjects/dashboard/UserPreferences';
5555
import { WebTerminalPage } from '../pageobjects/webterminal/WebTerminalPage';
5656
import { TrustAuthorPopup } from '../pageobjects/dashboard/TrustAuthorPopup';
57+
import { ViewsMoreActionsButton } from '../pageobjects/ide/ViewsMoreActionsButton';
5758

5859
const e2eContainer: Container = new Container({ defaultScope: 'Transient', skipBaseClassChecks: true });
5960

@@ -93,6 +94,7 @@ e2eContainer.bind<Generator>(EXTERNAL_CLASSES.Generator).to(Generator);
9394
e2eContainer.bind<LocatorLoader>(EXTERNAL_CLASSES.LocatorLoader).to(LocatorLoader);
9495
e2eContainer.bind<LocatorLoader>(EXTERNAL_CLASSES.LocatorLoader).to(LocatorLoader);
9596
e2eContainer.bind<TrustAuthorPopup>(CLASSES.TrustAuthorPopup).to(TrustAuthorPopup);
97+
e2eContainer.bind<ViewsMoreActionsButton>(CLASSES.ViewsMoreActionsButton).to(ViewsMoreActionsButton);
9698

9799
if (BASE_TEST_CONSTANTS.TS_PLATFORM === Platform.OPENSHIFT) {
98100
if (OAUTH_CONSTANTS.TS_SELENIUM_VALUE_OPENSHIFT_OAUTH) {

tests/e2e/configs/inversify.types.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ const CLASSES: any = {
5151
UserPreferences: 'UserPreferences',
5252
WebTerminalPage: 'WebTerminalPage',
5353
RevokeOauthPage: 'RevokeOauthPage',
54-
TrustAuthorPopup: 'TrustAuthorPopup'
54+
TrustAuthorPopup: 'TrustAuthorPopup',
55+
ViewsMoreActionsButton: 'ViewsMoreActionsButton'
5556
};
5657

5758
const EXTERNAL_CLASSES: any = {

tests/e2e/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export * from './pageobjects/dashboard/workspace-details/WorkspaceDetails';
3030
export * from './pageobjects/dashboard/Workspaces';
3131
export * from './pageobjects/git-providers/OauthPage';
3232
export * from './pageobjects/ide/CheCodeLocatorLoader';
33+
export * from './pageobjects/ide/ViewsMoreActionsButton';
3334
export * from './pageobjects/login/interfaces/ICheLoginPage';
3435
export * from './pageobjects/login/interfaces/IOcpLoginPage';
3536
export * from './pageobjects/login/kubernetes/DexLoginPage';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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+
}

tests/e2e/specs/factory/Factory.spec.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/** *******************************************************************
2-
* copyright (c) 2021 Red Hat, Inc.
2+
* copyright (c) 2021-2024 Red Hat, Inc.
33
*
44
* This program and the accompanying materials are made
55
* available under the terms of the Eclipse Public License 2.0
@@ -40,6 +40,7 @@ import { FACTORY_TEST_CONSTANTS } from '../../constants/FACTORY_TEST_CONSTANTS';
4040
import { ITestWorkspaceUtil } from '../../utils/workspace/ITestWorkspaceUtil';
4141
import { Dashboard } from '../../pageobjects/dashboard/Dashboard';
4242
import { CreateWorkspace } from '../../pageobjects/dashboard/CreateWorkspace';
43+
import { ViewsMoreActionsButton } from '../../pageobjects/ide/ViewsMoreActionsButton';
4344

4445
suite(
4546
`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(
5556
const testWorkspaceUtil: ITestWorkspaceUtil = e2eContainer.get(TYPES.WorkspaceUtil);
5657
const dashboard: Dashboard = e2eContainer.get(CLASSES.Dashboard);
5758
const createWorkspace: CreateWorkspace = e2eContainer.get(CLASSES.CreateWorkspace);
59+
const viewsMoreActionsButton: ViewsMoreActionsButton = e2eContainer.get(CLASSES.ViewsMoreActionsButton);
5860

5961
let projectSection: ViewSection;
6062
let scmProvider: SingleScmProvider;
6163
let rest: SingleScmProvider[];
6264
let scmContextMenu: ContextMenu;
65+
let viewsActionsButton: boolean;
6366

6467
// test specific data
6568
const timeToRefresh: number = 1500;
@@ -154,6 +157,10 @@ suite(
154157

155158
test('Stage the changes', async function (): Promise<void> {
156159
await driverHelper.waitVisibility(webCheCodeLocators.ScmView.more);
160+
viewsActionsButton = await viewsMoreActionsButton.viewsAndMoreActionsButtonIsVisible();
161+
if (viewsActionsButton) {
162+
await viewsMoreActionsButton.closeSourceControlGraph();
163+
}
157164
Logger.debug('scmProvider.openMoreActions');
158165
scmContextMenu = await scmProvider.openMoreActions();
159166
await driverHelper.waitVisibility(webCheCodeLocators.ContextMenu.contextView);

tests/e2e/specs/factory/NoSetupRepoFactory.spec.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/** *******************************************************************
2-
* copyright (c) 2021 Red Hat, Inc.
2+
* copyright (c) 2021-2024 Red Hat, Inc.
33
*
44
* This program and the accompanying materials are made
55
* available under the terms of the Eclipse Public License 2.0
@@ -41,6 +41,7 @@ import { OAUTH_CONSTANTS } from '../../constants/OAUTH_CONSTANTS';
4141
import { BASE_TEST_CONSTANTS } from '../../constants/BASE_TEST_CONSTANTS';
4242
import { ITestWorkspaceUtil } from '../../utils/workspace/ITestWorkspaceUtil';
4343
import { CreateWorkspace } from '../../pageobjects/dashboard/CreateWorkspace';
44+
import { ViewsMoreActionsButton } from '../../pageobjects/ide/ViewsMoreActionsButton';
4445

4546
suite(
4647
`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(
5657
const loginTests: LoginTests = e2eContainer.get(CLASSES.LoginTests);
5758
const testWorkspaceUtil: ITestWorkspaceUtil = e2eContainer.get(TYPES.WorkspaceUtil);
5859
const createWorkspace: CreateWorkspace = e2eContainer.get(CLASSES.CreateWorkspace);
60+
const viewsMoreActionsButton: ViewsMoreActionsButton = e2eContainer.get(CLASSES.ViewsMoreActionsButton);
5961

6062
let projectSection: ViewSection;
6163
let scmProvider: SingleScmProvider;
6264
let scmContextMenu: ContextMenu;
65+
let viewsActionsButton: boolean;
6366

6467
// test specific data
6568
let numberOfCreatedWorkspaces: number = 0;
@@ -172,7 +175,10 @@ suite(
172175

173176
test('Stage the changes', async function (): Promise<void> {
174177
await driverHelper.waitVisibility(webCheCodeLocators.ScmView.more);
175-
Logger.debug('scmProvider.openMoreActions');
178+
viewsActionsButton = await viewsMoreActionsButton.viewsAndMoreActionsButtonIsVisible();
179+
if (viewsActionsButton) {
180+
await viewsMoreActionsButton.closeSourceControlGraph();
181+
}
176182
scmContextMenu = await scmProvider.openMoreActions();
177183
await driverHelper.waitVisibility(webCheCodeLocators.ContextMenu.contextView);
178184
Logger.debug('scmContextMenu.select: "Changes" -> "Stage All Changes"');

tests/e2e/specs/factory/RefusedOAuthFactory.spec.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/** *******************************************************************
2-
* copyright (c) 2021 Red Hat, Inc.
2+
* copyright (c) 2021-2024 Red Hat, Inc.
33
*
44
* This program and the accompanying materials are made
55
* available under the terms of the Eclipse Public License 2.0
@@ -40,6 +40,7 @@ import { FACTORY_TEST_CONSTANTS, GitProviderType } from '../../constants/FACTORY
4040
import { ITestWorkspaceUtil } from '../../utils/workspace/ITestWorkspaceUtil';
4141
import { Dashboard } from '../../pageobjects/dashboard/Dashboard';
4242
import { CreateWorkspace } from '../../pageobjects/dashboard/CreateWorkspace';
43+
import { ViewsMoreActionsButton } from '../../pageobjects/ide/ViewsMoreActionsButton';
4344

4445
suite(
4546
`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(
5556
const testWorkspaceUtil: ITestWorkspaceUtil = e2eContainer.get(TYPES.WorkspaceUtil);
5657
const dashboard: Dashboard = e2eContainer.get(CLASSES.Dashboard);
5758
const createWorkspace: CreateWorkspace = e2eContainer.get(CLASSES.CreateWorkspace);
59+
const viewsMoreActionsButton: ViewsMoreActionsButton = e2eContainer.get(CLASSES.ViewsMoreActionsButton);
5860

5961
let projectSection: ViewSection;
6062
let scmProvider: SingleScmProvider;
6163
let rest: SingleScmProvider[];
6264
let scmContextMenu: ContextMenu;
65+
let viewsActionsButton: boolean;
6366

6467
// test specific data
6568
const timeToRefresh: number = 1500;
@@ -171,6 +174,10 @@ suite(
171174

172175
test('Stage the changes', async function (): Promise<void> {
173176
await driverHelper.waitVisibility(webCheCodeLocators.ScmView.more);
177+
viewsActionsButton = await viewsMoreActionsButton.viewsAndMoreActionsButtonIsVisible();
178+
if (viewsActionsButton) {
179+
await viewsMoreActionsButton.closeSourceControlGraph();
180+
}
174181
Logger.debug('scmProvider.openMoreActions');
175182
scmContextMenu = await scmProvider.openMoreActions();
176183
await driverHelper.waitVisibility(webCheCodeLocators.ContextMenu.contextView);

0 commit comments

Comments
 (0)