Skip to content

Commit

Permalink
fix: wait dashboard after login (#22180)
Browse files Browse the repository at this point in the history
Signed-off-by: mdolhalo <mdolhalo@redhat.com>
Co-authored-by: Maryna Dolhalova <mdolhalo@redhat.com>
  • Loading branch information
nallikaea and Maryna Dolhalova committed Apr 26, 2023
1 parent 34b9a8b commit 5e8a484
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
9 changes: 5 additions & 4 deletions tests/e2e/pageobjects/dashboard/Dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class Dashboard {
private static readonly WORKSPACES_BUTTON_XPATH: string = `//div[@id='page-sidebar']//a[contains(text(), 'Workspaces (')]`;
private static readonly CREATE_WORKSPACE_BUTTON_XPATH: string = `//div[@id='page-sidebar']//a[text()='Create Workspace']`;
private static readonly LOADER_PAGE_STEP_TITLES_XPATH: string = '//*[@data-testid="step-title"]';
private static readonly WORKSPACE_STARTING_PAGE_CSS: string = '.ide-loader-page';
private static readonly STARTING_PAGE_LOADER_CSS: string = '.main-page-loader';
private static readonly LOADER_ALERT_XPATH: string = '//*[@data-testid="loader-alert"]';
private static readonly LOGOUT_BUTTON_XPATH: string = '//button[text()="Logout"]';

Expand Down Expand Up @@ -121,10 +121,11 @@ export class Dashboard {
await this.driverHelper.waitDisappearance(By.id('chenavmenu'), timeout);
}

async waitWorkspaceStartingPage(timeout: number = TimeoutConstants.TS_COMMON_DASHBOARD_WAIT_TIMEOUT): Promise<void> {
Logger.debug(`Dashboard.waitWorkspaceStartingPage`);
async waitStartingPageLoaderDisappearance(timeout: number = TimeoutConstants.TS_COMMON_DASHBOARD_WAIT_TIMEOUT): Promise<void> {
Logger.debug(`Dashboard.waitStartingPageLoaderDisappearance`);

await this.driverHelper.waitPresence(By.css(Dashboard.WORKSPACE_STARTING_PAGE_CSS), timeout);
await this.driverHelper.waitDisappearance(By.css(Dashboard.STARTING_PAGE_LOADER_CSS), timeout);
await this.driverHelper.wait(TestConstants.TS_SELENIUM_DEFAULT_POLLING);
}

async getRecentWorkspaceName(timeout: number = TimeoutConstants.TS_COMMON_DASHBOARD_WAIT_TIMEOUT): Promise<string> {
Expand Down
30 changes: 14 additions & 16 deletions tests/e2e/pageobjects/login/RedHatLoginPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,48 +15,46 @@ import { DriverHelper } from '../../utils/DriverHelper';
import { Logger } from '../../utils/Logger';
import { TestConstants } from '../../constants/TestConstants';

const USERNAME_INPUT_ID: string = 'username-verification';
const PASSWORD_INPUT_ID: string = 'password';
const NEXT_BUTTON_ID: string = 'login-show-step2';
const LOGIN_BUTTON_ID: string = 'rh-password-verification-submit-button';
const timeout: number = 10000;

@injectable()
export class RedHatLoginPage {
private readonly USERNAME_INPUT_ID: string = 'username-verification';
private readonly PASSWORD_INPUT_ID: string = 'password';
private readonly NEXT_BUTTON_ID: string = 'login-show-step2';
private readonly LOGIN_BUTTON_ID: string = 'rh-password-verification-submit-button';

constructor(
@inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper) { }

async waitRedHatLoginWelcomePage(): Promise<void> {
Logger.debug('RedHatLoginPage.waitRedHatLoginWelcomePage');
await this.driverHelper.waitVisibility(By.id(USERNAME_INPUT_ID));
await this.driverHelper.waitVisibility(By.id(this.USERNAME_INPUT_ID));
}

async enterPasswordRedHat(): Promise<void> {
Logger.debug('RedHatLoginPage.enterPasswordRedHat');
const passwordFieldLocator: By = By.id(PASSWORD_INPUT_ID);
const passwordFieldLocator: By = By.id(this.PASSWORD_INPUT_ID);
await this.driverHelper.waitVisibility(passwordFieldLocator, 3000);
await this.driverHelper.enterValue(passwordFieldLocator, TestConstants.TS_SELENIUM_OCP_PASSWORD, timeout );
await this.driverHelper.enterValue(passwordFieldLocator, TestConstants.TS_SELENIUM_OCP_PASSWORD);
}
async clickOnLoginButton(): Promise<void> {
Logger.debug('RedHatLoginPage.clickOnLoginButton');
const loginButtonLocator: By = By.id(LOGIN_BUTTON_ID);
await this.driverHelper.waitAndClick(loginButtonLocator, timeout);
const loginButtonLocator: By = By.id(this.LOGIN_BUTTON_ID);
await this.driverHelper.waitAndClick(loginButtonLocator);
}
async waitDisappearanceRedHatLoginWelcomePage(): Promise<void> {
Logger.debug('RedHatLoginPage.waitDisappearanceRedHatLoginWelcomePage');
await this.driverHelper.waitDisappearance(By.id(LOGIN_BUTTON_ID));
await this.driverHelper.waitDisappearance(By.id(this.LOGIN_BUTTON_ID));
}
async enterUserNameRedHat(): Promise<void> {
Logger.debug('RedHatLoginPage.enterUserNameRedHat');
const usernameFieldLocator: By = By.id(USERNAME_INPUT_ID);
const usernameFieldLocator: By = By.id(this.USERNAME_INPUT_ID);
await this.driverHelper.waitVisibility(usernameFieldLocator, 20000);
await this.driverHelper.enterValue(usernameFieldLocator, TestConstants.TS_SELENIUM_OCP_USERNAME, timeout );
await this.driverHelper.enterValue(usernameFieldLocator, TestConstants.TS_SELENIUM_OCP_USERNAME);
}

async clickNextButton(): Promise<void> {
Logger.debug('RedHatLoginPage.clickNextButton');
const nextButtonLocator: By = By.id(NEXT_BUTTON_ID);
await this.driverHelper.waitAndClick(nextButtonLocator, timeout);
const nextButtonLocator: By = By.id(this.NEXT_BUTTON_ID);
await this.driverHelper.waitAndClick(nextButtonLocator);
}
}
1 change: 1 addition & 0 deletions tests/e2e/tests-library/LoginTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export class LoginTests {
if (TestConstants.TS_SELENIUM_LAUNCH_FULLSCREEN) {
Logger.debug(`TS_SELENIUM_LAUNCH_FULLSCREEN is set to true, maximizing window.`);
await this.browserTabsUtil.maximize();
await this.dashboard.waitStartingPageLoaderDisappearance();
}
});
}
Expand Down

0 comments on commit 5e8a484

Please sign in to comment.