Skip to content

Commit fc727e0

Browse files
authored
Fix StartWorkspaceUsingDesktopEditors.spec.ts to test JetBrains Toolbox editors separately (#23999)
Signed-off-by: Dmytro Nochevnov <dnochevn@redhat.com>
1 parent 93e411d commit fc727e0

2 files changed

Lines changed: 38 additions & 5 deletions

File tree

‎tests/e2e/constants/EDITOR_CONSTANTS.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* SPDX-License-Identifier: EPL-2.0
99
**********************************************************************/
1010

11-
export type EditorType = 'vscode' | 'intellij';
11+
export type EditorType = 'vscode' | 'intellij' | 'intellij-toolbox';
1212

1313
export interface EditorConfig {
1414
readonly environmentId: string;
@@ -114,7 +114,7 @@ export const ALL_EDITORS: Map<string, EditorConfig> = new Map([
114114
environmentId: 'JETBRAINS_SSH_EDITOR',
115115
xpath: '//*[@id="editor-selector-card-che-incubator/jetbrains-sshd/latest"]',
116116
name: 'JetBrains Toolbox App',
117-
type: 'intellij'
117+
type: 'intellij-toolbox'
118118
}
119119
]
120120
]);

‎tests/e2e/specs/dashboard-samples/StartWorkspaceUsingDesktopEditors.spec.ts‎

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { assert, expect } from 'chai';
1818
import { Logger } from '../../utils/Logger';
1919
import { BASE_TEST_CONSTANTS } from '../../constants/BASE_TEST_CONSTANTS';
2020
import { DriverHelper } from '../../utils/DriverHelper';
21-
import { EditorConfig, ALL_EDITORS } from '../../constants/EDITOR_CONSTANTS';
21+
import { EditorConfig, EditorType, ALL_EDITORS } from '../../constants/EDITOR_CONSTANTS';
2222
import { ScreenCatcher } from '../../utils/ScreenCatcher';
2323
import { StringUtil } from '../../utils/StringUtil';
2424
import { REPORTER_CONSTANTS } from '../../constants/REPORTER_CONSTANTS';
@@ -36,11 +36,19 @@ suite('Check all editors with all samples', function (): void {
3636

3737
const useExtensionSwitcher: string = '//label[@class="switch"]';
3838
const intellijTitleXpath: string = '//main[@class="page-container"]/h1';
39+
// the Toolbox landing page has no "page-container" wrapper like the Gateway page, so the heading is narrowed by its sibling
40+
const toolboxTitleXpath: string = '//h1[following-sibling::div[@class="border"]]';
3941
const vsCodeTitleXpath: string = '//div[@class="header-title"]';
4042
const gatewayButtonXpath: string = '//a[@class="gateway-button"]';
4143
const openInIdeTitleXpath: string = '(//div[@class="connection-option"]/h3)[2]';
4244
const dashboardLinkXpath: string = '//p[@class="dashboard-link"]/a';
4345

46+
const titleXpathByEditorType: Record<EditorType, string> = {
47+
vscode: vsCodeTitleXpath,
48+
intellij: intellijTitleXpath,
49+
'intellij-toolbox': toolboxTitleXpath
50+
};
51+
4452
let currentTabHandle: string = 'undefined';
4553
// polling below the webdriver roundtrip cost (~300ms) gives no real pause between checks and breaks the timeout arithmetic
4654
const pollingForCheckTitleVSCode: number = 1000;
@@ -238,9 +246,32 @@ suite('Check all editors with all samples', function (): void {
238246
Logger.debug('"Open Dashboard" link was found');
239247
}
240248

249+
async function verifyJetBrainsToolboxEditor(titleXpath: string): Promise<void> {
250+
Logger.debug();
251+
252+
const workspaceName: string = WorkspaceHandlingTests.getWorkspaceName();
253+
254+
const headerText: string = await workspaceHandlingTests.getTextFromUIElementByXpath(titleXpath);
255+
expect(headerText).equal('Workspace ' + workspaceName + ' is running');
256+
Logger.debug('Workspace title verified for JetBrains Toolbox editor: ' + headerText);
257+
258+
// the page builds the deep link in an inline script and opens it via onclick, so there is no href to inspect
259+
const pageHtml: string = await driverHelper.getDriver().executeScript('return document.body.innerHTML;');
260+
expect(pageHtml, 'Toolbox deep link was not found')
261+
.contains('jetbrains://gateway/com.redhat.devtools.toolbox')
262+
.and.contains('dwName=' + workspaceName);
263+
Logger.debug('Toolbox deep link for workspace "' + workspaceName + '" was found');
264+
265+
const pageText: string = await driverHelper.getDriver().executeScript('return document.body.innerText;');
266+
267+
// connecting to the workspace relies on port forwarding, so the page serves no private key
268+
expect(pageText, `Actual page text:\n${pageText}`).contains('oc port-forward -n ' + actualUser + '-devspaces');
269+
Logger.debug('"oc port-forward -n ' + actualUser + '-devspaces" was found');
270+
}
271+
241272
async function testWorkspaceStartup(
242273
editorXpath: string,
243-
editorType: 'vscode' | 'intellij',
274+
editorType: EditorType,
244275
sampleNameOrUrl: string,
245276
isUrl: boolean
246277
): Promise<void> {
@@ -249,7 +280,7 @@ suite('Check all editors with all samples', function (): void {
249280
await dashboard.clickCreateWorkspaceButton();
250281

251282
const pollingForCheckTitle: number = editorType === 'vscode' ? pollingForCheckTitleVSCode : pollingForCheckTitleIntelliJ;
252-
const titleXpath: string = editorType === 'vscode' ? vsCodeTitleXpath : intellijTitleXpath;
283+
const titleXpath: string = titleXpathByEditorType[editorType];
253284

254285
if (isUrl) {
255286
await workspaceHandlingTests.createAndOpenWorkspaceWithSpecificEditorAndGitUrl(
@@ -269,6 +300,8 @@ suite('Check all editors with all samples', function (): void {
269300

270301
if (editorType === 'vscode') {
271302
await verifyVSCodeEditor();
303+
} else if (editorType === 'intellij-toolbox') {
304+
await verifyJetBrainsToolboxEditor(titleXpath);
272305
} else {
273306
await verifyIntelliJEditor(titleXpath);
274307
}

0 commit comments

Comments
 (0)