@@ -29,26 +29,99 @@ 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+
3265 before ( async function context ( ) {
3366 this . timeout ( 30_000 ) ;
34- await new EditorView ( ) . closeAllEditors ( ) ;
35- view = await ( await new ActivityBar ( ) . getViewControl ( VIEWS . openshift ) ) . openView ( ) ;
36- for ( const item of [
67+
68+ const editorView = new EditorView ( ) ;
69+ console . log ( `[BEFORE] Closing all editors...` ) ;
70+ await editorView . closeAllEditors ( ) ;
71+ console . log ( `[BEFORE] All editors closed.` ) ;
72+
73+ console . log ( `[BEFORE] Opening the OpenShift view...` ) ;
74+ const activityBar = new ActivityBar ( ) ;
75+ const viewControl = await activityBar . getViewControl ( VIEWS . openshift ) ;
76+ console . log ( `[BEFORE] Got view control: ${ VIEWS . openshift } ` ) ;
77+ view = await viewControl . openView ( ) ;
78+ console . log ( `[BEFORE] OpenShift view opened.` ) ;
79+
80+ console . log ( `[BEFORE] Collapsing all other views...` ) ;
81+ const treeItemsToCollapse = [
3782 VIEWS . appExplorer ,
3883 VIEWS . compRegistries ,
3984 VIEWS . serverlessFunctions ,
4085 VIEWS . debugSessions ,
41- ] ) {
42- await ( await view . getContent ( ) . getSection ( item ) ) . collapse ( ) ;
86+ ] ;
87+
88+ for ( const item of treeItemsToCollapse ) {
89+ // await (await view.getContent().getSection(item)).collapse();
90+
91+ console . log ( `[BEFORE] Collapsing section: ${ item } ` ) ;
92+ const section = await view . getContent ( ) . getSection ( item ) ;
93+
94+ // Scroll the section into view before collapsing/expanding
95+ const element = ( section as any ) . element ;
96+ const loc = await element . getLocation ( ) ;
97+ const size = await element . getSize ( ) ;
98+ console . log (
99+ `[BEFORE] Section element: ${ item } , location: (${ loc . x } , ${ loc . y } ), size: (${ size . width } x${ size . height } )`
100+ ) ;
101+ await section . getDriver ( ) . executeScript ( 'arguments[0].scrollIntoView(true);' , element ) ;
102+ console . log ( `[BEFORE] Section ${ item } scrolled into view.` ) ;
103+
104+ // Collapse
105+ const expandedBefore = await section . isExpanded ( ) ;
106+ await section . collapse ( ) ;
107+ const expandedAfter = await section . isExpanded ( ) ;
108+ console . log (
109+ `[BEFORE] Section ${ item } collapse attempted. Was expanded: ${ expandedBefore } , Now expanded: ${ expandedAfter } `
110+ ) ;
43111 }
44112
45113 //expect component is running
114+ console . log ( `[BEFORE] Checking that component is running: ${ componentName } ` ) ;
46115 section = await view . getContent ( ) . getSection ( VIEWS . components ) ;
47116 try {
48117 await itemExists ( `${ componentName } (dev running)` , section ) ;
49- } catch {
118+ console . log ( `[BEFORE] Component ${ componentName } is running.` ) ;
119+ } catch ( err ) {
120+ console . warn ( `[BEFORE] Component ${ componentName } not found or not running, skipping tests.` ) ;
50121 this . skip ( ) ;
51122 }
123+
124+ console . log ( `[BEFORE] Setup completed.` ) ;
52125 } ) ;
53126
54127 after ( async function ( ) {
0 commit comments