Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix loading react, react-dom, and react-dom/client.js for unit tests #5238

Merged
merged 1 commit into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/vs/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -1614,7 +1614,7 @@ var AMDLoader;
// The set of original paths adjust.
const reactDomClientElectron = `/out/../node_modules/react-dom/umd/react-dom.${edition}.js/client.js`;
const reactDomClientWeb = `remote/web/node_modules/react-dom/umd/react-dom.${edition}.js/client.js`;
// REH web release builds load from 'static'
// REH web release builds load from 'static'.
const reactDomClientRehWeb = `static/node_modules/react-dom/umd/react-dom.${edition}.js/client.js`;

// Attempt to adjust the original path.
Expand All @@ -1624,6 +1624,14 @@ var AMDLoader;
paths[0] = `${paths[0].substr(0, paths[0].length - reactDomClientWeb.length)}out/react-dom/client.js`;
} else if (paths[0].endsWith(reactDomClientRehWeb)) {
paths[0] = `${paths[0].substr(0, paths[0].length - reactDomClientRehWeb.length)}static/out/react-dom/client.js`;
} else {
// Unit tests load client.js from 'http://localhost'. For example:
// http://localhost:51262/e9416c1769b269baf1f33978a0695be1/node_modules/react-dom/umd/react-dom.production.min.js/client.js
const reactDomClientLocalhost = /(http:\/\/localhost:[0-9]+\/[0-9A-Fa-f]+)(\/node_modules\/react-dom\/umd\/react-dom.production.min.js\/client.js)/;
const result = paths[0].match(reactDomClientLocalhost);
if (result && result.length === 3) {
paths[0] = `${result[1]}/out/react-dom/client.js`;
}
}
}

Expand Down
48 changes: 24 additions & 24 deletions src/vs/workbench/browser/parts/editor/editorActionBarControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@
import 'vs/css!./editorActionBarControl';

// React.
// import * as React from 'react';
import * as React from 'react';

// Other dependencies.
import { Emitter } from 'vs/base/common/event';
// import { IHoverService } from 'vs/platform/hover/browser/hover';
import { IHoverService } from 'vs/platform/hover/browser/hover';
import { Disposable, DisposableStore } from 'vs/base/common/lifecycle';
// import { ICommandService } from 'vs/platform/commands/common/commands';
import { ICommandService } from 'vs/platform/commands/common/commands';
import { IEditorGroupView } from 'vs/workbench/browser/parts/editor/editor';
// import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
// import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { PositronReactRenderer } from 'vs/base/browser/positronReactRenderer';
// import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
// import { EditorActionBar } from 'vs/workbench/browser/parts/editor/editorActionBar';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { EditorActionBar } from 'vs/workbench/browser/parts/editor/editorActionBar';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';

Expand Down Expand Up @@ -61,12 +61,12 @@ export class EditorActionBarControl extends Disposable {
*/
constructor(
private readonly _parent: HTMLElement,
// @ICommandService private readonly _commandService: ICommandService,
// @IConfigurationService private readonly _configurationService: IConfigurationService,
// @IContextKeyService private readonly _contextKeyService: IContextKeyService,
// @IContextMenuService private readonly _contextMenuService: IContextMenuService,
// @IHoverService private readonly _hoverService: IHoverService,
// @IKeybindingService private readonly _keybindingService: IKeybindingService,
@ICommandService private readonly _commandService: ICommandService,
@IConfigurationService private readonly _configurationService: IConfigurationService,
@IContextKeyService private readonly _contextKeyService: IContextKeyService,
@IContextMenuService private readonly _contextMenuService: IContextMenuService,
@IHoverService private readonly _hoverService: IHoverService,
@IKeybindingService private readonly _keybindingService: IKeybindingService,
) {
// Call the base class's constructor.
super();
Expand All @@ -77,17 +77,17 @@ export class EditorActionBarControl extends Disposable {
this._parent.appendChild(this._container);

// Render the editor action bar component in the editor action bar container.
// this._positronReactRenderer = new PositronReactRenderer(this._container);
// this._positronReactRenderer.render(
// <EditorActionBar
// commandService={this._commandService}
// configurationService={this._configurationService}
// contextKeyService={this._contextKeyService}
// contextMenuService={this._contextMenuService}
// hoverService={this._hoverService}
// keybindingService={this._keybindingService}
// />
// );
this._positronReactRenderer = new PositronReactRenderer(this._container);
this._positronReactRenderer.render(
<EditorActionBar
commandService={this._commandService}
configurationService={this._configurationService}
contextKeyService={this._contextKeyService}
contextMenuService={this._contextMenuService}
hoverService={this._hoverService}
keybindingService={this._keybindingService}
/>
);
}

/**
Expand Down
6 changes: 5 additions & 1 deletion test/unit/browser/renderer.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@
'@xterm/xterm': new URL('../../../node_modules/@xterm/xterm/lib/xterm.js', baseUrl).href,
'@vscode/iconv-lite-umd': new URL('../../../node_modules/@vscode/iconv-lite-umd/lib/iconv-lite-umd.js', baseUrl).href,
'@vscode/tree-sitter-wasm': new URL('../../../node_modules/@vscode/tree-sitter-wasm/wasm/tree-sitter.js', baseUrl).href,
jschardet: new URL('../../../node_modules/jschardet/dist/jschardet.min.js', baseUrl).href
jschardet: new URL('../../../node_modules/jschardet/dist/jschardet.min.js', baseUrl).href,
// --- Start Positron ---
'react': new URL('../../../node_modules/react/umd/react.production.min.js', baseUrl).href,
'react-dom': new URL('../../../node_modules/react-dom/umd/react-dom.production.min.js', baseUrl).href,
// --- End Positron ---
}
});
</script>
Expand Down
Loading