From 51a833aa2bf29b363c62068312bc7cc795d75bf9 Mon Sep 17 00:00:00 2001 From: Shmaraiev Oleksandr Date: Thu, 31 Oct 2024 14:40:37 +0200 Subject: [PATCH] Add handling 'two-step-verification' in E2E tests when Bitbucket.org OAuth setup (#23223) * Add handling 'two-step-verification' of Bitbucket provider --- .../pageobjects/git-providers/OauthPage.ts | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tests/e2e/pageobjects/git-providers/OauthPage.ts b/tests/e2e/pageobjects/git-providers/OauthPage.ts index 62a05f96d68..20dc35fd848 100644 --- a/tests/e2e/pageobjects/git-providers/OauthPage.ts +++ b/tests/e2e/pageobjects/git-providers/OauthPage.ts @@ -24,6 +24,8 @@ export class OauthPage { private static APPROVE_BUTTON: By; private static DENY_ACCESS_BUTTON: By; private static DENY_SAVE_CREDENTIALS_BUTTON: By; + private static ENABLE_TWO_STEP_VERIFICATION_FORM: By; + private static DENY_TWO_STEP_VERIFICATION: By; constructor( @inject(CLASSES.DriverHelper) @@ -55,6 +57,8 @@ export class OauthPage { OauthPage.SUBMIT_BUTTON = By.id('login-submit'); OauthPage.APPROVE_BUTTON = By.xpath('//button[@value="approve"]'); OauthPage.DENY_ACCESS_BUTTON = By.xpath('//button[@value="deny"]'); + OauthPage.ENABLE_TWO_STEP_VERIFICATION_FORM = By.id('ProductHeading'); + OauthPage.DENY_TWO_STEP_VERIFICATION = By.id('mfa-promote-dismiss'); } break; case GitProviderType.GITLAB: @@ -153,6 +157,24 @@ export class OauthPage { await this.driverHelper.waitDisappearance(OauthPage.APPROVE_BUTTON); } + async waitVisibilityTwoStepVerificationForm(): Promise { + Logger.debug(); + + return this.driverHelper.waitVisibilityBoolean(OauthPage.ENABLE_TWO_STEP_VERIFICATION_FORM); + } + + async clickOnDenyTwoStepVerification(): Promise { + Logger.debug(); + + await this.driverHelper.waitAndClick(OauthPage.DENY_TWO_STEP_VERIFICATION); + } + + async waitDisappearanceTwoStepVerificationForm(): Promise { + Logger.debug(); + + await this.driverHelper.waitDisappearance(OauthPage.ENABLE_TWO_STEP_VERIFICATION_FORM); + } + async login(): Promise { Logger.debug(); @@ -170,6 +192,13 @@ export class OauthPage { await this.clickOnNotRememberCredentialsButton(); } await this.waitClosingLoginPage(); + + if (FACTORY_TEST_CONSTANTS.TS_SELENIUM_FACTORY_GIT_PROVIDER === GitProviderType.BITBUCKET_CLOUD_OAUTH2) { + if (await this.waitVisibilityTwoStepVerificationForm()) { + await this.clickOnDenyTwoStepVerification(); + await this.waitDisappearanceTwoStepVerificationForm(); + } + } } async confirmAccess(): Promise {