Skip to content

Commit e31078d

Browse files
authored
Fix bad method calls in notebook execution test, via microsoft#164297 (microsoft#166078)
1 parent 9f2be31 commit e31078d

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

src/vs/workbench/contrib/notebook/test/browser/notebookExecutionService.test.ts

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ import { mock } from 'vs/base/test/common/mock';
1212
import { assertThrowsAsync } from 'vs/base/test/common/utils';
1313
import { PLAINTEXT_LANGUAGE_ID } from 'vs/editor/common/languages/modesRegistry';
1414
import { IMenu, IMenuService } from 'vs/platform/actions/common/actions';
15+
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
1516
import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
1617
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
17-
import { MockContextKeyService } from 'vs/platform/keybinding/test/common/mockKeybindingService';
1818
import { insertCellAtIndex } from 'vs/workbench/contrib/notebook/browser/controller/cellOperations';
1919
import { NotebookExecutionService } from 'vs/workbench/contrib/notebook/browser/services/notebookExecutionServiceImpl';
2020
import { NotebookKernelService } from 'vs/workbench/contrib/notebook/browser/services/notebookKernelServiceImpl';
@@ -29,6 +29,7 @@ import { setupInstantiationService, withTestNotebook as _withTestNotebook } from
2929
suite('NotebookExecutionService', () => {
3030

3131
let instantiationService: TestInstantiationService;
32+
let contextKeyService: IContextKeyService;
3233
let kernelService: INotebookKernelService;
3334
let disposables: DisposableStore;
3435

@@ -56,6 +57,7 @@ suite('NotebookExecutionService', () => {
5657

5758
kernelService = instantiationService.createInstance(NotebookKernelService);
5859
instantiationService.set(INotebookKernelService, kernelService);
60+
contextKeyService = instantiationService.get(IContextKeyService);
5961

6062
});
6163

@@ -77,48 +79,48 @@ suite('NotebookExecutionService', () => {
7779
test('cell is not runnable when no kernel is selected', async () => {
7880
await withTestNotebook(
7981
[],
80-
async (viewModel) => {
82+
async (viewModel, textModel) => {
8183
const executionService = instantiationService.createInstance(NotebookExecutionService);
8284

8385
const cell = insertCellAtIndex(viewModel, 1, 'var c = 3', 'javascript', CellKind.Code, {}, [], true, true);
84-
await assertThrowsAsync(async () => await executionService.executeNotebookCell(cell));
86+
await assertThrowsAsync(async () => await executionService.executeNotebookCells(textModel, [cell.model], contextKeyService));
8587
});
8688
});
8789

8890
test('cell is not runnable when kernel does not support the language', async () => {
8991
await withTestNotebook(
9092
[],
91-
async (viewModel) => {
93+
async (viewModel, textModel) => {
9294

9395
kernelService.registerKernel(new TestNotebookKernel({ languages: ['testlang'] }));
9496
const executionService = instantiationService.createInstance(NotebookExecutionService);
9597
const cell = insertCellAtIndex(viewModel, 1, 'var c = 3', 'javascript', CellKind.Code, {}, [], true, true);
96-
await assertThrowsAsync(async () => await executionService.executeNotebookCell(cell));
98+
await assertThrowsAsync(async () => await executionService.executeNotebookCells(textModel, [cell.model], contextKeyService));
9799

98100
});
99101
});
100102

101103
test('cell is runnable when kernel does support the language', async () => {
102104
await withTestNotebook(
103105
[],
104-
async (viewModel) => {
106+
async (viewModel, textModel) => {
105107
const kernel = new TestNotebookKernel({ languages: ['javascript'] });
106108
kernelService.registerKernel(kernel);
107109
const executionService = instantiationService.createInstance(NotebookExecutionService);
108110
const executeSpy = sinon.spy();
109111
kernel.executeNotebookCellsRequest = executeSpy;
110112

111113
const cell = insertCellAtIndex(viewModel, 0, 'var c = 3', 'javascript', CellKind.Code, {}, [], true, true);
112-
await executionService.executeNotebookCells(viewModel.notebookDocument, [cell], new MockContextKeyService());
114+
await executionService.executeNotebookCells(viewModel.notebookDocument, [cell.model], contextKeyService);
113115
assert.strictEqual(executeSpy.calledOnce, true);
114116
});
115117
});
116118

117119
test('select kernel when running cell', async function () {
118120
// https://github.com/microsoft/vscode/issues/121904
119121

120-
return withTestNotebook([], async viewModel => {
121-
assert.strictEqual(kernelService.getMatchingKernel(viewModel.notebookDocument).all.length, 0);
122+
return withTestNotebook([], async (viewModel, textModel) => {
123+
assert.strictEqual(kernelService.getMatchingKernel(textModel).all.length, 0);
122124

123125
let didExecute = false;
124126
const kernel = new class extends TestNotebookKernel {
@@ -140,7 +142,7 @@ suite('NotebookExecutionService', () => {
140142
kernelService.onDidChangeSelectedNotebooks(e => event = e);
141143

142144
const cell = insertCellAtIndex(viewModel, 0, 'var c = 3', 'javascript', CellKind.Code, {}, [], true, true);
143-
await executionService.executeNotebookCells(viewModel.notebookDocument, [cell], new MockContextKeyService());
145+
await executionService.executeNotebookCells(textModel, [cell.model], contextKeyService);
144146

145147
assert.strictEqual(didExecute, true);
146148
assert.ok(event !== undefined);
@@ -151,7 +153,7 @@ suite('NotebookExecutionService', () => {
151153

152154
test('Completes unconfirmed executions', async function () {
153155

154-
return withTestNotebook([], async viewModel => {
156+
return withTestNotebook([], async (viewModel, textModel) => {
155157
let didExecute = false;
156158
const kernel = new class extends TestNotebookKernel {
157159
constructor() {
@@ -170,7 +172,7 @@ suite('NotebookExecutionService', () => {
170172
const exeStateService = instantiationService.get(INotebookExecutionStateService);
171173

172174
const cell = insertCellAtIndex(viewModel, 0, 'var c = 3', 'javascript', CellKind.Code, {}, [], true, true);
173-
await executionService.executeNotebookCells(viewModel.notebookDocument, [cell], new MockContextKeyService());
175+
await executionService.executeNotebookCells(textModel, [cell.model], contextKeyService);
174176

175177
assert.strictEqual(didExecute, true);
176178
assert.strictEqual(exeStateService.getCellExecution(cell.uri), undefined);

0 commit comments

Comments
 (0)