|
1 | | -// Copyright (c) Microsoft Corporation. |
2 | | -// Licensed under the MIT License. |
3 | | - |
4 | 1 | /* eslint-disable @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */ |
5 | 2 | import { assert } from 'chai'; |
6 | 3 | import * as path from '../../../platform/vscode-path/path'; |
@@ -105,6 +102,33 @@ suite('Deepnote Integration Tests @kernelCore', function () { |
105 | 102 | logger.debug('Test: Kernel starts for .deepnote file - completed'); |
106 | 103 | }); |
107 | 104 |
|
| 105 | + test('Init notebook executes automatically', async function () { |
| 106 | + logger.debug('Test: Init notebook executes automatically - starting'); |
| 107 | + |
| 108 | + const notebookManager = api.serviceContainer.get<IDeepnoteNotebookManager>(IDeepnoteNotebookManager); |
| 109 | + |
| 110 | + notebookManager.selectNotebookForProject('test-project-id', 'main-notebook-id'); |
| 111 | + |
| 112 | + await workspace.openNotebookDocument(deepnoteFilePath); |
| 113 | + |
| 114 | + const hasInitNotebookRun = notebookManager.hasInitNotebookBeenRun('test-project-id'); |
| 115 | + assert.isTrue(hasInitNotebookRun, 'Init notebook should have been executed automatically when kernel started'); |
| 116 | + |
| 117 | + const cell = await notebook.appendCodeCell( |
| 118 | + 'import sys; print("Init notebook executed" if "sys" in globals() else "Init notebook not executed")' |
| 119 | + ); |
| 120 | + await Promise.all([kernelExecution.executeCell(cell), waitForExecutionCompletedSuccessfully(cell)]); |
| 121 | + |
| 122 | + const output = getCellOutputs(cell); |
| 123 | + assert.include( |
| 124 | + output, |
| 125 | + 'Init notebook executed', |
| 126 | + 'Init notebook should have executed and set up the environment' |
| 127 | + ); |
| 128 | + |
| 129 | + logger.debug('Test: Init notebook executes automatically - completed'); |
| 130 | + }); |
| 131 | + |
108 | 132 | test('Execute code block', async function () { |
109 | 133 | logger.debug('Test: Execute code block - starting'); |
110 | 134 |
|
|
0 commit comments