44import { assert } from 'chai' ;
55import * as path from 'path' ;
66import * as sinon from 'sinon' ;
7- import { env } from 'vscode' ;
7+ import { CodeLens , commands , env , window } from 'vscode' ;
88import { IExperimentService } from '../../client/common/types' ;
99import { IServiceManager } from '../../client/ioc/types' ;
1010import { TensorBoardNbextensionCodeLensProvider } from '../../client/tensorBoard/nbextensionCodeLensProvider' ;
@@ -17,6 +17,7 @@ import {
1717 initializeTest ,
1818} from '../initialize' ;
1919import { openFile , waitForCondition } from '../common' ;
20+ import { openNotebook } from '../smoke/common' ;
2021
2122suite ( 'TensorBoard code lens provider' , ( ) => {
2223 suiteSetup ( async function ( ) {
@@ -63,23 +64,23 @@ suite('TensorBoard code lens provider', () => {
6364 ) ;
6465 assert . ok ( spy . notCalled , 'Called provideCodeLens for Python file loading tensorboard nbextension' ) ;
6566 } ) ;
66- // test('Provide code lens for Python notebook loading and launching tensorboard nbextension', async () => {
67- // const filePath = path.join(
68- // EXTENSION_ROOT_DIR_FOR_TESTS,
69- // 'src',
70- // 'test',
71- // 'pythonFiles',
72- // 'tensorBoard',
73- // 'tensorboard_nbextension.ipynb',
74- // );
75- // const notebook = await openNotebook(filePath);
76- // assert(window.activeTextEditor, 'No active editor');
77- // const codeLenses = await commands.executeCommand<CodeLens[]>(
78- // 'vscode.executeCodeLensProvider',
79- // notebook.cellAt(0).document.uri,
80- // );
81- // assert.ok(codeLenses?.length && codeLenses.length > 0, 'Code lens provider did not provide codelenses');
82- // });
67+ test ( 'Provide code lens for Python notebook loading and launching tensorboard nbextension' , async ( ) => {
68+ const filePath = path . join (
69+ EXTENSION_ROOT_DIR_FOR_TESTS ,
70+ 'src' ,
71+ 'test' ,
72+ 'pythonFiles' ,
73+ 'tensorBoard' ,
74+ 'tensorboard_nbextension.ipynb' ,
75+ ) ;
76+ const notebook = await openNotebook ( filePath ) ;
77+ assert ( window . activeTextEditor , 'No active editor' ) ;
78+ const codeLenses = await commands . executeCommand < CodeLens [ ] > (
79+ 'vscode.executeCodeLensProvider' ,
80+ notebook . cellAt ( 0 ) . document . uri ,
81+ ) ;
82+ assert . ok ( codeLenses ?. length && codeLenses . length > 0 , 'Code lens provider did not provide codelenses' ) ;
83+ } ) ;
8384 } ) ;
8485 suite ( 'Imports' , ( ) => {
8586 let codeLensProvider : TensorBoardImportCodeLensProvider ;
@@ -120,23 +121,23 @@ suite('TensorBoard code lens provider', () => {
120121 assert . ok ( spy . returnValues . length > 0 , 'No return values recorded for provideCodeLens' ) ;
121122 assert . ok ( spy . returnValues [ 0 ] . length === 1 , 'provideCodeLenses did not return codelenses' ) ;
122123 } ) ;
123- // test('Provide code lens for Python notebook importing tensorboard', async () => {
124- // const filePath = path.join(
125- // EXTENSION_ROOT_DIR_FOR_TESTS,
126- // 'src',
127- // 'test',
128- // 'pythonFiles',
129- // 'tensorBoard',
130- // 'tensorboard_import.ipynb',
131- // );
132- // const notebook = await openNotebook(filePath);
133- // assert(window.activeTextEditor, 'No active editor');
134- // const codeLenses = await commands.executeCommand<CodeLens[]>(
135- // 'vscode.executeCodeLensProvider',
136- // notebook.cellAt(0).document.uri,
137- // );
138- // assert.ok(codeLenses?.length && codeLenses.length > 0, 'Code lens provider did not provide codelenses');
139- // });
124+ test ( 'Provide code lens for Python notebook importing tensorboard' , async ( ) => {
125+ const filePath = path . join (
126+ EXTENSION_ROOT_DIR_FOR_TESTS ,
127+ 'src' ,
128+ 'test' ,
129+ 'pythonFiles' ,
130+ 'tensorBoard' ,
131+ 'tensorboard_import.ipynb' ,
132+ ) ;
133+ const notebook = await openNotebook ( filePath ) ;
134+ assert ( window . activeTextEditor , 'No active editor' ) ;
135+ const codeLenses = await commands . executeCommand < CodeLens [ ] > (
136+ 'vscode.executeCodeLensProvider' ,
137+ notebook . cellAt ( 0 ) . document . uri ,
138+ ) ;
139+ assert . ok ( codeLenses ?. length && codeLenses . length > 0 , 'Code lens provider did not provide codelenses' ) ;
140+ } ) ;
140141 test ( 'Does not provide code lens if no matching import' , async ( ) => {
141142 await openFile (
142143 path . join ( EXTENSION_ROOT_DIR_FOR_TESTS , 'src' , 'test' , 'pythonFiles' , 'tensorBoard' , 'noMatch.py' ) ,
0 commit comments