Skip to content

Commit a349746

Browse files
authored
Automates "start workspace using IntelliJ IDEA Editors" test (#23765)
Signed-off-by: Oleksii Korniienko <olkornii@redhat.com>
1 parent aa80fd5 commit a349746

File tree

3 files changed

+175
-8
lines changed

3 files changed

+175
-8
lines changed
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
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+
});

tests/e2e/tests-library/WorkspaceHandlingTests.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,18 +150,28 @@ export class WorkspaceHandlingTests {
150150
Logger.info('Start workspace progress description: ' + alertDescription);
151151
}
152152

153-
async createAndOpenWorkspaceWithSpecificEditorAndSample(editor: string, sampleName: string, xPath: string): Promise<void> {
153+
async createAndOpenWorkspaceWithSpecificEditorAndSample(
154+
editor: string,
155+
sampleName: string,
156+
xPath: string,
157+
polling: number = TIMEOUT_CONSTANTS.TS_SELENIUM_DEFAULT_POLLING
158+
): Promise<void> {
154159
Logger.debug('Create and open workspace with specific Editor and Sample. Sample ' + editor);
155160
await this.selectEditor(editor);
156161
await this.createWorkspace.clickOnSampleNoEditorSelection(sampleName);
157-
await this.waitForControlXpath(xPath);
162+
await this.waitForControlXpath(xPath, polling);
158163
}
159164

160-
async createAndOpenWorkspaceWithSpecificEditorAndGitUrl(editor: string, sampleUrl: string, xPath: string): Promise<void> {
165+
async createAndOpenWorkspaceWithSpecificEditorAndGitUrl(
166+
editor: string,
167+
sampleUrl: string,
168+
xPath: string,
169+
polling: number = TIMEOUT_CONSTANTS.TS_SELENIUM_DEFAULT_POLLING
170+
): Promise<void> {
161171
Logger.debug('Create and open workspace with specific Editor and URL. Sample ' + editor);
162172
await this.selectEditor(editor);
163173
await this.createWorkspace.importFromGitUsingUI(sampleUrl);
164-
await this.waitForControlXpath(xPath);
174+
await this.waitForControlXpath(xPath, polling);
165175
}
166176

167177
async selectEditor(editor: string): Promise<void> {
@@ -175,11 +185,11 @@ export class WorkspaceHandlingTests {
175185
return await this.driverHelper.getDriver().findElement(By.xpath(xpath)).getText();
176186
}
177187

178-
private async waitForControlXpath(xPathToWait: string): Promise<void> {
188+
private async waitForControlXpath(xPathToWait: string, polling: number): Promise<void> {
179189
await this.browserTabsUtil.waitAndSwitchToAnotherWindow(WorkspaceHandlingTests.parentGUID, TIMEOUT_CONSTANTS.TS_IDE_LOAD_TIMEOUT);
180190
await this.obtainWorkspaceNameFromStartingPage();
181191

182-
await this.driverHelper.waitVisibility(By.xpath(xPathToWait), TIMEOUT_CONSTANTS.TS_SELENIUM_START_WORKSPACE_TIMEOUT);
192+
await this.driverHelper.waitVisibility(By.xpath(xPathToWait), TIMEOUT_CONSTANTS.TS_SELENIUM_START_WORKSPACE_TIMEOUT, polling);
183193
}
184194

185195
private async getWorkspaceAlertDescription(): Promise<string> {

tests/e2e/utils/DriverHelper.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,11 @@ export class DriverHelper {
9292
return false;
9393
}
9494

95-
async waitVisibility(elementLocator: By, timeout: number = TIMEOUT_CONSTANTS.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<WebElement> {
96-
const polling: number = TIMEOUT_CONSTANTS.TS_SELENIUM_DEFAULT_POLLING;
95+
async waitVisibility(
96+
elementLocator: By,
97+
timeout: number = TIMEOUT_CONSTANTS.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM,
98+
polling: number = TIMEOUT_CONSTANTS.TS_SELENIUM_DEFAULT_POLLING
99+
): Promise<WebElement> {
97100
const attempts: number = Math.ceil(timeout / polling);
98101
Logger.trace(`${elementLocator}`);
99102

0 commit comments

Comments
 (0)