Skip to content

Commit

Permalink
Update 'Factory' e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
artaleks9 committed Jan 9, 2025
1 parent 2f9d491 commit 9a6852e
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 9 deletions.
12 changes: 12 additions & 0 deletions tests/e2e/constants/BASE_TEST_CONSTANTS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export enum Platform {
export const BASE_TEST_CONSTANTS: {
OCP_INFRA: string;
DELETE_WORKSPACE_ON_FAILED_TEST: boolean;
DELETE_WORKSPACE_ON_SUCCESSFUL_TEST: boolean;
IS_RESTART_EXISTING_WORKSPACE: boolean;
IS_CLUSTER_DISCONNECTED: () => boolean;
IS_PRODUCT_DOCUMENTATION_RELEASED: any;
OCP_VERSION: string;
Expand Down Expand Up @@ -130,6 +132,16 @@ export const BASE_TEST_CONSTANTS: {
*/
DELETE_WORKSPACE_ON_FAILED_TEST: process.env.DELETE_WORKSPACE_ON_FAILED_TEST === 'true',

/**
* stop and remove workspace if a test is successful.
*/
DELETE_WORKSPACE_ON_SUCCESSFUL_TEST: process.env.DELETE_WORKSPACE_ON_SUCCESSFUL_TEST !== 'false',

/**
* restart existing workspace.
*/
IS_RESTART_EXISTING_WORKSPACE: process.env.IS_RESTART_EXISTING_WORKSPACE === 'true',

/**
* constant, which prolong timeout constants for local debug.
*/
Expand Down
7 changes: 7 additions & 0 deletions tests/e2e/pageobjects/dashboard/Dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export class Dashboard {
username: 'username'
};
private static readonly CONTINUE_WITH_DEFAULT_DEVFILE_BUTTON: By = By.xpath('//button[text()="Continue with default devfile"]');
private static readonly OPEN_EXISTING_WORKSPACE_LINK: By = By.xpath('//button[text()="Open the existing workspace"]');

constructor(
@inject(CLASSES.DriverHelper)
Expand Down Expand Up @@ -176,6 +177,12 @@ export class Dashboard {
await this.driverHelper.waitAndClick(Dashboard.CREATE_NEW_WORKSPACE_LINK, timeout);
}

async clickOpenExistingWorkspaceButton(timeout: number = TIMEOUT_CONSTANTS.TS_CLICK_DASHBOARD_ITEM_TIMEOUT): Promise<void> {
Logger.debug();

await this.driverHelper.waitAndClick(Dashboard.OPEN_EXISTING_WORKSPACE_LINK, timeout);
}

async logout(timeout: number = TIMEOUT_CONSTANTS.TS_COMMON_DASHBOARD_WAIT_TIMEOUT): Promise<void> {
Logger.debug();

Expand Down
31 changes: 22 additions & 9 deletions tests/e2e/specs/factory/Factory.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ suite(
});
}

if (BASE_TEST_CONSTANTS.IS_RESTART_EXISTING_WORKSPACE) {
test('Restart existing workspace', async function (): Promise<void> {
await dashboard.waitExistingWorkspaceFoundAlert();
await dashboard.clickOpenExistingWorkspaceButton();
});
}

test('Obtain workspace name from workspace loader page', async function (): Promise<void> {
await workspaceHandlingTests.obtainWorkspaceNameFromStartingPage();
});
Expand Down Expand Up @@ -209,14 +216,20 @@ suite(
await browserTabsUtil.closeAllTabsExceptCurrent();
});

suiteTeardown('Stop and delete the workspace by API', async function (): Promise<void> {
// to avoid a possible creating workspace which is not appeared on Dashboard yet. TODO: implement a better solution.
await driverHelper.wait(30000);
await testWorkspaceUtil.stopAndDeleteWorkspaceByName(WorkspaceHandlingTests.getWorkspaceName());
});

suiteTeardown('Unregister running workspace', function (): void {
registerRunningWorkspace('');
});
if (BASE_TEST_CONSTANTS.DELETE_WORKSPACE_ON_SUCCESSFUL_TEST) {
suiteTeardown('Stop and delete the workspace by API', async function (): Promise<void> {
// to avoid a possible creating workspace which is not appeared on Dashboard yet. TODO: implement a better solution.
await driverHelper.wait(30000);
await testWorkspaceUtil.stopAndDeleteWorkspaceByName(WorkspaceHandlingTests.getWorkspaceName());
});

suiteTeardown('Unregister running workspace', function (): void {
registerRunningWorkspace('');
});
} else {
suiteTeardown('Registering the running workspace', function (): void {
registerRunningWorkspace(WorkspaceHandlingTests.getWorkspaceName());
});
}
}
);

0 comments on commit 9a6852e

Please sign in to comment.