Skip to content

Commit 7b5877c

Browse files
Update tests for notebook execution
1 parent 6d81dfd commit 7b5877c

7 files changed

Lines changed: 29 additions & 21 deletions

File tree

apps/client-e2e/src/tests/notebooks/helpers/run-notebook-and-check-call-stack-decorations.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export async function RunNotebookAndCheckCallStackDecorations(
5252
await vscode.commands.executeCommand(VSCODE_COMMANDS.NOTEBOOK_RUN_ALL);
5353

5454
// make sure launched
55-
expect(controller.isStarted()).toBeTruthy();
55+
expect(controller.isStarted(nb)).toBeTruthy();
5656

5757
// short pause based on the number of cells we have
5858
// sometimes the rendering takes too long to register (like complex maps)

apps/client-e2e/src/tests/notebooks/helpers/run-notebook-and-compare-cells.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export async function RunNotebookAndCompareCells(
4949
await vscode.commands.executeCommand(VSCODE_COMMANDS.NOTEBOOK_RUN_ALL);
5050

5151
// make sure launched
52-
expect(controller.isStarted()).toBeTruthy();
52+
expect(controller.isStarted(nb)).toBeTruthy();
5353

5454
// short pause based on the number of cells we have
5555
// sometimes the rendering takes too long to register (like complex maps)

apps/client-e2e/src/tests/notebooks/notebook-reset.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export const RunNotebookReset: RunnerFunction = async (init) => {
3939
await vscode.commands.executeCommand(VSCODE_COMMANDS.NOTEBOOK_RUN_ALL);
4040

4141
// make sure launched
42-
expect(init.notebooks.controller.isStarted()).toBeTruthy();
42+
expect(init.notebooks.controller.isStarted(nb)).toBeTruthy();
4343

4444
// trigger a run
4545
vscode.commands.executeCommand(VSCODE_COMMANDS.NOTEBOOK_RUN_ALL);
@@ -54,7 +54,7 @@ export const RunNotebookReset: RunnerFunction = async (init) => {
5454
await Sleep(100);
5555

5656
// make sure stopped
57-
expect(init.notebooks.controller.isStarted()).toBeTruthy();
57+
expect(init.notebooks.controller.isStarted(nb)).toBeTruthy();
5858

5959
// compare state
6060
CompareCellOutputs(nb, CELL_OUTPUT);

apps/client-e2e/src/tests/notebooks/notebook-stop.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export const RunNotebookStop: RunnerFunction = async (init) => {
3939
await vscode.commands.executeCommand(VSCODE_COMMANDS.NOTEBOOK_RUN_ALL);
4040

4141
// make sure launched
42-
expect(init.notebooks.controller.isStarted()).toBeTruthy();
42+
expect(init.notebooks.controller.isStarted(nb)).toBeTruthy();
4343

4444
// trigger a run
4545
vscode.commands.executeCommand(VSCODE_COMMANDS.NOTEBOOK_RUN_ALL);
@@ -54,7 +54,7 @@ export const RunNotebookStop: RunnerFunction = async (init) => {
5454
await Sleep(100);
5555

5656
// make sure stopped
57-
expect(init.notebooks.controller.isStarted()).toBeFalsy();
57+
expect(init.notebooks.controller.isStarted(nb)).toBeFalsy();
5858

5959
// compare state
6060
CompareCellOutputs(nb, CELL_OUTPUT);

apps/client-e2e/src/tests/notebooks/run-unsaved-notebook.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,6 @@ export const RunUnsavedNotebook: RunnerFunction = async (init) => {
2727
/** Get reference to the notebook controller */
2828
const controller = init.notebooks.controller;
2929

30-
// start IDL if it hasnt yet
31-
if (!controller.isStarted()) {
32-
await controller.launchIDL('Launching IDL');
33-
}
34-
35-
// make sure launched
36-
expect(controller.isStarted()).toBeTruthy();
37-
3830
// make new notebook
3931
await vscode.commands.executeCommand(
4032
IDL_COMMANDS.NOTEBOOKS.NEW_NOTEBOOK,
@@ -53,6 +45,14 @@ export const RunUnsavedNotebook: RunnerFunction = async (init) => {
5345
/** Get reference to the current notebook */
5446
const nb = editor.notebook;
5547

48+
// start IDL if it hasnt yet
49+
if (!controller.isStarted(nb)) {
50+
await controller.launchIDL(nb, 'Launching IDL');
51+
}
52+
53+
// make sure launched
54+
expect(controller.isStarted(nb)).toBeTruthy();
55+
5656
// update text
5757
const cells = nb.getCells();
5858

apps/client-e2e/src/tests/notebooks/verify-quiet-notebook-setting.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { GetExtensionPath, IDL_COMMANDS, Sleep } from '@idl/shared';
22
import { GetWorkspaceConfig, IIDLWorkspaceConfig } from '@idl/vscode/config';
33
import { IDL_EXTENSION_CONFIG_KEYS } from '@idl/vscode/extension-config';
4+
import { OpenNotebookInVSCode } from '@idl/vscode/shared';
45
import expect from 'expect';
56
import * as vscode from 'vscode';
67

@@ -34,6 +35,9 @@ export const NOT_QUIET_OUTPUT: ICompareCellOutputs[] = [
3435
* Function that runs basic tests for ENVI message listeners
3536
*/
3637
export const VerifyQuietNotebookSetting: RunnerFunction = async (init) => {
38+
const quietFile = GetExtensionPath(
39+
'idl/test/client-e2e/notebooks/quiet-preference.idlnb'
40+
);
3741
// get the current workspace config
3842
const config = GetWorkspaceConfig();
3943

@@ -46,7 +50,7 @@ export const VerifyQuietNotebookSetting: RunnerFunction = async (init) => {
4650

4751
// run in quiet mode
4852
await RunNotebookAndCompareCells(
49-
GetExtensionPath('idl/test/client-e2e/notebooks/quiet-preference.idlnb'),
53+
quietFile,
5054
QUIET_OUTPUT,
5155
init.notebooks.controller
5256
);
@@ -64,12 +68,9 @@ export const VerifyQuietNotebookSetting: RunnerFunction = async (init) => {
6468
// short pause
6569
await Sleep(100);
6670

67-
// make sure stopped
68-
expect(init.notebooks.controller.isStarted()).toBeTruthy();
69-
7071
// run in quiet mode
7172
await RunNotebookAndCompareCells(
72-
GetExtensionPath('idl/test/client-e2e/notebooks/quiet-preference.idlnb'),
73+
quietFile,
7374
NOT_QUIET_OUTPUT,
7475
init.notebooks.controller
7576
);
@@ -87,6 +88,9 @@ export const VerifyQuietNotebookSetting: RunnerFunction = async (init) => {
8788
// short pause
8889
await Sleep(100);
8990

91+
// open NB
92+
const nb = await OpenNotebookInVSCode(quietFile);
93+
9094
// make sure stopped
91-
expect(init.notebooks.controller.isStarted()).toBeFalsy();
95+
expect(init.notebooks.controller.isStarted(nb)).toBeFalsy();
9296
};

libs/vscode/notebooks/src/lib/controller/idl-notebook-controller.class.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,11 @@ export class IDLNotebookController {
143143
this.knownNotebooks[_notebook.uri.toString()] = _notebook;
144144

145145
/** Have manager run notebook cell */
146-
this.getNotebookManager(_notebook)._execute(cells, _notebook, _controller);
146+
await this.getNotebookManager(_notebook)._execute(
147+
cells,
148+
_notebook,
149+
_controller
150+
);
147151
}
148152

149153
/**

0 commit comments

Comments
 (0)