-
Notifications
You must be signed in to change notification settings - Fork 295
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e24477a
commit 6655f6b
Showing
4 changed files
with
579 additions
and
287 deletions.
There are no files selected for viewing
85 changes: 85 additions & 0 deletions
85
src/test/datascience/notebook/intellisense/completion.vscode.common.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
/* eslint-disable @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */ | ||
import { assert } from 'chai'; | ||
import * as sinon from 'sinon'; | ||
import { commands, CompletionList, Position, window } from 'vscode'; | ||
import { traceInfo } from '../../../../platform/logging'; | ||
import { IDisposable } from '../../../../platform/common/types'; | ||
import { | ||
closeNotebooksAndCleanUpAfterTests, | ||
runCell, | ||
insertCodeCell, | ||
waitForExecutionCompletedSuccessfully, | ||
prewarmNotebooks, | ||
createEmptyPythonNotebook | ||
} from '../helper'; | ||
import { captureScreenShot, initialize, startJupyterServer } from '../../../common'; | ||
import { getTextOutputValue } from '../../../../kernels/execution/helpers'; | ||
|
||
/* eslint-disable @typescript-eslint/no-explicit-any, no-invalid-this */ | ||
suite('VSCode Intellisense Notebook and Interactive Code Completion @lsp', function () { | ||
const disposables: IDisposable[] = []; | ||
this.timeout(120_000); | ||
suiteSetup(async function () { | ||
traceInfo(`Start Suite Code Completion via Jupyter`); | ||
this.timeout(120_000); | ||
await initialize(); | ||
await startJupyterServer(); | ||
await prewarmNotebooks(); | ||
sinon.restore(); | ||
traceInfo(`Start Suite (Completed) Code Completion via Jupyter`); | ||
}); | ||
// Use same notebook without starting kernel in every single test (use one for whole suite). | ||
setup(async function () { | ||
traceInfo(`Start Test ${this.currentTest?.title}`); | ||
sinon.restore(); | ||
await startJupyterServer(); | ||
await createEmptyPythonNotebook(disposables); | ||
traceInfo(`Start Test (completed) ${this.currentTest?.title}`); | ||
}); | ||
teardown(async function () { | ||
traceInfo(`Ended Test ${this.currentTest?.title}`); | ||
if (this.currentTest?.isFailed()) { | ||
await captureScreenShot(this); | ||
} | ||
await closeNotebooksAndCleanUpAfterTests(disposables); | ||
traceInfo(`Ended Test (completed) ${this.currentTest?.title}`); | ||
}); | ||
suiteTeardown(() => closeNotebooksAndCleanUpAfterTests(disposables)); | ||
test('Execute cell and get completions for variable', async () => { | ||
await insertCodeCell('import sys\nprint(sys.executable)\na = 1', { index: 0 }); | ||
const cell = window.activeNotebookEditor?.notebook.cellAt(0)!; | ||
|
||
await runCell(cell); | ||
|
||
// Wait till execution count changes and status is success. | ||
await waitForExecutionCompletedSuccessfully(cell); | ||
const outputText = getTextOutputValue(cell.outputs[0]).trim(); | ||
traceInfo(`Cell Output ${outputText}`); | ||
await insertCodeCell('a.', { index: 1 }); | ||
const cell2 = window.activeNotebookEditor!.notebook.cellAt(1); | ||
|
||
const position = new Position(0, 2); | ||
traceInfo('Get completions in test'); | ||
// Executing the command `vscode.executeCompletionItemProvider` to simulate triggering completion | ||
const completions = (await commands.executeCommand( | ||
'vscode.executeCompletionItemProvider', | ||
cell2.document.uri, | ||
position | ||
)) as CompletionList; | ||
const items = completions.items.map((item) => item.label); | ||
assert.isOk(items.length); | ||
assert.ok( | ||
items.find((item) => | ||
typeof item === 'string' ? item.includes('bit_length') : item.label.includes('bit_length') | ||
) | ||
); | ||
assert.ok( | ||
items.find((item) => | ||
typeof item === 'string' ? item.includes('to_bytes') : item.label.includes('to_bytes') | ||
) | ||
); | ||
}); | ||
}); |
158 changes: 78 additions & 80 deletions
158
src/test/datascience/notebook/intellisense/completion.vscode.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,87 +1,85 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
/* eslint-disable @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */ | ||
import { assert } from 'chai'; | ||
import * as sinon from 'sinon'; | ||
import { commands, CompletionList, Position, window } from 'vscode'; | ||
import { traceInfo } from '../../../../platform/logging'; | ||
import { IDisposable } from '../../../../platform/common/types'; | ||
import { captureScreenShot } from '../../../common.node'; | ||
import { initialize } from '../../../initialize.node'; | ||
import { | ||
closeNotebooksAndCleanUpAfterTests, | ||
runCell, | ||
insertCodeCell, | ||
startJupyterServer, | ||
waitForExecutionCompletedSuccessfully, | ||
prewarmNotebooks, | ||
createEmptyPythonNotebook | ||
} from '../helper.node'; | ||
import { getTextOutputValue } from '../../../../kernels/execution/helpers'; | ||
// /* eslint-disable @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */ | ||
// import { assert } from 'chai'; | ||
// import * as sinon from 'sinon'; | ||
// import { commands, CompletionList, Position, window } from 'vscode'; | ||
// import { traceInfo } from '../../../../platform/logging'; | ||
// import { IDisposable } from '../../../../platform/common/types'; | ||
// import { | ||
// closeNotebooksAndCleanUpAfterTests, | ||
// runCell, | ||
// insertCodeCell, | ||
// waitForExecutionCompletedSuccessfully, | ||
// prewarmNotebooks, | ||
// createEmptyPythonNotebook | ||
// } from '../helper'; | ||
// import { captureScreenShot, initialize, startJupyterServer } from '../../../common'; | ||
// import { getTextOutputValue } from '../../../../kernels/execution/helpers'; | ||
|
||
/* eslint-disable @typescript-eslint/no-explicit-any, no-invalid-this */ | ||
suite('VSCode Intellisense Notebook and Interactive Code Completion @lsp', function () { | ||
const disposables: IDisposable[] = []; | ||
this.timeout(120_000); | ||
suiteSetup(async function () { | ||
traceInfo(`Start Suite Code Completion via Jupyter`); | ||
this.timeout(120_000); | ||
await initialize(); | ||
await startJupyterServer(); | ||
await prewarmNotebooks(); | ||
sinon.restore(); | ||
traceInfo(`Start Suite (Completed) Code Completion via Jupyter`); | ||
}); | ||
// Use same notebook without starting kernel in every single test (use one for whole suite). | ||
setup(async function () { | ||
traceInfo(`Start Test ${this.currentTest?.title}`); | ||
sinon.restore(); | ||
await startJupyterServer(); | ||
await createEmptyPythonNotebook(disposables); | ||
traceInfo(`Start Test (completed) ${this.currentTest?.title}`); | ||
}); | ||
teardown(async function () { | ||
traceInfo(`Ended Test ${this.currentTest?.title}`); | ||
if (this.currentTest?.isFailed()) { | ||
await captureScreenShot(this); | ||
} | ||
await closeNotebooksAndCleanUpAfterTests(disposables); | ||
traceInfo(`Ended Test (completed) ${this.currentTest?.title}`); | ||
}); | ||
suiteTeardown(() => closeNotebooksAndCleanUpAfterTests(disposables)); | ||
test('Execute cell and get completions for variable', async () => { | ||
await insertCodeCell('import sys\nprint(sys.executable)\na = 1', { index: 0 }); | ||
const cell = window.activeNotebookEditor?.notebook.cellAt(0)!; | ||
// /* eslint-disable @typescript-eslint/no-explicit-any, no-invalid-this */ | ||
// suite('VSCode Intellisense Notebook and Interactive Code Completion @lsp', function () { | ||
// const disposables: IDisposable[] = []; | ||
// this.timeout(120_000); | ||
// suiteSetup(async function () { | ||
// traceInfo(`Start Suite Code Completion via Jupyter`); | ||
// this.timeout(120_000); | ||
// await initialize(); | ||
// await startJupyterServer(); | ||
// await prewarmNotebooks(); | ||
// sinon.restore(); | ||
// traceInfo(`Start Suite (Completed) Code Completion via Jupyter`); | ||
// }); | ||
// // Use same notebook without starting kernel in every single test (use one for whole suite). | ||
// setup(async function () { | ||
// traceInfo(`Start Test ${this.currentTest?.title}`); | ||
// sinon.restore(); | ||
// await startJupyterServer(); | ||
// await createEmptyPythonNotebook(disposables); | ||
// traceInfo(`Start Test (completed) ${this.currentTest?.title}`); | ||
// }); | ||
// teardown(async function () { | ||
// traceInfo(`Ended Test ${this.currentTest?.title}`); | ||
// if (this.currentTest?.isFailed()) { | ||
// await captureScreenShot(this); | ||
// } | ||
// await closeNotebooksAndCleanUpAfterTests(disposables); | ||
// traceInfo(`Ended Test (completed) ${this.currentTest?.title}`); | ||
// }); | ||
// suiteTeardown(() => closeNotebooksAndCleanUpAfterTests(disposables)); | ||
// test('Execute cell and get completions for variable', async () => { | ||
// await insertCodeCell('import sys\nprint(sys.executable)\na = 1', { index: 0 }); | ||
// const cell = window.activeNotebookEditor?.notebook.cellAt(0)!; | ||
|
||
await runCell(cell); | ||
// await runCell(cell); | ||
|
||
// Wait till execution count changes and status is success. | ||
await waitForExecutionCompletedSuccessfully(cell); | ||
const outputText = getTextOutputValue(cell.outputs[0]).trim(); | ||
traceInfo(`Cell Output ${outputText}`); | ||
await insertCodeCell('a.', { index: 1 }); | ||
const cell2 = window.activeNotebookEditor!.notebook.cellAt(1); | ||
// // Wait till execution count changes and status is success. | ||
// await waitForExecutionCompletedSuccessfully(cell); | ||
// const outputText = getTextOutputValue(cell.outputs[0]).trim(); | ||
// traceInfo(`Cell Output ${outputText}`); | ||
// await insertCodeCell('a.', { index: 1 }); | ||
// const cell2 = window.activeNotebookEditor!.notebook.cellAt(1); | ||
|
||
const position = new Position(0, 2); | ||
traceInfo('Get completions in test'); | ||
// Executing the command `vscode.executeCompletionItemProvider` to simulate triggering completion | ||
const completions = (await commands.executeCommand( | ||
'vscode.executeCompletionItemProvider', | ||
cell2.document.uri, | ||
position | ||
)) as CompletionList; | ||
const items = completions.items.map((item) => item.label); | ||
assert.isOk(items.length); | ||
assert.ok( | ||
items.find((item) => | ||
typeof item === 'string' ? item.includes('bit_length') : item.label.includes('bit_length') | ||
) | ||
); | ||
assert.ok( | ||
items.find((item) => | ||
typeof item === 'string' ? item.includes('to_bytes') : item.label.includes('to_bytes') | ||
) | ||
); | ||
}); | ||
}); | ||
// const position = new Position(0, 2); | ||
// traceInfo('Get completions in test'); | ||
// // Executing the command `vscode.executeCompletionItemProvider` to simulate triggering completion | ||
// const completions = (await commands.executeCommand( | ||
// 'vscode.executeCompletionItemProvider', | ||
// cell2.document.uri, | ||
// position | ||
// )) as CompletionList; | ||
// const items = completions.items.map((item) => item.label); | ||
// assert.isOk(items.length); | ||
// assert.ok( | ||
// items.find((item) => | ||
// typeof item === 'string' ? item.includes('bit_length') : item.label.includes('bit_length') | ||
// ) | ||
// ); | ||
// assert.ok( | ||
// items.find((item) => | ||
// typeof item === 'string' ? item.includes('to_bytes') : item.label.includes('to_bytes') | ||
// ) | ||
// ); | ||
// }); | ||
// }); |
Oops, something went wrong.