@@ -18,7 +18,7 @@ import { assert, expect } from 'chai';
1818import { Logger } from '../../utils/Logger' ;
1919import { BASE_TEST_CONSTANTS } from '../../constants/BASE_TEST_CONSTANTS' ;
2020import { DriverHelper } from '../../utils/DriverHelper' ;
21- import { EditorConfig , ALL_EDITORS } from '../../constants/EDITOR_CONSTANTS' ;
21+ import { EditorConfig , EditorType , ALL_EDITORS } from '../../constants/EDITOR_CONSTANTS' ;
2222import { ScreenCatcher } from '../../utils/ScreenCatcher' ;
2323import { StringUtil } from '../../utils/StringUtil' ;
2424import { 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