|
| 1 | +/** ******************************************************************* |
| 2 | + * copyright (c) 2020-2026 Red Hat, Inc. |
| 3 | + * |
| 4 | + * This program and the accompanying materials are made |
| 5 | + * available under the terms of the Eclipse Public License 2.0 |
| 6 | + * which is available at https://www.eclipse.org/legal/epl-2.0/ |
| 7 | + * |
| 8 | + * SPDX-License-Identifier: EPL-2.0 |
| 9 | + **********************************************************************/ |
| 10 | +import { e2eContainer } from '../../configs/inversify.config'; |
| 11 | +import { Workbench, ActivityBar, ViewControl } from 'monaco-page-objects'; |
| 12 | +import { CLASSES } from '../../configs/inversify.types'; |
| 13 | +import { expect } from 'chai'; |
| 14 | +import { WorkspaceHandlingTests } from '../../tests-library/WorkspaceHandlingTests'; |
| 15 | +import { ProjectAndFileTests } from '../../tests-library/ProjectAndFileTests'; |
| 16 | +import { LoginTests } from '../../tests-library/LoginTests'; |
| 17 | +import { registerRunningWorkspace } from '../MochaHooks'; |
| 18 | +import { BrowserTabsUtil } from '../../utils/BrowserTabsUtil'; |
| 19 | +import { BASE_TEST_CONSTANTS } from '../../constants/BASE_TEST_CONSTANTS'; |
| 20 | +import { Dashboard } from '../../pageobjects/dashboard/Dashboard'; |
| 21 | +import { CreateWorkspace } from '../../pageobjects/dashboard/CreateWorkspace'; |
| 22 | +import { Logger } from '../../utils/Logger'; |
| 23 | + |
| 24 | +suite(`"Create Empty Workspace sample" test ${BASE_TEST_CONSTANTS.TEST_ENVIRONMENT}`, function (): void { |
| 25 | + const workspaceHandlingTests: WorkspaceHandlingTests = e2eContainer.get(CLASSES.WorkspaceHandlingTests); |
| 26 | + const projectAndFileTests: ProjectAndFileTests = e2eContainer.get(CLASSES.ProjectAndFileTests); |
| 27 | + const loginTests: LoginTests = e2eContainer.get(CLASSES.LoginTests); |
| 28 | + const browserTabsUtil: BrowserTabsUtil = e2eContainer.get(CLASSES.BrowserTabsUtil); |
| 29 | + const dashboard: Dashboard = e2eContainer.get(CLASSES.Dashboard); |
| 30 | + const createWorkspace: CreateWorkspace = e2eContainer.get(CLASSES.CreateWorkspace); |
| 31 | + |
| 32 | + const stackName: string = 'Empty Workspace'; |
| 33 | + |
| 34 | + let firstWorkspaceName: string; |
| 35 | + let secondWorkspaceName: string; |
| 36 | + |
| 37 | + suiteSetup('Login', async function (): Promise<void> { |
| 38 | + await loginTests.loginIntoChe(); |
| 39 | + }); |
| 40 | + |
| 41 | + async function waitDashboardPage(): Promise<void> { |
| 42 | + await dashboard.openDashboard(); |
| 43 | + await dashboard.waitPage(); |
| 44 | + await browserTabsUtil.closeAllTabsExceptCurrent(); |
| 45 | + |
| 46 | + await dashboard.clickCreateWorkspaceButton(); |
| 47 | + await createWorkspace.waitPage(); |
| 48 | + expect(await createWorkspace.isCreateNewWorkspaceCheckboxChecked()).to.be.true; |
| 49 | + } |
| 50 | + |
| 51 | + async function waitWorkspaceReadiness(): Promise<void> { |
| 52 | + await projectAndFileTests.waitWorkspaceReadinessForCheCodeEditor(); |
| 53 | + const workbench: Workbench = new Workbench(); |
| 54 | + const activityBar: ActivityBar = workbench.getActivityBar(); |
| 55 | + const activityBarControls: ViewControl[] = await activityBar.getViewControls(); |
| 56 | + |
| 57 | + Logger.debug('Editor sections:'); |
| 58 | + for (const control of activityBarControls) { |
| 59 | + Logger.debug(`${await control.getTitle()}`); |
| 60 | + } |
| 61 | + } |
| 62 | + |
| 63 | + test('Verify "Create New" is on and a new workspace is created without warnings', async function (): Promise<void> { |
| 64 | + await waitDashboardPage(); |
| 65 | + |
| 66 | + // verify "Create New" checkbox is checked by default |
| 67 | + expect(await createWorkspace.isCreateNewWorkspaceCheckboxChecked()).to.be.true; |
| 68 | + await workspaceHandlingTests.createAndOpenWorkspace(stackName, true); |
| 69 | + await workspaceHandlingTests.obtainWorkspaceNameFromStartingPage(); |
| 70 | + registerRunningWorkspace(WorkspaceHandlingTests.getWorkspaceName()); |
| 71 | + await waitWorkspaceReadiness(); |
| 72 | + |
| 73 | + firstWorkspaceName = WorkspaceHandlingTests.getWorkspaceName(); |
| 74 | + }); |
| 75 | + |
| 76 | + test('Verify "Create New" is off and a new workspace is created', async function (): Promise<void> { |
| 77 | + await waitDashboardPage(); |
| 78 | + |
| 79 | + expect(await createWorkspace.isCreateNewWorkspaceCheckboxChecked()).to.be.true; |
| 80 | + await workspaceHandlingTests.createAndOpenWorkspace(stackName, false); |
| 81 | + await workspaceHandlingTests.obtainWorkspaceNameFromStartingPage(); |
| 82 | + registerRunningWorkspace(WorkspaceHandlingTests.getWorkspaceName()); |
| 83 | + await waitWorkspaceReadiness(); |
| 84 | + |
| 85 | + secondWorkspaceName = WorkspaceHandlingTests.getWorkspaceName(); |
| 86 | + |
| 87 | + // empty Workspace sample generates unique names, so workspaces should have different names |
| 88 | + expect(WorkspaceHandlingTests.getWorkspaceName()).not.to.be.equal(firstWorkspaceName); |
| 89 | + }); |
| 90 | + |
| 91 | + suiteTeardown('Stop and delete all created workspaces', async function (): Promise<void> { |
| 92 | + await workspaceHandlingTests.stopAndRemoveWorkspace(firstWorkspaceName); |
| 93 | + await workspaceHandlingTests.stopAndRemoveWorkspace(secondWorkspaceName); |
| 94 | + }); |
| 95 | + |
| 96 | + suiteTeardown('Unregister running workspace', function (): void { |
| 97 | + registerRunningWorkspace(''); |
| 98 | + }); |
| 99 | +}); |
0 commit comments