Skip to content

Commit

Permalink
Add native variable view doc switch tests (#6303)
Browse files Browse the repository at this point in the history
  • Loading branch information
IanMatthewHuff authored Jun 15, 2021
1 parent d8a42ac commit 613468d
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 1 deletion.
1 change: 1 addition & 0 deletions news/3 Code Health/4355.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add doc switching variable view tests for native notebooks.
2 changes: 1 addition & 1 deletion pvsc.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
"env": {
"VSC_JUPYTER_CI_TEST_GREP": "VSCode Notebook", // Leave as `VSCode Notebook` to run only Notebook tests.
"VSC_JUPYTER_CI_TEST_INVERT_GREP": "", // Initialize this to invert the grep (exclude tests with value defined in grep).
"CI_PYTHON_PATH": "/Users/donjayamanne/Desktop/Development/crap/docBug/venvDS/bin/python", // Update with path to real python interpereter used for testing.
"CI_PYTHON_PATH": "<PythonPath>", // Update with path to real python interpereter used for testing.
"VSC_FORCE_REAL_JUPYTER": "true", // Enalbe tests that require Jupyter.
"VSC_JUPYTER_CI_RUN_NON_PYTHON_NB_TEST": "", // Initialize this to run tests again Julia & other kernels.
"VSC_JUPYTER_RUN_NB_TEST": "true", // Initialize this to run notebook tests (must be using VSC Insiders).
Expand Down
58 changes: 58 additions & 0 deletions src/test/datascience/variableView/variableView.vscode.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,62 @@ suite('DataScience - VariableView', () => {
];
verifyViewVariables(expectedVariables, htmlResult);
});

test('Variable view document switching (webview-test)', async function () {
// Add one simple cell and execute it
await insertCodeCell('test = "MYTESTVALUE"', { index: 0 });
const cell = vscodeNotebook.activeNotebookEditor?.document.getCells()![0]!;
await runCell(cell);
await waitForExecutionCompletedSuccessfully(cell);

// Send the command to open the view
await commandManager.executeCommand(Commands.OpenVariableView);

// Aquire the variable view from the provider
const coreVariableView = await variableViewProvider.activeVariableView;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const variableView = (coreVariableView as any) as ITestWebviewHost;

// Add our message listener
const onMessageListener = new OnMessageListener(variableView);

// Wait until our VariablesComplete message to see that we have the new variables and have rendered them
await onMessageListener.waitForMessage(InteractiveWindowMessages.VariablesComplete);

const htmlResult = await variableView?.getHTMLById('variable-view-main-panel');

// Parse the HTML for our expected variables
const expectedVariables = [{ name: 'test', type: 'str', length: '11', value: ' MYTESTVALUE' }];
verifyViewVariables(expectedVariables, htmlResult);

// Now create a second document
await createEmptyPythonNotebook(disposables);

// Execute a cell on the second document
await insertCodeCell('test2 = "MYTESTVALUE2"', { index: 0 });
const cell2 = vscodeNotebook.activeNotebookEditor?.document.getCells()![0]!;
await runCell(cell2);
await waitForExecutionCompletedSuccessfully(cell2);

// Because this document was not open, we need to open the variable view again
await commandManager.executeCommand(Commands.OpenVariableView);

// Execute a second cell on the second document
await insertCodeCell('test3 = "MYTESTVALUE3"', { index: 1 });
const cell3 = vscodeNotebook.activeNotebookEditor?.document.getCells()![1]!;
await runCell(cell3);
await waitForExecutionCompletedSuccessfully(cell3);

// Wait until our VariablesComplete message to see that we have the new variables and have rendered them
await onMessageListener.waitForMessage(InteractiveWindowMessages.VariablesComplete);

const htmlResult2 = await variableView?.getHTMLById('variable-view-main-panel');

// Parse the HTML for our expected variables
const expectedVariables2 = [
{ name: 'test2', type: 'str', length: '12', value: ' MYTESTVALUE2' },
{ name: 'test3', type: 'str', length: '12', value: ' MYTESTVALUE3' }
];
verifyViewVariables(expectedVariables2, htmlResult2);
});
});

0 comments on commit 613468d

Please sign in to comment.