1616
1717// @ts -check
1818describe ( 'TypeScript' , function ( ) {
19- this . timeout ( 30_000 ) ;
19+ this . timeout ( 200_000 ) ;
2020
2121 const { assert } = chai ;
2222 const { timeout } = require ( '@theia/core/lib/common/promise-util' ) ;
@@ -94,6 +94,24 @@ describe('TypeScript', function () {
9494 await preferences . set ( 'files.autoSave' , originalAutoSaveValue ) ;
9595 } )
9696
97+ async function waitLanguageServerReady ( ) {
98+ // quite a bit of jitter in the "Initializing LS" status bar entry,
99+ // so we want to read a few times in a row that it's done (undefined)
100+ const MAX_N = 5
101+ let n = MAX_N ;
102+ while ( n > 0 ) {
103+ await timeout ( 1000 ) ;
104+ if ( progressStatusBarItem . currentProgress ) {
105+ n = MAX_N ;
106+ } else {
107+ n -- ;
108+ }
109+ if ( n < 5 ) {
110+ console . debug ( 'n = ' + n ) ;
111+ }
112+ }
113+ }
114+
97115 /**
98116 * @param {Uri.default } uri
99117 * @param {boolean } preview
@@ -106,8 +124,8 @@ describe('TypeScript', function () {
106124 // wait till tsserver is running, see:
107125 // https://github.com/microsoft/vscode/blob/93cbbc5cae50e9f5f5046343c751b6d010468200/extensions/typescript-language-features/src/extension.ts#L98-L103
108126 await waitForAnimation ( ( ) => contextKeyService . match ( 'typescript.isManagedFile' ) ) ;
109- // https://github.com/microsoft/vscode/blob/4aac84268c6226d23828cc6a1fe45ee3982927f0/extensions/typescript-language-features/src/typescriptServiceClient.ts#L911
110- await waitForAnimation ( ( ) => ! progressStatusBarItem . currentProgress ) ;
127+
128+ waitLanguageServerReady ( ) ;
111129 return /** @type {MonacoEditor } */ ( editor ) ;
112130 }
113131
@@ -388,6 +406,14 @@ describe('TypeScript', function () {
388406 assert . isTrue ( contextKeyService . match ( 'editorTextFocus' ) ) ;
389407 assert . isTrue ( contextKeyService . match ( 'suggestWidgetVisible' ) ) ;
390408
409+
410+ const suggestController = editor . getControl ( ) . getContribution ( 'editor.contrib.suggestController' ) ;
411+
412+ waitForAnimation ( ( ) => {
413+ const content = nodeAsString ( suggestController ? [ '_widget' ] ?. [ '_value' ] ?. [ 'element' ] ?. [ 'domNode' ] ) ;
414+ return ! content . includes ( 'loading' ) ;
415+ } ) ;
416+
391417 // May need a couple extra "Enter" being sent for the suggest to be accepted
392418 keybindings . dispatchKeyDown ( 'Enter' ) ;
393419 await waitForAnimation ( ( ) => {
@@ -398,7 +424,7 @@ describe('TypeScript', function () {
398424 return false ;
399425 }
400426 return true ;
401- } , 5000 , 'Suggest widget has not been dismissed despite attempts to accept suggestion' ) ;
427+ } , 20000 , 'Suggest widget has not been dismissed despite attempts to accept suggestion' ) ;
402428
403429 assert . isTrue ( contextKeyService . match ( 'editorTextFocus' ) ) ;
404430 assert . isFalse ( contextKeyService . match ( 'suggestWidgetVisible' ) ) ;
@@ -542,6 +568,7 @@ describe('TypeScript', function () {
542568 } ) ;
543569
544570 it ( 'editor.action.showHover' , async function ( ) {
571+
545572 const editor = await openEditor ( demoFileUri ) ;
546573 // class |DemoClass);
547574 editor . getControl ( ) . setPosition ( { lineNumber : 8 , column : 7 } ) ;
@@ -558,6 +585,11 @@ describe('TypeScript', function () {
558585 assert . isTrue ( contextKeyService . match ( 'editorHoverVisible' ) ) ;
559586 assert . isTrue ( contextKeyService . match ( 'editorTextFocus' ) ) ;
560587
588+ waitForAnimation ( ( ) => {
589+ const content = nodeAsString ( hover [ '_contentWidget' ] ?. [ '_widget' ] ?. [ '_hover' ] ?. [ 'contentsDomNode' ] ) ;
590+ return ! content . includes ( 'loading' ) ;
591+ } ) ;
592+
561593 assert . deepEqual ( nodeAsString ( hover [ '_contentWidget' ] ?. [ '_widget' ] ?. [ '_hover' ] ?. [ 'contentsDomNode' ] ) . trim ( ) , `
562594DIV {
563595 DIV {
0 commit comments