From 492fe05e52e1e01e3e7fbb18310310706b330ae3 Mon Sep 17 00:00:00 2001 From: mdolhalo Date: Mon, 30 Oct 2023 12:29:55 +0100 Subject: [PATCH] fix: missed await Signed-off-by: mdolhalo --- .../workspace-details/WorkspaceDetails.ts | 2 +- tests/e2e/specs/MochaHooks.ts | 24 +++++++++---------- .../dashboard-samples/EmptyWorkspace.spec.ts | 4 ++-- .../specs/dashboard-samples/Quarkus.spec.ts | 4 ++-- .../RecommendedExtensions.spec.ts | 4 ++-- tests/e2e/specs/factory/Factory.spec.ts | 4 ++-- .../specs/factory/NoSetupRepoFactory.spec.ts | 4 ++-- .../specs/factory/RefusedOAuthFactory.spec.ts | 4 ++-- .../CreateWorkspaceWithExistedName.spec.ts | 6 ++--- .../miscellaneous/KubedockPodmanTest.spec.ts | 4 ++-- .../WorkspaceIdleTimeout.spec.ts | 4 ++-- .../miscellaneous/WorkspaceWithParent.spec.ts | 2 +- .../e2e/utils/workspace/ITestWorkspaceUtil.ts | 14 +++++------ 13 files changed, 40 insertions(+), 40 deletions(-) diff --git a/tests/e2e/pageobjects/dashboard/workspace-details/WorkspaceDetails.ts b/tests/e2e/pageobjects/dashboard/workspace-details/WorkspaceDetails.ts index 8a096148292b..27074835572d 100644 --- a/tests/e2e/pageobjects/dashboard/workspace-details/WorkspaceDetails.ts +++ b/tests/e2e/pageobjects/dashboard/workspace-details/WorkspaceDetails.ts @@ -101,7 +101,7 @@ export class WorkspaceDetails { await this.clickOnOpenButton(timeout); await this.testProjectAndFileCheCode.waitWorkspaceReadinessForCheCodeEditor(); - this.testWorkspaceUtil.waitWorkspaceStatus(workspaceName, WorkspaceStatus.STARTING); + await this.testWorkspaceUtil.waitWorkspaceStatus(workspaceName, WorkspaceStatus.STARTING); } async waitTabsPresence(timeout: number = TIMEOUT_CONSTANTS.TS_COMMON_DASHBOARD_WAIT_TIMEOUT): Promise { diff --git a/tests/e2e/specs/MochaHooks.ts b/tests/e2e/specs/MochaHooks.ts index 82c088150262..b415fbb45165 100644 --- a/tests/e2e/specs/MochaHooks.ts +++ b/tests/e2e/specs/MochaHooks.ts @@ -114,29 +114,29 @@ exports.mochaHooks = { } }, // stop and remove running workspace - function deleteWorkspaceOnFailedTest(this: Mocha.Context): void { + async function deleteWorkspaceOnFailedTest(this: Mocha.Context): Promise { if (this.currentTest?.state === 'failed') { if (BASE_TEST_CONSTANTS.DELETE_WORKSPACE_ON_FAILED_TEST) { Logger.info('Property DELETE_WORKSPACE_ON_FAILED_TEST is true - trying to stop and delete running workspace with API.'); const testWorkspaceUtil: ITestWorkspaceUtil = e2eContainer.get(TYPES.WorkspaceUtil); - testWorkspaceUtil.stopAndDeleteWorkspaceByName(latestWorkspace); + await testWorkspaceUtil.stopAndDeleteWorkspaceByName(latestWorkspace); } } } ], afterAll: [ // stop and remove running workspace - function deleteAllWorkspacesOnFinish(): void { - if (BASE_TEST_CONSTANTS.DELETE_ALL_WORKSPACES_ON_RUN_FINISH) { - Logger.info( - 'Property DELETE_WORKSPACE_ON_FAILED_TEST is true - trying to stop and delete all running workspace after test run with API.' - ); - const testWorkspaceUtil: ITestWorkspaceUtil = e2eContainer.get(TYPES.WorkspaceUtil); - try { - testWorkspaceUtil.stopAndDeleteAllRunningWorkspaces(); - } catch (e) { - Logger.trace('Running workspaces not found'); + async function deleteAllWorkspacesOnFinish(): Promise { + try { + if (BASE_TEST_CONSTANTS.DELETE_ALL_WORKSPACES_ON_RUN_FINISH) { + Logger.info( + 'Property DELETE_WORKSPACE_ON_FAILED_TEST is true - trying to stop and delete all running workspace after test run with API.' + ); + const testWorkspaceUtil: ITestWorkspaceUtil = e2eContainer.get(TYPES.WorkspaceUtil); + await testWorkspaceUtil.stopAndDeleteAllRunningWorkspaces(); } + } catch (e) { + Logger.trace('Running workspaces not found'); } }, async function stopTheDriver(): Promise { diff --git a/tests/e2e/specs/dashboard-samples/EmptyWorkspace.spec.ts b/tests/e2e/specs/dashboard-samples/EmptyWorkspace.spec.ts index db0c9cccfb8a..3aac7ba430d0 100644 --- a/tests/e2e/specs/dashboard-samples/EmptyWorkspace.spec.ts +++ b/tests/e2e/specs/dashboard-samples/EmptyWorkspace.spec.ts @@ -63,8 +63,8 @@ suite(`${stackName} test ${BASE_TEST_CONSTANTS.TEST_ENVIRONMENT}`, function (): await browserTabsUtil.closeAllTabsExceptCurrent(); }); - suiteTeardown('Stop and delete the workspace by API', function (): void { - testWorkspaceUtil.stopAndDeleteWorkspaceByName(WorkspaceHandlingTests.getWorkspaceName()); + suiteTeardown('Stop and delete the workspace by API', async function (): Promise { + await testWorkspaceUtil.stopAndDeleteWorkspaceByName(WorkspaceHandlingTests.getWorkspaceName()); }); suiteTeardown('Unregister running workspace', function (): void { diff --git a/tests/e2e/specs/dashboard-samples/Quarkus.spec.ts b/tests/e2e/specs/dashboard-samples/Quarkus.spec.ts index a6586813c1f3..f1aacb142bd0 100644 --- a/tests/e2e/specs/dashboard-samples/Quarkus.spec.ts +++ b/tests/e2e/specs/dashboard-samples/Quarkus.spec.ts @@ -75,8 +75,8 @@ suite(`The ${stackName} userstory ${BASE_TEST_CONSTANTS.TEST_ENVIRONMENT}`, func await browserTabsUtil.closeAllTabsExceptCurrent(); }); - suiteTeardown('Stop and delete the workspace by API', function (): void { - testWorkspaceUtil.stopAndDeleteWorkspaceByName(WorkspaceHandlingTests.getWorkspaceName()); + suiteTeardown('Stop and delete the workspace by API', async function (): Promise { + await testWorkspaceUtil.stopAndDeleteWorkspaceByName(WorkspaceHandlingTests.getWorkspaceName()); }); suiteTeardown('Unregister running workspace', function (): void { diff --git a/tests/e2e/specs/dashboard-samples/RecommendedExtensions.spec.ts b/tests/e2e/specs/dashboard-samples/RecommendedExtensions.spec.ts index 9948fd579d30..a88b4c5fe598 100644 --- a/tests/e2e/specs/dashboard-samples/RecommendedExtensions.spec.ts +++ b/tests/e2e/specs/dashboard-samples/RecommendedExtensions.spec.ts @@ -213,8 +213,8 @@ for (const sample of samples) { await browserTabsUtil.closeAllTabsExceptCurrent(); }); - suiteTeardown('Stop and delete the workspace by API', function (): void { - testWorkspaceUtil.stopAndDeleteWorkspaceByName(WorkspaceHandlingTests.getWorkspaceName()); + suiteTeardown('Stop and delete the workspace by API', async function (): Promise { + await testWorkspaceUtil.stopAndDeleteWorkspaceByName(WorkspaceHandlingTests.getWorkspaceName()); }); suiteTeardown('Unregister running workspace', function (): void { diff --git a/tests/e2e/specs/factory/Factory.spec.ts b/tests/e2e/specs/factory/Factory.spec.ts index 4ab45f2d4ecd..70d237a4603d 100644 --- a/tests/e2e/specs/factory/Factory.spec.ts +++ b/tests/e2e/specs/factory/Factory.spec.ts @@ -200,8 +200,8 @@ suite( await browserTabsUtil.closeAllTabsExceptCurrent(); }); - suiteTeardown('Stop and delete the workspace by API', function (): void { - testWorkspaceUtil.stopAndDeleteWorkspaceByName(WorkspaceHandlingTests.getWorkspaceName()); + suiteTeardown('Stop and delete the workspace by API', async function (): Promise { + await testWorkspaceUtil.stopAndDeleteWorkspaceByName(WorkspaceHandlingTests.getWorkspaceName()); }); suiteTeardown('Unregister running workspace', function (): void { diff --git a/tests/e2e/specs/factory/NoSetupRepoFactory.spec.ts b/tests/e2e/specs/factory/NoSetupRepoFactory.spec.ts index b77faebaf572..aab5ac7b0051 100644 --- a/tests/e2e/specs/factory/NoSetupRepoFactory.spec.ts +++ b/tests/e2e/specs/factory/NoSetupRepoFactory.spec.ts @@ -248,8 +248,8 @@ suite( await browserTabsUtil.closeAllTabsExceptCurrent(); }); - suiteTeardown('Stop and delete the workspace by API', function (): void { - testWorkspaceUtil.stopAndDeleteWorkspaceByName(WorkspaceHandlingTests.getWorkspaceName()); + suiteTeardown('Stop and delete the workspace by API', async function (): Promise { + await testWorkspaceUtil.stopAndDeleteWorkspaceByName(WorkspaceHandlingTests.getWorkspaceName()); }); } diff --git a/tests/e2e/specs/factory/RefusedOAuthFactory.spec.ts b/tests/e2e/specs/factory/RefusedOAuthFactory.spec.ts index fe9dd15b9735..0630c00a7180 100644 --- a/tests/e2e/specs/factory/RefusedOAuthFactory.spec.ts +++ b/tests/e2e/specs/factory/RefusedOAuthFactory.spec.ts @@ -243,8 +243,8 @@ suite( await browserTabsUtil.closeAllTabsExceptCurrent(); }); - suiteTeardown('Stop and delete the workspace by API', function (): void { - testWorkspaceUtil.stopAndDeleteWorkspaceByName(WorkspaceHandlingTests.getWorkspaceName()); + suiteTeardown('Stop and delete the workspace by API', async function (): Promise { + await testWorkspaceUtil.stopAndDeleteWorkspaceByName(WorkspaceHandlingTests.getWorkspaceName()); }); suiteTeardown('Unregister running workspace', function (): void { diff --git a/tests/e2e/specs/miscellaneous/CreateWorkspaceWithExistedName.spec.ts b/tests/e2e/specs/miscellaneous/CreateWorkspaceWithExistedName.spec.ts index 775265e9f45a..22d657125aee 100644 --- a/tests/e2e/specs/miscellaneous/CreateWorkspaceWithExistedName.spec.ts +++ b/tests/e2e/specs/miscellaneous/CreateWorkspaceWithExistedName.spec.ts @@ -86,9 +86,9 @@ suite(`"Start workspace with existed workspace name" test ${BASE_TEST_CONSTANTS. await browserTabsUtil.closeAllTabsExceptCurrent(); }); - suiteTeardown(`Stop and delete all created ${stackName} workspaces by API`, function (): void { - testWorkspaceUtil.stopAndDeleteWorkspaceByName(WorkspaceHandlingTests.getWorkspaceName()); - testWorkspaceUtil.stopAndDeleteWorkspaceByName(existedWorkspaceName); + suiteTeardown(`Stop and delete all created ${stackName} workspaces by API`, async function (): Promise { + await testWorkspaceUtil.stopAndDeleteWorkspaceByName(WorkspaceHandlingTests.getWorkspaceName()); + await testWorkspaceUtil.stopAndDeleteWorkspaceByName(existedWorkspaceName); }); suiteTeardown('Unregister running workspace', function (): void { diff --git a/tests/e2e/specs/miscellaneous/KubedockPodmanTest.spec.ts b/tests/e2e/specs/miscellaneous/KubedockPodmanTest.spec.ts index 769445df36a8..bd0247fa9301 100644 --- a/tests/e2e/specs/miscellaneous/KubedockPodmanTest.spec.ts +++ b/tests/e2e/specs/miscellaneous/KubedockPodmanTest.spec.ts @@ -94,8 +94,8 @@ suite( await browserTabsUtil.closeAllTabsExceptCurrent(); }); - suiteTeardown('Stop and delete the workspace by API', function (): void { - testWorkspaceUtil.stopAndDeleteWorkspaceByName(WorkspaceHandlingTests.getWorkspaceName()); + suiteTeardown('Stop and delete the workspace by API', async function (): Promise { + await testWorkspaceUtil.stopAndDeleteWorkspaceByName(WorkspaceHandlingTests.getWorkspaceName()); }); suiteTeardown('Unregister running workspace', function (): void { diff --git a/tests/e2e/specs/miscellaneous/WorkspaceIdleTimeout.spec.ts b/tests/e2e/specs/miscellaneous/WorkspaceIdleTimeout.spec.ts index 6df161531037..b0f35b5539fe 100644 --- a/tests/e2e/specs/miscellaneous/WorkspaceIdleTimeout.spec.ts +++ b/tests/e2e/specs/miscellaneous/WorkspaceIdleTimeout.spec.ts @@ -101,8 +101,8 @@ suite('"Check workspace idle timeout" test', function (): void { await browserTabsUtil.closeAllTabsExceptCurrent(); }); - suiteTeardown('Stop and delete the workspace by API', function (): void { - testWorkspaceUtil.deleteWorkspaceByName(WorkspaceHandlingTests.getWorkspaceName()); + suiteTeardown('Stop and delete the workspace by API', async function (): Promise { + await testWorkspaceUtil.deleteWorkspaceByName(WorkspaceHandlingTests.getWorkspaceName()); }); suiteTeardown('Unregister running workspace', function (): void { diff --git a/tests/e2e/specs/miscellaneous/WorkspaceWithParent.spec.ts b/tests/e2e/specs/miscellaneous/WorkspaceWithParent.spec.ts index 4f220f260797..d5012a5c625d 100644 --- a/tests/e2e/specs/miscellaneous/WorkspaceWithParent.spec.ts +++ b/tests/e2e/specs/miscellaneous/WorkspaceWithParent.spec.ts @@ -103,7 +103,7 @@ suite(`Workspace using a parent test suite ${BASE_TEST_CONSTANTS.TEST_ENVIRONMEN suiteTeardown('Stop and delete the workspace by API', async function (): Promise { await dashboard.openDashboard(); await browserTabsUtil.closeAllTabsExceptCurrent(); - testWorkspaceUtil.stopAndDeleteWorkspaceByName(WorkspaceHandlingTests.getWorkspaceName()); + await testWorkspaceUtil.stopAndDeleteWorkspaceByName(WorkspaceHandlingTests.getWorkspaceName()); }); suiteTeardown('Unregister running workspace', function (): void { diff --git a/tests/e2e/utils/workspace/ITestWorkspaceUtil.ts b/tests/e2e/utils/workspace/ITestWorkspaceUtil.ts index 533192c2a99f..1fd3ce0ae569 100644 --- a/tests/e2e/utils/workspace/ITestWorkspaceUtil.ts +++ b/tests/e2e/utils/workspace/ITestWorkspaceUtil.ts @@ -11,33 +11,33 @@ import { WorkspaceStatus } from './WorkspaceStatus'; export interface ITestWorkspaceUtil { - waitWorkspaceStatus(workspaceName: string, expectedWorkspaceStatus: WorkspaceStatus): void; + waitWorkspaceStatus(workspaceName: string, expectedWorkspaceStatus: WorkspaceStatus): Promise; - stopWorkspaceByName(workspaceName: string): void; + stopWorkspaceByName(workspaceName: string): Promise; /** * delete a workspace without stopping phase (similar with force deleting) */ - deleteWorkspaceByName(workspaceName: string): void; + deleteWorkspaceByName(workspaceName: string): Promise; /** * stop workspace before deleting with checking stopping phase */ - stopAndDeleteWorkspaceByName(workspaceName: string): void; + stopAndDeleteWorkspaceByName(workspaceName: string): Promise; /** * stop all run workspaces in the namespace */ - stopAllRunningWorkspaces(): void; + stopAllRunningWorkspaces(): Promise; /** * stop all run workspaces, check statused and remove the workspaces */ - stopAndDeleteAllRunningWorkspaces(): void; + stopAndDeleteAllRunningWorkspaces(): Promise; /** * stop all run workspaces without stopping and waiting for of 'Stopped' phase * Similar with 'force' deleting */ - deleteAllWorkspaces(): void; + deleteAllWorkspaces(): Promise; }