From 0d5a12ee79b7aa94cabedb5137f50db283b7b00c Mon Sep 17 00:00:00 2001 From: Don Jayamanne Date: Wed, 18 Dec 2024 09:50:39 +1100 Subject: [PATCH 1/3] New way to hide output panel for tests --- src/test/datascience/widgets/commUtils.ts | 9 ++++++++- .../widgets/standardWidgets.vscode.common.test.ts | 6 +++--- .../widgets/thirdpartyWidgets.vscode.common.test.ts | 6 +++--- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/test/datascience/widgets/commUtils.ts b/src/test/datascience/widgets/commUtils.ts index da99a00b70b..1d79a7a2982 100644 --- a/src/test/datascience/widgets/commUtils.ts +++ b/src/test/datascience/widgets/commUtils.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { NotebookCell, NotebookEditor, NotebookRendererMessaging, notebooks } from 'vscode'; +import { commands, NotebookCell, NotebookEditor, NotebookRendererMessaging, notebooks } from 'vscode'; import { dispose } from '../../../platform/common/utils/lifecycle'; import { logger } from '../../../platform/logging'; import { IDisposable } from '../../../platform/common/types'; @@ -124,3 +124,10 @@ export class Utils { }); } } + +export async function hideOutputPanel(){ + // Work around for the removal of the command `workbench.action.closePanel`. + await commands.executeCommand('workbench.action.terminal.killAll'); + // await commands.executeCommand('workbench.action.terminal.new'); + // await commands.executeCommand('workbench.action.togglePanel'); +} diff --git a/src/test/datascience/widgets/standardWidgets.vscode.common.test.ts b/src/test/datascience/widgets/standardWidgets.vscode.common.test.ts index 6b727f71030..fe3aca60431 100644 --- a/src/test/datascience/widgets/standardWidgets.vscode.common.test.ts +++ b/src/test/datascience/widgets/standardWidgets.vscode.common.test.ts @@ -34,7 +34,7 @@ import { waitForExecutionCompletedSuccessfully, waitForTextOutput } from '../notebook/helper'; -import { initializeWidgetComms, Utils } from './commUtils'; +import { hideOutputPanel, initializeWidgetComms, Utils } from './commUtils'; import { WidgetRenderingTimeoutForTests } from './constants'; import { getTextOutputValue } from '../../../kernels/execution/helpers'; import { isWeb } from '../../../platform/common/utils/misc'; @@ -128,7 +128,7 @@ suite('Standard IPyWidget Tests @widgets', function () { // Widgets get rendered only when the output is in view. If we have a very large notebook // and the output is not visible, then it will not get rendered & the tests will fail. The tests inspect the rendered HTML. // Solution - maximize available real-estate by hiding the output panels & hiding the input cells. - await commands.executeCommand('workbench.action.closePanel'); + await hideOutputPanel(); await commands.executeCommand('workbench.action.maximizeEditorHideSidebar'); await commands.executeCommand('notebook.cell.collapseAllCellInputs'); comms = await initializeWidgetComms(disposables); @@ -142,7 +142,7 @@ suite('Standard IPyWidget Tests @widgets', function () { await startJupyterServer(); logger.info(`Start Test (completed) ${this.currentTest?.title}`); // With less realestate, the outputs might not get rendered (VS Code optimization to avoid rendering if not in viewport). - await commands.executeCommand('workbench.action.closePanel'); + await hideOutputPanel(); }); teardown(async function () { logger.info(`Ended Test ${this.currentTest?.title}`); diff --git a/src/test/datascience/widgets/thirdpartyWidgets.vscode.common.test.ts b/src/test/datascience/widgets/thirdpartyWidgets.vscode.common.test.ts index 1fb7fd4632d..e2cfcccb889 100644 --- a/src/test/datascience/widgets/thirdpartyWidgets.vscode.common.test.ts +++ b/src/test/datascience/widgets/thirdpartyWidgets.vscode.common.test.ts @@ -32,7 +32,7 @@ import { initializeNotebookForWidgetTest } from './standardWidgets.vscode.common.test'; import { GlobalStateKeyToTrackIfUserConfiguredCDNAtLeastOnce } from '../../../notebooks/controllers/ipywidgets/scriptSourceProvider/cdnWidgetScriptSourceProvider'; -import { initializeWidgetComms, Utils } from './commUtils'; +import { hideOutputPanel, initializeWidgetComms, Utils } from './commUtils'; import { isWeb } from '../../../platform/common/utils/misc'; [true, false].forEach((useCDN) => { @@ -71,7 +71,7 @@ import { isWeb } from '../../../platform/common/utils/misc'; // Widgets get rendered only when the output is in view. If we have a very large notebook // and the output is not visible, then it will not get rendered & the tests will fail. The tests inspect the rendered HTML. // Solution - maximize available real-estate by hiding the output panels & hiding the input cells. - await commands.executeCommand('workbench.action.closePanel'); + await hideOutputPanel(); await commands.executeCommand('workbench.action.maximizeEditorHideSidebar'); comms = await initializeWidgetComms(disposables); @@ -83,7 +83,7 @@ import { isWeb } from '../../../platform/common/utils/misc'; sinon.restore(); logger.info(`Start Test (completed) ${this.currentTest?.title}`); // With less real estate, the outputs might not get rendered (VS Code optimization to avoid rendering if not in viewport). - await commands.executeCommand('workbench.action.closePanel'); + await hideOutputPanel(); }); teardown(async function () { logger.info(`Ended Test ${this.currentTest?.title}`); From 28d5754e800e90f9fc9e922043db5badcb003d9f Mon Sep 17 00:00:00 2001 From: Don Jayamanne Date: Wed, 18 Dec 2024 10:17:51 +1100 Subject: [PATCH 2/3] Misc --- src/test/datascience/widgets/commUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/datascience/widgets/commUtils.ts b/src/test/datascience/widgets/commUtils.ts index 1d79a7a2982..8eadf6a8e29 100644 --- a/src/test/datascience/widgets/commUtils.ts +++ b/src/test/datascience/widgets/commUtils.ts @@ -125,7 +125,7 @@ export class Utils { } } -export async function hideOutputPanel(){ +export async function hideOutputPanel() { // Work around for the removal of the command `workbench.action.closePanel`. await commands.executeCommand('workbench.action.terminal.killAll'); // await commands.executeCommand('workbench.action.terminal.new'); From 570cf39b0e88d898a043621f08365ad2ee6563db Mon Sep 17 00:00:00 2001 From: Don Jayamanne Date: Wed, 18 Dec 2024 10:26:38 +1100 Subject: [PATCH 3/3] Fixes --- src/test/datascience/widgets/commUtils.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/datascience/widgets/commUtils.ts b/src/test/datascience/widgets/commUtils.ts index 8eadf6a8e29..75dbff10c4b 100644 --- a/src/test/datascience/widgets/commUtils.ts +++ b/src/test/datascience/widgets/commUtils.ts @@ -127,7 +127,7 @@ export class Utils { export async function hideOutputPanel() { // Work around for the removal of the command `workbench.action.closePanel`. - await commands.executeCommand('workbench.action.terminal.killAll'); - // await commands.executeCommand('workbench.action.terminal.new'); - // await commands.executeCommand('workbench.action.togglePanel'); + // await commands.executeCommand('workbench.action.terminal.killAll'); + await commands.executeCommand('workbench.action.problems.focus'); + await commands.executeCommand('workbench.action.togglePanel'); }