Skip to content

Commit cefccd1

Browse files
authored
Fix functional tests for ipywidgets and download just chrome b… (#11093)
For #11092 playwright downloads other browsers, we need just one chrome (as this is closest to what VSCode is built upon)
1 parent 022fe05 commit cefccd1

File tree

6 files changed

+78
-31
lines changed

6 files changed

+78
-31
lines changed

package-lock.json

Lines changed: 57 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3184,7 +3184,7 @@
31843184
"node-has-native-dependencies": "^1.0.2",
31853185
"node-html-parser": "^1.1.13",
31863186
"nyc": "^15.0.0",
3187-
"playwright": "^0.11.1",
3187+
"playwright-chromium": "^0.13.0",
31883188
"postcss": "^7.0.27",
31893189
"postcss-cssnext": "^3.1.0",
31903190
"postcss-import": "^12.0.1",

src/test/datascience/dataScienceIocContainer.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ import { ProductService } from '../../client/common/installer/productService';
105105
import { IInstallationChannelManager, IProductPathService, IProductService } from '../../client/common/installer/types';
106106
import { InterpreterPathService } from '../../client/common/interpreterPathService';
107107
import { BrowserService } from '../../client/common/net/browser';
108+
import { HttpClient } from '../../client/common/net/httpClient';
108109
import { IS_WINDOWS } from '../../client/common/platform/constants';
109110
import { PathUtils } from '../../client/common/platform/pathUtils';
110111
import { RegistryImplementation } from '../../client/common/platform/registry';
@@ -145,6 +146,7 @@ import {
145146
IExperimentsManager,
146147
IExtensionContext,
147148
IExtensions,
149+
IHttpClient,
148150
IInstaller,
149151
IInterpreterPathService,
150152
IMemento,
@@ -192,6 +194,7 @@ import { InteractiveWindow } from '../../client/datascience/interactive-window/i
192194
import { InteractiveWindowCommandListener } from '../../client/datascience/interactive-window/interactiveWindowCommandListener';
193195
import { IPyWidgetHandler } from '../../client/datascience/ipywidgets/ipywidgetHandler';
194196
import { IPyWidgetMessageDispatcherFactory } from '../../client/datascience/ipywidgets/ipyWidgetMessageDispatcherFactory';
197+
import { IPyWidgetScriptSource } from '../../client/datascience/ipywidgets/ipyWidgetScriptSource';
195198
import { JupyterCommandFactory } from '../../client/datascience/jupyter/interpreter/jupyterCommand';
196199
import { JupyterCommandFinder } from '../../client/datascience/jupyter/interpreter/jupyterCommandFinder';
197200
import { JupyterCommandInterpreterDependencyService } from '../../client/datascience/jupyter/interpreter/jupyterCommandInterpreterDependencyService';
@@ -535,6 +538,8 @@ export class DataScienceIocContainer extends UnitTestIocContainer {
535538
when(this.webPanelProvider.create(anything())).thenCall(this.onCreateWebPanel.bind(this));
536539
if (this.uiTest) {
537540
this.serviceManager.addSingleton<IWebPanelProvider>(IWebPanelProvider, WebBrowserPanelProvider);
541+
this.serviceManager.add<IInteractiveWindowListener>(IInteractiveWindowListener, IPyWidgetScriptSource);
542+
this.serviceManager.addSingleton<IHttpClient>(IHttpClient, HttpClient);
538543
} else {
539544
this.serviceManager.addSingletonInstance<IWebPanelProvider>(
540545
IWebPanelProvider,
@@ -622,6 +627,7 @@ export class DataScienceIocContainer extends UnitTestIocContainer {
622627
);
623628
const mockExtensionContext = TypeMoq.Mock.ofType<IExtensionContext>();
624629
mockExtensionContext.setup((m) => m.globalStoragePath).returns(() => os.tmpdir());
630+
mockExtensionContext.setup((m) => m.extensionPath).returns(() => os.tmpdir());
625631
this.serviceManager.addSingletonInstance<IExtensionContext>(IExtensionContext, mockExtensionContext.object);
626632

627633
const mockServerSelector = mock(JupyterServerSelector);
@@ -1403,7 +1409,7 @@ export class DataScienceIocContainer extends UnitTestIocContainer {
14031409
variableQueries: [],
14041410
jupyterCommandLineArguments: [],
14051411
disableJupyterAutoStart: true,
1406-
widgetScriptSources: []
1412+
widgetScriptSources: ['jsdelivr.com', 'unpkg.com']
14071413
};
14081414
pythonSettings.jediEnabled = false;
14091415
pythonSettings.downloadLanguageServer = false;

src/test/datascience/uiTests/helpers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import * as fs from 'fs-extra';
66
import * as path from 'path';
7-
import * as playwright from 'playwright';
7+
import * as playwright from 'playwright-chromium';
88
import { IAsyncDisposable, IDisposable } from '../../../client/common/types';
99
import { createDeferred } from '../../../client/common/utils/async';
1010
import { InteractiveWindowMessages } from '../../../client/datascience/interactive-common/interactiveWindowTypes';
@@ -35,7 +35,7 @@ const maxWaitTimeForMessage = 75_000;
3535
* UI could take a while to update, could be slower on CI server.
3636
* (500ms is generally enough, but increasing to 3s to avoid flaky CI tests).
3737
*/
38-
export const waitTimeForUIToUpdate = 5_000;
38+
export const waitTimeForUIToUpdate = 10_000;
3939

4040
export class BaseWebUI implements IAsyncDisposable {
4141
public page?: playwright.Page;

src/test/datascience/uiTests/ipywidget.ui.functional.test.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -441,12 +441,12 @@ use(chaiAsPromised);
441441

442442
// Confirm canvas is rendered.
443443
await retryIfFail(async () => {
444-
const cellOutputHtml = await notebookUI.getCellOutputHTML(3);
444+
let cellOutputHtml = await notebookUI.getCellOutputHTML(3);
445445
assert.include(cellOutputHtml, '<canvas ');
446446
// Last cell is flakey. Can take too long to render. We need some way
447447
// to know when a widget is done rendering.
448-
// cellOutputHtml = await notebookUI.getCellOutputHTML(8);
449-
// assert.include(cellOutputHtml, '<canvas ');
448+
cellOutputHtml = await notebookUI.getCellOutputHTML(8);
449+
assert.include(cellOutputHtml, '<canvas ');
450450
});
451451
});
452452
test('Render beakerx', async () => {
@@ -478,13 +478,13 @@ use(chaiAsPromised);
478478
});
479479

480480
// This last part if flakey. BeakerX can fail itself loading settings
481-
// await notebookUI.executeCell(3);
482-
// await retryIfFail(async () => {
483-
// // Confirm form with fields have been rendered.
484-
// const cellOutput = await notebookUI.getCellOutput(3);
485-
// const textAreas = await cellOutput.$$('div.widget-textarea');
486-
// assert.isAtLeast(textAreas.length, 1);
487-
// });
481+
await notebookUI.executeCell(3);
482+
await retryIfFail(async () => {
483+
// Confirm form with fields have been rendered.
484+
const cellOutput = await notebookUI.getCellOutput(3);
485+
const textAreas = await cellOutput.$$('div.widget-textarea');
486+
assert.isAtLeast(textAreas.length, 1);
487+
});
488488
});
489489
test('Render bqplot', async () => {
490490
const { notebookUI } = await openBqplotIpynb();

src/test/datascience/uiTests/notebookUi.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
'use strict';
55

66
import { assert } from 'chai';
7-
import { ElementHandle } from 'playwright';
7+
import { ElementHandle } from 'playwright-chromium';
88
import { InteractiveWindowMessages } from '../../../client/datascience/interactive-common/interactiveWindowTypes';
99
import { CommonActionType } from '../../../datascience-ui/interactive-common/redux/reducers/types';
1010
import { BaseWebUI } from './helpers';

0 commit comments

Comments
 (0)