diff --git a/src/test/terminals/codeExecution/helper.test.ts b/src/test/terminals/codeExecution/helper.test.ts index 166c4db12e7d..7cc0e551ef2a 100644 --- a/src/test/terminals/codeExecution/helper.test.ts +++ b/src/test/terminals/codeExecution/helper.test.ts @@ -38,7 +38,7 @@ import { ReplType } from '../../../client/repl/types'; const TEST_FILES_PATH = path.join(EXTENSION_ROOT_DIR, 'src', 'test', 'python_files', 'terminalExec'); -suite('Terminal - Code Execution Helper', () => { +suite('Terminal - Code Execution Helper', async () => { let activeResourceService: TypeMoq.IMock; let documentManager: TypeMoq.IMock; let applicationShell: TypeMoq.IMock; diff --git a/src/test/terminals/codeExecution/smartSend.test.ts b/src/test/terminals/codeExecution/smartSend.test.ts index 5a8171bbabd8..d5458ab16e21 100644 --- a/src/test/terminals/codeExecution/smartSend.test.ts +++ b/src/test/terminals/codeExecution/smartSend.test.ts @@ -168,70 +168,67 @@ suite('REPL - Smart Send', async () => { commandManager.verifyAll(); }); - const pythonVersion = await getPythonSemVer(); - if (pythonVersion && pythonVersion.minor < 13) { - test('Smart send should perform smart selection and move cursor', async () => { - configurationService - .setup((c) => c.getSettings(TypeMoq.It.isAny())) - .returns({ - REPL: { - REPLSmartSend: true, - }, - // eslint-disable-next-line @typescript-eslint/no-explicit-any - } as any); - - const activeEditor = TypeMoq.Mock.ofType(); - const firstIndexPosition = new Position(0, 0); - const selection = TypeMoq.Mock.ofType(); - const wholeFileContent = await fs.readFile(path.join(TEST_FILES_PATH, `sample_smart_selection.py`), 'utf8'); - - selection.setup((s) => s.anchor).returns(() => firstIndexPosition); - selection.setup((s) => s.active).returns(() => firstIndexPosition); - selection.setup((s) => s.isEmpty).returns(() => true); - activeEditor.setup((e) => e.selection).returns(() => selection.object); - - documentManager.setup((d) => d.activeTextEditor).returns(() => activeEditor.object); - document.setup((d) => d.getText(TypeMoq.It.isAny())).returns(() => wholeFileContent); - const actualProcessService = new ProcessService(); - - const { execObservable } = actualProcessService; - - processService - .setup((p) => p.execObservable(TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny())) - .returns((file, args, options) => execObservable.apply(actualProcessService, [file, args, options])); - - const actualSmartOutput = await codeExecutionHelper.normalizeLines( - 'my_dict = {', - ReplType.terminal, - wholeFileContent, - ); - - // my_dict = { <----- smart shift+enter here - // "key1": "value1", - // "key2": "value2" - // } <---- cursor should be here afterwards, hence offset 3 - commandManager - .setup((c) => c.executeCommand('cursorMove', TypeMoq.It.isAny())) - .callback((_, arg2) => { - assert.deepEqual(arg2, { - to: 'down', - by: 'line', - value: 3, - }); - return Promise.resolve(); - }) - .verifiable(TypeMoq.Times.once()); - - commandManager - .setup((c) => c.executeCommand('cursorEnd')) - .returns(() => Promise.resolve()) - .verifiable(TypeMoq.Times.once()); - - const expectedSmartOutput = 'my_dict = {\n "key1": "value1",\n "key2": "value2"\n}\n'; - expect(actualSmartOutput).to.be.equal(expectedSmartOutput); - commandManager.verifyAll(); - }); - } + test('Smart send should perform smart selection and move cursor', async () => { + configurationService + .setup((c) => c.getSettings(TypeMoq.It.isAny())) + .returns({ + REPL: { + REPLSmartSend: true, + }, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + } as any); + + const activeEditor = TypeMoq.Mock.ofType(); + const firstIndexPosition = new Position(0, 0); + const selection = TypeMoq.Mock.ofType(); + const wholeFileContent = await fs.readFile(path.join(TEST_FILES_PATH, `sample_smart_selection.py`), 'utf8'); + + selection.setup((s) => s.anchor).returns(() => firstIndexPosition); + selection.setup((s) => s.active).returns(() => firstIndexPosition); + selection.setup((s) => s.isEmpty).returns(() => true); + activeEditor.setup((e) => e.selection).returns(() => selection.object); + + documentManager.setup((d) => d.activeTextEditor).returns(() => activeEditor.object); + document.setup((d) => d.getText(TypeMoq.It.isAny())).returns(() => wholeFileContent); + const actualProcessService = new ProcessService(); + + const { execObservable } = actualProcessService; + + processService + .setup((p) => p.execObservable(TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny())) + .returns((file, args, options) => execObservable.apply(actualProcessService, [file, args, options])); + + const actualSmartOutput = await codeExecutionHelper.normalizeLines( + 'my_dict = {', + ReplType.terminal, + wholeFileContent, + ); + + // my_dict = { <----- smart shift+enter here + // "key1": "value1", + // "key2": "value2" + // } <---- cursor should be here afterwards, hence offset 3 + commandManager + .setup((c) => c.executeCommand('cursorMove', TypeMoq.It.isAny())) + .callback((_, arg2) => { + assert.deepEqual(arg2, { + to: 'down', + by: 'line', + value: 3, + }); + return Promise.resolve(); + }) + .verifiable(TypeMoq.Times.once()); + + commandManager + .setup((c) => c.executeCommand('cursorEnd')) + .returns(() => Promise.resolve()) + .verifiable(TypeMoq.Times.once()); + + const expectedSmartOutput = 'my_dict = {\n "key1": "value1",\n "key2": "value2"\n}\n'; + expect(actualSmartOutput).to.be.equal(expectedSmartOutput); + commandManager.verifyAll(); + }); // Do not perform smart selection when there is explicit selection test('Smart send should not perform smart selection when there is explicit selection', async () => {