Skip to content

Commit e3dc592

Browse files
committed
add UserPreferences page test and page object
1 parent 1c9b84e commit e3dc592

File tree

4 files changed

+123
-1
lines changed

4 files changed

+123
-1
lines changed

tests/e2e/configs/inversify.config.ts

+2
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ import { DevfilesRegistryHelper } from '../utils/DevfilesRegistryHelper';
5151
import { Main as Generator } from '@eclipse-che/che-devworkspace-generator/lib/main';
5252
import { ContainerTerminal, KubernetesCommandLineToolsExecutor } from '../utils/KubernetesCommandLineToolsExecutor';
5353
import { ShellExecutor } from '../utils/ShellExecutor';
54+
import { UserPreferences } from '../pageobjects/dashboard/UserPreferences';
5455

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

@@ -84,6 +85,7 @@ e2eContainer.bind<DevfilesRegistryHelper>(CLASSES.DevfilesRegistryHelper).to(Dev
8485
e2eContainer.bind<KubernetesCommandLineToolsExecutor>(CLASSES.KubernetesCommandLineToolsExecutor).to(KubernetesCommandLineToolsExecutor);
8586
e2eContainer.bind<ShellExecutor>(CLASSES.ShellExecutor).to(ShellExecutor);
8687
e2eContainer.bind<ContainerTerminal>(CLASSES.ContainerTerminal).to(ContainerTerminal);
88+
e2eContainer.bind<UserPreferences>(CLASSES.UserPreferences).to(UserPreferences);
8789

8890
e2eContainer.bind<Generator>(EXTERNAL_CLASSES.Generator).to(Generator);
8991
e2eContainer.bind<LocatorLoader>(EXTERNAL_CLASSES.LocatorLoader).to(LocatorLoader);

tests/e2e/configs/inversify.types.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ const CLASSES: any = {
4747
DevfilesRegistryHelper: 'DevfilesRegistryHelper',
4848
KubernetesCommandLineToolsExecutor: 'KubernetesCommandLineToolsExecutor',
4949
ShellExecutor: 'ShellExecutor',
50-
ContainerTerminal: 'ContainerTerminal'
50+
ContainerTerminal: 'ContainerTerminal',
51+
UserPreferences: 'UserPreferences'
5152
};
5253

5354
const EXTERNAL_CLASSES: any = {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
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+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/** *******************************************************************
2+
* copyright (c) 2020-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 { e2eContainer } from '../../configs/inversify.config';
11+
import { CLASSES } from '../../configs/inversify.types';
12+
import { LoginTests } from '../../tests-library/LoginTests';
13+
import { BASE_TEST_CONSTANTS } from '../../constants/BASE_TEST_CONSTANTS';
14+
import { UserPreferences } from '../../pageobjects/dashboard/UserPreferences';
15+
16+
17+
suite(`"Check User Preferences page" test ${BASE_TEST_CONSTANTS.TEST_ENVIRONMENT}`, function (): void {
18+
const loginTests: LoginTests = e2eContainer.get(CLASSES.LoginTests);
19+
const userPreferences: UserPreferences = e2eContainer.get(CLASSES.UserPreferences);
20+
21+
suiteSetup('Login', async function (): Promise<void> {
22+
await loginTests.loginIntoChe();
23+
});
24+
25+
test(`Check user preferences page`, async function (): Promise<void> {
26+
await userPreferences.openUserPreferencesPage();
27+
await userPreferences.checkTabsAvailability();
28+
});
29+
30+
});

0 commit comments

Comments
 (0)