Skip to content

Commit 04eef07

Browse files
committed
add test that asserts cell document open are fired when the notebook is ready, not before
1 parent 00dea1c commit 04eef07

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

extensions/vscode-notebook-tests/src/notebook.test.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,27 @@ suite('Notebook API tests', () => {
119119
await vscode.commands.executeCommand('workbench.action.closeAllEditors');
120120
});
121121

122+
test('notebook open/close, notebook ready when cell-document open event is fired', async function () {
123+
const resource = vscode.Uri.file(join(vscode.workspace.rootPath || '', './first.vsctestnb'));
124+
let didHappen = false;
125+
const p = getEventOncePromise(vscode.workspace.onDidOpenTextDocument).then(doc => {
126+
if (doc.uri.scheme !== 'vscode-notebook-cell') {
127+
return;
128+
}
129+
const notebook = vscode.notebook.notebookDocuments.find(notebook => {
130+
const cell = notebook.cells.find(cell => cell.document === doc);
131+
return Boolean(cell);
132+
});
133+
assert.ok(notebook, `notebook for cell ${doc.uri} NOT found`);
134+
didHappen = true;
135+
});
136+
137+
await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest');
138+
await p;
139+
assert.strictEqual(didHappen, true);
140+
await vscode.commands.executeCommand('workbench.action.closeAllEditors');
141+
});
142+
122143
test('shared document in notebook editors', async function () {
123144
const resource = vscode.Uri.file(join(vscode.workspace.rootPath || '', './first.vsctestnb'));
124145
let counter = 0;

0 commit comments

Comments
 (0)