@@ -12,7 +12,7 @@ import { MonacoEditor } from '../../datascience-ui/react-common/monacoEditor';
12
12
import { noop } from '../core' ;
13
13
import { DataScienceIocContainer } from './dataScienceIocContainer' ;
14
14
import { getOrCreateInteractiveWindow , runMountedTest } from './interactiveWindowTestHelpers' ;
15
- import { getInteractiveEditor , typeCode } from './testHelpers' ;
15
+ import { enterEditorKey , getInteractiveEditor , typeCode } from './testHelpers' ;
16
16
17
17
// tslint:disable:max-func-body-length trailing-comma no-any no-multiline-string
18
18
suite ( 'DataScience Intellisense tests' , ( ) => {
@@ -69,6 +69,14 @@ suite('DataScience Intellisense tests', () => {
69
69
assert . ok ( innerTexts . includes ( expectedSpan ) , 'Intellisense row not matching' ) ;
70
70
}
71
71
72
+ function verifyIntellisenseNotVisible (
73
+ wrapper : ReactWrapper < any , Readonly < { } > , React . Component > ,
74
+ expectedSpan : string
75
+ ) {
76
+ const innerTexts = getIntellisenseTextLines ( wrapper ) ;
77
+ assert . ok ( ! innerTexts . includes ( expectedSpan ) , 'Intellisense row is showing' ) ;
78
+ }
79
+
72
80
function waitForSuggestion (
73
81
wrapper : ReactWrapper < any , Readonly < { } > , React . Component >
74
82
) : { disposable : IDisposable ; promise : Promise < void > } {
@@ -230,4 +238,60 @@ suite('DataScience Intellisense tests', () => {
230
238
return ioc ;
231
239
}
232
240
) ;
241
+
242
+ runMountedTest (
243
+ 'Filtered Jupyter autocomplete, verify magic commands appear' ,
244
+ async wrapper => {
245
+ if ( ioc . mockJupyter ) {
246
+ // This test only works when mocking.
247
+
248
+ // Create an interactive window so that it listens to the results.
249
+ const interactiveWindow = await getOrCreateInteractiveWindow ( ioc ) ;
250
+ await interactiveWindow . show ( ) ;
251
+
252
+ // Then enter some code. Don't submit, we're just testing that autocomplete appears
253
+ const suggestion = waitForSuggestion ( wrapper ) ;
254
+ typeCode ( getInteractiveEditor ( wrapper ) , 'print' ) ;
255
+ enterEditorKey ( wrapper , { code : ' ' , ctrlKey : true } ) ;
256
+ await suggestion . promise ;
257
+ suggestion . disposable . dispose ( ) ;
258
+ verifyIntellisenseNotVisible ( wrapper , '%%bash' ) ;
259
+
260
+ // Force suggestion box to disappear so that shutdown doesn't try to generate suggestions
261
+ // while we're destroying the editor.
262
+ clearEditor ( wrapper ) ;
263
+ }
264
+ } ,
265
+ ( ) => {
266
+ return ioc ;
267
+ }
268
+ ) ;
269
+
270
+ runMountedTest (
271
+ 'Filtered Jupyter autocomplete, verify magic commands are filtered' ,
272
+ async wrapper => {
273
+ if ( ioc . mockJupyter ) {
274
+ // This test only works when mocking.
275
+
276
+ // Create an interactive window so that it listens to the results.
277
+ const interactiveWindow = await getOrCreateInteractiveWindow ( ioc ) ;
278
+ await interactiveWindow . show ( ) ;
279
+
280
+ // Then enter some code. Don't submit, we're just testing that autocomplete appears
281
+ const suggestion = waitForSuggestion ( wrapper ) ;
282
+ typeCode ( getInteractiveEditor ( wrapper ) , ' ' ) ;
283
+ enterEditorKey ( wrapper , { code : ' ' , ctrlKey : true } ) ;
284
+ await suggestion . promise ;
285
+ suggestion . disposable . dispose ( ) ;
286
+ verifyIntellisenseVisible ( wrapper , '%%bash' ) ;
287
+
288
+ // Force suggestion box to disappear so that shutdown doesn't try to generate suggestions
289
+ // while we're destroying the editor.
290
+ clearEditor ( wrapper ) ;
291
+ }
292
+ } ,
293
+ ( ) => {
294
+ return ioc ;
295
+ }
296
+ ) ;
233
297
} ) ;
0 commit comments