Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix restart kernel tests #13844

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ import { isUri } from '../../../../platform/common/utils/misc';
import { hasErrorOutput, translateCellErrorOutput } from '../../../../kernels/execution/helpers';
import { BaseKernelError } from '../../../../kernels/errors/types';
import { IControllerRegistration } from '../../../../notebooks/controllers/types';
import { traceVerbose } from '../../../../platform/logging';

/* eslint-disable no-invalid-this, , , @typescript-eslint/no-explicit-any */
suite('Install IPyKernel (install) @kernelInstall', function () {
Expand Down Expand Up @@ -562,7 +563,7 @@ suite('Install IPyKernel (install) @kernelInstall', function () {
await openNotebookAndInstallIpyKernelWhenRunningCell(venvNoKernelPath, venvNoRegPath, 'DoNotInstallIPyKernel');
});
// https://github.com/microsoft/vscode-jupyter/issues/12766
test.skip('Should be prompted to re-install ipykernel when restarting a kernel from which ipykernel was uninstalled (VSCode Notebook)', async function () {
test('Should be prompted to re-install ipykernel when restarting a kernel from which ipykernel was uninstalled (VSCode Notebook)', async function () {
if (IS_REMOTE_NATIVE_TEST()) {
return this.skip();
}
Expand All @@ -578,16 +579,25 @@ suite('Install IPyKernel (install) @kernelInstall', function () {

// Confirm message is displayed.
installerSpy = sinon.spy(installer, 'install');
const promptToInstall = await clickInstallFromIPyKernelPrompt();
// Confirm message is displayed.
let installedIPyKernel = false;

// First hookup the prompt for restarting the kernel;
const restartPrompt = await clickOKForRestartPrompt();
restartPrompt.displayed
.then(async () => {
restartPrompt.dispose();
// Next hookup the prompt for re-install ipykernel.
const selectionPrompt = await clickInstallFromIPyKernelPrompt();
installedIPyKernel = await selectionPrompt.displayed;
})
.catch(noop);

await Promise.all([
commandManager.executeCommand(Commands.RestartKernel, {
notebookEditor: { notebookUri: nbFile }
}),
waitForCondition(
async () => promptToInstall.displayed.then(() => true),
delayForUITest,
'Prompt not displayed'
),
waitForCondition(async () => installedIPyKernel, delayForUITest, 'Prompt not displayed'),
waitForIPyKernelToGetInstalled()
]);
});
Expand All @@ -607,19 +617,29 @@ suite('Install IPyKernel (install) @kernelInstall', function () {
assert.ok(startController);

// Confirm message is displayed.
const promptToInstall = await selectKernelFromIPyKernelPrompt();
const { kernelSelected } = hookupKernelSelected(promptToInstall, venvNoRegPath);

let promptToInstallDisplayed = false;
let kernelSelected = false;

// First hookup the prompt for restarting the kernel;
const restartPrompt = await clickOKForRestartPrompt();
restartPrompt.displayed
.then(async () => {
restartPrompt.dispose();
// Next hookup the prompt for re-install ipykernel.
const selectionPrompt = await selectKernelFromIPyKernelPrompt();
traceVerbose('Hooked prompt to change kernel');
promptToInstallDisplayed = await selectionPrompt.displayed;
traceVerbose('Displayed and handled prompt to change kernel', promptToInstallDisplayed);
// Next hookup the prompt for selecting a kernel
kernelSelected = await hookupKernelSelected(restartPrompt, venvNoRegPath).kernelSelected;
traceVerbose('Hooked prompt to select a new kernel', kernelSelected);
})
.catch(noop);
traceVerbose('Waiting For all');
await Promise.all([
commandManager.executeCommand(Commands.RestartKernel, {
notebookEditor: { notebookUri: nbFile }
}),
waitForCondition(
async () => promptToInstall.displayed.then(() => true),
delayForUITest,
'Prompt not displayed'
),
waitForCondition(async () => kernelSelected, delayForUITest, 'New kernel not selected'),
commandManager.executeCommand(Commands.RestartKernel, { notebookEditor: { notebookUri: nbFile } }),
waitForCondition(() => promptToInstallDisplayed, delayForUITest, 'Prompt not displayed'),
waitForCondition(() => kernelSelected, delayForUITest, 'New kernel not selected'),
// Verify the new kernel associated with this notebook is different.
waitForCondition(
async () => {
Expand Down Expand Up @@ -755,6 +775,14 @@ suite('Install IPyKernel (install) @kernelInstall', function () {
disposables
);
}
async function clickOKForRestartPrompt() {
return hijackPrompt(
'showInformationMessage',
{ contains: DataScience.restartKernelMessage },
{ result: DataScience.restartKernelMessageYes, clickImmediately: true },
disposables
);
}
async function clickInstallFromIPyKernelPrompt() {
return hijackPrompt(
'showInformationMessage',
Expand Down
Loading