@@ -54,9 +54,9 @@ describe('Liberty Config Language Server Tests for Maven Project', function () {
5454 logger . error ( `Test failed: ${ this . currentTest ?. title } ` ) ;
5555 }
5656
57- // Always close the bottom bar and re-focus the editor first — any test that
58- // opens the Output or Problems panel leaves VS Code focus off the editor ,
59- // making the TextEditor handle stale. Re-acquire before touching editor content .
57+ // Close the bottom bar and re-focus the editor before restoring content.
58+ // Any test that opens the Output or Problems panel shifts VS Code focus,
59+ // making subsequent editor operations unreliable .
6060 await new BottomBarPanel ( ) . toggle ( false ) ;
6161 editor = await editorView . openEditor ( 'server.xml' ) as TextEditor ;
6262
@@ -65,24 +65,10 @@ describe('Liberty Config Language Server Tests for Maven Project', function () {
6565 await editor . clearText ( ) ;
6666 await editor . setText ( originalContent ) ;
6767 await editor . save ( ) ;
68- // Wait for LCLS to reanalyse the restored file and clear any diagnostics
69- // before the next test starts — poll the Problems panel rather than sleeping
70- await wait . forCondition ( async ( ) => {
71- try {
72- const bottomBar = new BottomBarPanel ( ) ;
73- await bottomBar . toggle ( true ) ;
74- const problemsView = await bottomBar . openProblemsView ( ) ;
75- const markers = await problemsView . getAllVisibleMarkers ( MarkerType . Error ) ;
76- return markers . length === 0 ? true : undefined ;
77- } catch {
78- return undefined ;
79- }
80- } , {
81- timeout : 10000 ,
82- pollInterval : 1000 ,
83- message : 'Diagnostics did not clear after restoring server.xml'
84- } ) ;
85- await new BottomBarPanel ( ) . toggle ( false ) ;
68+ // Give LCLS time to reanalyse the restored file before the next test.
69+ // Avoid opening the Problems panel here — doing so steals focus from
70+ // the editor and poisons the clipboard used by getText().
71+ await wait . sleep ( 3000 ) ;
8672 logger . info ( 'Restored original server.xml content' ) ;
8773 }
8874 } ) ;
@@ -117,6 +103,10 @@ describe('Liberty Config Language Server Tests for Maven Project', function () {
117103 this . timeout ( 60000 ) ;
118104 logger . testStart ( 'Testing diagnostic for invalid feature' ) ;
119105
106+ // Re-acquire editor handle at test start — afterEach may have left focus
107+ // on a different panel; openEditor() clicks the tab and returns a live handle
108+ editor = await editorView . openEditor ( 'server.xml' ) as TextEditor ;
109+
120110 logger . step ( 1 , 'Finding feature line' ) ;
121111 const lineNumber = await editor . getLineOfText ( 'jsp-2.3' ) ;
122112 logger . stepSuccess ( 1 , `Found feature at line ${ lineNumber } ` ) ;
@@ -164,6 +154,8 @@ describe('Liberty Config Language Server Tests for Maven Project', function () {
164154 this . timeout ( 90000 ) ;
165155 logger . testStart ( 'Testing quick fix for invalid feature' ) ;
166156
157+ editor = await editorView . openEditor ( 'server.xml' ) as TextEditor ;
158+
167159 logger . step ( 1 , 'Adding invalid feature' ) ;
168160 const lineNumber = await editor . getLineOfText ( 'jsp-2.3' ) ;
169161 const currentLine = await editor . getTextAtLine ( lineNumber ) ;
@@ -263,6 +255,8 @@ describe('Liberty Config Language Server Tests for Maven Project', function () {
263255 this . timeout ( 60000 ) ;
264256 logger . testStart ( 'Testing autocomplete for features' ) ;
265257
258+ editor = await editorView . openEditor ( 'server.xml' ) as TextEditor ;
259+
266260 // The flow: type a full <feature></feature> tag, place cursor inside it,
267261 // trigger Ctrl+Space to get the LCLS dropdown of feature names, then select
268262 // a specific known feature. This matches the toggleContentAssist pattern
@@ -312,6 +306,8 @@ describe('Liberty Config Language Server Tests for Maven Project', function () {
312306 this . timeout ( 60000 ) ;
313307 logger . testStart ( 'Testing autocomplete for dataSource stanza' ) ;
314308
309+ editor = await editorView . openEditor ( 'server.xml' ) as TextEditor ;
310+
315311 // The flow: type a partial element name at server level, trigger Ctrl+Space,
316312 // select from the dropdown. LCLS inserts <dataSource></dataSource>.
317313 logger . step ( 1 , 'Finding </featureManager> as insertion point' ) ;
@@ -352,6 +348,8 @@ describe('Liberty Config Language Server Tests for Maven Project', function () {
352348 this . timeout ( 60000 ) ;
353349 logger . testStart ( 'Testing autocomplete for application stanza' ) ;
354350
351+ editor = await editorView . openEditor ( 'server.xml' ) as TextEditor ;
352+
355353 logger . step ( 1 , 'Finding </featureManager> as insertion point' ) ;
356354 const lineNumber = await editor . getLineOfText ( '</featureManager>' ) ;
357355 logger . stepSuccess ( 1 , `Found featureManager end at line ${ lineNumber } ` ) ;
0 commit comments