diff --git a/tests/e2e/constants/FACTORY_TEST_CONSTANTS.ts b/tests/e2e/constants/FACTORY_TEST_CONSTANTS.ts index 9207062c5b4..7671080ff0d 100644 --- a/tests/e2e/constants/FACTORY_TEST_CONSTANTS.ts +++ b/tests/e2e/constants/FACTORY_TEST_CONSTANTS.ts @@ -12,7 +12,9 @@ import { BASE_TEST_CONSTANTS } from './BASE_TEST_CONSTANTS'; export enum GitProviderType { GITHUB = 'github', GITLAB = 'gitlab', - BITBUCKET = 'bitbucket', + BITBUCKET_SERVER_OAUTH1 = 'bitbucket-server-oauth1', + BITBUCKET_SERVER_OAUTH2 = 'bitbucket-server-oauth2', + BITBUCKET_CLOUD_OAUTH2 = 'bitbucket-org', AZURE_DEVOPS = 'azure-devops' } diff --git a/tests/e2e/pageobjects/git-providers/OauthPage.ts b/tests/e2e/pageobjects/git-providers/OauthPage.ts index d86da9e0d78..62a05f96d68 100644 --- a/tests/e2e/pageobjects/git-providers/OauthPage.ts +++ b/tests/e2e/pageobjects/git-providers/OauthPage.ts @@ -30,7 +30,7 @@ export class OauthPage { private readonly driverHelper: DriverHelper ) { switch (FACTORY_TEST_CONSTANTS.TS_SELENIUM_FACTORY_GIT_PROVIDER) { - case GitProviderType.BITBUCKET: + case GitProviderType.BITBUCKET_SERVER_OAUTH1: { OauthPage.LOGIN_FORM = By.id('j_username'); OauthPage.PASSWORD_FORM = By.id('j_password'); @@ -39,6 +39,24 @@ export class OauthPage { OauthPage.DENY_ACCESS_BUTTON = By.id('deny'); } break; + case GitProviderType.BITBUCKET_SERVER_OAUTH2: + { + OauthPage.LOGIN_FORM = By.id('j_username'); + OauthPage.PASSWORD_FORM = By.id('j_password'); + OauthPage.APPROVE_BUTTON = By.xpath('//span[text()="Allow"]'); + OauthPage.SUBMIT_BUTTON = By.id('submit'); + OauthPage.DENY_ACCESS_BUTTON = By.xpath('//span[text()="Deny"]'); + } + break; + case GitProviderType.BITBUCKET_CLOUD_OAUTH2: + { + OauthPage.LOGIN_FORM = By.id('username'); + OauthPage.PASSWORD_FORM = By.id('password'); + OauthPage.SUBMIT_BUTTON = By.id('login-submit'); + OauthPage.APPROVE_BUTTON = By.xpath('//button[@value="approve"]'); + OauthPage.DENY_ACCESS_BUTTON = By.xpath('//button[@value="deny"]'); + } + break; case GitProviderType.GITLAB: { OauthPage.LOGIN_FORM = By.id('user_login'); @@ -69,7 +87,7 @@ export class OauthPage { break; default: { throw new Error( - `Invalid git provider. The value should be ${GitProviderType.GITHUB}, ${GitProviderType.GITLAB}, ${GitProviderType.AZURE_DEVOPS} or ${GitProviderType.BITBUCKET}` + `Invalid git provider. The value should be ${GitProviderType.GITHUB}, ${GitProviderType.GITLAB}, ${GitProviderType.AZURE_DEVOPS}, ${GitProviderType.BITBUCKET_SERVER_OAUTH1}, ${GitProviderType.BITBUCKET_SERVER_OAUTH2} or ${GitProviderType.BITBUCKET_CLOUD_OAUTH2}` ); } } @@ -140,7 +158,10 @@ export class OauthPage { await this.waitLoginPage(); await this.enterUserName(OAUTH_CONSTANTS.TS_SELENIUM_GIT_PROVIDER_USERNAME); - if (FACTORY_TEST_CONSTANTS.TS_SELENIUM_FACTORY_GIT_PROVIDER === GitProviderType.AZURE_DEVOPS) { + if ( + FACTORY_TEST_CONSTANTS.TS_SELENIUM_FACTORY_GIT_PROVIDER === GitProviderType.AZURE_DEVOPS || + FACTORY_TEST_CONSTANTS.TS_SELENIUM_FACTORY_GIT_PROVIDER === GitProviderType.BITBUCKET_CLOUD_OAUTH2 + ) { await this.clickOnSubmitButton(); } await this.enterPassword(OAUTH_CONSTANTS.TS_SELENIUM_GIT_PROVIDER_PASSWORD); diff --git a/tests/e2e/pageobjects/ide/CheCodeLocatorLoader.ts b/tests/e2e/pageobjects/ide/CheCodeLocatorLoader.ts index 93b5477dbde..f72818c3e91 100644 --- a/tests/e2e/pageobjects/ide/CheCodeLocatorLoader.ts +++ b/tests/e2e/pageobjects/ide/CheCodeLocatorLoader.ts @@ -42,12 +42,15 @@ export class CheCodeLocatorLoader extends LocatorLoader { button: By.xpath('//div[@class="monaco-dialog-box"]//a[@class="monaco-button monaco-text-button"]') }, ScmView: { - actionConstructor: (title: string): By => By.xpath(`.//a[@title="${title}"]`) + actionConstructor: (title: string): By => By.xpath(`.//a[@title='${title}']`) } }, extras: { ExtensionsViewSection: { requireReloadButton: By.xpath('//a[text()="Reload Required"]') + }, + TreeItem: { + projectFolderItem: By.xpath('.//div[contains(@class, "rootfolder-icon projects-name-dir")]') } } }; diff --git a/tests/e2e/specs/factory/NoSetupRepoFactory.spec.ts b/tests/e2e/specs/factory/NoSetupRepoFactory.spec.ts index aab5ac7b005..6c77c0fbd68 100644 --- a/tests/e2e/specs/factory/NoSetupRepoFactory.spec.ts +++ b/tests/e2e/specs/factory/NoSetupRepoFactory.spec.ts @@ -86,7 +86,7 @@ suite( }); if (FACTORY_TEST_CONSTANTS.TS_SELENIUM_IS_PRIVATE_FACTORY_GIT_REPO) { - test(`Check that workspace cannot be created without OAuth for ${isPrivateRepo} repo`, async function (): Promise { + test(`Check that workspace cannot be created without PAT/OAuth for ${isPrivateRepo} repo`, async function (): Promise { await dashboard.waitLoader(); const loaderAlert: string = await dashboard.getLoaderAlert(); expect(loaderAlert).to.contain('Cause: Could not reach devfile at'); diff --git a/tests/e2e/specs/factory/RefusedOAuthFactory.spec.ts b/tests/e2e/specs/factory/RefusedOAuthFactory.spec.ts index 0630c00a718..ada67bcf317 100644 --- a/tests/e2e/specs/factory/RefusedOAuthFactory.spec.ts +++ b/tests/e2e/specs/factory/RefusedOAuthFactory.spec.ts @@ -16,7 +16,6 @@ import { EditorView, InputBox, Locators, - ModalDialog, NewScmView, SingleScmProvider, TextEditor, @@ -57,6 +56,7 @@ suite( let projectSection: ViewSection; let scmProvider: SingleScmProvider; + let rest: SingleScmProvider[]; let scmContextMenu: ContextMenu; // test specific data @@ -78,13 +78,11 @@ suite( await browserTabsUtil.navigateTo(FACTORY_TEST_CONSTANTS.TS_SELENIUM_FACTORY_URL()); }); - if (OAUTH_CONSTANTS.TS_SELENIUM_GIT_PROVIDER_OAUTH) { - test(`Authorize with a ${FACTORY_TEST_CONSTANTS.TS_SELENIUM_FACTORY_GIT_PROVIDER} OAuth and deny access`, async function (): Promise { - await oauthPage.login(); - await oauthPage.waitOauthPage(); - await oauthPage.denyAccess(); - }); - } + test(`Authorize with a ${FACTORY_TEST_CONSTANTS.TS_SELENIUM_FACTORY_GIT_PROVIDER} OAuth and deny access`, async function (): Promise { + await oauthPage.login(); + await oauthPage.waitOauthPage(); + await oauthPage.denyAccess(); + }); test('Obtain workspace name from workspace loader page', async function (): Promise { await workspaceHandlingTests.obtainWorkspaceNameFromStartingPage(); @@ -102,29 +100,31 @@ suite( await projectAndFileTests.waitWorkspaceReadinessForCheCodeEditor(); }); - test('Check if a project folder has been created', async function (): Promise { - testRepoProjectName = StringUtil.getProjectNameFromGitUrl(FACTORY_TEST_CONSTANTS.TS_SELENIUM_FACTORY_GIT_REPO_URL); - projectSection = await projectAndFileTests.getProjectViewSession(); - expect(await projectAndFileTests.getProjectTreeItem(projectSection, testRepoProjectName), 'Project folder was not imported').not - .undefined; - }); - - test('Accept the project as a trusted one', async function (): Promise { - await projectAndFileTests.performTrustAuthorDialog(); - }); - if (FACTORY_TEST_CONSTANTS.TS_SELENIUM_IS_PRIVATE_FACTORY_GIT_REPO) { - test('Check that project can not be cloned', async function (): Promise { - await driverHelper.waitVisibility(webCheCodeLocators.Dialog.message); - const workspaceDoesNotExistDialog: ModalDialog = new ModalDialog(); - const message: string = await workspaceDoesNotExistDialog.getMessage(); - expect(message).contains('space does not exist'); + test('Check that a project folder has not been cloned', async function (): Promise { + testRepoProjectName = StringUtil.getProjectNameFromGitUrl(FACTORY_TEST_CONSTANTS.TS_SELENIUM_FACTORY_GIT_REPO_URL); + await driverHelper.waitVisibility(webCheCodeLocators.ScmView.multiProviderItem); + await projectAndFileTests.performTrustAuthorDialog(); + const isProjectFolderUnable: string = await driverHelper.waitAndGetElementAttribute( + (webCheCodeLocators.TreeItem as any).projectFolderItem, + 'aria-label' + ); + expect(isProjectFolderUnable).to.contain( + '/projects/' + testRepoProjectName + ' • Unable to resolve workspace folder (Unable to resolve nonexistent file' + ); + }); + } else { + test('Check if a project folder has been created', async function (): Promise { + testRepoProjectName = StringUtil.getProjectNameFromGitUrl(FACTORY_TEST_CONSTANTS.TS_SELENIUM_FACTORY_GIT_REPO_URL); + projectSection = await projectAndFileTests.getProjectViewSession(); + expect(await projectAndFileTests.getProjectTreeItem(projectSection, testRepoProjectName), 'Project folder was not imported') + .not.undefined; }); - test('Check that project files were not imported', async function (): Promise { - expect(await projectAndFileTests.getProjectTreeItem(projectSection, label), 'Project files were found').to.be.undefined; + test('Accept the project as a trusted one', async function (): Promise { + await projectAndFileTests.performTrustAuthorDialog(); }); - } else { + test('Check if the project files were imported', async function (): Promise { expect(await projectAndFileTests.getProjectTreeItem(projectSection, label), 'Project files were not imported').not .undefined; @@ -148,7 +148,6 @@ suite( await sourceControl.openView(); const scmView: NewScmView = new NewScmView(); await driverHelper.waitVisibility(webCheCodeLocators.ScmView.inputField); - let rest: SingleScmProvider[]; [scmProvider, ...rest] = await scmView.getProviders(); Logger.debug(`scmView.getProviders: "${JSON.stringify(scmProvider)}, ${rest}"`); }); diff --git a/tests/e2e/tests-library/ProjectAndFileTests.ts b/tests/e2e/tests-library/ProjectAndFileTests.ts index b9518feb3df..f581b8ba270 100644 --- a/tests/e2e/tests-library/ProjectAndFileTests.ts +++ b/tests/e2e/tests-library/ProjectAndFileTests.ts @@ -46,12 +46,6 @@ export class ProjectAndFileTests { Logger.debug(); // sometimes the trust dialog does not appear at first time, for avoiding this problem we send click event for activating const workbench: Workbench = new Workbench(); - await workbench.click(); - - await this.driverHelper.waitAndClick( - this.cheCodeLocatorLoader.webCheCodeLocators.WelcomeContent.button, - TIMEOUT_CONSTANTS.TS_DIALOG_WINDOW_DEFAULT_TIMEOUT - ); try { await workbench.click();