@@ -17,15 +17,16 @@ import {
1717 Workbench ,
1818} from 'vscode-extension-tester' ;
1919import { parse } from 'yaml' ;
20- import { itemExists } from '../common/conditions' ;
20+ import { log , waitForItemStable , warn } from '../common/conditions' ;
2121import { VIEWS } from '../common/constants' ;
2222import { reloadWindow } from '../common/overdrives' ;
2323import { OpenshiftTerminalWebviewView } from '../common/ui/webviewView/openshiftTerminalWebviewView' ;
2424
2525export function testComponentCommands ( path : string ) {
2626 describe ( 'Component Commands' , function ( ) {
27+ this . timeout ( 30_000 ) ;
28+
2729 let view : SideBarView ;
28- let section : ViewSection ;
2930 let commands : TreeItem [ ] ;
3031
3132 const componentName = 'nodejs-starter' ;
@@ -46,10 +47,15 @@ export function testComponentCommands(path: string) {
4647 }
4748
4849 // expect component is running
49- section = await view . getContent ( ) . getSection ( VIEWS . components ) ;
5050 try {
51- await itemExists ( `${ componentName } (dev running)` , section ) ;
52- } catch {
51+ const componentInDevName = `${ componentName } (dev running)` ;
52+ const item = await waitForItemStable ( getSection , componentInDevName , true , 40_000 ) ;
53+ if ( ! item ) {
54+ warn ( `Component "${ componentName } " not found or isn't running in Dev, skipping tests` ) ;
55+ this . skip ( ) ;
56+ }
57+ } catch ( err ) {
58+ warn ( 'Error in before hook: "Component Commands":' , err ) ;
5359 this . skip ( ) ;
5460 }
5561 } ) ;
@@ -69,8 +75,11 @@ export function testComponentCommands(path: string) {
6975 expectedCommands . push ( command . id ) ;
7076 } ) ;
7177
78+ log ( `Expected commands: ${ JSON . stringify ( expectedCommands ) } ` ) ;
79+
7280 //get component
73- const components = await section . getVisibleItems ( ) ;
81+ const section = await getSection ( ) ;
82+ const components = section . getVisibleItems ( ) ;
7483 const component = components [ 0 ] as TreeItem ;
7584 await component . expand ( ) ;
7685
@@ -84,6 +93,7 @@ export function testComponentCommands(path: string) {
8493 for ( const command of commands ) {
8594 actualCommands . push ( await command . getLabel ( ) ) ;
8695 }
96+ log ( `Actual commands: ${ JSON . stringify ( actualCommands ) } ` ) ;
8797 expect ( actualCommands ) . to . include . members ( expectedCommands ) ;
8898 } ) ;
8999
@@ -117,5 +127,9 @@ export function testComponentCommands(path: string) {
117127
118128 expect ( terminalText ) . to . contain ( 'Press any key to close this terminal' ) ;
119129 } ) ;
130+
131+ async function getSection ( ) : Promise < ViewSection > {
132+ return await view . getContent ( ) . getSection ( VIEWS . components ) ;
133+ }
120134 } ) ;
121135}
0 commit comments