@@ -56,7 +56,32 @@ async function splitEditor() {
5656 await once ;
5757}
5858
59- suite ( 'API tests' , ( ) => {
59+ suite ( 'Notebook API tests' , ( ) => {
60+ // test.only('crash', async function () {
61+ // for (let i = 0; i < 200; i++) {
62+ // let resource = vscode.Uri.file(join(vscode.workspace.rootPath || '', './first.vsctestnb'));
63+ // await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest');
64+ // await vscode.commands.executeCommand('workbench.action.revertAndCloseActiveEditor');
65+
66+ // resource = vscode.Uri.file(join(vscode.workspace.rootPath || '', './empty.vsctestnb'));
67+ // await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest');
68+ // await vscode.commands.executeCommand('workbench.action.revertAndCloseActiveEditor');
69+ // }
70+ // });
71+
72+ // test.only('crash', async function () {
73+ // for (let i = 0; i < 200; i++) {
74+ // let resource = vscode.Uri.file(join(vscode.workspace.rootPath || '', './first.vsctestnb'));
75+ // await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest');
76+ // await vscode.commands.executeCommand('workbench.action.files.save');
77+ // await vscode.commands.executeCommand('workbench.action.closeAllEditors');
78+ // resource = vscode.Uri.file(join(vscode.workspace.rootPath || '', './empty.vsctestnb'));
79+ // await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest');
80+ // await vscode.commands.executeCommand('workbench.action.files.save');
81+ // await vscode.commands.executeCommand('workbench.action.closeAllEditors');
82+ // }
83+ // });
84+
6085 test ( 'document open/close event' , async function ( ) {
6186 const resource = vscode . Uri . file ( join ( vscode . workspace . rootPath || '' , './first.vsctestnb' ) ) ;
6287 const firstDocumentOpen = getEventOncePromise ( vscode . notebook . onDidOpenNotebookDocument ) ;
@@ -222,6 +247,13 @@ suite('API tests', () => {
222247
223248 await vscode . commands . executeCommand ( 'workbench.action.files.save' ) ;
224249 await vscode . commands . executeCommand ( 'workbench.action.closeAllEditors' ) ;
250+
251+ await vscode . commands . executeCommand ( 'vscode.openWith' , resource , 'notebookCoreTest' ) ;
252+ const firstEditor = vscode . notebook . activeNotebookEditor ;
253+ assert . equal ( firstEditor ?. document . cells . length , 1 ) ;
254+
255+ await vscode . commands . executeCommand ( 'workbench.action.files.save' ) ;
256+ await vscode . commands . executeCommand ( 'workbench.action.closeAllEditors' ) ;
225257 } ) ;
226258
227259 test ( 'notebook editor active/visible' , async function ( ) {
@@ -290,7 +322,7 @@ suite('API tests', () => {
290322 assert . equal ( cellChangeEventRet . changes [ 0 ] . items [ 0 ] , vscode . notebook . activeNotebookEditor ! . document . cells [ 1 ] ) ;
291323
292324 await vscode . commands . executeCommand ( 'workbench.action.files.save' ) ;
293- await vscode . commands . executeCommand ( 'workbench.action.closeActiveEditor ' ) ;
325+ await vscode . commands . executeCommand ( 'workbench.action.closeAllEditors ' ) ;
294326 } ) ;
295327
296328 test ( 'initialzation should not emit cell change events.' , async function ( ) {
@@ -766,6 +798,9 @@ suite('metadata', () => {
766798 assert . equal ( vscode . notebook . activeNotebookEditor ! . document . metadata . custom ! [ 'testMetadata' ] as boolean , false ) ;
767799 assert . equal ( vscode . notebook . activeNotebookEditor ! . selection ?. metadata . custom ! [ 'testCellMetadata' ] as number , 123 ) ;
768800 assert . equal ( vscode . notebook . activeNotebookEditor ! . selection ?. language , 'typescript' ) ;
801+
802+ await vscode . commands . executeCommand ( 'workbench.action.files.saveAll' ) ;
803+ await vscode . commands . executeCommand ( 'workbench.action.closeAllEditors' ) ;
769804 } ) ;
770805
771806
@@ -781,6 +816,9 @@ suite('metadata', () => {
781816 const activeCell = vscode . notebook . activeNotebookEditor ! . selection ;
782817 assert . equal ( vscode . notebook . activeNotebookEditor ! . document . cells . indexOf ( activeCell ! ) , 1 ) ;
783818 assert . equal ( activeCell ?. metadata . custom ! [ 'testCellMetadata' ] as number , 123 ) ;
819+
820+ await vscode . commands . executeCommand ( 'workbench.action.files.saveAll' ) ;
821+ await vscode . commands . executeCommand ( 'workbench.action.closeAllEditors' ) ;
784822 } ) ;
785823} ) ;
786824
@@ -808,7 +846,7 @@ suite('regression', () => {
808846 await vscode . commands . executeCommand ( 'vscode.openWith' , resource , 'default' ) ;
809847 assert . equal ( vscode . window . activeTextEditor ?. document . uri . path , resource . path ) ;
810848
811- await vscode . commands . executeCommand ( 'workbench.action.files.saveAll ' ) ;
849+ await vscode . commands . executeCommand ( 'workbench.action.revertAndCloseActiveEditor ' ) ;
812850 await vscode . commands . executeCommand ( 'workbench.action.closeAllEditors' ) ;
813851 } ) ;
814852
@@ -824,7 +862,7 @@ suite('regression', () => {
824862 assert . notEqual ( vscode . notebook . activeNotebookEditor , undefined , 'notebook first' ) ;
825863 assert . notEqual ( vscode . window . activeTextEditor , undefined ) ;
826864
827- // await vscode.commands.executeCommand('workbench.action.files.saveAll ');
865+ await vscode . commands . executeCommand ( 'workbench.action.revertAndCloseActiveEditor ' ) ;
828866 await vscode . commands . executeCommand ( 'workbench.action.closeAllEditors' ) ;
829867 } ) ;
830868
0 commit comments