mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-21 00:59:03 +01:00
Add test for scrolling
This commit is contained in:
@@ -24,6 +24,22 @@ async function createInteractiveWindow(kernel: Kernel) {
|
||||
return notebookEditor;
|
||||
}
|
||||
|
||||
async function addCell(code: string, notebook: vscode.NotebookDocument) {
|
||||
const cell = new vscode.NotebookCellData(vscode.NotebookCellKind.Code, code, 'typescript');
|
||||
const edit = vscode.NotebookEdit.insertCells(notebook.cellCount, [cell]);
|
||||
const workspaceEdit = new vscode.WorkspaceEdit();
|
||||
workspaceEdit.set(notebook.uri, [edit]);
|
||||
await vscode.workspace.applyEdit(workspaceEdit);
|
||||
return notebook.cellAt(notebook.cellCount - 1);
|
||||
}
|
||||
|
||||
async function addCellAndRun(code: string, notebook: vscode.NotebookDocument) {
|
||||
const cell = await addCell(code, notebook);
|
||||
await vscode.commands.executeCommand('notebook.execute');
|
||||
assert.strictEqual(cell.outputs.length, 1, 'execute failed');
|
||||
return cell;
|
||||
}
|
||||
|
||||
|
||||
(vscode.env.uiKind === vscode.UIKind.Web ? suite.skip : suite)('Interactive Window', function () {
|
||||
|
||||
@@ -49,17 +65,24 @@ async function createInteractiveWindow(kernel: Kernel) {
|
||||
assert.ok(notebookEditor);
|
||||
|
||||
// Try adding a cell and running it.
|
||||
const cell = new vscode.NotebookCellData(vscode.NotebookCellKind.Code, 'print foo', 'typescript');
|
||||
const edit = vscode.NotebookEdit.insertCells(0, [cell]);
|
||||
const workspaceEdit = new vscode.WorkspaceEdit();
|
||||
workspaceEdit.set(notebookEditor.notebook.uri, [edit]);
|
||||
await vscode.workspace.applyEdit(workspaceEdit);
|
||||
await addCell('print foo', notebookEditor.notebook);
|
||||
|
||||
assert.strictEqual(notebookEditor.notebook.cellCount, 1);
|
||||
assert.strictEqual(notebookEditor.notebook.cellAt(0).kind, vscode.NotebookCellKind.Code);
|
||||
});
|
||||
|
||||
await vscode.commands.executeCommand('notebook.execute');
|
||||
assert.strictEqual(notebookEditor.notebook.cellAt(0).outputs.length, 1, 'should execute');
|
||||
test('Interactive window scrolls after execute', async () => {
|
||||
assert.ok(vscode.workspace.workspaceFolders);
|
||||
const notebookEditor = await createInteractiveWindow(defaultKernel);
|
||||
assert.ok(notebookEditor);
|
||||
|
||||
// Run and add a bunch of cells
|
||||
for (let i = 0; i < 20; i++) {
|
||||
await addCellAndRun(`print ${i}`, notebookEditor.notebook);
|
||||
}
|
||||
|
||||
// Verify visible range has the last cell
|
||||
assert.strictEqual(notebookEditor.visibleRanges[notebookEditor.visibleRanges.length - 1].end, notebookEditor.notebook.cellCount, `Last cell is not visible`);
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user