mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-30 05:21:08 +01:00
poll for change to allow async update (#265724)
* poll for change to allow async update * import poll
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
import * as assert from 'assert';
|
||||
import 'mocha';
|
||||
import * as vscode from 'vscode';
|
||||
import { asPromise, disposeAll } from '../utils';
|
||||
import { asPromise, disposeAll, poll } from '../utils';
|
||||
import { Kernel, saveAllFilesAndCloseAll } from './notebook.api.test';
|
||||
|
||||
export type INativeInteractiveWindow = { notebookUri: vscode.Uri; inputUri: vscode.Uri; notebookEditor: vscode.NotebookEditor };
|
||||
@@ -108,7 +108,9 @@ async function addCellAndRun(code: string, notebook: vscode.NotebookDocument) {
|
||||
}
|
||||
});
|
||||
|
||||
test('Interactive window has the correct kernel', async () => {
|
||||
test('Interactive window has the correct kernel', async function () {
|
||||
// Extend timeout a bit as kernel association can be async & occasionally slow on CI
|
||||
this.timeout(20000);
|
||||
assert.ok(vscode.workspace.workspaceFolders);
|
||||
await createInteractiveWindow(defaultKernel);
|
||||
|
||||
@@ -118,11 +120,15 @@ async function addCellAndRun(code: string, notebook: vscode.NotebookDocument) {
|
||||
const { notebookEditor } = await createInteractiveWindow(secondKernel);
|
||||
assert.ok(notebookEditor);
|
||||
|
||||
// Verify the kernel is the secondary one
|
||||
// Run a cell to ensure the kernel is actually exercised
|
||||
await addCellAndRun(`print`, notebookEditor.notebook);
|
||||
|
||||
await poll(
|
||||
() => Promise.resolve(secondKernel.associatedNotebooks.has(notebookEditor.notebook.uri.toString())),
|
||||
v => v,
|
||||
'Secondary kernel was not set as the kernel for the interactive window'
|
||||
);
|
||||
assert.strictEqual(secondKernel.associatedNotebooks.has(notebookEditor.notebook.uri.toString()), true, `Secondary kernel was not set as the kernel for the interactive window`);
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user