Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some test instantiation service errors in notebooks #166069

Merged
merged 1 commit into from Nov 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -44,9 +44,9 @@ suite('NotebookFileWorkingCopyModel', function () {
const notebook = instantiationService.createInstance(NotebookTextModel,
'notebook',
URI.file('test'),
[{ cellKind: CellKind.Code, language: 'foo', source: 'foo', outputs: [{ outputId: 'id', outputs: [{ mime: Mimes.text, value: 'Hello Out' }] }] }],
[{ cellKind: CellKind.Code, language: 'foo', mime: 'foo', source: 'foo', outputs: [{ outputId: 'id', outputs: [{ mime: Mimes.text, data: VSBuffer.fromString('Hello Out') }] }] }],
{},
{ transientCellMetadata: {}, transientDocumentMetadata: {}, transientOutputs: false }
{ transientCellMetadata: {}, transientDocumentMetadata: {}, cellContentMetadata: {}, transientOutputs: false }
);

{ // transient output
Expand Down Expand Up @@ -92,9 +92,9 @@ suite('NotebookFileWorkingCopyModel', function () {
const notebook = instantiationService.createInstance(NotebookTextModel,
'notebook',
URI.file('test'),
[{ cellKind: CellKind.Code, language: 'foo', source: 'foo', outputs: [] }],
[{ cellKind: CellKind.Code, language: 'foo', mime: 'foo', source: 'foo', outputs: [] }],
{ foo: 123, bar: 456 },
{ transientCellMetadata: {}, transientDocumentMetadata: {}, transientOutputs: false }
{ transientCellMetadata: {}, transientDocumentMetadata: {}, cellContentMetadata: {}, transientOutputs: false }
);

{ // transient
Expand Down Expand Up @@ -140,9 +140,9 @@ suite('NotebookFileWorkingCopyModel', function () {
const notebook = instantiationService.createInstance(NotebookTextModel,
'notebook',
URI.file('test'),
[{ cellKind: CellKind.Code, language: 'foo', source: 'foo', outputs: [], metadata: { foo: 123, bar: 456 } }],
[{ cellKind: CellKind.Code, language: 'foo', mime: 'foo', source: 'foo', outputs: [], metadata: { foo: 123, bar: 456 } }],
{},
{ transientCellMetadata: {}, transientDocumentMetadata: {}, transientOutputs: false }
{ transientCellMetadata: {}, transientDocumentMetadata: {}, cellContentMetadata: {}, transientOutputs: false, }
);

{ // transient
Expand Down
Expand Up @@ -14,6 +14,7 @@ import { PLAINTEXT_LANGUAGE_ID } from 'vs/editor/common/languages/modesRegistry'
import { IMenu, IMenuService } from 'vs/platform/actions/common/actions';
import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
import { MockContextKeyService } from 'vs/platform/keybinding/test/common/mockKeybindingService';
import { insertCellAtIndex } from 'vs/workbench/contrib/notebook/browser/controller/cellOperations';
import { NotebookExecutionService } from 'vs/workbench/contrib/notebook/browser/services/notebookExecutionServiceImpl';
import { NotebookKernelService } from 'vs/workbench/contrib/notebook/browser/services/notebookKernelServiceImpl';
Expand Down Expand Up @@ -108,7 +109,7 @@ suite('NotebookExecutionService', () => {
kernel.executeNotebookCellsRequest = executeSpy;

const cell = insertCellAtIndex(viewModel, 0, 'var c = 3', 'javascript', CellKind.Code, {}, [], true, true);
await executionService.executeNotebookCells(viewModel.notebookDocument, [cell]);
await executionService.executeNotebookCells(viewModel.notebookDocument, [cell], new MockContextKeyService());
assert.strictEqual(executeSpy.calledOnce, true);
});
});
Expand Down Expand Up @@ -139,7 +140,7 @@ suite('NotebookExecutionService', () => {
kernelService.onDidChangeSelectedNotebooks(e => event = e);

const cell = insertCellAtIndex(viewModel, 0, 'var c = 3', 'javascript', CellKind.Code, {}, [], true, true);
await executionService.executeNotebookCells(viewModel.notebookDocument, [cell]);
await executionService.executeNotebookCells(viewModel.notebookDocument, [cell], new MockContextKeyService());

assert.strictEqual(didExecute, true);
assert.ok(event !== undefined);
Expand Down Expand Up @@ -169,7 +170,7 @@ suite('NotebookExecutionService', () => {
const exeStateService = instantiationService.get(INotebookExecutionStateService);

const cell = insertCellAtIndex(viewModel, 0, 'var c = 3', 'javascript', CellKind.Code, {}, [], true, true);
await executionService.executeNotebookCells(viewModel.notebookDocument, [cell]);
await executionService.executeNotebookCells(viewModel.notebookDocument, [cell], new MockContextKeyService());

assert.strictEqual(didExecute, true);
assert.strictEqual(exeStateService.getCellExecution(cell.uri), undefined);
Expand Down
Expand Up @@ -17,6 +17,7 @@ import { DisposableStore } from 'vs/base/common/lifecycle';
import { NotebookTextModel } from 'vs/workbench/contrib/notebook/common/model/notebookTextModel';
import { PLAINTEXT_LANGUAGE_ID } from 'vs/editor/common/languages/modesRegistry';
import { IMenu, IMenuService } from 'vs/platform/actions/common/actions';
import { TransientOptions } from 'vs/workbench/contrib/notebook/common/notebookCommon';

suite('NotebookKernelService', () => {

Expand Down Expand Up @@ -150,18 +151,25 @@ suite('NotebookKernelService', () => {
kernelService.selectKernelForNotebook(jupyterKernel, jupyter);
kernelService.selectKernelForNotebook(dotnetKernel, dotnet);

const transientOptions: TransientOptions = {
transientOutputs: false,
transientCellMetadata: {},
transientDocumentMetadata: {},
cellContentMetadata: {},
};

{
// open as jupyter -> bind event
const p1 = Event.toPromise(kernelService.onDidChangeSelectedNotebooks);
const d1 = instantiationService.createInstance(NotebookTextModel, jupyter.viewType, jupyter.uri, [], {}, {});
const d1 = instantiationService.createInstance(NotebookTextModel, jupyter.viewType, jupyter.uri, [], {}, transientOptions);
onDidAddNotebookDocument.fire(d1);
const event = await p1;
assert.strictEqual(event.newKernel, jupyterKernel.id);
}
{
// RE-open as dotnet -> bind event
const p2 = Event.toPromise(kernelService.onDidChangeSelectedNotebooks);
const d2 = instantiationService.createInstance(NotebookTextModel, dotnet.viewType, dotnet.uri, [], {}, {});
const d2 = instantiationService.createInstance(NotebookTextModel, dotnet.viewType, dotnet.uri, [], {}, transientOptions);
onDidAddNotebookDocument.fire(d2);
const event2 = await p2;
assert.strictEqual(event2.newKernel, dotnetKernel.id);
Expand Down