Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 54b99ff

Browse files
authored
Fix tests in ds/custom_editor branch (#10512)
* Fix tests * Revert "Disable proposed api used for custom editor" This reverts commit e93f77a. * More fixes * Don't need that
1 parent 88dd250 commit 54b99ff

File tree

11 files changed

+33
-13
lines changed

11 files changed

+33
-13
lines changed

.vscode/launch.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
"request": "launch",
99
"runtimeExecutable": "${execPath}",
1010
"args": [
11-
"--extensionDevelopmentPath=${workspaceFolder}"
11+
"--extensionDevelopmentPath=${workspaceFolder}",
12+
"--enable-proposed-api",
13+
"ms-python.python"
1214
],
1315
"stopOnEntry": false,
1416
"smartStep": true,

src/client/common/insidersBuild/insidersExtensionService.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,10 @@ export class InsidersExtensionService implements IExtensionSingleActivationServi
8585
* @returns `true` if install channel is handled in these miscellaneous cases, `false` if install channel needs further handling
8686
*/
8787
public async handleEdgeCases(installChannel: ExtensionChannels, isDefault: boolean): Promise<boolean> {
88-
if (await this.promptToInstallInsidersIfApplicable(isDefault)) {
88+
// When running UI Tests we might want to disable these prompts.
89+
if (process.env.UITEST_DISABLE_INSIDERS) {
90+
return true;
91+
} else if (await this.promptToInstallInsidersIfApplicable(isDefault)) {
8992
return true;
9093
} else if (await this.setInsidersChannelToOffIfApplicable(installChannel)) {
9194
return true;

src/datascience-ui/native-editor/nativeCell.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ export class NativeCell extends React.Component<INativeCellProps> {
336336
break;
337337
case 'z':
338338
case 'Z':
339-
if (!this.isFocused() && !UseCustomEditor) {
339+
if (!this.isFocused() && !UseCustomEditor.enabled) {
340340
if (e.shiftKey && !e.ctrlKey && !e.altKey) {
341341
e.stopPropagation();
342342
this.props.redo();
@@ -637,7 +637,7 @@ export class NativeCell extends React.Component<INativeCellProps> {
637637
keyDown={this.keyDownInput}
638638
showLineNumbers={this.props.cellVM.showLineNumbers}
639639
font={this.props.font}
640-
disableUndoStack={UseCustomEditor}
640+
disableUndoStack={UseCustomEditor.enabled}
641641
codeVersion={this.props.cellVM.codeVersion ? this.props.cellVM.codeVersion : 1}
642642
focusPending={this.props.focusPending}
643643
/>

src/datascience-ui/native-editor/nativeEditor.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ ${buildSettingsCss(this.props.settings)}`}</style>
193193
}
194194
case 'z':
195195
case 'Z':
196-
if (!getSelectedAndFocusedInfo(this.props).focusedCellId && !UseCustomEditor) {
196+
if (!getSelectedAndFocusedInfo(this.props).focusedCellId && !UseCustomEditor.enabled) {
197197
if (event.shiftKey && !event.ctrlKey && !event.altKey) {
198198
event.stopPropagation();
199199
this.props.redo();

src/datascience-ui/react-common/constants.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ export function getOSType() {
2424
}
2525
}
2626

27-
export const UseCustomEditor = true;
27+
export const UseCustomEditor = { enabled: true };

src/test/common/insidersBuild/insidersExtensionService.unit.test.ts

+6
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,10 @@ suite('Insiders Extension Service - Activation', () => {
106106
let handleEdgeCases: sinon.SinonStub<any>;
107107
let insidersInstaller: IExtensionBuildInstaller;
108108
let insidersExtensionService: InsidersExtensionService;
109+
let envUITEST_DISABLE_INSIDERSExists = false;
109110
setup(() => {
111+
envUITEST_DISABLE_INSIDERSExists = process.env.UITEST_DISABLE_INSIDERS !== undefined;
112+
delete process.env.UITEST_DISABLE_INSIDERS;
110113
extensionChannelService = mock(ExtensionChannelService);
111114
insidersInstaller = mock(InsidersBuildInstaller);
112115
appEnvironment = mock(ApplicationEnvironment);
@@ -119,6 +122,9 @@ suite('Insiders Extension Service - Activation', () => {
119122
});
120123

121124
teardown(() => {
125+
if (envUITEST_DISABLE_INSIDERSExists) {
126+
process.env.UITEST_DISABLE_INSIDERS = '1';
127+
}
122128
sinon.restore();
123129
});
124130

src/test/datascience/interactive-ipynb/nativeEditorProvider.unit.test.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { expect } from 'chai';
99
import { anything, instance, mock, when } from 'ts-mockito';
1010
import * as typemoq from 'typemoq';
1111
import { EventEmitter, Uri, WebviewPanel } from 'vscode';
12-
import { ICustomEditorService, IWorkspaceService } from '../../../client/common/application/types';
12+
import { CustomDocument, ICustomEditorService, IWorkspaceService } from '../../../client/common/application/types';
1313
import { WorkspaceService } from '../../../client/common/application/workspace';
1414
import { AsyncDisposableRegistry } from '../../../client/common/asyncDisposableRegistry';
1515
import { ConfigurationService } from '../../../client/common/configuration/service';
@@ -65,10 +65,13 @@ suite('Data Science - Native Editor Provider', () => {
6565
.returns((_a1, _a2, _a3) => {
6666
return { dispose: noop };
6767
});
68+
6869
customEditorService
6970
.setup(c => c.openEditor(typemoq.It.isAny()))
7071
.returns(async f => {
71-
return registeredProvider.resolveCustomEditor(f, panel.object);
72+
const doc = typemoq.Mock.ofType<CustomDocument>();
73+
doc.setup(d => d.uri).returns(() => f);
74+
return registeredProvider.resolveCustomEditor(doc.object, panel.object);
7275
});
7376

7477
editor

src/test/datascience/nativeEditor.functional.test.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import { ExecutionCount } from '../../datascience-ui/interactive-common/executio
3636
import { CommonActionType } from '../../datascience-ui/interactive-common/redux/reducers/types';
3737
import { NativeCell } from '../../datascience-ui/native-editor/nativeCell';
3838
import { NativeEditor } from '../../datascience-ui/native-editor/nativeEditor';
39+
import { UseCustomEditor } from '../../datascience-ui/react-common/constants';
3940
import { IKeyboardEvent } from '../../datascience-ui/react-common/event';
4041
import { ImageButton } from '../../datascience-ui/react-common/imageButton';
4142
import { IMonacoEditorState, MonacoEditor } from '../../datascience-ui/react-common/monacoEditor';
@@ -127,6 +128,7 @@ suite('DataScience Native Editor', () => {
127128
};
128129

129130
setup(async () => {
131+
UseCustomEditor.enabled = useCustomEditorApi;
130132
ioc = new DataScienceIocContainer();
131133
ioc.registerDataScienceTypes(useCustomEditorApi);
132134

@@ -899,6 +901,7 @@ df.head()`;
899901
cleanupCallback: Function;
900902
};
901903
function initIoc() {
904+
UseCustomEditor.enabled = useCustomEditorApi;
902905
ioc = new DataScienceIocContainer();
903906
ioc.registerDataScienceTypes(useCustomEditorApi);
904907
}

src/test/debuggerTest.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ function start() {
1818
extensionDevelopmentPath: EXTENSION_ROOT_DIR_FOR_TESTS,
1919
extensionTestsPath: path.join(EXTENSION_ROOT_DIR_FOR_TESTS, 'out', 'test', 'index'),
2020
launchArgs: [workspacePath],
21-
version: 'insiders'
21+
version: 'insiders',
22+
extensionTestsEnv: { ...process.env, UITEST_DISABLE_INSIDERS: '1' }
2223
}).catch(ex => {
2324
console.error('End Debugger tests (with errors)', ex);
2425
process.exit(1);

src/test/multiRootTest.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ function start() {
1313
runTests({
1414
extensionDevelopmentPath: EXTENSION_ROOT_DIR_FOR_TESTS,
1515
extensionTestsPath: path.join(EXTENSION_ROOT_DIR_FOR_TESTS, 'out', 'test', 'index'),
16-
launchArgs: [workspacePath],
17-
version: 'stable'
16+
launchArgs: [workspacePath, '--enable-proposed-api', 'ms-python.python'],
17+
version: 'insiders',
18+
extensionTestsEnv: { ...process.env, UITEST_DISABLE_INSIDERS: '1' }
1819
}).catch(ex => {
1920
console.error('End Multiroot tests (with errors)', ex);
2021
process.exit(1);

src/test/standardTest.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ function start() {
1919
runTests({
2020
extensionDevelopmentPath: extensionDevelopmentPath,
2121
extensionTestsPath: path.join(EXTENSION_ROOT_DIR_FOR_TESTS, 'out', 'test', 'index'),
22-
launchArgs: [workspacePath],
23-
version: 'stable'
22+
launchArgs: [workspacePath, '--enable-proposed-api', 'ms-python.python'],
23+
version: 'insiders',
24+
extensionTestsEnv: { ...process.env, UITEST_DISABLE_INSIDERS: '1' }
2425
}).catch(ex => {
2526
console.error('End Standard tests (with errors)', ex);
2627
process.exit(1);

0 commit comments

Comments
 (0)