diff --git a/tests/e2e/pageobjects/dashboard/UserPreferences.ts b/tests/e2e/pageobjects/dashboard/UserPreferences.ts index f87929eddd5..ce64e434c2e 100644 --- a/tests/e2e/pageobjects/dashboard/UserPreferences.ts +++ b/tests/e2e/pageobjects/dashboard/UserPreferences.ts @@ -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'); @@ -111,6 +119,18 @@ export class UserPreferences { await this.driverHelper.waitVisibility(UserPreferences.ADD_NEW_SSH_KEY_BUTTON); } + async getServiceConfig(service: string): Promise { + 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`); } diff --git a/tests/e2e/specs/miscellaneous/RevokeOauth.spec.ts b/tests/e2e/specs/miscellaneous/RevokeOauth.spec.ts index 5fc92c4856b..cfb6ee41b6c 100644 --- a/tests/e2e/specs/miscellaneous/RevokeOauth.spec.ts +++ b/tests/e2e/specs/miscellaneous/RevokeOauth.spec.ts @@ -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 { await loginTests.loginIntoChe(); }); - test('Check user preferences page', async function (): Promise { + test('Revoke OAuth test', async function (): Promise { await userPreferences.openUserPreferencesPage(); await userPreferences.checkTabsAvailability(); await userPreferences.openGitServicesTab(); - await userPreferences.revokeGitService('GitHub'); + + const selectedService: string = await userPreferences.getServiceConfig(gitService); + await userPreferences.revokeGitService(selectedService); }); });