11/* eslint-disable @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */
22import { assert } from 'chai' ;
3- import { Uri , workspace , NotebookDocument } from 'vscode' ;
3+ import { Uri , workspace } from 'vscode' ;
44import { IDisposable } from '../../../platform/common/types' ;
5- import { captureScreenShot , IExtensionTestApi , waitForCondition } from '../../common.node' ;
5+ import { captureScreenShot , IExtensionTestApi } from '../../common.node' ;
66import { EXTENSION_ROOT_DIR_FOR_TESTS , initialize } from '../../initialize.node' ;
7- import { closeNotebooksAndCleanUpAfterTests , startJupyterServer , getDefaultKernelConnection } from './helper.node' ;
7+ import { closeNotebooksAndCleanUpAfterTests } from './helper.node' ;
88import { logger } from '../../../platform/logging' ;
99import { IDeepnoteNotebookManager } from '../../../notebooks/types' ;
10- import { IKernel , IKernelProvider , INotebookKernelExecution } from '../../../kernels/types' ;
11- import { createKernelController } from './executionHelper' ;
1210
1311/* eslint-disable @typescript-eslint/no-explicit-any, no-invalid-this */
1412suite ( 'Deepnote Integration Tests @kernelCore' , function ( ) {
@@ -22,36 +20,13 @@ suite('Deepnote Integration Tests @kernelCore', function () {
2220 'notebook' ,
2321 'test.deepnote'
2422 ) ;
25- let nbDocument : NotebookDocument ;
26- let kernel : IKernel ;
27- let kernelExecution : INotebookKernelExecution ;
2823 this . timeout ( 240_000 ) ;
2924
3025 suiteSetup ( async function ( ) {
3126 logger . info ( 'Suite Setup VS Code Notebook - Deepnote Integration' ) ;
3227 this . timeout ( 240_000 ) ;
3328 try {
3429 api = await initialize ( ) ;
35- logger . info ( 'After initialize' ) ;
36-
37- await startJupyterServer ( ) ;
38- logger . info ( 'After starting Jupyter' ) ;
39-
40- const notebookManager = api . serviceContainer . get < IDeepnoteNotebookManager > ( IDeepnoteNotebookManager ) ;
41- notebookManager . selectNotebookForProject ( 'test-project-id' , 'main-notebook-id' ) ;
42-
43- nbDocument = await workspace . openNotebookDocument ( deepnoteFilePath ) ;
44- logger . info ( `Opened notebook with ${ nbDocument . cellCount } cells` ) ;
45-
46- const kernelProvider = api . serviceContainer . get < IKernelProvider > ( IKernelProvider ) ;
47- const metadata = await getDefaultKernelConnection ( ) ;
48- const controller = createKernelController ( ) ;
49- kernel = kernelProvider . getOrCreate ( nbDocument , { metadata, resourceUri : nbDocument . uri , controller } ) ;
50- logger . info ( 'Before starting kernel' ) ;
51- await kernel . start ( ) ;
52- logger . info ( 'After starting kernel' ) ;
53- kernelExecution = kernelProvider . getKernelExecution ( kernel ) ;
54-
5530 logger . info ( 'Suite Setup (completed)' ) ;
5631 } catch ( e ) {
5732 logger . error ( 'Suite Setup (failed) - Deepnote Integration' , e ) ;
@@ -73,94 +48,55 @@ suite('Deepnote Integration Tests @kernelCore', function () {
7348
7449 suiteTeardown ( ( ) => closeNotebooksAndCleanUpAfterTests ( disposables ) ) ;
7550
76- test ( 'Load .deepnote file' , async function ( ) {
51+ test ( 'Load .deepnote file and verify structure ' , async function ( ) {
7752 logger . debug ( 'Test: Load .deepnote file - starting' ) ;
7853
79- assert . equal ( nbDocument . notebookType , 'deepnote' , 'Notebook type should be deepnote' ) ;
80- assert . equal ( nbDocument . cellCount , 3 , 'Notebook should have 3 cells' ) ;
81- assert . equal ( nbDocument . metadata ?. deepnoteProjectId , 'test-project-id' , 'Project ID should match' ) ;
82- assert . equal ( nbDocument . metadata ?. deepnoteNotebookId , 'main-notebook-id' , 'Notebook ID should match' ) ;
83-
84- logger . debug ( 'Test: Load .deepnote file - completed' ) ;
85- } ) ;
86-
87- test ( 'Execute code cell and verify output' , async function ( ) {
88- logger . debug ( 'Test: Execute code cell - starting' ) ;
54+ const notebookManager = api . serviceContainer . get < IDeepnoteNotebookManager > ( IDeepnoteNotebookManager ) ;
55+ assert . isOk ( notebookManager , 'Notebook manager should be available' ) ;
8956
90- const cell = nbDocument . cellAt ( 0 ) ;
91- assert . equal ( cell . kind , 1 , 'First cell should be a code cell' ) ;
57+ notebookManager . selectNotebookForProject ( 'test-project-id' , 'main-notebook-id' ) ;
9258
93- await kernelExecution . executeCell ( cell ) ;
59+ const nbDocument = await workspace . openNotebookDocument ( deepnoteFilePath ) ;
9460
95- await waitForCondition (
96- async ( ) => cell . executionSummary ?. success === true ,
97- 30_000 ,
98- 'Cell execution did not complete successfully'
99- ) ;
61+ logger . debug ( `Opened notebook with type: ${ nbDocument . notebookType } , cells: ${ nbDocument . cellCount } ` ) ;
10062
101- assert . isAtLeast ( cell . executionSummary ?. executionOrder || 0 , 1 , 'Cell should have execution order' ) ;
102- assert . isTrue ( cell . executionSummary ?. success , 'Cell execution should succeed' ) ;
103- assert . isAtLeast ( cell . outputs . length , 1 , 'Cell should have at least one output' ) ;
63+ assert . equal ( nbDocument . notebookType , 'deepnote' , 'Notebook type should be deepnote' ) ;
64+ assert . equal ( nbDocument . cellCount , 3 , 'Notebook should have 3 cells' ) ;
10465
105- const outputText = new TextDecoder ( ) . decode ( cell . outputs [ 0 ] . items [ 0 ] . data ) . toString ( ) ;
106- assert . include ( outputText , 'Hello World ' , 'Output should contain "Hello World" ' ) ;
66+ assert . equal ( nbDocument . metadata ?. deepnoteProjectId , 'test-project-id' , 'Project ID should match' ) ;
67+ assert . equal ( nbDocument . metadata ?. deepnoteNotebookId , 'main-notebook-id ' , 'Notebook ID should match ' ) ;
10768
108- logger . debug ( 'Test: Execute code cell - completed' ) ;
69+ logger . debug ( 'Test: Load .deepnote file - completed' ) ;
10970 } ) ;
11071
111- test ( 'Execute multiple code cells with shared state ' , async function ( ) {
112- logger . debug ( 'Test: Execute multiple code cells - starting' ) ;
72+ test ( 'Verify notebook cells are correctly deserialized ' , async function ( ) {
73+ logger . debug ( 'Test: Verify cells - starting' ) ;
11374
114- const cell1 = nbDocument . cellAt ( 0 ) ;
115- const cell2 = nbDocument . cellAt ( 1 ) ;
75+ const notebookManager = api . serviceContainer . get < IDeepnoteNotebookManager > ( IDeepnoteNotebookManager ) ;
76+ notebookManager . selectNotebookForProject ( 'test-project-id' , 'main-notebook-id' ) ;
11677
117- await kernelExecution . executeCell ( cell1 ) ;
118- await waitForCondition (
119- async ( ) => cell1 . executionSummary ?. success === true ,
120- 30_000 ,
121- 'First cell execution did not complete'
122- ) ;
78+ const nbDocument = await workspace . openNotebookDocument ( deepnoteFilePath ) ;
12379
124- await kernelExecution . executeCell ( cell2 ) ;
125- await waitForCondition (
126- async ( ) => cell2 . executionSummary ?. success === true ,
127- 30_000 ,
128- 'Second cell execution did not complete'
129- ) ;
80+ const cell0 = nbDocument . cellAt ( 0 ) ;
81+ assert . equal ( cell0 . kind , 1 , 'First cell should be a code cell' ) ;
82+ assert . include ( cell0 . document . getText ( ) , 'print' , 'First cell should contain print statement' ) ;
13083
131- assert . isTrue ( cell2 . executionSummary ?. success , 'Second cell should execute successfully' ) ;
132- assert . isAtLeast ( cell2 . outputs . length , 1 , 'Second cell should have output' ) ;
84+ const cell1 = nbDocument . cellAt ( 1 ) ;
85+ assert . equal ( cell1 . kind , 1 , 'Second cell should be a code cell' ) ;
86+ assert . include ( cell1 . document . getText ( ) , '42' , 'Second cell should contain value 42' ) ;
13387
134- const outputText = new TextDecoder ( ) . decode ( cell2 . outputs [ 0 ] . items [ 0 ] . data ) . toString ( ) ;
135- assert . include ( outputText , '42' , 'Output should contain the value 42 ' ) ;
88+ const cell2 = nbDocument . cellAt ( 2 ) ;
89+ assert . equal ( cell2 . kind , 2 , 'Third cell should be a markdown cell ' ) ;
13690
137- logger . debug ( 'Test: Execute multiple code cells - completed' ) ;
91+ logger . debug ( 'Test: Verify cells - completed' ) ;
13892 } ) ;
13993
140- test ( 'Init notebook executes automatically ' , async function ( ) {
141- logger . debug ( 'Test: Init notebook execution - starting' ) ;
94+ test ( 'Extension services are available ' , async function ( ) {
95+ logger . debug ( 'Test: Extension services are available - starting' ) ;
14296
14397 const notebookManager = api . serviceContainer . get < IDeepnoteNotebookManager > ( IDeepnoteNotebookManager ) ;
98+ assert . isOk ( notebookManager , 'Notebook manager should be available' ) ;
14499
145- await waitForCondition (
146- async ( ) => notebookManager . hasInitNotebookBeenRun ( 'test-project-id' ) ,
147- 60_000 ,
148- 'Init notebook did not execute within timeout'
149- ) ;
150-
151- assert . isTrue (
152- notebookManager . hasInitNotebookBeenRun ( 'test-project-id' ) ,
153- 'Init notebook should have been marked as run'
154- ) ;
155-
156- const cell = nbDocument . cellAt ( 0 ) ;
157- await kernelExecution . executeCell ( cell ) ;
158- await waitForCondition (
159- async ( ) => cell . executionSummary ?. success === true ,
160- 30_000 ,
161- 'Cell execution did not complete'
162- ) ;
163-
164- logger . debug ( 'Test: Init notebook execution - completed' ) ;
100+ logger . debug ( 'Test: Extension services are available - completed' ) ;
165101 } ) ;
166102} ) ;
0 commit comments