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

Remove move cell integration test #156825

Merged
merged 3 commits into from Aug 1, 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 @@ -212,9 +212,9 @@ const apiTestContentProvider: vscode.NotebookContentProvider = {
addedCells: [editor.notebook.cellAt(1)]
});

const moveCellEvent = asPromise<vscode.NotebookDocumentChangeEvent>(vscode.workspace.onDidChangeNotebookDocument);
await vscode.commands.executeCommand('notebook.cell.moveUp');
await moveCellEvent;
// const moveCellEvent = asPromise<vscode.NotebookDocumentChangeEvent>(vscode.workspace.onDidChangeNotebookDocument);
// await vscode.commands.executeCommand('notebook.cell.moveUp');
// await moveCellEvent;

const cellOutputChange = asPromise<vscode.NotebookDocumentChangeEvent>(vscode.workspace.onDidChangeNotebookDocument);
await vscode.commands.executeCommand('notebook.cell.execute');
Expand Down Expand Up @@ -395,57 +395,10 @@ const apiTestContentProvider: vscode.NotebookContentProvider = {
activeCell = getFocusedCell(editor);
assert.strictEqual(editor.notebook.getCells().indexOf(activeCell!), 0);


// ---- move up and down ---- //

await vscode.commands.executeCommand('notebook.cell.moveDown');
assert.strictEqual(editor.notebook.getCells().indexOf(getFocusedCell(editor)!), 1,
`first move down, active cell ${getFocusedCell(editor)!.document.uri.toString()}, ${getFocusedCell(editor)!.document.getText()}`);

await vscode.commands.executeCommand('workbench.action.files.save');
await vscode.commands.executeCommand('workbench.action.closeActiveEditor');
});

test('editor move command - event and move cells will not recreate cells in ExtHost (#98126)', async function () {
const notebook = await openRandomNotebookDocument();
const editor = await vscode.window.showNotebookDocument(notebook);

const activeCell = getFocusedCell(editor);
assert.strictEqual(activeCell?.index, 0);
const notebookChangeEvent = asPromise(vscode.workspace.onDidChangeNotebookDocument);
await vscode.commands.executeCommand('notebook.cell.moveDown');
assert.ok(await notebookChangeEvent);

const newActiveCell = getFocusedCell(editor);
assert.strictEqual(newActiveCell?.index, 1);
assert.deepStrictEqual(activeCell, newActiveCell);
});

// test('document runnable based on kernel count', async () => {
// const resource = await createRandomNotebookFile();
// await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest');
// assert.strictEqual(vscode.window.activeNotebookEditor !== undefined, true, 'notebook first');
// const editor = vscode.window.activeNotebookEditor!;

// const cell = editor.notebook.cellAt(0);
// assert.strictEqual(cell.outputs.length, 0);

// currentKernelProvider.setHasKernels(false);
// await vscode.commands.executeCommand('notebook.execute');
// assert.strictEqual(cell.outputs.length, 0, 'should not execute'); // not runnable, didn't work

// currentKernelProvider.setHasKernels(true);

// await withEvent<vscode.NotebookCellOutputsChangeEvent>(vscode.notebooks.onDidChangeCellOutputs, async (event) => {
// await vscode.commands.executeCommand('notebook.execute');
// await event;
// assert.strictEqual(cell.outputs.length, 1, 'should execute'); // runnable, it worked
// });

// await saveAllFilesAndCloseAll(undefined);
// });


// TODO@rebornix this is wrong, `await vscode.commands.executeCommand('notebook.execute');` doesn't wait until the workspace edit is applied
test.skip('cell execute command takes arguments', async () => {
const resource = await createRandomNotebookFile();
Expand Down
Expand Up @@ -24,8 +24,11 @@ suite('CellOperations', () => {
],
async (editor, viewModel) => {
viewModel.updateSelectionsState({ kind: SelectionStateType.Index, focus: { start: 1, end: 2 }, selections: [{ start: 1, end: 2 }] });
await moveCellRange({ notebookEditor: editor, cell: viewModel.cellAt(1)! }, 'down');
const cell = viewModel.cellAt(1);
assert.ok(cell);
await moveCellRange({ notebookEditor: editor, cell: cell }, 'down');
assert.strictEqual(viewModel.cellAt(2)?.getText(), 'var b = 1;');
assert.strictEqual(cell, viewModel.cellAt(2));
});
});

Expand Down