|
| 1 | +/** ******************************************************************* |
| 2 | + * copyright (c) 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 { CLASSES } from '../../configs/inversify.types'; |
| 12 | +import { expect } from 'chai'; |
| 13 | +import { WorkspaceHandlingTests } from '../../tests-library/WorkspaceHandlingTests'; |
| 14 | +import { ProjectAndFileTests } from '../../tests-library/ProjectAndFileTests'; |
| 15 | +import { LoginTests } from '../../tests-library/LoginTests'; |
| 16 | +import { registerRunningWorkspace } from '../MochaHooks'; |
| 17 | +import { BrowserTabsUtil } from '../../utils/BrowserTabsUtil'; |
| 18 | +import { BASE_TEST_CONSTANTS } from '../../constants/BASE_TEST_CONSTANTS'; |
| 19 | +import { Dashboard } from '../../pageobjects/dashboard/Dashboard'; |
| 20 | +import { Workspaces } from '../../pageobjects/dashboard/Workspaces'; |
| 21 | +import { WorkspaceDetails } from '../../pageobjects/dashboard/workspace-details/WorkspaceDetails'; |
| 22 | +import { TIMEOUT_CONSTANTS } from '../../constants/TIMEOUT_CONSTANTS'; |
| 23 | + |
| 24 | +const stackName: string = BASE_TEST_CONSTANTS.TS_SELENIUM_DASHBOARD_SAMPLE_NAME || 'Empty Workspace'; |
| 25 | +const RENAMED_WORKSPACE_NAME: string = 'new-ws'; |
| 26 | + |
| 27 | +suite(`Rename workspace ${BASE_TEST_CONSTANTS.TEST_ENVIRONMENT}`, function (): void { |
| 28 | + const workspaceHandlingTests: WorkspaceHandlingTests = e2eContainer.get(CLASSES.WorkspaceHandlingTests); |
| 29 | + const projectAndFileTests: ProjectAndFileTests = e2eContainer.get(CLASSES.ProjectAndFileTests); |
| 30 | + const loginTests: LoginTests = e2eContainer.get(CLASSES.LoginTests); |
| 31 | + const browserTabsUtil: BrowserTabsUtil = e2eContainer.get(CLASSES.BrowserTabsUtil); |
| 32 | + const dashboard: Dashboard = e2eContainer.get(CLASSES.Dashboard); |
| 33 | + const workspaces: Workspaces = e2eContainer.get(CLASSES.Workspaces); |
| 34 | + const workspaceDetails: WorkspaceDetails = e2eContainer.get(CLASSES.WorkspaceDetails); |
| 35 | + |
| 36 | + let firstWorkspaceName: string = ''; |
| 37 | + let secondWorkspaceName: string = ''; |
| 38 | + |
| 39 | + async function openDashboardWorkspacesList(): Promise<void> { |
| 40 | + await dashboard.openDashboard(); |
| 41 | + await dashboard.clickWorkspacesButton(); |
| 42 | + await workspaces.waitPage(); |
| 43 | + } |
| 44 | + |
| 45 | + async function openWorkspaceDetailsOverview(workspaceName: string): Promise<void> { |
| 46 | + await openDashboardWorkspacesList(); |
| 47 | + await workspaces.clickWorkspaceListItemLink(workspaceName); |
| 48 | + await workspaceDetails.waitWorkspaceTitle(workspaceName); |
| 49 | + await workspaceDetails.waitLoaderDisappearance(); |
| 50 | + } |
| 51 | + |
| 52 | + suiteSetup('Login', async function (): Promise<void> { |
| 53 | + await loginTests.loginIntoChe(); |
| 54 | + }); |
| 55 | + |
| 56 | + test(`Create workspace from sample (${stackName})`, async function (): Promise<void> { |
| 57 | + await workspaceHandlingTests.createAndOpenWorkspace(stackName); |
| 58 | + await workspaceHandlingTests.obtainWorkspaceNameFromStartingPage(); |
| 59 | + firstWorkspaceName = WorkspaceHandlingTests.getWorkspaceName(); |
| 60 | + registerRunningWorkspace(firstWorkspaceName); |
| 61 | + |
| 62 | + await projectAndFileTests.waitWorkspaceReadinessForCheCodeEditor(); |
| 63 | + }); |
| 64 | + |
| 65 | + test('Workspace details: rename must not be available while the workspace is running', async function (): Promise<void> { |
| 66 | + await openWorkspaceDetailsOverview(firstWorkspaceName); |
| 67 | + await workspaceDetails.checkRenameButtonIsAbsent(); |
| 68 | + }); |
| 69 | + |
| 70 | + test('Stop the first workspace from the dashboard', async function (): Promise<void> { |
| 71 | + await workspaceHandlingTests.stopWorkspace(firstWorkspaceName); |
| 72 | + await browserTabsUtil.closeAllTabsExceptCurrent(); |
| 73 | + }); |
| 74 | + |
| 75 | + test(`Rename stopped workspace to "${RENAMED_WORKSPACE_NAME}" from workspace details`, async function (): Promise<void> { |
| 76 | + await openWorkspaceDetailsOverview(firstWorkspaceName); |
| 77 | + await workspaceDetails.renameWorkspace(RENAMED_WORKSPACE_NAME); |
| 78 | + firstWorkspaceName = RENAMED_WORKSPACE_NAME; |
| 79 | + }); |
| 80 | + |
| 81 | + test(`Dashboard lists and details show "${RENAMED_WORKSPACE_NAME}"`, async function (): Promise<void> { |
| 82 | + await openDashboardWorkspacesList(); |
| 83 | + await workspaces.waitWorkspaceListItem(RENAMED_WORKSPACE_NAME, TIMEOUT_CONSTANTS.TS_SELENIUM_LOAD_PAGE_TIMEOUT); |
| 84 | + await workspaces.clickWorkspaceListItemLink(RENAMED_WORKSPACE_NAME); |
| 85 | + await workspaceDetails.waitWorkspaceTitle(RENAMED_WORKSPACE_NAME); |
| 86 | + }); |
| 87 | + |
| 88 | + test(`Start "${RENAMED_WORKSPACE_NAME}" and wait until it is Running`, async function (): Promise<void> { |
| 89 | + await openDashboardWorkspacesList(); |
| 90 | + |
| 91 | + await workspaceHandlingTests.openWorkspace(RENAMED_WORKSPACE_NAME); |
| 92 | + await workspaceHandlingTests.obtainWorkspaceNameFromStartingPage(); |
| 93 | + const startedWorkspaceName: string = WorkspaceHandlingTests.getWorkspaceName(); |
| 94 | + expect(WorkspaceHandlingTests.getWorkspaceName()).equal(RENAMED_WORKSPACE_NAME); |
| 95 | + registerRunningWorkspace(startedWorkspaceName); |
| 96 | + await projectAndFileTests.waitWorkspaceReadinessForCheCodeEditor(); |
| 97 | + }); |
| 98 | + |
| 99 | + test(`Stop "${RENAMED_WORKSPACE_NAME}" again`, async function (): Promise<void> { |
| 100 | + await workspaceHandlingTests.stopWorkspace(RENAMED_WORKSPACE_NAME); |
| 101 | + await browserTabsUtil.closeAllTabsExceptCurrent(); |
| 102 | + }); |
| 103 | + |
| 104 | + test(`Workspace details: setting name to "${RENAMED_WORKSPACE_NAME}" when it is already the current name is rejected`, async function (): Promise<void> { |
| 105 | + await openWorkspaceDetailsOverview(RENAMED_WORKSPACE_NAME); |
| 106 | + await workspaceDetails.openRenameWorkspaceForm(); |
| 107 | + await workspaceDetails.typeWorkspaceName(RENAMED_WORKSPACE_NAME); |
| 108 | + await workspaceDetails.waitSaveButtonIsDisabled(); |
| 109 | + await workspaceDetails.cancelRenameWorkspace(); |
| 110 | + }); |
| 111 | + |
| 112 | + test(`Create a second workspace from sample (${stackName})`, async function (): Promise<void> { |
| 113 | + await workspaceHandlingTests.createAndOpenWorkspace(stackName); |
| 114 | + await workspaceHandlingTests.obtainWorkspaceNameFromStartingPage(); |
| 115 | + secondWorkspaceName = WorkspaceHandlingTests.getWorkspaceName(); |
| 116 | + registerRunningWorkspace(secondWorkspaceName); |
| 117 | + await projectAndFileTests.waitWorkspaceReadinessForCheCodeEditor(); |
| 118 | + }); |
| 119 | + |
| 120 | + test(`Second workspace details: rename to "${RENAMED_WORKSPACE_NAME}" shows conflict and does not apply`, async function (): Promise<void> { |
| 121 | + await workspaceHandlingTests.stopWorkspace(secondWorkspaceName); |
| 122 | + await browserTabsUtil.closeAllTabsExceptCurrent(); |
| 123 | + |
| 124 | + await openWorkspaceDetailsOverview(secondWorkspaceName); |
| 125 | + await workspaceDetails.openRenameWorkspaceForm(); |
| 126 | + await workspaceDetails.typeWorkspaceName(RENAMED_WORKSPACE_NAME); |
| 127 | + await workspaceDetails.waitSaveButtonIsDisabled(); |
| 128 | + await workspaceDetails.cancelRenameWorkspace(); |
| 129 | + }); |
| 130 | + |
| 131 | + suiteTeardown('Stop and delete workspaces created in this suite', async function (): Promise<void> { |
| 132 | + await openDashboardWorkspacesList(); |
| 133 | + |
| 134 | + await dashboard.deleteStoppedWorkspaceByUI(secondWorkspaceName); |
| 135 | + await dashboard.deleteStoppedWorkspaceByUI(RENAMED_WORKSPACE_NAME); |
| 136 | + }); |
| 137 | + |
| 138 | + suiteTeardown('Unregister running workspace', function (): void { |
| 139 | + registerRunningWorkspace(''); |
| 140 | + }); |
| 141 | +}); |
0 commit comments