|
| 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 | + |
| 11 | +import { KubernetesCommandLineToolsExecutor } from '../../utils/KubernetesCommandLineToolsExecutor'; |
| 12 | +import fs from 'fs'; |
| 13 | +import path from 'path'; |
| 14 | +import YAML from 'yaml'; |
| 15 | +import { e2eContainer } from '../../configs/inversify.config'; |
| 16 | +import { CLASSES } from '../../configs/inversify.types'; |
| 17 | +import { LoginTests } from '../../tests-library/LoginTests'; |
| 18 | +import { Dashboard } from '../../pageobjects/dashboard/Dashboard'; |
| 19 | +import { BrowserTabsUtil } from '../../utils/BrowserTabsUtil'; |
| 20 | +import { WorkspaceHandlingTests } from '../../tests-library/WorkspaceHandlingTests'; |
| 21 | +import { expect } from 'chai'; |
| 22 | +import { Logger } from '../../utils/Logger'; |
| 23 | +import { BASE_TEST_CONSTANTS } from '../../constants/BASE_TEST_CONSTANTS'; |
| 24 | + |
| 25 | +suite('Check Intellij IDE desktop Editor with all samples', function (): void { |
| 26 | + this.timeout(24000000); |
| 27 | + const workspaceHandlingTests: WorkspaceHandlingTests = e2eContainer.get(CLASSES.WorkspaceHandlingTests); |
| 28 | + const pathToSampleFile: string = path.resolve('resources/default-devfile.yaml'); |
| 29 | + const workspaceName: string = YAML.parse(fs.readFileSync(pathToSampleFile, 'utf8')).metadata.name; |
| 30 | + const kubernetesCommandLineToolsExecutor: KubernetesCommandLineToolsExecutor = e2eContainer.get( |
| 31 | + CLASSES.KubernetesCommandLineToolsExecutor |
| 32 | + ); |
| 33 | + kubernetesCommandLineToolsExecutor.workspaceName = workspaceName; |
| 34 | + const loginTests: LoginTests = e2eContainer.get(CLASSES.LoginTests); |
| 35 | + const dashboard: Dashboard = e2eContainer.get(CLASSES.Dashboard); |
| 36 | + const browserTabsUtil: BrowserTabsUtil = e2eContainer.get(CLASSES.BrowserTabsUtil); |
| 37 | + |
| 38 | + const titleXpath: string = '/html/body/h1'; |
| 39 | + let currentTabHandle: string = 'undefined'; |
| 40 | + |
| 41 | + const pollingForCheckTitle: number = 500; |
| 42 | + |
| 43 | + const editorsForCheck: string[] = [ |
| 44 | + '//*[@id="editor-selector-card-che-incubator/che-clion-server/latest"]', |
| 45 | + '//*[@id="editor-selector-card-che-incubator/che-goland-server/latest"]', |
| 46 | + '//*[@id="editor-selector-card-che-incubator/che-idea-server/latest"]', |
| 47 | + '//*[@id="editor-selector-card-che-incubator/che-phpstorm-server/latest"]', |
| 48 | + '//*[@id="editor-selector-card-che-incubator/che-pycharm-server/latest"]', |
| 49 | + '//*[@id="editor-selector-card-che-incubator/che-rider-server/latest"]', |
| 50 | + '//*[@id="editor-selector-card-che-incubator/che-rubymine-server/latest"]', |
| 51 | + '//*[@id="editor-selector-card-che-incubator/che-webstorm-server/latest"]', |
| 52 | + '//*[@id="editor-selector-card-che-incubator/jetbrains-sshd/latest"]' |
| 53 | + ]; |
| 54 | + |
| 55 | + const samplesForCheck: string[] = [ |
| 56 | + 'Empty Workspace', |
| 57 | + 'JBoss EAP 8.0', |
| 58 | + 'Java Lombok', |
| 59 | + 'Node.js Express', |
| 60 | + 'Python', |
| 61 | + 'Quarkus REST API', |
| 62 | + '.NET', |
| 63 | + 'Ansible', |
| 64 | + 'C/C++', |
| 65 | + 'Go', |
| 66 | + 'PHP' |
| 67 | + ]; |
| 68 | + |
| 69 | + const gitRepoUrlsToCheck: string[] = [ |
| 70 | + 'https://github.com/crw-qe/quarkus-api-example-public/tree/ubi8-latest', |
| 71 | + 'https://github.com/crw-qe/ubi9-based-sample-public/tree/ubi9-minimal' |
| 72 | + ]; |
| 73 | + |
| 74 | + const gitRepoUrlsToCheckAirgap: string[] = [ |
| 75 | + 'https://gh.crw-qe.com/test-automation-only/ubi8/tree/ubi8-latest', |
| 76 | + 'https://gh.crw-qe.com/test-automation-only/ubi9-based-sample-public/tree/ubi9-minimal' |
| 77 | + ]; |
| 78 | + |
| 79 | + function clearCurrentTabHandle(): void { |
| 80 | + currentTabHandle = 'undefined'; |
| 81 | + } |
| 82 | + |
| 83 | + suiteSetup('Login into Che', async function (): Promise<void> { |
| 84 | + await loginTests.loginIntoChe(); |
| 85 | + }); |
| 86 | + |
| 87 | + async function testWorkspaceStartup(editorXpath: string, sampleNameOrUrl: string, isUrl: boolean): Promise<void> { |
| 88 | + await dashboard.openDashboard(); |
| 89 | + currentTabHandle = await browserTabsUtil.getCurrentWindowHandle(); |
| 90 | + |
| 91 | + if (isUrl) { |
| 92 | + await workspaceHandlingTests.createAndOpenWorkspaceWithSpecificEditorAndGitUrl( |
| 93 | + editorXpath, |
| 94 | + sampleNameOrUrl, |
| 95 | + titleXpath, |
| 96 | + pollingForCheckTitle |
| 97 | + ); |
| 98 | + } else { |
| 99 | + await workspaceHandlingTests.createAndOpenWorkspaceWithSpecificEditorAndSample( |
| 100 | + editorXpath, |
| 101 | + sampleNameOrUrl, |
| 102 | + titleXpath, |
| 103 | + pollingForCheckTitle |
| 104 | + ); |
| 105 | + } |
| 106 | + |
| 107 | + // check title |
| 108 | + const headerText: string = await workspaceHandlingTests.getTextFromUIElementByXpath(titleXpath); |
| 109 | + expect('Workspace ' + WorkspaceHandlingTests.getWorkspaceName() + ' is running').equal(headerText); |
| 110 | + } |
| 111 | + |
| 112 | + editorsForCheck.forEach((editorXpath): void => { |
| 113 | + samplesForCheck.forEach((sampleName): void => { |
| 114 | + test(`Test start of Editor with xPath: ${editorXpath} and with sample name: ${sampleName}`, async function (): Promise<void> { |
| 115 | + await testWorkspaceStartup(editorXpath, sampleName, false); |
| 116 | + }); |
| 117 | + }); |
| 118 | + }); |
| 119 | + |
| 120 | + editorsForCheck.forEach((editorXpath): void => { |
| 121 | + if (BASE_TEST_CONSTANTS.IS_CLUSTER_DISCONNECTED()) { |
| 122 | + Logger.info('Test cluster is disconnected. Using url for airgap cluster.'); |
| 123 | + gitRepoUrlsToCheckAirgap.forEach((gitUbiUrl): void => { |
| 124 | + test(`Test start of Editor with xPath: ${editorXpath} and with ubi url: ${gitUbiUrl}`, async function (): Promise<void> { |
| 125 | + await testWorkspaceStartup(editorXpath, gitUbiUrl, true); |
| 126 | + }); |
| 127 | + }); |
| 128 | + } else { |
| 129 | + gitRepoUrlsToCheck.forEach((gitUbiUrl): void => { |
| 130 | + test(`Test start of Editor with xPath: ${editorXpath} and with ubi url: ${gitUbiUrl}`, async function (): Promise<void> { |
| 131 | + await testWorkspaceStartup(editorXpath, gitUbiUrl, true); |
| 132 | + }); |
| 133 | + }); |
| 134 | + } |
| 135 | + }); |
| 136 | + |
| 137 | + teardown('Delete DevWorkspace', async function (): Promise<void> { |
| 138 | + Logger.info('Delete DevWorkspace. After each test.'); |
| 139 | + if (currentTabHandle !== 'undefined') { |
| 140 | + await browserTabsUtil.switchToWindow(currentTabHandle); |
| 141 | + } |
| 142 | + |
| 143 | + await dashboard.openDashboard(); |
| 144 | + await browserTabsUtil.closeAllTabsExceptCurrent(); |
| 145 | + |
| 146 | + if (WorkspaceHandlingTests.getWorkspaceName() !== 'undefined') { |
| 147 | + Logger.info('Workspace name is defined. Deleting workspace...'); |
| 148 | + await dashboard.deleteStoppedWorkspaceByUI(WorkspaceHandlingTests.getWorkspaceName()); |
| 149 | + } |
| 150 | + |
| 151 | + WorkspaceHandlingTests.clearWorkspaceName(); |
| 152 | + clearCurrentTabHandle(); |
| 153 | + }); |
| 154 | +}); |
0 commit comments