💄 strict assertions

This commit is contained in:
Johannes Rieken 2021-02-08 18:15:10 +01:00
parent 809bbd7b62
commit a873e60a71

View file

@ -101,9 +101,9 @@ async function withEvent<T>(event: vscode.Event<T>, callback: (e: Promise<T>) =>
function assertInitalState() {
// no-op unless we figure out why some documents are opened after the editor is closed
// assert.equal(vscode.window.activeNotebookEditor, undefined);
// assert.equal(vscode.notebook.notebookDocuments.length, 0);
// assert.equal(vscode.notebook.visibleNotebookEditors.length, 0);
// assert.strictEqual(vscode.window.activeNotebookEditor, undefined);
// assert.strictEqual(vscode.notebook.notebookDocuments.length, 0);
// assert.strictEqual(vscode.notebook.visibleNotebookEditors.length, 0);
}
suite('Notebook API tests', () => {
@ -198,12 +198,12 @@ suite('Notebook API tests', () => {
counter--;
}));
await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest');
assert.equal(counter, 1);
assert.strictEqual(counter, 1);
await splitEditor();
assert.equal(counter, 1);
assert.strictEqual(counter, 1);
await vscode.commands.executeCommand('workbench.action.closeAllEditors');
assert.equal(counter, 0);
assert.strictEqual(counter, 0);
disposables.forEach(d => d.dispose());
});
@ -232,13 +232,13 @@ suite('Notebook API tests', () => {
}));
await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest');
assert.equal(count, 1);
assert.strictEqual(count, 1);
await splitEditor();
assert.equal(count, 2);
assert.strictEqual(count, 2);
await vscode.commands.executeCommand('workbench.action.closeAllEditors');
assert.equal(count, 0);
assert.strictEqual(count, 0);
});
test('editor editing event 2', async function () {
@ -250,9 +250,9 @@ suite('Notebook API tests', () => {
const cellsChangeEvent = getEventOncePromise<vscode.NotebookCellsChangeEvent>(vscode.notebook.onDidChangeNotebookCells);
await vscode.commands.executeCommand('notebook.cell.insertCodeCellBelow');
const cellChangeEventRet = await cellsChangeEvent;
assert.equal(cellChangeEventRet.document, vscode.window.activeNotebookEditor?.document);
assert.equal(cellChangeEventRet.changes.length, 1);
assert.deepEqual(cellChangeEventRet.changes[0], {
assert.strictEqual(cellChangeEventRet.document, vscode.window.activeNotebookEditor?.document);
assert.strictEqual(cellChangeEventRet.changes.length, 1);
assert.deepStrictEqual(cellChangeEventRet.changes[0], {
start: 1,
deletedCount: 0,
deletedItems: [],
@ -266,7 +266,7 @@ suite('Notebook API tests', () => {
const moveCellEvent = getEventOncePromise<vscode.NotebookCellsChangeEvent>(vscode.notebook.onDidChangeNotebookCells);
await vscode.commands.executeCommand('notebook.cell.moveUp');
const moveCellEventRet = await moveCellEvent;
assert.deepEqual(moveCellEventRet, {
assert.deepStrictEqual(moveCellEventRet, {
document: vscode.window.activeNotebookEditor!.document,
changes: [
{
@ -287,25 +287,25 @@ suite('Notebook API tests', () => {
const cellOutputChange = getEventOncePromise<vscode.NotebookCellOutputsChangeEvent>(vscode.notebook.onDidChangeCellOutputs);
await vscode.commands.executeCommand('notebook.cell.execute');
const cellOutputsAddedRet = await cellOutputChange;
assert.deepEqual(cellOutputsAddedRet, {
assert.deepStrictEqual(cellOutputsAddedRet, {
document: vscode.window.activeNotebookEditor!.document,
cells: [vscode.window.activeNotebookEditor!.document.cells[0]]
});
assert.equal(cellOutputsAddedRet.cells[0].outputs.length, 1);
assert.strictEqual(cellOutputsAddedRet.cells[0].outputs.length, 1);
const cellOutputClear = getEventOncePromise<vscode.NotebookCellOutputsChangeEvent>(vscode.notebook.onDidChangeCellOutputs);
await vscode.commands.executeCommand('notebook.cell.clearOutputs');
const cellOutputsCleardRet = await cellOutputClear;
assert.deepEqual(cellOutputsCleardRet, {
assert.deepStrictEqual(cellOutputsCleardRet, {
document: vscode.window.activeNotebookEditor!.document,
cells: [vscode.window.activeNotebookEditor!.document.cells[0]]
});
assert.equal(cellOutputsAddedRet.cells[0].outputs.length, 0);
assert.strictEqual(cellOutputsAddedRet.cells[0].outputs.length, 0);
// const cellChangeLanguage = getEventOncePromise<vscode.NotebookCellLanguageChangeEvent>(vscode.notebook.onDidChangeCellLanguage);
// await vscode.commands.executeCommand('notebook.cell.changeToMarkdown');
// const cellChangeLanguageRet = await cellChangeLanguage;
// assert.deepEqual(cellChangeLanguageRet, {
// assert.deepStrictEqual(cellChangeLanguageRet, {
// document: vscode.window.activeNotebookEditor!.document,
// cells: vscode.window.activeNotebookEditor!.document.cells[0],
// language: 'markdown'
@ -324,11 +324,11 @@ suite('Notebook API tests', () => {
await vscode.commands.executeCommand('notebook.focusTop');
const activeCell = vscode.window.activeNotebookEditor!.selection;
assert.equal(vscode.window.activeNotebookEditor!.document.cells.indexOf(activeCell!), 0);
assert.strictEqual(vscode.window.activeNotebookEditor!.document.cells.indexOf(activeCell!), 0);
const moveChange = getEventOncePromise(vscode.notebook.onDidChangeNotebookCells);
await vscode.commands.executeCommand('notebook.cell.moveDown');
const ret = await moveChange;
assert.deepEqual(ret, {
assert.deepStrictEqual(ret, {
document: vscode.window.activeNotebookEditor?.document,
changes: [
{
@ -351,7 +351,7 @@ suite('Notebook API tests', () => {
await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest');
const firstEditor = vscode.window.activeNotebookEditor;
assert.equal(firstEditor?.document.cells.length, 1);
assert.strictEqual(firstEditor?.document.cells.length, 1);
await vscode.commands.executeCommand('workbench.action.files.save');
await vscode.commands.executeCommand('workbench.action.closeAllEditors');
@ -369,7 +369,7 @@ suite('Notebook API tests', () => {
assert.strictEqual(secondEditor && vscode.window.visibleNotebookEditors.indexOf(secondEditor) >= 0, true);
assert.notStrictEqual(firstEditor, secondEditor);
assert.strictEqual(firstEditor && vscode.window.visibleNotebookEditors.indexOf(firstEditor) >= 0, true);
assert.equal(vscode.window.visibleNotebookEditors.length, 2);
assert.strictEqual(vscode.window.visibleNotebookEditors.length, 2);
const untitledEditorChange = getEventOncePromise(vscode.window.onDidChangeActiveNotebookEditor);
await vscode.commands.executeCommand('workbench.action.files.newUntitledFile');
@ -378,13 +378,13 @@ suite('Notebook API tests', () => {
assert.notStrictEqual(firstEditor, vscode.window.activeNotebookEditor);
assert.strictEqual(secondEditor && vscode.window.visibleNotebookEditors.indexOf(secondEditor) < 0, true);
assert.notStrictEqual(secondEditor, vscode.window.activeNotebookEditor);
assert.equal(vscode.window.visibleNotebookEditors.length, 1);
assert.strictEqual(vscode.window.visibleNotebookEditors.length, 1);
const activeEditorClose = getEventOncePromise(vscode.window.onDidChangeActiveNotebookEditor);
await vscode.commands.executeCommand('workbench.action.closeActiveEditor');
await activeEditorClose;
assert.strictEqual(secondEditor, vscode.window.activeNotebookEditor);
assert.equal(vscode.window.visibleNotebookEditors.length, 2);
assert.strictEqual(vscode.window.visibleNotebookEditors.length, 2);
assert.strictEqual(secondEditor && vscode.window.visibleNotebookEditors.indexOf(secondEditor) >= 0, true);
await vscode.commands.executeCommand('workbench.action.files.save');
@ -717,7 +717,7 @@ suite('Notebook API tests', () => {
}));
await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest');
assert.equal(count, 0);
assert.strictEqual(count, 0);
disposables.forEach(d => d.dispose());
@ -730,19 +730,19 @@ suite('notebook workflow', () => {
assertInitalState();
const resource = await createRandomFile('', undefined, 'first', '.vsctestnb');
await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest');
assert.equal(vscode.window.activeNotebookEditor !== undefined, true, 'notebook first');
assert.equal(vscode.window.activeNotebookEditor!.selection?.document.getText(), 'test');
assert.equal(vscode.window.activeNotebookEditor!.selection?.language, 'typescript');
assert.strictEqual(vscode.window.activeNotebookEditor !== undefined, true, 'notebook first');
assert.strictEqual(vscode.window.activeNotebookEditor!.selection?.document.getText(), 'test');
assert.strictEqual(vscode.window.activeNotebookEditor!.selection?.language, 'typescript');
await vscode.commands.executeCommand('notebook.cell.insertCodeCellBelow');
assert.equal(vscode.window.activeNotebookEditor!.selection?.document.getText(), '');
assert.strictEqual(vscode.window.activeNotebookEditor!.selection?.document.getText(), '');
await vscode.commands.executeCommand('notebook.cell.insertCodeCellAbove');
const activeCell = vscode.window.activeNotebookEditor!.selection;
assert.notEqual(vscode.window.activeNotebookEditor!.selection, undefined);
assert.equal(activeCell!.document.getText(), '');
assert.equal(vscode.window.activeNotebookEditor!.document.cells.length, 3);
assert.equal(vscode.window.activeNotebookEditor!.document.cells.indexOf(activeCell!), 1);
assert.strictEqual(activeCell!.document.getText(), '');
assert.strictEqual(vscode.window.activeNotebookEditor!.document.cells.length, 3);
assert.strictEqual(vscode.window.activeNotebookEditor!.document.cells.indexOf(activeCell!), 1);
await vscode.commands.executeCommand('workbench.action.files.save');
await vscode.commands.executeCommand('workbench.action.closeActiveEditor');
@ -752,69 +752,69 @@ suite('notebook workflow', () => {
assertInitalState();
const resource = await createRandomFile('', undefined, 'first', '.vsctestnb');
await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest');
assert.equal(vscode.window.activeNotebookEditor !== undefined, true, 'notebook first');
assert.equal(vscode.window.activeNotebookEditor!.selection?.document.getText(), 'test');
assert.equal(vscode.window.activeNotebookEditor!.selection?.language, 'typescript');
assert.strictEqual(vscode.window.activeNotebookEditor !== undefined, true, 'notebook first');
assert.strictEqual(vscode.window.activeNotebookEditor!.selection?.document.getText(), 'test');
assert.strictEqual(vscode.window.activeNotebookEditor!.selection?.language, 'typescript');
// ---- insert cell below and focus ---- //
await vscode.commands.executeCommand('notebook.cell.insertCodeCellBelow');
assert.equal(vscode.window.activeNotebookEditor!.selection?.document.getText(), '');
assert.strictEqual(vscode.window.activeNotebookEditor!.selection?.document.getText(), '');
// ---- insert cell above and focus ---- //
await vscode.commands.executeCommand('notebook.cell.insertCodeCellAbove');
let activeCell = vscode.window.activeNotebookEditor!.selection;
assert.notEqual(vscode.window.activeNotebookEditor!.selection, undefined);
assert.equal(activeCell!.document.getText(), '');
assert.equal(vscode.window.activeNotebookEditor!.document.cells.length, 3);
assert.equal(vscode.window.activeNotebookEditor!.document.cells.indexOf(activeCell!), 1);
assert.strictEqual(activeCell!.document.getText(), '');
assert.strictEqual(vscode.window.activeNotebookEditor!.document.cells.length, 3);
assert.strictEqual(vscode.window.activeNotebookEditor!.document.cells.indexOf(activeCell!), 1);
// ---- focus bottom ---- //
await vscode.commands.executeCommand('notebook.focusBottom');
activeCell = vscode.window.activeNotebookEditor!.selection;
assert.equal(vscode.window.activeNotebookEditor!.document.cells.indexOf(activeCell!), 2);
assert.strictEqual(vscode.window.activeNotebookEditor!.document.cells.indexOf(activeCell!), 2);
// ---- focus top and then copy down ---- //
await vscode.commands.executeCommand('notebook.focusTop');
activeCell = vscode.window.activeNotebookEditor!.selection;
assert.equal(vscode.window.activeNotebookEditor!.document.cells.indexOf(activeCell!), 0);
assert.strictEqual(vscode.window.activeNotebookEditor!.document.cells.indexOf(activeCell!), 0);
await vscode.commands.executeCommand('notebook.cell.copyDown');
activeCell = vscode.window.activeNotebookEditor!.selection;
assert.equal(vscode.window.activeNotebookEditor!.document.cells.indexOf(activeCell!), 1);
assert.equal(activeCell?.document.getText(), 'test');
assert.strictEqual(vscode.window.activeNotebookEditor!.document.cells.indexOf(activeCell!), 1);
assert.strictEqual(activeCell?.document.getText(), 'test');
await vscode.commands.executeCommand('notebook.cell.delete');
activeCell = vscode.window.activeNotebookEditor!.selection;
assert.equal(vscode.window.activeNotebookEditor!.document.cells.indexOf(activeCell!), 1);
assert.equal(activeCell?.document.getText(), '');
assert.strictEqual(vscode.window.activeNotebookEditor!.document.cells.indexOf(activeCell!), 1);
assert.strictEqual(activeCell?.document.getText(), '');
// ---- focus top and then copy up ---- //
await vscode.commands.executeCommand('notebook.focusTop');
await vscode.commands.executeCommand('notebook.cell.copyUp');
assert.equal(vscode.window.activeNotebookEditor!.document.cells.length, 4);
assert.equal(vscode.window.activeNotebookEditor!.document.cells[0].document.getText(), 'test');
assert.equal(vscode.window.activeNotebookEditor!.document.cells[1].document.getText(), 'test');
assert.equal(vscode.window.activeNotebookEditor!.document.cells[2].document.getText(), '');
assert.equal(vscode.window.activeNotebookEditor!.document.cells[3].document.getText(), '');
assert.strictEqual(vscode.window.activeNotebookEditor!.document.cells.length, 4);
assert.strictEqual(vscode.window.activeNotebookEditor!.document.cells[0].document.getText(), 'test');
assert.strictEqual(vscode.window.activeNotebookEditor!.document.cells[1].document.getText(), 'test');
assert.strictEqual(vscode.window.activeNotebookEditor!.document.cells[2].document.getText(), '');
assert.strictEqual(vscode.window.activeNotebookEditor!.document.cells[3].document.getText(), '');
activeCell = vscode.window.activeNotebookEditor!.selection;
assert.equal(vscode.window.activeNotebookEditor!.document.cells.indexOf(activeCell!), 0);
assert.strictEqual(vscode.window.activeNotebookEditor!.document.cells.indexOf(activeCell!), 0);
// ---- move up and down ---- //
await vscode.commands.executeCommand('notebook.cell.moveDown');
assert.equal(vscode.window.activeNotebookEditor!.document.cells.indexOf(vscode.window.activeNotebookEditor!.selection!), 1,
assert.strictEqual(vscode.window.activeNotebookEditor!.document.cells.indexOf(vscode.window.activeNotebookEditor!.selection!), 1,
`first move down, active cell ${vscode.window.activeNotebookEditor!.selection!.uri.toString()}, ${vscode.window.activeNotebookEditor!.selection!.document.getText()}`);
// await vscode.commands.executeCommand('notebook.cell.moveDown');
// activeCell = vscode.window.activeNotebookEditor!.selection;
// assert.equal(vscode.window.activeNotebookEditor!.document.cells.indexOf(activeCell!), 2,
// assert.strictEqual(vscode.window.activeNotebookEditor!.document.cells.indexOf(activeCell!), 2,
// `second move down, active cell ${vscode.window.activeNotebookEditor!.selection!.uri.toString()}, ${vscode.window.activeNotebookEditor!.selection!.document.getText()}`);
// assert.equal(vscode.window.activeNotebookEditor!.document.cells[0].document.getText(), 'test');
// assert.equal(vscode.window.activeNotebookEditor!.document.cells[1].document.getText(), '');
// assert.equal(vscode.window.activeNotebookEditor!.document.cells[2].document.getText(), 'test');
// assert.equal(vscode.window.activeNotebookEditor!.document.cells[3].document.getText(), '');
// assert.strictEqual(vscode.window.activeNotebookEditor!.document.cells[0].document.getText(), 'test');
// assert.strictEqual(vscode.window.activeNotebookEditor!.document.cells[1].document.getText(), '');
// assert.strictEqual(vscode.window.activeNotebookEditor!.document.cells[2].document.getText(), 'test');
// assert.strictEqual(vscode.window.activeNotebookEditor!.document.cells[3].document.getText(), '');
// ---- ---- //
@ -826,12 +826,12 @@ suite('notebook workflow', () => {
assertInitalState();
const resource = await createRandomFile('', undefined, 'first', '.vsctestnb');
await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest');
assert.equal(vscode.window.activeNotebookEditor !== undefined, true, 'notebook first');
assert.equal(vscode.window.activeNotebookEditor!.selection?.document.getText(), 'test');
assert.equal(vscode.window.activeNotebookEditor!.selection?.language, 'typescript');
assert.strictEqual(vscode.window.activeNotebookEditor !== undefined, true, 'notebook first');
assert.strictEqual(vscode.window.activeNotebookEditor!.selection?.document.getText(), 'test');
assert.strictEqual(vscode.window.activeNotebookEditor!.selection?.language, 'typescript');
await vscode.commands.executeCommand('notebook.cell.insertCodeCellBelow');
assert.equal(vscode.window.activeNotebookEditor!.selection?.document.getText(), '');
assert.strictEqual(vscode.window.activeNotebookEditor!.selection?.document.getText(), '');
const edit = new vscode.WorkspaceEdit();
edit.insert(vscode.window.activeNotebookEditor!.selection!.uri, new vscode.Position(0, 0), 'var abc = 0;');
await vscode.workspace.applyEdit(edit);
@ -840,7 +840,7 @@ suite('notebook workflow', () => {
await vscode.commands.executeCommand('notebook.cell.joinAbove');
await cellsChangeEvent;
assert.deepEqual(vscode.window.activeNotebookEditor!.selection?.document.getText().split(/\r\n|\r|\n/), ['test', 'var abc = 0;']);
assert.deepStrictEqual(vscode.window.activeNotebookEditor!.selection?.document.getText().split(/\r\n|\r|\n/), ['test', 'var abc = 0;']);
await vscode.commands.executeCommand('workbench.action.files.save');
await vscode.commands.executeCommand('workbench.action.closeActiveEditor');
@ -855,37 +855,37 @@ suite('notebook workflow', () => {
await vscode.commands.executeCommand('notebook.focusTop');
const activeCell = vscode.window.activeNotebookEditor!.selection;
assert.equal(vscode.window.activeNotebookEditor!.document.cells.indexOf(activeCell!), 0);
assert.strictEqual(vscode.window.activeNotebookEditor!.document.cells.indexOf(activeCell!), 0);
await vscode.commands.executeCommand('notebook.cell.moveDown');
await vscode.commands.executeCommand('notebook.cell.moveDown');
const newActiveCell = vscode.window.activeNotebookEditor!.selection;
assert.deepEqual(activeCell, newActiveCell);
assert.deepStrictEqual(activeCell, newActiveCell);
await saveFileAndCloseAll(resource);
// TODO@rebornix, there are still some events order issue.
// assert.equal(vscode.window.activeNotebookEditor!.document.cells.indexOf(newActiveCell!), 2);
// assert.strictEqual(vscode.window.activeNotebookEditor!.document.cells.indexOf(newActiveCell!), 2);
});
// test.only('document metadata is respected', async function () {
// const resource = await createRandomFile('', undefined, 'first', '.vsctestnb');
// await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest');
// assert.equal(vscode.window.activeNotebookEditor !== undefined, true, 'notebook first');
// assert.strictEqual(vscode.window.activeNotebookEditor !== undefined, true, 'notebook first');
// const editor = vscode.window.activeNotebookEditor!;
// assert.equal(editor.document.cells.length, 1);
// assert.strictEqual(editor.document.cells.length, 1);
// editor.document.metadata.editable = false;
// await editor.edit(builder => builder.delete(0));
// assert.equal(editor.document.cells.length, 1, 'should not delete cell'); // Not editable, no effect
// assert.strictEqual(editor.document.cells.length, 1, 'should not delete cell'); // Not editable, no effect
// await editor.edit(builder => builder.insert(0, 'test', 'python', vscode.CellKind.Code, [], undefined));
// assert.equal(editor.document.cells.length, 1, 'should not insert cell'); // Not editable, no effect
// assert.strictEqual(editor.document.cells.length, 1, 'should not insert cell'); // Not editable, no effect
// editor.document.metadata.editable = true;
// await editor.edit(builder => builder.delete(0));
// assert.equal(editor.document.cells.length, 0, 'should delete cell'); // Editable, it worked
// assert.strictEqual(editor.document.cells.length, 0, 'should delete cell'); // Editable, it worked
// await editor.edit(builder => builder.insert(0, 'test', 'python', vscode.CellKind.Code, [], undefined));
// assert.equal(editor.document.cells.length, 1, 'should insert cell'); // Editable, it worked
// assert.strictEqual(editor.document.cells.length, 1, 'should insert cell'); // Editable, it worked
// // await vscode.commands.executeCommand('workbench.action.files.save');
// await vscode.commands.executeCommand('workbench.action.closeActiveEditor');
@ -895,26 +895,26 @@ suite('notebook workflow', () => {
assertInitalState();
const resource = await createRandomFile('', undefined, 'first', '.vsctestnb');
await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest');
assert.equal(vscode.window.activeNotebookEditor !== undefined, true, 'notebook first');
assert.strictEqual(vscode.window.activeNotebookEditor !== undefined, true, 'notebook first');
const editor = vscode.window.activeNotebookEditor!;
await vscode.commands.executeCommand('notebook.focusTop');
const cell = editor.document.cells[0];
assert.equal(cell.outputs.length, 0);
assert.strictEqual(cell.outputs.length, 0);
let metadataChangeEvent = getEventOncePromise<vscode.NotebookCellMetadataChangeEvent>(vscode.notebook.onDidChangeCellMetadata);
await updateCellMetadata(resource, cell, { ...cell.metadata, runnable: false });
await metadataChangeEvent;
await vscode.commands.executeCommand('notebook.cell.execute');
assert.equal(cell.outputs.length, 0, 'should not execute'); // not runnable, didn't work
assert.strictEqual(cell.outputs.length, 0, 'should not execute'); // not runnable, didn't work
metadataChangeEvent = getEventOncePromise<vscode.NotebookCellMetadataChangeEvent>(vscode.notebook.onDidChangeCellMetadata);
await updateCellMetadata(resource, cell, { ...cell.metadata, runnable: true });
await metadataChangeEvent;
await vscode.commands.executeCommand('notebook.cell.execute');
assert.equal(cell.outputs.length, 1, 'should execute'); // runnable, it worked
assert.strictEqual(cell.outputs.length, 1, 'should execute'); // runnable, it worked
await vscode.commands.executeCommand('workbench.action.files.save');
await vscode.commands.executeCommand('workbench.action.closeActiveEditor');
@ -924,11 +924,11 @@ suite('notebook workflow', () => {
assertInitalState();
const resource = await createRandomFile('', undefined, 'first', '.vsctestnb');
await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest');
assert.equal(vscode.window.activeNotebookEditor !== undefined, true, 'notebook first');
assert.strictEqual(vscode.window.activeNotebookEditor !== undefined, true, 'notebook first');
const editor = vscode.window.activeNotebookEditor!;
const cell = editor.document.cells[0];
assert.equal(cell.outputs.length, 0);
assert.strictEqual(cell.outputs.length, 0);
await withEvent(vscode.notebook.onDidChangeNotebookDocumentMetadata, async event => {
editor.document.metadata.runnable = false;
@ -936,7 +936,7 @@ suite('notebook workflow', () => {
});
await vscode.commands.executeCommand('notebook.execute');
assert.equal(cell.outputs.length, 0, 'should not execute'); // not runnable, didn't work
assert.strictEqual(cell.outputs.length, 0, 'should not execute'); // not runnable, didn't work
await withEvent(vscode.notebook.onDidChangeNotebookDocumentMetadata, async event => {
editor.document.metadata.runnable = true;
@ -946,7 +946,7 @@ suite('notebook workflow', () => {
await withEvent<vscode.NotebookCellOutputsChangeEvent>(vscode.notebook.onDidChangeCellOutputs, async (event) => {
await vscode.commands.executeCommand('notebook.execute');
await event;
assert.equal(cell.outputs.length, 1, 'should execute'); // runnable, it worked
assert.strictEqual(cell.outputs.length, 1, 'should execute'); // runnable, it worked
});
await vscode.commands.executeCommand('workbench.action.files.save');
@ -959,12 +959,12 @@ suite('notebook workflow', () => {
assertInitalState();
const resource = await createRandomFile('', undefined, 'first', '.vsctestnb');
await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest');
assert.equal(vscode.window.activeNotebookEditor !== undefined, true, 'notebook first');
assert.strictEqual(vscode.window.activeNotebookEditor !== undefined, true, 'notebook first');
const editor = vscode.window.activeNotebookEditor!;
const cell = editor.document.cells[0];
await vscode.commands.executeCommand('notebook.execute');
assert.equal(cell.outputs.length, 0, 'should not execute'); // not runnable, didn't work
assert.strictEqual(cell.outputs.length, 0, 'should not execute'); // not runnable, didn't work
await vscode.commands.executeCommand('workbench.action.files.save');
await vscode.commands.executeCommand('workbench.action.closeActiveEditor');
@ -974,7 +974,7 @@ suite('notebook workflow', () => {
assertInitalState();
const resource = await createRandomFile('', undefined, 'first', '.vsctestnb');
await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest');
assert.equal(vscode.window.activeNotebookEditor !== undefined, true, 'notebook first');
assert.strictEqual(vscode.window.activeNotebookEditor !== undefined, true, 'notebook first');
const editor = vscode.window.activeNotebookEditor!;
const cell = editor.document.cells[0];
@ -986,13 +986,13 @@ suite('notebook workflow', () => {
await withEvent(vscode.notebook.onDidChangeCellOutputs, async (event) => {
await vscode.commands.executeCommand('notebook.execute');
await event;
assert.equal(cell.outputs.length, 1, 'should execute'); // runnable, it worked
assert.strictEqual(cell.outputs.length, 1, 'should execute'); // runnable, it worked
});
await withEvent(vscode.notebook.onDidChangeCellOutputs, async event => {
await vscode.commands.executeCommand('notebook.cell.clearOutputs');
await event;
assert.equal(cell.outputs.length, 0, 'should clear');
assert.strictEqual(cell.outputs.length, 0, 'should clear');
});
const secondResource = await createRandomFile('', undefined, 'second', '.vsctestnb');
@ -1001,8 +1001,8 @@ suite('notebook workflow', () => {
await withEvent<vscode.NotebookCellOutputsChangeEvent>(vscode.notebook.onDidChangeCellOutputs, async (event) => {
await vscode.commands.executeCommand('notebook.cell.execute', { start: 0, end: 1 }, resource);
await event;
assert.equal(cell.outputs.length, 1, 'should execute'); // runnable, it worked
assert.equal(vscode.window.activeNotebookEditor?.document.uri.fsPath, secondResource.fsPath);
assert.strictEqual(cell.outputs.length, 1, 'should execute'); // runnable, it worked
assert.strictEqual(vscode.window.activeNotebookEditor?.document.uri.fsPath, secondResource.fsPath);
});
await vscode.commands.executeCommand('workbench.action.files.save');
@ -1015,25 +1015,25 @@ suite('notebook workflow', () => {
assertInitalState();
const resource = await createRandomFile('', undefined, 'first', '.vsctestnb');
await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest');
assert.equal(vscode.window.activeNotebookEditor !== undefined, true, 'notebook first');
assert.strictEqual(vscode.window.activeNotebookEditor !== undefined, true, 'notebook first');
const editor = vscode.window.activeNotebookEditor!;
const cell = editor.document.cells[0];
const metadataChangeEvent = getEventOncePromise<vscode.NotebookDocumentMetadataChangeEvent>(vscode.notebook.onDidChangeNotebookDocumentMetadata);
editor.document.metadata.runnable = true;
await metadataChangeEvent;
assert.equal(editor.document.metadata.runnable, true);
assert.strictEqual(editor.document.metadata.runnable, true);
await withEvent<vscode.NotebookCellOutputsChangeEvent>(vscode.notebook.onDidChangeCellOutputs, async (event) => {
await vscode.commands.executeCommand('notebook.execute');
await event;
assert.equal(cell.outputs.length, 1, 'should execute'); // runnable, it worked
assert.strictEqual(cell.outputs.length, 1, 'should execute'); // runnable, it worked
});
const clearChangeEvent = getEventOncePromise<vscode.NotebookCellOutputsChangeEvent>(vscode.notebook.onDidChangeCellOutputs);
await vscode.commands.executeCommand('notebook.cell.clearOutputs');
await clearChangeEvent;
assert.equal(cell.outputs.length, 0, 'should clear');
assert.strictEqual(cell.outputs.length, 0, 'should clear');
const secondResource = await createRandomFile('', undefined, 'second', '.vsctestnb');
await vscode.commands.executeCommand('vscode.openWith', secondResource, 'notebookCoreTest');
@ -1041,8 +1041,8 @@ suite('notebook workflow', () => {
await withEvent<vscode.NotebookCellOutputsChangeEvent>(vscode.notebook.onDidChangeCellOutputs, async (event) => {
await vscode.commands.executeCommand('notebook.execute', resource);
await event;
assert.equal(cell.outputs.length, 1, 'should execute'); // runnable, it worked
assert.equal(vscode.window.activeNotebookEditor?.document.uri.fsPath, secondResource.fsPath);
assert.strictEqual(cell.outputs.length, 1, 'should execute'); // runnable, it worked
assert.strictEqual(vscode.window.activeNotebookEditor?.document.uri.fsPath, secondResource.fsPath);
});
await vscode.commands.executeCommand('workbench.action.files.save');
@ -1055,7 +1055,7 @@ suite('notebook workflow', () => {
assertInitalState();
const resource = await createRandomFile('', undefined, 'first', '.vsctestnb');
await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest');
assert.equal(vscode.window.activeNotebookEditor !== undefined, true, 'notebook first');
assert.strictEqual(vscode.window.activeNotebookEditor !== undefined, true, 'notebook first');
const editor = vscode.window.activeNotebookEditor!;
const cell = editor.document.cells[0];
@ -1064,17 +1064,17 @@ suite('notebook workflow', () => {
await metadataChangeEvent;
await vscode.commands.executeCommand('notebook.cell.execute');
assert.equal(cell.outputs.length, 1, 'should execute'); // runnable, it worked
assert.deepEqual((cell.outputs[0] as vscode.CellDisplayOutput).data, {
assert.strictEqual(cell.outputs.length, 1, 'should execute'); // runnable, it worked
assert.deepStrictEqual((cell.outputs[0] as vscode.CellDisplayOutput).data, {
'text/plain': [
'my output'
]
});
await vscode.commands.executeCommand('notebook.selectKernel', { extension: 'vscode.vscode-notebook-tests', id: 'secondaryKernel' })
await vscode.commands.executeCommand('notebook.selectKernel', { extension: 'vscode.vscode-notebook-tests', id: 'secondaryKernel' });
await vscode.commands.executeCommand('notebook.cell.execute');
assert.equal(cell.outputs.length, 1, 'should execute'); // runnable, it worked
assert.deepEqual((cell.outputs[0] as vscode.CellDisplayOutput).data, {
assert.strictEqual(cell.outputs.length, 1, 'should execute'); // runnable, it worked
assert.deepStrictEqual((cell.outputs[0] as vscode.CellDisplayOutput).data, {
'text/plain': [
'my second output'
]
@ -1089,29 +1089,29 @@ suite('notebook dirty state', () => {
assertInitalState();
const resource = await createRandomFile('', undefined, 'first', '.vsctestnb');
await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest');
assert.equal(vscode.window.activeNotebookEditor !== undefined, true, 'notebook first');
assert.equal(vscode.window.activeNotebookEditor!.selection?.document.getText(), 'test');
assert.equal(vscode.window.activeNotebookEditor!.selection?.language, 'typescript');
assert.strictEqual(vscode.window.activeNotebookEditor !== undefined, true, 'notebook first');
assert.strictEqual(vscode.window.activeNotebookEditor!.selection?.document.getText(), 'test');
assert.strictEqual(vscode.window.activeNotebookEditor!.selection?.language, 'typescript');
await vscode.commands.executeCommand('notebook.cell.insertCodeCellBelow');
assert.equal(vscode.window.activeNotebookEditor!.selection?.document.getText(), '');
assert.strictEqual(vscode.window.activeNotebookEditor!.selection?.document.getText(), '');
await vscode.commands.executeCommand('notebook.cell.insertCodeCellAbove');
const activeCell = vscode.window.activeNotebookEditor!.selection;
assert.notEqual(vscode.window.activeNotebookEditor!.selection, undefined);
assert.equal(activeCell!.document.getText(), '');
assert.equal(vscode.window.activeNotebookEditor!.document.cells.length, 3);
assert.equal(vscode.window.activeNotebookEditor!.document.cells.indexOf(activeCell!), 1);
assert.notStrictEqual(vscode.window.activeNotebookEditor!.selection, undefined);
assert.strictEqual(activeCell!.document.getText(), '');
assert.strictEqual(vscode.window.activeNotebookEditor!.document.cells.length, 3);
assert.strictEqual(vscode.window.activeNotebookEditor!.document.cells.indexOf(activeCell!), 1);
await withEvent(vscode.workspace.onDidChangeTextDocument, async event => {
const edit = new vscode.WorkspaceEdit();
edit.insert(activeCell!.uri, new vscode.Position(0, 0), 'var abc = 0;');
await vscode.workspace.applyEdit(edit);
await event;
assert.equal(vscode.window.activeNotebookEditor !== undefined, true);
assert.equal(vscode.window.activeNotebookEditor?.selection !== undefined, true);
assert.deepEqual(vscode.window.activeNotebookEditor?.document.cells[1], vscode.window.activeNotebookEditor?.selection);
assert.equal(vscode.window.activeNotebookEditor?.selection?.document.getText(), 'var abc = 0;');
assert.strictEqual(vscode.window.activeNotebookEditor !== undefined, true);
assert.strictEqual(vscode.window.activeNotebookEditor?.selection !== undefined, true);
assert.deepStrictEqual(vscode.window.activeNotebookEditor?.document.cells[1], vscode.window.activeNotebookEditor?.selection);
assert.strictEqual(vscode.window.activeNotebookEditor?.selection?.document.getText(), 'var abc = 0;');
});
await saveFileAndCloseAll(resource);
@ -1123,19 +1123,19 @@ suite('notebook undo redo', () => {
assertInitalState();
const resource = await createRandomFile('', undefined, 'first', '.vsctestnb');
await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest');
assert.equal(vscode.window.activeNotebookEditor !== undefined, true, 'notebook first');
assert.equal(vscode.window.activeNotebookEditor!.selection?.document.getText(), 'test');
assert.equal(vscode.window.activeNotebookEditor!.selection?.language, 'typescript');
assert.strictEqual(vscode.window.activeNotebookEditor !== undefined, true, 'notebook first');
assert.strictEqual(vscode.window.activeNotebookEditor!.selection?.document.getText(), 'test');
assert.strictEqual(vscode.window.activeNotebookEditor!.selection?.language, 'typescript');
await vscode.commands.executeCommand('notebook.cell.insertCodeCellBelow');
assert.equal(vscode.window.activeNotebookEditor!.selection?.document.getText(), '');
assert.strictEqual(vscode.window.activeNotebookEditor!.selection?.document.getText(), '');
await vscode.commands.executeCommand('notebook.cell.insertCodeCellAbove');
const activeCell = vscode.window.activeNotebookEditor!.selection;
assert.notEqual(vscode.window.activeNotebookEditor!.selection, undefined);
assert.equal(activeCell!.document.getText(), '');
assert.equal(vscode.window.activeNotebookEditor!.document.cells.length, 3);
assert.equal(vscode.window.activeNotebookEditor!.document.cells.indexOf(activeCell!), 1);
assert.notStrictEqual(vscode.window.activeNotebookEditor!.selection, undefined);
assert.strictEqual(activeCell!.document.getText(), '');
assert.strictEqual(vscode.window.activeNotebookEditor!.document.cells.length, 3);
assert.strictEqual(vscode.window.activeNotebookEditor!.document.cells.indexOf(activeCell!), 1);
// modify the second cell, delete it
@ -1143,21 +1143,21 @@ suite('notebook undo redo', () => {
edit.insert(vscode.window.activeNotebookEditor!.selection!.uri, new vscode.Position(0, 0), 'var abc = 0;');
await vscode.workspace.applyEdit(edit);
await vscode.commands.executeCommand('notebook.cell.delete');
assert.equal(vscode.window.activeNotebookEditor!.document.cells.length, 2);
assert.equal(vscode.window.activeNotebookEditor!.document.cells.indexOf(vscode.window.activeNotebookEditor!.selection!), 1);
assert.strictEqual(vscode.window.activeNotebookEditor!.document.cells.length, 2);
assert.strictEqual(vscode.window.activeNotebookEditor!.document.cells.indexOf(vscode.window.activeNotebookEditor!.selection!), 1);
// undo should bring back the deleted cell, and revert to previous content and selection
await vscode.commands.executeCommand('undo');
assert.equal(vscode.window.activeNotebookEditor!.document.cells.length, 3);
assert.equal(vscode.window.activeNotebookEditor!.document.cells.indexOf(vscode.window.activeNotebookEditor!.selection!), 1);
assert.equal(vscode.window.activeNotebookEditor?.selection?.document.getText(), 'var abc = 0;');
assert.strictEqual(vscode.window.activeNotebookEditor!.document.cells.length, 3);
assert.strictEqual(vscode.window.activeNotebookEditor!.document.cells.indexOf(vscode.window.activeNotebookEditor!.selection!), 1);
assert.strictEqual(vscode.window.activeNotebookEditor?.selection?.document.getText(), 'var abc = 0;');
// redo
// await vscode.commands.executeCommand('notebook.redo');
// assert.equal(vscode.window.activeNotebookEditor!.document.cells.length, 2);
// assert.equal(vscode.window.activeNotebookEditor!.document.cells.indexOf(vscode.window.activeNotebookEditor!.selection!), 1);
// assert.equal(vscode.window.activeNotebookEditor?.selection?.document.getText(), 'test');
// assert.strictEqual(vscode.window.activeNotebookEditor!.document.cells.length, 2);
// assert.strictEqual(vscode.window.activeNotebookEditor!.document.cells.indexOf(vscode.window.activeNotebookEditor!.selection!), 1);
// assert.strictEqual(vscode.window.activeNotebookEditor?.selection?.document.getText(), 'test');
await saveFileAndCloseAll(resource);
});
@ -1170,9 +1170,9 @@ suite('notebook undo redo', () => {
const cellsChangeEvent = getEventOncePromise<vscode.NotebookCellsChangeEvent>(vscode.notebook.onDidChangeNotebookCells);
await vscode.commands.executeCommand('notebook.cell.insertCodeCellBelow');
const cellChangeEventRet = await cellsChangeEvent;
assert.equal(cellChangeEventRet.document, vscode.window.activeNotebookEditor?.document);
assert.equal(cellChangeEventRet.changes.length, 1);
assert.deepEqual(cellChangeEventRet.changes[0], {
assert.strictEqual(cellChangeEventRet.document, vscode.window.activeNotebookEditor?.document);
assert.strictEqual(cellChangeEventRet.changes.length, 1);
assert.deepStrictEqual(cellChangeEventRet.changes[0], {
start: 1,
deletedCount: 0,
deletedItems: [],
@ -1186,7 +1186,7 @@ suite('notebook undo redo', () => {
const moveCellEvent = getEventOncePromise<vscode.NotebookCellsChangeEvent>(vscode.notebook.onDidChangeNotebookCells);
await vscode.commands.executeCommand('notebook.cell.moveUp');
const moveCellEventRet = await moveCellEvent;
assert.deepEqual(moveCellEventRet, {
assert.deepStrictEqual(moveCellEventRet, {
document: vscode.window.activeNotebookEditor!.document,
changes: [
{
@ -1207,20 +1207,20 @@ suite('notebook undo redo', () => {
const cellOutputChange = getEventOncePromise<vscode.NotebookCellOutputsChangeEvent>(vscode.notebook.onDidChangeCellOutputs);
await vscode.commands.executeCommand('notebook.cell.execute');
const cellOutputsAddedRet = await cellOutputChange;
assert.deepEqual(cellOutputsAddedRet, {
assert.deepStrictEqual(cellOutputsAddedRet, {
document: vscode.window.activeNotebookEditor!.document,
cells: [vscode.window.activeNotebookEditor!.document.cells[0]]
});
assert.equal(cellOutputsAddedRet.cells[0].outputs.length, 1);
assert.strictEqual(cellOutputsAddedRet.cells[0].outputs.length, 1);
const cellOutputClear = getEventOncePromise<vscode.NotebookCellOutputsChangeEvent>(vscode.notebook.onDidChangeCellOutputs);
await vscode.commands.executeCommand('undo');
const cellOutputsCleardRet = await cellOutputClear;
assert.deepEqual(cellOutputsCleardRet, {
assert.deepStrictEqual(cellOutputsCleardRet, {
document: vscode.window.activeNotebookEditor!.document,
cells: [vscode.window.activeNotebookEditor!.document.cells[0]]
});
assert.equal(cellOutputsAddedRet.cells[0].outputs.length, 0);
assert.strictEqual(cellOutputsAddedRet.cells[0].outputs.length, 0);
await saveFileAndCloseAll(resource);
});
@ -1232,7 +1232,7 @@ suite('notebook working copy', () => {
// const resource = await createRandomFile('', undefined, 'first', '.vsctestnb');
// await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest');
// await vscode.commands.executeCommand('notebook.cell.insertCodeCellBelow');
// assert.equal(vscode.window.activeNotebookEditor!.selection?.document.getText(), '');
// assert.strictEqual(vscode.window.activeNotebookEditor!.selection?.document.getText(), '');
// await vscode.commands.executeCommand('notebook.cell.insertCodeCellAbove');
// await vscode.commands.executeCommand('default:type', { text: 'var abc = 0;' });
@ -1240,10 +1240,10 @@ suite('notebook working copy', () => {
// // close active editor from command will revert the file
// await vscode.commands.executeCommand('workbench.action.closeActiveEditor');
// await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest');
// assert.equal(vscode.window.activeNotebookEditor !== undefined, true);
// assert.equal(vscode.window.activeNotebookEditor?.selection !== undefined, true);
// assert.deepEqual(vscode.window.activeNotebookEditor?.document.cells[0], vscode.window.activeNotebookEditor?.selection);
// assert.equal(vscode.window.activeNotebookEditor?.selection?.document.getText(), 'test');
// assert.strictEqual(vscode.window.activeNotebookEditor !== undefined, true);
// assert.strictEqual(vscode.window.activeNotebookEditor?.selection !== undefined, true);
// assert.deepStrictEqual(vscode.window.activeNotebookEditor?.document.cells[0], vscode.window.activeNotebookEditor?.selection);
// assert.strictEqual(vscode.window.activeNotebookEditor?.selection?.document.getText(), 'test');
// await vscode.commands.executeCommand('workbench.action.files.save');
// await vscode.commands.executeCommand('workbench.action.closeActiveEditor');
@ -1253,17 +1253,17 @@ suite('notebook working copy', () => {
// const resource = await createRandomFile('', undefined, 'first', '.vsctestnb');
// await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest');
// await vscode.commands.executeCommand('notebook.cell.insertCodeCellBelow');
// assert.equal(vscode.window.activeNotebookEditor!.selection?.document.getText(), '');
// assert.strictEqual(vscode.window.activeNotebookEditor!.selection?.document.getText(), '');
// await vscode.commands.executeCommand('notebook.cell.insertCodeCellAbove');
// await vscode.commands.executeCommand('default:type', { text: 'var abc = 0;' });
// await vscode.commands.executeCommand('workbench.action.files.revert');
// assert.equal(vscode.window.activeNotebookEditor !== undefined, true);
// assert.equal(vscode.window.activeNotebookEditor?.selection !== undefined, true);
// assert.deepEqual(vscode.window.activeNotebookEditor?.document.cells[0], vscode.window.activeNotebookEditor?.selection);
// assert.deepEqual(vscode.window.activeNotebookEditor?.document.cells.length, 1);
// assert.equal(vscode.window.activeNotebookEditor?.selection?.document.getText(), 'test');
// assert.strictEqual(vscode.window.activeNotebookEditor !== undefined, true);
// assert.strictEqual(vscode.window.activeNotebookEditor?.selection !== undefined, true);
// assert.deepStrictEqual(vscode.window.activeNotebookEditor?.document.cells[0], vscode.window.activeNotebookEditor?.selection);
// assert.deepStrictEqual(vscode.window.activeNotebookEditor?.document.cells.length, 1);
// assert.strictEqual(vscode.window.activeNotebookEditor?.selection?.document.getText(), 'test');
// await vscode.commands.executeCommand('workbench.action.files.saveAll');
// await vscode.commands.executeCommand('workbench.action.closeAllEditors');
@ -1274,7 +1274,7 @@ suite('notebook working copy', () => {
const resource = await createRandomFile('', undefined, 'first', '.vsctestnb');
await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest');
await vscode.commands.executeCommand('notebook.cell.insertCodeCellBelow');
assert.equal(vscode.window.activeNotebookEditor!.selection?.document.getText(), '');
assert.strictEqual(vscode.window.activeNotebookEditor!.selection?.document.getText(), '');
await vscode.commands.executeCommand('notebook.cell.insertCodeCellAbove');
const edit = new vscode.WorkspaceEdit();
@ -1286,11 +1286,11 @@ suite('notebook working copy', () => {
await vscode.commands.executeCommand('workbench.action.closeActiveEditor');
// make sure that the previous dirty editor is still restored in the extension host and no data loss
assert.equal(vscode.window.activeNotebookEditor !== undefined, true);
assert.equal(vscode.window.activeNotebookEditor?.selection !== undefined, true);
assert.deepEqual(vscode.window.activeNotebookEditor?.document.cells[1], vscode.window.activeNotebookEditor?.selection);
assert.deepEqual(vscode.window.activeNotebookEditor?.document.cells.length, 3);
assert.equal(vscode.window.activeNotebookEditor?.selection?.document.getText(), 'var abc = 0;');
assert.strictEqual(vscode.window.activeNotebookEditor !== undefined, true);
assert.strictEqual(vscode.window.activeNotebookEditor?.selection !== undefined, true);
assert.deepStrictEqual(vscode.window.activeNotebookEditor?.document.cells[1], vscode.window.activeNotebookEditor?.selection);
assert.deepStrictEqual(vscode.window.activeNotebookEditor?.document.cells.length, 3);
assert.strictEqual(vscode.window.activeNotebookEditor?.selection?.document.getText(), 'var abc = 0;');
await saveFileAndCloseAll(resource);
});
@ -1300,7 +1300,7 @@ suite('notebook working copy', () => {
const resource = await createRandomFile('', undefined, 'first', '.vsctestnb');
await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest');
await vscode.commands.executeCommand('notebook.cell.insertCodeCellBelow');
assert.equal(vscode.window.activeNotebookEditor!.selection?.document.getText(), '');
assert.strictEqual(vscode.window.activeNotebookEditor!.selection?.document.getText(), '');
await vscode.commands.executeCommand('notebook.cell.insertCodeCellAbove');
const edit = new vscode.WorkspaceEdit();
@ -1310,23 +1310,23 @@ suite('notebook working copy', () => {
const secondResource = await createRandomFile('', undefined, 'second', '.vsctestnb');
await vscode.commands.executeCommand('vscode.openWith', secondResource, 'notebookCoreTest');
await vscode.commands.executeCommand('notebook.cell.insertCodeCellBelow');
assert.equal(vscode.window.activeNotebookEditor!.selection?.document.getText(), '');
assert.strictEqual(vscode.window.activeNotebookEditor!.selection?.document.getText(), '');
// switch to the first editor
await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest');
assert.equal(vscode.window.activeNotebookEditor !== undefined, true);
assert.equal(vscode.window.activeNotebookEditor?.selection !== undefined, true);
assert.deepEqual(vscode.window.activeNotebookEditor?.document.cells[1], vscode.window.activeNotebookEditor?.selection);
assert.deepEqual(vscode.window.activeNotebookEditor?.document.cells.length, 3);
assert.equal(vscode.window.activeNotebookEditor?.selection?.document.getText(), 'var abc = 0;');
assert.strictEqual(vscode.window.activeNotebookEditor !== undefined, true);
assert.strictEqual(vscode.window.activeNotebookEditor?.selection !== undefined, true);
assert.deepStrictEqual(vscode.window.activeNotebookEditor?.document.cells[1], vscode.window.activeNotebookEditor?.selection);
assert.deepStrictEqual(vscode.window.activeNotebookEditor?.document.cells.length, 3);
assert.strictEqual(vscode.window.activeNotebookEditor?.selection?.document.getText(), 'var abc = 0;');
// switch to the second editor
await vscode.commands.executeCommand('vscode.openWith', secondResource, 'notebookCoreTest');
assert.equal(vscode.window.activeNotebookEditor !== undefined, true);
assert.equal(vscode.window.activeNotebookEditor?.selection !== undefined, true);
assert.deepEqual(vscode.window.activeNotebookEditor?.document.cells[1], vscode.window.activeNotebookEditor?.selection);
assert.deepEqual(vscode.window.activeNotebookEditor?.document.cells.length, 2);
assert.equal(vscode.window.activeNotebookEditor?.selection?.document.getText(), '');
assert.strictEqual(vscode.window.activeNotebookEditor !== undefined, true);
assert.strictEqual(vscode.window.activeNotebookEditor?.selection !== undefined, true);
assert.deepStrictEqual(vscode.window.activeNotebookEditor?.document.cells[1], vscode.window.activeNotebookEditor?.selection);
assert.deepStrictEqual(vscode.window.activeNotebookEditor?.document.cells.length, 2);
assert.strictEqual(vscode.window.activeNotebookEditor?.selection?.document.getText(), '');
await saveAllFilesAndCloseAll(secondResource);
// await vscode.commands.executeCommand('workbench.action.files.saveAll');
@ -1339,18 +1339,18 @@ suite('notebook working copy', () => {
const resource = await createRandomFile('', undefined, 'first', '.vsctestnb');
await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest');
const firstNotebookEditor = vscode.window.activeNotebookEditor;
assert.equal(firstNotebookEditor !== undefined, true, 'notebook first');
assert.equal(firstNotebookEditor!.selection?.document.getText(), 'test');
assert.equal(firstNotebookEditor!.selection?.language, 'typescript');
assert.strictEqual(firstNotebookEditor !== undefined, true, 'notebook first');
assert.strictEqual(firstNotebookEditor!.selection?.document.getText(), 'test');
assert.strictEqual(firstNotebookEditor!.selection?.language, 'typescript');
await splitEditor();
const secondNotebookEditor = vscode.window.activeNotebookEditor;
assert.equal(secondNotebookEditor !== undefined, true, 'notebook first');
assert.equal(secondNotebookEditor!.selection?.document.getText(), 'test');
assert.equal(secondNotebookEditor!.selection?.language, 'typescript');
assert.strictEqual(secondNotebookEditor !== undefined, true, 'notebook first');
assert.strictEqual(secondNotebookEditor!.selection?.document.getText(), 'test');
assert.strictEqual(secondNotebookEditor!.selection?.language, 'typescript');
assert.notEqual(firstNotebookEditor, secondNotebookEditor);
assert.equal(firstNotebookEditor?.document, secondNotebookEditor?.document, 'split notebook editors share the same document');
assert.strictEqual(firstNotebookEditor?.document, secondNotebookEditor?.document, 'split notebook editors share the same document');
// assert.notEqual(firstNotebookEditor?.asWebviewUri(vscode.Uri.file('./hello.png')), secondNotebookEditor?.asWebviewUri(vscode.Uri.file('./hello.png')));
await saveAllFilesAndCloseAll(resource);
@ -1365,10 +1365,10 @@ suite('metadata', () => {
assertInitalState();
const resource = await createRandomFile('', undefined, 'first', '.vsctestnb');
await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest');
assert.equal(vscode.window.activeNotebookEditor !== undefined, true, 'notebook first');
assert.equal(vscode.window.activeNotebookEditor!.document.metadata.custom!['testMetadata'] as boolean, false);
assert.equal(vscode.window.activeNotebookEditor!.selection?.metadata.custom!['testCellMetadata'] as number, 123);
assert.equal(vscode.window.activeNotebookEditor!.selection?.language, 'typescript');
assert.strictEqual(vscode.window.activeNotebookEditor !== undefined, true, 'notebook first');
assert.strictEqual(vscode.window.activeNotebookEditor!.document.metadata.custom!['testMetadata'] as boolean, false);
assert.strictEqual(vscode.window.activeNotebookEditor!.selection?.metadata.custom!['testCellMetadata'] as number, 123);
assert.strictEqual(vscode.window.activeNotebookEditor!.selection?.language, 'typescript');
await saveFileAndCloseAll(resource);
});
@ -1379,16 +1379,16 @@ suite('metadata', () => {
assertInitalState();
const resource = await createRandomFile('', undefined, 'first', '.vsctestnb');
await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest');
assert.equal(vscode.window.activeNotebookEditor !== undefined, true, 'notebook first');
assert.equal(vscode.window.activeNotebookEditor!.document.metadata.custom!['testMetadata'] as boolean, false);
assert.equal(vscode.window.activeNotebookEditor!.selection?.metadata.custom!['testCellMetadata'] as number, 123);
assert.equal(vscode.window.activeNotebookEditor!.selection?.language, 'typescript');
assert.strictEqual(vscode.window.activeNotebookEditor !== undefined, true, 'notebook first');
assert.strictEqual(vscode.window.activeNotebookEditor!.document.metadata.custom!['testMetadata'] as boolean, false);
assert.strictEqual(vscode.window.activeNotebookEditor!.selection?.metadata.custom!['testCellMetadata'] as number, 123);
assert.strictEqual(vscode.window.activeNotebookEditor!.selection?.language, 'typescript');
// TODO see #101462
// await vscode.commands.executeCommand('notebook.cell.copyDown');
// const activeCell = vscode.window.activeNotebookEditor!.selection;
// assert.equal(vscode.window.activeNotebookEditor!.document.cells.indexOf(activeCell!), 1);
// assert.equal(activeCell?.metadata.custom!['testCellMetadata'] as number, 123);
// assert.strictEqual(vscode.window.activeNotebookEditor!.document.cells.indexOf(activeCell!), 1);
// assert.strictEqual(activeCell?.metadata.custom!['testCellMetadata'] as number, 123);
await saveFileAndCloseAll(resource);
});
@ -1398,9 +1398,9 @@ suite('regression', () => {
// test('microsoft/vscode-github-issue-notebooks#26. Insert template cell in the new empty document', async function () {
// assertInitalState();
// await vscode.commands.executeCommand('workbench.action.files.newUntitledFile', { "viewType": "notebookCoreTest" });
// assert.equal(vscode.window.activeNotebookEditor !== undefined, true, 'notebook first');
// assert.equal(vscode.window.activeNotebookEditor!.selection?.document.getText(), '');
// assert.equal(vscode.window.activeNotebookEditor!.selection?.language, 'typescript');
// assert.strictEqual(vscode.window.activeNotebookEditor !== undefined, true, 'notebook first');
// assert.strictEqual(vscode.window.activeNotebookEditor!.selection?.document.getText(), '');
// assert.strictEqual(vscode.window.activeNotebookEditor!.selection?.language, 'typescript');
// await vscode.commands.executeCommand('workbench.action.closeAllEditors');
// });
@ -1449,12 +1449,12 @@ suite('regression', () => {
edit.insert(vscode.window.activeNotebookEditor!.selection!.uri, new vscode.Position(0, 0), 'var abc = 0;');
await vscode.workspace.applyEdit(edit);
assert.equal(vscode.window.activeNotebookEditor !== undefined, true, 'notebook first');
assert.equal(vscode.window.activeNotebookEditor!.selection?.document.getText(), 'var abc = 0;');
assert.equal(vscode.window.activeNotebookEditor!.selection?.language, 'typescript');
assert.strictEqual(vscode.window.activeNotebookEditor !== undefined, true, 'notebook first');
assert.strictEqual(vscode.window.activeNotebookEditor!.selection?.document.getText(), 'var abc = 0;');
assert.strictEqual(vscode.window.activeNotebookEditor!.selection?.language, 'typescript');
await vscode.commands.executeCommand('vscode.openWith', resource, 'default');
assert.equal(vscode.window.activeTextEditor?.document.uri.path, resource.path);
assert.strictEqual(vscode.window.activeTextEditor?.document.uri.path, resource.path);
await vscode.commands.executeCommand('workbench.action.closeAllEditors');
});
@ -1490,19 +1490,19 @@ suite('regression', () => {
await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest');
let activeCell = vscode.window.activeNotebookEditor!.selection;
assert.equal(activeCell?.document.getText(), 'test');
assert.strictEqual(activeCell?.document.getText(), 'test');
await vscode.commands.executeCommand('notebook.cell.copyDown');
await vscode.commands.executeCommand('notebook.cell.edit');
activeCell = vscode.window.activeNotebookEditor!.selection;
assert.equal(vscode.window.activeNotebookEditor!.document.cells.indexOf(activeCell!), 1);
assert.equal(activeCell?.document.getText(), 'test');
assert.strictEqual(vscode.window.activeNotebookEditor!.document.cells.indexOf(activeCell!), 1);
assert.strictEqual(activeCell?.document.getText(), 'test');
const edit = new vscode.WorkspaceEdit();
edit.insert(vscode.window.activeNotebookEditor!.selection!.uri, new vscode.Position(0, 0), 'var abc = 0;');
await vscode.workspace.applyEdit(edit);
assert.equal(vscode.window.activeNotebookEditor!.document.cells.length, 2);
assert.strictEqual(vscode.window.activeNotebookEditor!.document.cells.length, 2);
assert.notEqual(vscode.window.activeNotebookEditor!.document.cells[0].document.getText(), vscode.window.activeNotebookEditor!.document.cells[1].document.getText());
await vscode.commands.executeCommand('workbench.action.closeAllEditors');
@ -1518,9 +1518,9 @@ suite('webview', () => {
// const resource = await createRandomFile('', undefined, 'first', '.vsctestnb');
// await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest');
// assert.equal(vscode.window.activeNotebookEditor !== undefined, true, 'notebook first');
// assert.strictEqual(vscode.window.activeNotebookEditor !== undefined, true, 'notebook first');
// const uri = vscode.window.activeNotebookEditor!.asWebviewUri(vscode.Uri.file('./hello.png'));
// assert.equal(uri.scheme, 'vscode-webview-resource');
// assert.strictEqual(uri.scheme, 'vscode-webview-resource');
// await vscode.commands.executeCommand('workbench.action.closeAllEditors');
// });