Skip to content

Commit

Permalink
add RevokeOauth test
Browse files Browse the repository at this point in the history
  • Loading branch information
SkorikSergey committed Jan 11, 2024
1 parent a31face commit 227657d
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 3 deletions.
2 changes: 1 addition & 1 deletion tests/e2e/configs/inversify.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import { Main as Generator } from '@eclipse-che/che-devworkspace-generator/lib/m
import { ContainerTerminal, KubernetesCommandLineToolsExecutor } from '../utils/KubernetesCommandLineToolsExecutor';
import { ShellExecutor } from '../utils/ShellExecutor';
import { UserPreferences } from '../pageobjects/dashboard/UserPreferences';
import { WebTerminalPage } from "../pageobjects/webterminal/WebTerminalPage";
import { WebTerminalPage } from '../pageobjects/webterminal/WebTerminalPage';

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

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 @@ -49,7 +49,8 @@ const CLASSES: any = {
ShellExecutor: 'ShellExecutor',
ContainerTerminal: 'ContainerTerminal',
UserPreferences: 'UserPreferences',
WebTerminalPage: 'WebTerminalPage'
WebTerminalPage: 'WebTerminalPage',
RevokeOauthPage: 'RevokeOauthPage'
};

const EXTERNAL_CLASSES: any = {
Expand Down
28 changes: 28 additions & 0 deletions tests/e2e/pageobjects/dashboard/UserPreferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ export class UserPreferences {
private static readonly USER_PREFERENCES_PAGE: By = By.xpath('//h1[text()="User Preferences"]');

private static readonly CONTAINER_REGISTRIES_TAB: By = By.xpath('//button[text()="Container Registries"]');

private static readonly GIT_SERVICES_TAB: By = By.xpath('//button[text()="Git Services"]');
private static readonly GIT_SERVICES_REVOKE_BUTTON: By = By.xpath('//button[text()="Revoke"]');

private static readonly PAT_TAB: By = By.xpath('//button[text()="Personal Access Tokens"]');
private static readonly ADD_NEW_PAT_BUTTON: By = By.xpath('//button[text()="Add Personal Access Token"]');
Expand All @@ -31,6 +33,10 @@ export class UserPreferences {
private static readonly SSH_KEY_TAB: By = By.xpath('//button[text()="SSH Keys"]');
private static readonly ADD_NEW_SSH_KEY_BUTTON: By = By.xpath('//button[text()="Add SSH Key"]');

private static readonly CONFIRMATION_WINDOW: By = By.xpath('//span[text()="Revoke Git Services"]');
private static readonly DELETE_CONFIRMATION_CHECKBOX: By = By.xpath('//input[@data-testid="warning-info-checkbox"]');
private static readonly DELETE_ITEM_BUTTON_ENABLED: By = By.xpath('//button[@data-testid="revoke-button" and not(@disabled)]');

constructor(
@inject(CLASSES.DriverHelper)
readonly driverHelper: DriverHelper
Expand Down Expand Up @@ -67,6 +73,24 @@ export class UserPreferences {
await this.driverHelper.waitAndClick(UserPreferences.GIT_SERVICES_TAB);
}

async revokeGitService(servicesName: string): Promise<void> {
Logger.debug();

await this.selectListItem(servicesName);
await this.driverHelper.waitAndClick(UserPreferences.GIT_SERVICES_REVOKE_BUTTON);

await this.driverHelper.waitVisibility(UserPreferences.CONFIRMATION_WINDOW);
await this.driverHelper.waitAndClick(UserPreferences.DELETE_CONFIRMATION_CHECKBOX);
await this.driverHelper.waitAndClick(UserPreferences.DELETE_ITEM_BUTTON_ENABLED);
await this.driverHelper.waitDisappearance(this.getServicesListItemLocator(servicesName));
}

async selectListItem(servicesName: string): Promise<void> {
Logger.debug(`of the '${servicesName}' list item`);

await this.driverHelper.waitAndClick(this.getServicesListItemLocator(servicesName));
}

async openPatTab(): Promise<void> {
Logger.debug();

Expand All @@ -86,4 +110,8 @@ export class UserPreferences {
await this.driverHelper.waitAndClick(UserPreferences.SSH_KEY_TAB);
await this.driverHelper.waitVisibility(UserPreferences.ADD_NEW_SSH_KEY_BUTTON);
}

private getServicesListItemLocator(servicesName: string): By {
return By.xpath(`//tr[td[text()='${servicesName}']]//input`);
}
}
31 changes: 31 additions & 0 deletions tests/e2e/specs/miscellaneous/RevokeOauth.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/** *******************************************************************
* copyright (c) 2020-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 { e2eContainer } from '../../configs/inversify.config';
import { CLASSES } from '../../configs/inversify.types';
import { LoginTests } from '../../tests-library/LoginTests';
import { BASE_TEST_CONSTANTS } from '../../constants/BASE_TEST_CONSTANTS';
import { UserPreferences } from '../../pageobjects/dashboard/UserPreferences';

suite(`"Check User Preferences page" test ${BASE_TEST_CONSTANTS.TEST_ENVIRONMENT}`, function (): void {
const loginTests: LoginTests = e2eContainer.get(CLASSES.LoginTests);
const userPreferences: UserPreferences = e2eContainer.get(CLASSES.UserPreferences);

suiteSetup('Login', async function (): Promise<void> {
await loginTests.loginIntoChe();
});

test('Check user preferences page', async function (): Promise<void> {
await userPreferences.openUserPreferencesPage();
await userPreferences.checkTabsAvailability();

await userPreferences.openGitServicesTab();
await userPreferences.revokeGitService('GitHub');
});
});
2 changes: 1 addition & 1 deletion tests/e2e/specs/miscellaneous/UserPreferencesTest.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ suite(`"Check User Preferences page" test ${BASE_TEST_CONSTANTS.TEST_ENVIRONMENT
await loginTests.loginIntoChe();
});

test(`Check user preferences page`, async function (): Promise<void> {
test('Check user preferences page', async function (): Promise<void> {
await userPreferences.openUserPreferencesPage();
await userPreferences.checkTabsAvailability();
});
Expand Down

0 comments on commit 227657d

Please sign in to comment.