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

notebook tests - run verbose (#165149) #167212

Merged
merged 4 commits into from
Nov 26, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import * as assert from 'assert';
import * as vscode from 'vscode';
import * as utils from '../utils';

(vscode.env.uiKind === vscode.UIKind.Web ? suite.skip : suite.skip)('Notebook Editor', function () {
(vscode.env.uiKind === vscode.UIKind.Web ? suite.skip : suite)('Notebook Editor', function () {

const contentSerializer = new class implements vscode.NotebookSerializer {
deserializeNotebook() {
Expand Down Expand Up @@ -66,14 +66,14 @@ import * as utils from '../utils';
});

// #138683
test('Opening a notebook should fire activeNotebook event changed only once', async function () {
test('Opening a notebook should fire activeNotebook event changed only once', utils.withVerboseLogs(async function () {
const openedEditor = onDidOpenNotebookEditor();
const resource = await utils.createRandomFile(undefined, undefined, '.nbdtest');
const document = await vscode.workspace.openNotebookDocument(resource);
const editor = await vscode.window.showNotebookDocument(document);
assert.ok(await openedEditor);
assert.strictEqual(editor.notebook.uri.toString(), resource.toString());
});
}));

test('Active/Visible Editor', async function () {
const firstEditorOpen = onDidOpenNotebookEditor();
Expand Down
12 changes: 10 additions & 2 deletions extensions/vscode-api-tests/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ export function delay(ms: number) {
return new Promise(resolve => setTimeout(resolve, ms));
}

export function withLogDisabled(runnable: () => Promise<any>): () => Promise<void> {
function withLogLevel(level: string, runnable: () => Promise<any>): () => Promise<void> {
return async (): Promise<void> => {
const logLevel = await vscode.commands.executeCommand('_extensionTests.getLogLevel');
await vscode.commands.executeCommand('_extensionTests.setLogLevel', 'off');
await vscode.commands.executeCommand('_extensionTests.setLogLevel', level);

try {
await runnable();
Expand All @@ -79,6 +79,14 @@ export function withLogDisabled(runnable: () => Promise<any>): () => Promise<voi
};
}

export function withLogDisabled(runnable: () => Promise<any>): () => Promise<void> {
return withLogLevel('off', runnable);
}

export function withVerboseLogs(runnable: () => Promise<any>): () => Promise<void> {
return withLogLevel('trace', runnable);
}

export function assertNoRpc() {
assertNoRpcFromEntry([vscode, 'vscode']);
}
Expand Down