Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print error message from start workspace page in E2E test logs #22983

Merged
merged 3 commits into from
Nov 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion tests/e2e/tests-library/ProjectAndFileTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { Logger } from '../utils/Logger';
import { TIMEOUT_CONSTANTS } from '../constants/TIMEOUT_CONSTANTS';
import { CheCodeLocatorLoader } from '../pageobjects/ide/CheCodeLocatorLoader';
import { By, SideBarView, ViewContent, ViewItem, ViewSection, Workbench } from 'monaco-page-objects';
import { WorkspaceHandlingTests } from '../tests-library/WorkspaceHandlingTests';

@injectable()
export class ProjectAndFileTests {
Expand All @@ -25,7 +26,9 @@ export class ProjectAndFileTests {
@inject(CLASSES.DriverHelper)
private readonly driverHelper: DriverHelper,
@inject(CLASSES.CheCodeLocatorLoader)
private readonly cheCodeLocatorLoader: CheCodeLocatorLoader
private readonly cheCodeLocatorLoader: CheCodeLocatorLoader,
@inject(CLASSES.WorkspaceHandlingTests)
private readonly workspaceHandlingTests: WorkspaceHandlingTests
) {}

async waitWorkspaceReadinessForCheCodeEditor(): Promise<void> {
Expand All @@ -40,6 +43,10 @@ export class ProjectAndFileTests {
Logger.debug(`editor was opened in ${end - start} seconds.`);
} catch (err) {
Logger.error(`waiting for workspace readiness failed: ${err}`);

// assume that start workspace page is still opened
await this.workspaceHandlingTests.logStartWorkspaceInfo();

throw err;
}
}
Expand Down
44 changes: 40 additions & 4 deletions tests/e2e/tests-library/WorkspaceHandlingTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ import { By, error } from 'selenium-webdriver';
@injectable()
export class WorkspaceHandlingTests {
private static WORKSPACE_NAME: By = By.xpath('//h1[contains(.,"Starting workspace ")]');
private static WORKSPACE_STATUS: By = By.xpath('//*/span[@class="pf-c-label__content"]');
private static WORKSPACE_ALERT_TITLE: By = By.xpath('//h4[@class="pf-c-alert__title"]');
private static WORKSPACE_ALERT_DESCRIPTION: By = By.xpath('//*/div[@class="pf-c-alert__description"]');
private static workspaceName: string = 'undefined';
private static parentGUID: string;

Expand Down Expand Up @@ -111,10 +114,9 @@ export class WorkspaceHandlingTests {
Logger.info(`obtained workspace name from workspace loader page: ${WorkspaceHandlingTests.workspaceName}`);
return;
}
Logger.error(`failed to obtain workspace name:${WorkspaceHandlingTests.workspaceName}`);
throw new error.InvalidArgumentError(
`WorkspaceHandlingTests.obtainWorkspaceNameFromStartingPage failed to obtain workspace name:${WorkspaceHandlingTests.workspaceName}`
);
Logger.error('failed to obtain workspace name');
await this.logStartWorkspaceInfo();
throw new error.InvalidArgumentError('WorkspaceHandlingTests.obtainWorkspaceNameFromStartingPage failed to obtain workspace name.');
}

async stopWorkspace(workspaceName: string): Promise<void> {
Expand All @@ -131,4 +133,38 @@ export class WorkspaceHandlingTests {
await this.dashboard.openDashboard();
await this.dashboard.stopAndRemoveWorkspaceByUI(workspaceName);
}

async logStartWorkspaceInfo(): Promise<void> {
const status: string = await this.getWorkspaceStatus();
const alertTitle: string = await this.getWorkspaceAlertTitle();
const alertDescription: string = await this.getWorkspaceAlertDescription();

Logger.info('Start workspace status: ' + status);
Logger.info('Start workspace progress title: ' + alertTitle);
Logger.info('Start workspace progress description: ' + alertDescription);
}

private async getWorkspaceAlertDescription(): Promise<string> {
try {
return await this.driverHelper.getDriver().findElement(WorkspaceHandlingTests.WORKSPACE_ALERT_DESCRIPTION).getText();
} catch (err) {
return '(unknown)';
}
}

private async getWorkspaceStatus(): Promise<string> {
try {
return await this.driverHelper.getDriver().findElement(WorkspaceHandlingTests.WORKSPACE_STATUS).getText();
} catch (err) {
return '(unknown)';
}
}

private async getWorkspaceAlertTitle(): Promise<string> {
try {
return await this.driverHelper.getDriver().findElement(WorkspaceHandlingTests.WORKSPACE_ALERT_TITLE).getAttribute('innerHTML');
} catch (err) {
return '(unknown)';
}
}
}
Loading