From 44314a4acf8f688af99e7bc1c39be0adc2e57893 Mon Sep 17 00:00:00 2001 From: Aleksandr Shmaraiev Date: Mon, 23 Oct 2023 14:23:17 +0300 Subject: [PATCH 1/7] Update title of test-case in 'NoSetupRepoFactory' --- tests/e2e/specs/factory/NoSetupRepoFactory.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e/specs/factory/NoSetupRepoFactory.spec.ts b/tests/e2e/specs/factory/NoSetupRepoFactory.spec.ts index 21d943327be..80e70580225 100644 --- a/tests/e2e/specs/factory/NoSetupRepoFactory.spec.ts +++ b/tests/e2e/specs/factory/NoSetupRepoFactory.spec.ts @@ -82,7 +82,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'); From 24bebd98eac885a3e4a1d88bce70937908633991 Mon Sep 17 00:00:00 2001 From: Aleksandr Shmaraiev Date: Mon, 23 Oct 2023 14:25:16 +0300 Subject: [PATCH 2/7] Add new items to 'GitProviderType' enum --- tests/e2e/constants/FACTORY_TEST_CONSTANTS.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/e2e/constants/FACTORY_TEST_CONSTANTS.ts b/tests/e2e/constants/FACTORY_TEST_CONSTANTS.ts index 9207062c5b4..124579a2804 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 = 'bb-server-oauth1', + BITBUCKET_SERVER_OAUTH2 = 'bb-server-oauth2', + BITBUCKET_CLOUD_OAUTH2 = 'bb-cloud-oauth2', AZURE_DEVOPS = 'azure-devops' } From 11c601dccb20b21ce90ac892a2f685de63aa17ef Mon Sep 17 00:00:00 2001 From: Aleksandr Shmaraiev Date: Mon, 23 Oct 2023 14:28:19 +0300 Subject: [PATCH 3/7] Update 'git-providers/OauthPage' to implement Bitbucket OAuth2 --- .../pageobjects/git-providers/OauthPage.ts | 27 ++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) 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); From 6f146375d7349b6cca0c5707879c16b3dcf50edc Mon Sep 17 00:00:00 2001 From: Aleksandr Shmaraiev Date: Mon, 23 Oct 2023 14:29:57 +0300 Subject: [PATCH 4/7] Update 'CheCodeLocatorLoader' to add new locator --- tests/e2e/pageobjects/ide/CheCodeLocatorLoader.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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")]') } } }; From 9f72a20d64bf17fdea60266ef21036c230516371 Mon Sep 17 00:00:00 2001 From: Aleksandr Shmaraiev Date: Mon, 23 Oct 2023 14:31:46 +0300 Subject: [PATCH 5/7] Fix 'RefusedOAuthFactory' for private factory flow --- .../specs/factory/RefusedOAuthFactory.spec.ts | 55 +++++++++---------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/tests/e2e/specs/factory/RefusedOAuthFactory.spec.ts b/tests/e2e/specs/factory/RefusedOAuthFactory.spec.ts index 27967ce3f67..a927ce2b9b9 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, @@ -53,6 +52,7 @@ suite( let projectSection: ViewSection; let scmProvider: SingleScmProvider; + let rest: SingleScmProvider[]; let scmContextMenu: ContextMenu; // test specific data @@ -72,13 +72,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(); @@ -96,29 +94,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; @@ -142,7 +142,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}"`); }); From 21834543a7dff2d3e81ac246f23258af42afe7f5 Mon Sep 17 00:00:00 2001 From: Aleksandr Shmaraiev Date: Wed, 25 Oct 2023 13:54:56 +0300 Subject: [PATCH 6/7] Change the values in 'GitProviderType' enum --- tests/e2e/constants/FACTORY_TEST_CONSTANTS.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/e2e/constants/FACTORY_TEST_CONSTANTS.ts b/tests/e2e/constants/FACTORY_TEST_CONSTANTS.ts index 124579a2804..7671080ff0d 100644 --- a/tests/e2e/constants/FACTORY_TEST_CONSTANTS.ts +++ b/tests/e2e/constants/FACTORY_TEST_CONSTANTS.ts @@ -12,9 +12,9 @@ import { BASE_TEST_CONSTANTS } from './BASE_TEST_CONSTANTS'; export enum GitProviderType { GITHUB = 'github', GITLAB = 'gitlab', - BITBUCKET_SERVER_OAUTH1 = 'bb-server-oauth1', - BITBUCKET_SERVER_OAUTH2 = 'bb-server-oauth2', - BITBUCKET_CLOUD_OAUTH2 = 'bb-cloud-oauth2', + BITBUCKET_SERVER_OAUTH1 = 'bitbucket-server-oauth1', + BITBUCKET_SERVER_OAUTH2 = 'bitbucket-server-oauth2', + BITBUCKET_CLOUD_OAUTH2 = 'bitbucket-org', AZURE_DEVOPS = 'azure-devops' } From ab1ea3a8bc5139bc2d8651f844f80391ee9199c3 Mon Sep 17 00:00:00 2001 From: Aleksandr Shmaraiev Date: Mon, 30 Oct 2023 11:23:47 +0200 Subject: [PATCH 7/7] Fix up 'performTrustAuthorDialog' method --- tests/e2e/tests-library/ProjectAndFileTests.ts | 6 ------ 1 file changed, 6 deletions(-) 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();