@@ -29,26 +29,118 @@ export function testComponentCommands(path: string) {
2929
3030 const componentName = 'nodejs-starter' ;
3131
32+ // before(async function context() {
33+ // this.timeout(30_000);
34+ // console.log(`Closing all editors...`)
35+ // await new EditorView().closeAllEditors();
36+ // console.log(`Opening the OpenShift view...`)
37+ // view = await (await new ActivityBar().getViewControl(VIEWS.openshift)).openView();
38+ // console.log(`Collapsing all the trees...`)
39+ // for (const item of [
40+ // VIEWS.appExplorer,
41+ // VIEWS.compRegistries,
42+ // VIEWS.serverlessFunctions,
43+ // VIEWS.debugSessions,
44+ // ]) {
45+ // console.log(`Collapsing $`)
46+ // // await (await view.getContent().getSection(item)).collapse();
47+ // const section = await view.getContent().getSection(item);
48+
49+ // // Scroll the section into view before collapsing/expanding
50+ // const element = (section as any).element; // access the protected WebElement
51+ // await section.getDriver().executeScript('arguments[0].scrollIntoView(true);', element);
52+
53+ // await section.collapse();
54+ // }
55+
56+ // //expect component is running
57+ // section = await view.getContent().getSection(VIEWS.components);
58+ // try {
59+ // await itemExists(`${componentName} (dev running)`, section);
60+ // } catch {
61+ // this.skip();
62+ // }
63+ // });
64+
65+ /* eslint-disable no-console */
66+
3267 before ( async function context ( ) {
3368 this . timeout ( 30_000 ) ;
69+
70+ console . log ( '[BEFORE] Closing all editors...' ) ;
3471 await new EditorView ( ) . closeAllEditors ( ) ;
72+ console . log ( '[BEFORE] All editors closed.' ) ;
73+
74+ console . log ( '[BEFORE] Opening the OpenShift view...' ) ;
3575 view = await ( await new ActivityBar ( ) . getViewControl ( VIEWS . openshift ) ) . openView ( ) ;
76+ console . log ( '[BEFORE] OpenShift view opened.' ) ;
77+
78+ const content = view . getContent ( ) ;
79+
80+ console . log ( '[BEFORE] Waiting for OpenShift view content to load...' ) ;
81+
82+ let firstSection ;
83+ for ( let i = 0 ; i < 10 ; i ++ ) {
84+ firstSection = await content . getSection ( VIEWS . appExplorer ) ;
85+ if ( firstSection && ( firstSection as any ) . element ) {
86+ console . log ( '[BEFORE] View content is ready.' ) ;
87+ break ;
88+ }
89+ console . log ( '[BEFORE] View not ready yet (attempt ${i + 1}), retrying...' ) ;
90+ await new Promise ( res => setTimeout ( res , 1000 ) ) ;
91+ }
92+
93+ if ( ! firstSection || ! ( firstSection as any ) . element ) {
94+ throw new Error ( '[BEFORE] OpenShift view content did not load properly.' ) ;
95+ }
96+
97+ console . log ( '[BEFORE] Collapsing all other sections...' ) ;
3698 for ( const item of [
3799 VIEWS . appExplorer ,
38100 VIEWS . compRegistries ,
39101 VIEWS . serverlessFunctions ,
40102 VIEWS . debugSessions ,
41103 ] ) {
42- await ( await view . getContent ( ) . getSection ( item ) ) . collapse ( ) ;
104+ // await (await view.getContent().getSection(item)).collapse();
105+
106+ console . log ( `[BEFORE] Collapsing section: ${ item } ` ) ;
107+ const section = await view . getContent ( ) . getSection ( item ) ;
108+ if ( ! section ) {
109+ console . warn ( `[BEFORE] Section "${ item } " not found! Skipping collapse.` ) ;
110+ continue ;
111+ }
112+
113+ // Scroll the section into view before collapsing
114+ const element = ( section as any ) . element ; // access protected WebElement
115+ if ( ! element ) {
116+ console . warn ( `[BEFORE] WebElement for section "${ item } " is undefined! Skipping scroll.` ) ;
117+ } else {
118+ const location = await element . getRect ( ) ;
119+ console . log ( `[BEFORE] Section element location: x=${ location . x } , y=${ location . y } ` ) ;
120+ await section . getDriver ( ) . executeScript ( 'arguments[0].scrollIntoView(true);' , element ) ;
121+ console . log ( `[BEFORE] Section ${ item } scrolled into view.` ) ;
122+ }
123+
124+
125+ // Collapse
126+ const expandedBefore = section ? await section . isExpanded ( ) : false ;
127+ if ( section ) await section . collapse ( ) ;
128+ const expandedAfter = section ? await section . isExpanded ( ) : false ;
129+ console . log ( `[BEFORE] Section ${ item } collapse attempted. Expanded before: ${ expandedBefore } , Expanded after: ${ expandedAfter } ` ) ;
43130 }
44131
45132 //expect component is running
133+ console . log ( `[BEFORE] Checking that component "${ componentName } " is running...` ) ;
46134 section = await view . getContent ( ) . getSection ( VIEWS . components ) ;
47135 try {
48136 await itemExists ( `${ componentName } (dev running)` , section ) ;
137+ console . log ( `[BEFORE] Component "${ componentName } " is running.` ) ;
49138 } catch {
139+ console . warn ( `[BEFORE] Component "${ componentName } " not found or not running. Skipping tests.` ) ;
50140 this . skip ( ) ;
51141 }
142+
143+ console . log ( '[BEFORE] Setup completed.' ) ;
52144 } ) ;
53145
54146 after ( async function ( ) {
0 commit comments