diff --git a/news/3 Code Health/8255.md b/news/3 Code Health/8255.md new file mode 100644 index 000000000000..fcfe36913369 --- /dev/null +++ b/news/3 Code Health/8255.md @@ -0,0 +1 @@ +Timeout with new waitForMessage in native editor tests. diff --git a/src/test/datascience/nativeEditor.functional.test.tsx b/src/test/datascience/nativeEditor.functional.test.tsx index dcddf66545c2..4495464a780d 100644 --- a/src/test/datascience/nativeEditor.functional.test.tsx +++ b/src/test/datascience/nativeEditor.functional.test.tsx @@ -345,7 +345,8 @@ for _ in range(50): assert.ok(cell, 'Cannot find the first cell'); const imageButtons = cell!.find(ImageButton); assert.equal(imageButtons.length, 7, 'Cell buttons not found'); - const runButton = imageButtons.at(2); + const runButton = imageButtons.findWhere(w => w.props().tooltip === 'Run cell'); + assert.equal(runButton.length, 1, 'No run button found'); const update = waitForMessage(ioc, InteractiveWindowMessages.RenderComplete); runButton.simulate('click'); await update; diff --git a/src/test/datascience/testHelpers.tsx b/src/test/datascience/testHelpers.tsx index dc2071a395cd..44099f6f9675 100644 --- a/src/test/datascience/testHelpers.tsx +++ b/src/test/datascience/testHelpers.tsx @@ -36,7 +36,7 @@ export enum CellPosition { Last = 'last' } -export function waitForMessage(ioc: DataScienceIocContainer, message: string): Promise { +export function waitForMessage(ioc: DataScienceIocContainer, message: string, timeoutMs: number = 65000): Promise { // Wait for the mounted web panel to send a message back to the data explorer const promise = createDeferred(); let handler: (m: string, p: any) => void; @@ -44,7 +44,7 @@ export function waitForMessage(ioc: DataScienceIocContainer, message: string): P if (!promise.resolved) { promise.reject(new Error(`Waiting for ${message} timed out`)); } - }, 3000); // Max 3 seconds for a message. Should be almost instant but this will make tests fail faster than the max timeout. + }, timeoutMs); handler = (m: string, _p: any) => { if (m === message) { ioc.removeMessageListener(handler); diff --git a/src/test/datascience/variableexplorer.functional.test.tsx b/src/test/datascience/variableexplorer.functional.test.tsx index 385df9b391e5..cefe39f2b8e1 100644 --- a/src/test/datascience/variableexplorer.functional.test.tsx +++ b/src/test/datascience/variableexplorer.functional.test.tsx @@ -14,9 +14,8 @@ import { InteractivePanel } from '../../datascience-ui/history-react/interactive import { VariableExplorer } from '../../datascience-ui/interactive-common/variableExplorer'; import { NativeEditor } from '../../datascience-ui/native-editor/nativeEditor'; import { DataScienceIocContainer } from './dataScienceIocContainer'; -import { addCode, runMountedTest as interactiveRunMountedTest } from './interactiveWindowTestHelpers'; -import { addCell, createNewEditor, runMountedTest as nativeRunMountedTest } from './nativeEditorTestHelpers'; -import { waitForUpdate } from './reactHelpers'; +import { addCode } from './interactiveWindowTestHelpers'; +import { addCell, createNewEditor } from './nativeEditorTestHelpers'; import { runDoubleTest, waitForMessage } from './testHelpers'; // tslint:disable:max-func-body-length trailing-comma no-any no-multiline-string @@ -65,34 +64,6 @@ suite('DataScience Interactive Window variable explorer tests', () => { return waitForMessage(ioc, InteractiveWindowMessages.VariablesComplete); } - async function checkVariableLoading(wrapper: ReactWrapper, React.Component>, targetRenderCount: number) { - const basicCode: string = `value = 'hello world'`; - - openVariableExplorer(wrapper); - - await addCodeImpartial(wrapper, 'a=1\na'); - await addCodeImpartial(wrapper, basicCode, false); - - // Target a render count before loading is finished - await waitForUpdate(wrapper, VariableExplorer, targetRenderCount); - - let targetVariables: IJupyterVariable[] = [ - {name: 'a', value: '1', supportsDataExplorer: false, type: 'int', size: 54, shape: '', count: 0, truncated: false}, - {name: 'value', value: 'Loading...', supportsDataExplorer: false, type: 'str', size: 54, shape: '', count: 0, truncated: false} - ]; - verifyVariables(wrapper, targetVariables); - - // Now wait for one more update and then check the variables, we should have loaded the value var - await waitForUpdate(wrapper, VariableExplorer, 1); - - targetVariables = [ - {name: 'a', value: '1', supportsDataExplorer: false, type: 'int', size: 54, shape: '', count: 0, truncated: false}, - // tslint:disable-next-line:quotemark - {name: 'value', value: "'hello world'", supportsDataExplorer: false, type: 'str', size: 54, shape: '', count: 0, truncated: false} - ]; - verifyVariables(wrapper, targetVariables); - } - async function addCodeImpartial(wrapper: ReactWrapper, React.Component>, code: string, waitForVariables: boolean = true, expectedRenderCount: number = 4, expectError: boolean = false): Promise, React.Component>> { const variablesUpdated = waitForVariables ? waitForVariablesUpdated() : Promise.resolve(); const nodes = wrapper.find('InteractivePanel'); @@ -181,16 +152,6 @@ value = 'hello world'`; verifyVariables(wrapper, targetVariables); }, () => { return ioc; }); - // For the loading tests we check before the explorer is fully loaded, so split tests here to check - // with different target render counts - nativeRunMountedTest('Variable Explorer - Native Loading', async (wrapper) => { - await checkVariableLoading(wrapper, 3); - }, () => { return ioc; }); - - interactiveRunMountedTest('Variable Explorer - Interactive Loading', async (wrapper) => { - await checkVariableLoading(wrapper, 2); - }, () => { return ioc; }); - // Test our display of basic types. We render 8 rows by default so only 8 values per test runDoubleTest('Variable explorer - Types A', async (wrapper) => { const basicCode: string = `myList = [1, 2, 3]