From 2e130aa7b1194430e33295a26dfa593025f2f0fb Mon Sep 17 00:00:00 2001 From: tomas Date: Fri, 23 Oct 2026 14:48:29 +0000 Subject: [PATCH] test(e2e): wait for the notebook kernel before clicking Run All On notebook open, the Deepnote controller registers only after the interpreter resolves, which waits on the Python extension and can finish after the editor and its Run All button are up. A Run All click in that window finds no kernel, so VS Code opens its kernel picker and holds the run on it. Nothing answers the picker, the first attempt times out waiting for output, and Mocha's retry then fails with "Run All button did not appear". This made the execution shard flaky on main and unrelated PRs. clickRunAll now waits until the notebook toolbar's kernel label names a kernel: the same selected-or-only kernel VS Code resolves Run All against. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01CqyiyR2czV5oi4Y4bu76FS --- test/e2e/helpers/notebook.ts | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/test/e2e/helpers/notebook.ts b/test/e2e/helpers/notebook.ts index 5ce01552a0..0af0b9f369 100644 --- a/test/e2e/helpers/notebook.ts +++ b/test/e2e/helpers/notebook.ts @@ -3,6 +3,8 @@ import { By, EditorView, VSBrowser, WebElement, WebView } from 'vscode-extension import { OUTPUT_FRAME_SWITCH_TIMEOUT, OUTPUT_POLL_INTERVAL, OUTPUT_SELECTOR, WORKBENCH_TIMEOUT } from './constants'; import { dismissAllNotifications } from './notifications'; +const NO_KERNEL_LABEL = 'Select Kernel'; + /** * Focuses the given notebook editor and clicks the toolbar button carrying `ariaLabel`. The * command-palette entries for these actions are gated behind context keys @@ -53,7 +55,36 @@ async function clickNotebookToolbarButton( ); } +/** + * Waits until the notebook toolbar names a kernel. "Run All" runs on the kernel that label shows; with + * none, VS Code holds the run on a kernel picker that nothing answers under automation. The Deepnote + * controller registers only once the interpreter resolves, which can land after the editor opens. + */ +async function awaitNotebookKernel(): Promise { + const driver = VSBrowser.instance.driver; + + await driver.wait( + async () => { + try { + const [label] = await driver.findElements(By.css('.kernel-action-view-item .kernel-label')); + const text = ((await label?.getAttribute('textContent')) ?? '').trim(); + + return text !== '' && text !== NO_KERNEL_LABEL; + } catch (error) { + console.warn('[deepnote-e2e] read notebook kernel label (retrying):', error); + + return false; + } + }, + WORKBENCH_TIMEOUT, + 'notebook toolbar never named a kernel, so "Run All" would block on the kernel picker' + ); +} + export async function clickRunAll(notebookFileName: string): Promise { + await new EditorView().openEditor(notebookFileName); + await awaitNotebookKernel(); + return clickNotebookToolbarButton(notebookFileName, 'Run All'); }