Skip to content

Commit

Permalink
test should work with all providers
Browse files Browse the repository at this point in the history
  • Loading branch information
SkorikSergey committed Jan 15, 2024
1 parent ecd59c7 commit 02c74bb
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
20 changes: 20 additions & 0 deletions tests/e2e/pageobjects/dashboard/UserPreferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ import { By } from 'selenium-webdriver';
import { DriverHelper } from '../../utils/DriverHelper';
import { Logger } from '../../utils/Logger';

enum GitService {
github = 'github',
gitlab='gitlab',
'azure-devops'='azure-devops',
'bitbucket-server-oauth1'='bitbucket-server-oauth1',
'bitbucket-server-oauth2'='bitbucket-server-oauth2'
}

@injectable()
export class UserPreferences {
private static readonly USER_SETTINGS_DROPDOWN: By = By.xpath('//header//button/span[text()!=""]//parent::button');
Expand Down Expand Up @@ -111,6 +119,18 @@ export class UserPreferences {
await this.driverHelper.waitVisibility(UserPreferences.ADD_NEW_SSH_KEY_BUTTON);
}

async getServiceConfig(service: string): Promise<string> {
const gitService: { [key: string]: string } = {
[GitService.github]: 'GitHub',
[GitService.gitlab]: 'GitLab',
[GitService['azure-devops']]: 'Microsoft Azure DevOps',
[GitService['bitbucket-server-oauth1']]: 'Bitbucket Server',
[GitService['bitbucket-server-oauth2']]: 'Bitbucket Server'
};

return gitService[service];
}

private getServicesListItemLocator(servicesName: string): By {
return By.xpath(`//tr[td[text()='${servicesName}']]//input`);
}
Expand Down
8 changes: 6 additions & 2 deletions tests/e2e/specs/miscellaneous/RevokeOauth.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,24 @@ import { e2eContainer } from '../../configs/inversify.config';
import { CLASSES } from '../../configs/inversify.types';
import { LoginTests } from '../../tests-library/LoginTests';
import { UserPreferences } from '../../pageobjects/dashboard/UserPreferences';
import { FACTORY_TEST_CONSTANTS } from '../../constants/FACTORY_TEST_CONSTANTS';

suite(`"Revoke OAuth" test`, function (): void {
const loginTests: LoginTests = e2eContainer.get(CLASSES.LoginTests);
const userPreferences: UserPreferences = e2eContainer.get(CLASSES.UserPreferences);
const gitService: string = FACTORY_TEST_CONSTANTS.TS_SELENIUM_FACTORY_GIT_PROVIDER || 'github';

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

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

await userPreferences.openGitServicesTab();
await userPreferences.revokeGitService('GitHub');

const selectedService: string = await userPreferences.getServiceConfig(gitService);
await userPreferences.revokeGitService(selectedService);
});
});

0 comments on commit 02c74bb

Please sign in to comment.