Skip to content

Commit 1a2e3fa

Browse files
committed
1 parent ba85a1a commit 1a2e3fa

1 file changed

Lines changed: 24 additions & 13 deletions

File tree

extensions/vscode-notebook-tests/src/notebook.test.ts

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,9 @@ suite('notebook workflow', () => {
447447

448448
await vscode.commands.executeCommand('notebook.cell.insertCodeCellBelow');
449449
assert.equal(vscode.notebook.activeNotebookEditor!.selection?.document.getText(), '');
450-
await vscode.commands.executeCommand('default:type', { text: 'var abc = 0;' });
450+
const edit = new vscode.WorkspaceEdit();
451+
edit.insert(vscode.notebook.activeNotebookEditor!.selection!.uri, new vscode.Position(0, 0), 'var abc = 0;');
452+
await vscode.workspace.applyEdit(edit);
451453

452454
const cellsChangeEvent = getEventOncePromise<vscode.NotebookCellsChangeEvent>(vscode.notebook.onDidChangeNotebookCells);
453455
await vscode.commands.executeCommand('notebook.cell.joinAbove');
@@ -564,12 +566,9 @@ suite('notebook dirty state', () => {
564566
assert.equal(vscode.notebook.activeNotebookEditor!.document.cells.length, 3);
565567
assert.equal(vscode.notebook.activeNotebookEditor!.document.cells.indexOf(activeCell!), 1);
566568

567-
568-
await vscode.commands.executeCommand('default:type', { text: 'var abc = 0;' });
569-
await vscode.commands.executeCommand('workbench.action.files.newUntitledFile');
570-
await vscode.commands.executeCommand('workbench.action.closeActiveEditor');
571-
572-
await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest');
569+
const edit = new vscode.WorkspaceEdit();
570+
edit.insert(activeCell!.uri, new vscode.Position(0, 0), 'var abc = 0;');
571+
await vscode.workspace.applyEdit(edit);
573572
assert.equal(vscode.notebook.activeNotebookEditor !== undefined, true);
574573
assert.equal(vscode.notebook.activeNotebookEditor?.selection !== undefined, true);
575574
assert.deepEqual(vscode.notebook.activeNotebookEditor?.document.cells[1], vscode.notebook.activeNotebookEditor?.selection);
@@ -600,7 +599,9 @@ suite('notebook undo redo', () => {
600599

601600

602601
// modify the second cell, delete it
603-
await vscode.commands.executeCommand('default:type', { text: 'var abc = 0;' });
602+
const edit = new vscode.WorkspaceEdit();
603+
edit.insert(vscode.notebook.activeNotebookEditor!.selection!.uri, new vscode.Position(0, 0), 'var abc = 0;');
604+
await vscode.workspace.applyEdit(edit);
604605
await vscode.commands.executeCommand('notebook.cell.delete');
605606
assert.equal(vscode.notebook.activeNotebookEditor!.document.cells.length, 2);
606607
assert.equal(vscode.notebook.activeNotebookEditor!.document.cells.indexOf(vscode.notebook.activeNotebookEditor!.selection!), 1);
@@ -736,7 +737,9 @@ suite('notebook working copy', () => {
736737
assert.equal(vscode.notebook.activeNotebookEditor!.selection?.document.getText(), '');
737738

738739
await vscode.commands.executeCommand('notebook.cell.insertCodeCellAbove');
739-
await vscode.commands.executeCommand('default:type', { text: 'var abc = 0;' });
740+
const edit = new vscode.WorkspaceEdit();
741+
edit.insert(vscode.notebook.activeNotebookEditor!.selection!.uri, new vscode.Position(0, 0), 'var abc = 0;');
742+
await vscode.workspace.applyEdit(edit);
740743

741744
const secondResource = vscode.Uri.file(join(vscode.workspace.rootPath || '', './second.vsctestnb'));
742745
await vscode.commands.executeCommand('vscode.openWith', secondResource, 'notebookCoreTest');
@@ -760,7 +763,9 @@ suite('notebook working copy', () => {
760763
assert.equal(vscode.notebook.activeNotebookEditor!.selection?.document.getText(), '');
761764

762765
await vscode.commands.executeCommand('notebook.cell.insertCodeCellAbove');
763-
await vscode.commands.executeCommand('default:type', { text: 'var abc = 0;' });
766+
const edit = new vscode.WorkspaceEdit();
767+
edit.insert(vscode.notebook.activeNotebookEditor!.selection!.uri, new vscode.Position(0, 0), 'var abc = 0;');
768+
await vscode.workspace.applyEdit(edit);
764769

765770
const secondResource = vscode.Uri.file(join(vscode.workspace.rootPath || '', './second.vsctestnb'));
766771
await vscode.commands.executeCommand('vscode.openWith', secondResource, 'notebookCoreTest');
@@ -860,7 +865,9 @@ suite('regression', () => {
860865
const resource = vscode.Uri.file(join(vscode.workspace.rootPath || '', './empty.vsctestnb'));
861866
await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest');
862867
await vscode.commands.executeCommand('notebook.cell.insertCodeCellBelow');
863-
await vscode.commands.executeCommand('default:type', { text: 'var abc = 0;' });
868+
const edit = new vscode.WorkspaceEdit();
869+
edit.insert(vscode.notebook.activeNotebookEditor!.selection!.uri, new vscode.Position(0, 0), 'var abc = 0;');
870+
await vscode.workspace.applyEdit(edit);
864871

865872
assert.equal(vscode.notebook.activeNotebookEditor !== undefined, true, 'notebook first');
866873
assert.equal(vscode.notebook.activeNotebookEditor!.selection?.document.getText(), 'var abc = 0;');
@@ -878,7 +885,9 @@ suite('regression', () => {
878885
const resource = vscode.Uri.file(join(vscode.workspace.rootPath || '', './empty.vsctestnb'));
879886
await vscode.commands.executeCommand('vscode.openWith', resource, 'default');
880887
await vscode.commands.executeCommand('notebook.cell.insertCodeCellBelow');
881-
await vscode.commands.executeCommand('default:type', { text: 'var abc = 0;' });
888+
const edit = new vscode.WorkspaceEdit();
889+
edit.insert(vscode.notebook.activeNotebookEditor!.selection!.uri, new vscode.Position(0, 0), 'var abc = 0;');
890+
await vscode.workspace.applyEdit(edit);
882891

883892
// now it's dirty, open the resource with notebook editor should open a new one
884893
await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest');
@@ -907,7 +916,9 @@ suite('regression', () => {
907916
assert.equal(vscode.notebook.activeNotebookEditor!.document.cells.indexOf(activeCell!), 1);
908917
assert.equal(activeCell?.document.getText(), 'test');
909918

910-
await vscode.commands.executeCommand('default:type', { text: 'var abc = 0;' });
919+
const edit = new vscode.WorkspaceEdit();
920+
edit.insert(vscode.notebook.activeNotebookEditor!.selection!.uri, new vscode.Position(0, 0), 'var abc = 0;');
921+
await vscode.workspace.applyEdit(edit);
911922

912923
assert.equal(vscode.notebook.activeNotebookEditor!.document.cells.length, 2);
913924
assert.notEqual(vscode.notebook.activeNotebookEditor!.document.cells[0].document.getText(), vscode.notebook.activeNotebookEditor!.document.cells[1].document.getText());

0 commit comments

Comments
 (0)