From 4da9d1099426e66ca468c9f14ad41c85fea8248d Mon Sep 17 00:00:00 2001 From: Dmytro Nochevnov Date: Fri, 8 Nov 2024 22:45:28 +0200 Subject: [PATCH] Log start workspace info when failed on waiting workspace readiness Signed-off-by: Dmytro Nochevnov --- .../e2e/tests-library/ProjectAndFileTests.ts | 9 +++++- .../tests-library/WorkspaceHandlingTests.ts | 32 +++++++++---------- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/tests/e2e/tests-library/ProjectAndFileTests.ts b/tests/e2e/tests-library/ProjectAndFileTests.ts index c7a312a09af..ed60705ed1a 100644 --- a/tests/e2e/tests-library/ProjectAndFileTests.ts +++ b/tests/e2e/tests-library/ProjectAndFileTests.ts @@ -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 { @@ -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 { @@ -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; } } diff --git a/tests/e2e/tests-library/WorkspaceHandlingTests.ts b/tests/e2e/tests-library/WorkspaceHandlingTests.ts index 47d517eaa85..5262f31cab7 100644 --- a/tests/e2e/tests-library/WorkspaceHandlingTests.ts +++ b/tests/e2e/tests-library/WorkspaceHandlingTests.ts @@ -134,37 +134,37 @@ export class WorkspaceHandlingTests { await this.dashboard.stopAndRemoveWorkspaceByUI(workspaceName); } - async getWorkspaceAlertDescription(): Promise { + async logStartWorkspaceInfo(): Promise { + 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 { try { return await this.driverHelper.getDriver().findElement(WorkspaceHandlingTests.WORKSPACE_ALERT_DESCRIPTION).getText(); } catch (err) { - return ''; + return '(unknown)'; } } - async getWorkspaceStatus(): Promise { + private async getWorkspaceStatus(): Promise { try { return await this.driverHelper.getDriver().findElement(WorkspaceHandlingTests.WORKSPACE_STATUS).getText(); } catch (err) { - return ''; + return '(unknown)'; } } - async getWorkspaceAlertTitle(): Promise { + private async getWorkspaceAlertTitle(): Promise { try { return await this.driverHelper.getDriver().findElement(WorkspaceHandlingTests.WORKSPACE_ALERT_TITLE).getAttribute('innerHTML'); } catch (err) { - return ''; + return '(unknown)'; } } - - async logStartWorkspaceInfo(): Promise { - 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); - } }