@@ -68,6 +68,7 @@ import { isUri } from '../../../../platform/common/utils/misc';
68
68
import { hasErrorOutput , translateCellErrorOutput } from '../../../../kernels/execution/helpers' ;
69
69
import { BaseKernelError } from '../../../../kernels/errors/types' ;
70
70
import { IControllerRegistration } from '../../../../notebooks/controllers/types' ;
71
+ import { traceVerbose } from '../../../../platform/logging' ;
71
72
72
73
/* eslint-disable no-invalid-this, , , @typescript-eslint/no-explicit-any */
73
74
suite ( 'Install IPyKernel (install) @kernelInstall' , function ( ) {
@@ -562,7 +563,7 @@ suite('Install IPyKernel (install) @kernelInstall', function () {
562
563
await openNotebookAndInstallIpyKernelWhenRunningCell ( venvNoKernelPath , venvNoRegPath , 'DoNotInstallIPyKernel' ) ;
563
564
} ) ;
564
565
// https://github.com/microsoft/vscode-jupyter/issues/12766
565
- test . skip ( 'Should be prompted to re-install ipykernel when restarting a kernel from which ipykernel was uninstalled (VSCode Notebook)' , async function ( ) {
566
+ test ( 'Should be prompted to re-install ipykernel when restarting a kernel from which ipykernel was uninstalled (VSCode Notebook)' , async function ( ) {
566
567
if ( IS_REMOTE_NATIVE_TEST ( ) ) {
567
568
return this . skip ( ) ;
568
569
}
@@ -578,16 +579,25 @@ suite('Install IPyKernel (install) @kernelInstall', function () {
578
579
579
580
// Confirm message is displayed.
580
581
installerSpy = sinon . spy ( installer , 'install' ) ;
581
- const promptToInstall = await clickInstallFromIPyKernelPrompt ( ) ;
582
+ // Confirm message is displayed.
583
+ let installedIPyKernel = false ;
584
+
585
+ // First hookup the prompt for restarting the kernel;
586
+ const restartPrompt = await clickOKForRestartPrompt ( ) ;
587
+ restartPrompt . displayed
588
+ . then ( async ( ) => {
589
+ restartPrompt . dispose ( ) ;
590
+ // Next hookup the prompt for re-install ipykernel.
591
+ const selectionPrompt = await clickInstallFromIPyKernelPrompt ( ) ;
592
+ installedIPyKernel = await selectionPrompt . displayed ;
593
+ } )
594
+ . catch ( noop ) ;
595
+
582
596
await Promise . all ( [
583
597
commandManager . executeCommand ( Commands . RestartKernel , {
584
598
notebookEditor : { notebookUri : nbFile }
585
599
} ) ,
586
- waitForCondition (
587
- async ( ) => promptToInstall . displayed . then ( ( ) => true ) ,
588
- delayForUITest ,
589
- 'Prompt not displayed'
590
- ) ,
600
+ waitForCondition ( async ( ) => installedIPyKernel , delayForUITest , 'Prompt not displayed' ) ,
591
601
waitForIPyKernelToGetInstalled ( )
592
602
] ) ;
593
603
} ) ;
@@ -607,19 +617,29 @@ suite('Install IPyKernel (install) @kernelInstall', function () {
607
617
assert . ok ( startController ) ;
608
618
609
619
// Confirm message is displayed.
610
- const promptToInstall = await selectKernelFromIPyKernelPrompt ( ) ;
611
- const { kernelSelected } = hookupKernelSelected ( promptToInstall , venvNoRegPath ) ;
612
-
620
+ let promptToInstallDisplayed = false ;
621
+ let kernelSelected = false ;
622
+
623
+ // First hookup the prompt for restarting the kernel;
624
+ const restartPrompt = await clickOKForRestartPrompt ( ) ;
625
+ restartPrompt . displayed
626
+ . then ( async ( ) => {
627
+ restartPrompt . dispose ( ) ;
628
+ // Next hookup the prompt for re-install ipykernel.
629
+ const selectionPrompt = await selectKernelFromIPyKernelPrompt ( ) ;
630
+ traceVerbose ( 'Hooked prompt to change kernel' ) ;
631
+ promptToInstallDisplayed = await selectionPrompt . displayed ;
632
+ traceVerbose ( 'Displayed and handled prompt to change kernel' , promptToInstallDisplayed ) ;
633
+ // Next hookup the prompt for selecting a kernel
634
+ kernelSelected = await hookupKernelSelected ( restartPrompt , venvNoRegPath ) . kernelSelected ;
635
+ traceVerbose ( 'Hooked prompt to select a new kernel' , kernelSelected ) ;
636
+ } )
637
+ . catch ( noop ) ;
638
+ traceVerbose ( 'Waiting For all' ) ;
613
639
await Promise . all ( [
614
- commandManager . executeCommand ( Commands . RestartKernel , {
615
- notebookEditor : { notebookUri : nbFile }
616
- } ) ,
617
- waitForCondition (
618
- async ( ) => promptToInstall . displayed . then ( ( ) => true ) ,
619
- delayForUITest ,
620
- 'Prompt not displayed'
621
- ) ,
622
- waitForCondition ( async ( ) => kernelSelected , delayForUITest , 'New kernel not selected' ) ,
640
+ commandManager . executeCommand ( Commands . RestartKernel , { notebookEditor : { notebookUri : nbFile } } ) ,
641
+ waitForCondition ( ( ) => promptToInstallDisplayed , delayForUITest , 'Prompt not displayed' ) ,
642
+ waitForCondition ( ( ) => kernelSelected , delayForUITest , 'New kernel not selected' ) ,
623
643
// Verify the new kernel associated with this notebook is different.
624
644
waitForCondition (
625
645
async ( ) => {
@@ -755,6 +775,14 @@ suite('Install IPyKernel (install) @kernelInstall', function () {
755
775
disposables
756
776
) ;
757
777
}
778
+ async function clickOKForRestartPrompt ( ) {
779
+ return hijackPrompt (
780
+ 'showInformationMessage' ,
781
+ { contains : DataScience . restartKernelMessage } ,
782
+ { result : DataScience . restartKernelMessageYes , clickImmediately : true } ,
783
+ disposables
784
+ ) ;
785
+ }
758
786
async function clickInstallFromIPyKernelPrompt ( ) {
759
787
return hijackPrompt (
760
788
'showInformationMessage' ,
0 commit comments