Skip to content

Commit

Permalink
create WorkspaceIdleTimeout test
Browse files Browse the repository at this point in the history
  • Loading branch information
SkorikSergey committed Sep 26, 2023
1 parent e862bb5 commit 09ff112
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tests/e2e/pageobjects/ide/CheCodeLocatorLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ export class CheCodeLocatorLoader extends LocatorLoader {
extras: {
ExtensionsViewSection: {
requireReloadButton: By.xpath('//a[text()="Reload Required"]')
},
Dialog: {
message: By.xpath('//div[text()="Your workspace has stopped due to inactivity."]'),
returnToDashboardButton: By.xpath('//a[@title="Return to dashboard"]')
}
}
};
Expand Down
66 changes: 66 additions & 0 deletions tests/e2e/specs/miscellaneous/WorkspaceIdleTimeout.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/** *******************************************************************
* copyright (c) 2020-2023 Red Hat, Inc.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
import { e2eContainer } from '../../configs/inversify.config';
import { CLASSES } from '../../configs/inversify.types';
import { WorkspaceHandlingTests } from '../../tests-library/WorkspaceHandlingTests';
import { ProjectAndFileTests } from '../../tests-library/ProjectAndFileTests';
import { LoginTests } from '../../tests-library/LoginTests';
import { registerRunningWorkspace } from '../MochaHooks';
import { Dashboard } from '../../pageobjects/dashboard/Dashboard';
import { Workspaces } from '../../pageobjects/dashboard/Workspaces';
import { By } from 'selenium-webdriver';
import { TIMEOUT_CONSTANTS } from '../../constants/TIMEOUT_CONSTANTS';
import { DriverHelper } from '../../utils/DriverHelper';
import { CheCodeLocatorLoader } from '../../pageobjects/ide/CheCodeLocatorLoader';
import { Locators } from 'monaco-page-objects';

const stackName: string = 'Empty Workspace';

suite('"Check workspace idle timeout" test', function (): void {
const workspaceHandlingTests: WorkspaceHandlingTests = e2eContainer.get(CLASSES.WorkspaceHandlingTests);
const projectAndFileTests: ProjectAndFileTests = e2eContainer.get(CLASSES.ProjectAndFileTests);
const loginTests: LoginTests = e2eContainer.get(CLASSES.LoginTests);
const dashboard: Dashboard = e2eContainer.get(CLASSES.Dashboard);
const workspaces: Workspaces = e2eContainer.get(CLASSES.Workspaces);
const driverHelper: DriverHelper = e2eContainer.get(CLASSES.DriverHelper);
const cheCodeLocatorLoader: CheCodeLocatorLoader = e2eContainer.get(CLASSES.CheCodeLocatorLoader);
const webCheCodeLocators: Locators = cheCodeLocatorLoader.webCheCodeLocators;

loginTests.loginIntoChe();

test(`Create and open new workspace, stack:${stackName}`, async function (): Promise<void> {
await workspaceHandlingTests.createAndOpenWorkspace(stackName);
await workspaceHandlingTests.obtainWorkspaceNameFromStartingPage();
});

test('Wait workspace readiness', async function (): Promise<void> {
registerRunningWorkspace(WorkspaceHandlingTests.getWorkspaceName());
await projectAndFileTests.waitWorkspaceReadinessForCheCodeEditor();
await projectAndFileTests.performTrustAuthorDialog();
});

test('Wait idle timeout dialog and click on "Return to Dashboard" button', async function (): Promise<void> {
await driverHelper.waitVisibility(webCheCodeLocators.Dialog.message, TIMEOUT_CONSTANTS.TS_SELENIUM_START_WORKSPACE_TIMEOUT);
if (await driverHelper.isVisible((webCheCodeLocators.Dialog as any).returnToDashboardButton)) {
await driverHelper.waitAndClick((webCheCodeLocators.Dialog as any).returnToDashboardButton);
}
});

test('Check that the workskpace has Stopped state', async function (): Promise<void> {
await dashboard.waitPage();
await workspaces.waitWorkspaceWithStoppedStatus(WorkspaceHandlingTests.getWorkspaceName());
});

test('Delete the workspace', async function (): Promise<void> {
await dashboard.deleteStoppedWorkspaceByUI(WorkspaceHandlingTests.getWorkspaceName());
});

loginTests.logoutFromChe();
});

0 comments on commit 09ff112

Please sign in to comment.