@@ -11,6 +11,8 @@ import { closeActiveWindows, initialize, initializeTest } from '../initialize.no
11
11
import { captureScreenShot } from '../common' ;
12
12
import { getCachedEnvironments } from '../../platform/interpreter/helpers' ;
13
13
import { PythonExtension , type EnvironmentPath } from '@vscode/python-extension' ;
14
+ import { waitForExecutionCompletedSuccessfullyV2 , waitForTextOutputV2 } from '../datascience/notebook/helper' ;
15
+ import { DisposableStore } from '../../platform/common/utils/lifecycle' ;
14
16
15
17
type JupyterApi = {
16
18
openNotebook ( uri : vscode . Uri , env : EnvironmentPath ) : Promise < void > ;
@@ -19,6 +21,7 @@ type JupyterApi = {
19
21
const timeoutForCellToRun = 3 * 60 * 1_000 ;
20
22
suite ( 'Smoke Tests' , function ( ) {
21
23
this . timeout ( timeoutForCellToRun ) ;
24
+ const disposableStore = new DisposableStore ( ) ;
22
25
suiteSetup ( async function ( ) {
23
26
this . timeout ( timeoutForCellToRun ) ;
24
27
if ( ! IS_SMOKE_TEST ( ) ) {
@@ -33,6 +36,7 @@ suite('Smoke Tests', function () {
33
36
} ) ;
34
37
suiteTeardown ( closeActiveWindows ) ;
35
38
teardown ( async function ( ) {
39
+ disposableStore . clear ( ) ;
36
40
logger . info ( `End Test ${ this . currentTest ?. title } ` ) ;
37
41
if ( this . currentTest ?. isFailed ( ) ) {
38
42
await captureScreenShot ( this ) ;
@@ -69,15 +73,15 @@ suite('Smoke Tests', function () {
69
73
// }).timeout(timeoutForCellToRun);
70
74
71
75
test ( 'Run Cell in Notebook' , async function ( ) {
72
- const cell = new vscode . NotebookCellData ( vscode . NotebookCellKind . Code , 'print("Hello World")' , 'python' ) ;
73
76
const jupyterExt = vscode . extensions . getExtension < JupyterApi > ( JVSC_EXTENSION_ID_FOR_TESTS ) ;
74
77
if ( ! jupyterExt ) {
75
78
throw new Error ( 'Jupyter extension not found' ) ;
76
79
}
80
+ const cellData = new vscode . NotebookCellData ( vscode . NotebookCellKind . Code , 'print("Hello World")' , 'python' ) ;
77
81
const [ pythonEnv , { notebook } ] = await Promise . all ( [
78
82
PythonExtension . api ( ) . then ( ( api ) => api . environments . resolveEnvironment ( PYTHON_PATH ) ) ,
79
83
vscode . workspace
80
- . openNotebookDocument ( 'jupyter-notebook' , new vscode . NotebookData ( [ cell ] ) )
84
+ . openNotebookDocument ( 'jupyter-notebook' , new vscode . NotebookData ( [ cellData ] ) )
81
85
. then ( ( notebook ) => vscode . window . showNotebookDocument ( notebook ) ) ,
82
86
jupyterExt . activate ( )
83
87
] ) ;
@@ -87,22 +91,11 @@ suite('Smoke Tests', function () {
87
91
}
88
92
await jupyterExt . exports . openNotebook ( notebook . uri , pythonEnv ) ;
89
93
90
- await vscode . commands . executeCommand < void > ( 'notebook.execute' ) ;
91
-
92
- await new Promise < void > ( ( resolve ) => {
93
- const disposable = vscode . workspace . onDidChangeNotebookDocument ( ( e ) => {
94
- e . cellChanges . forEach ( ( change ) => {
95
- if (
96
- change . outputs ?. some ( ( o ) =>
97
- o . items . some ( ( i ) => Buffer . from ( i . data ) . toString ( 'utf-8' ) . includes ( 'Hello World' ) )
98
- )
99
- ) {
100
- disposable . dispose ( ) ;
101
- resolve ( ) ;
102
- }
103
- } ) ;
104
- } ) ;
105
- } ) ;
94
+ await Promise . all ( [
95
+ vscode . commands . executeCommand < void > ( 'notebook.execute' ) ,
96
+ waitForTextOutputV2 ( notebook . cellAt ( 0 ) , 'Hello World' , 0 , false , disposableStore ) ,
97
+ waitForExecutionCompletedSuccessfullyV2 ( notebook . cellAt ( 0 ) , disposableStore )
98
+ ] ) ;
106
99
} ) . timeout ( timeoutForCellToRun ) ;
107
100
108
101
test ( 'Interactive window should always pick up current active interpreter' , async function ( ) {
0 commit comments