From 887af7485dc5a20861bbe15d4ec5aeaaf67ae55c Mon Sep 17 00:00:00 2001 From: "@rugpanov" Date: Fri, 14 Aug 2026 22:05:06 +0200 Subject: [PATCH 1/2] test(e2e): defeat template-filter pollution in the bundle_init wizard MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Why `bundle_init :: should initialize new project` still flakes on the Windows shard with "Can't complete cli bundle init wizard" (its two follow-on tests then cascade), despite #2034 gating the first keystroke on tab-readiness. Two races remain: keystrokes can land before the editor terminal holds keyboard focus, and — per BundleInitWizard.bundleInitInTerminal — the Python extension can inject env-setup text into the freshly opened terminal that lands in the template *search filter*, so the typed "default-python" appends to that text, matches no template, and the wizard stalls until the 40s completion loop times out. ## What - Move keyboard focus into the editor-hosted terminal (`workbench.action.terminal.focus`) before typing, so wizard keystrokes aren't swallowed by the editor-tab chrome. - Clear the template search filter with a burst of Backspace keys before typing the template name (a no-op when the filter is empty), removing any injected env-setup text so the name matches. - The completion loop and the ground-truth workspace-root gate are unchanged. Test-only: no production code, settings, persisted state, telemetry, or when-clause flags. Nothing changes for shards that never hit the races. ## Verification - `tsc -p src/test/e2e/tsconfig.json`: no new errors (the sole error is the pre-existing `assert {type: "json"}` in `wdio.conf.ts`, untouched here). - `eslint` + `prettier -c` clean on the touched file. - e2e-only behavior verified via isolated CI runs of `bundle_init` on the branch (repeated, since one green run != stable). Co-authored-by: Isaac --- .../src/test/e2e/bundle_init.e2e.ts | 31 +++++++++++++++---- 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/packages/databricks-vscode/src/test/e2e/bundle_init.e2e.ts b/packages/databricks-vscode/src/test/e2e/bundle_init.e2e.ts index 6f621b49f..b32f5ec96 100644 --- a/packages/databricks-vscode/src/test/e2e/bundle_init.e2e.ts +++ b/packages/databricks-vscode/src/test/e2e/bundle_init.e2e.ts @@ -77,12 +77,17 @@ describe("Bundle Init", async function () { assert(initTab, "Can't find a tab for project-init terminal wizard"); await initTab.select(); - // The init wizard runs inside an editor-hosted terminal. Keystrokes sent - // before the terminal prompt is ready land in the wrong place and desync - // the wizard ("Can't complete cli bundle init wizard") on the slow - // Windows shard. The terminal buffer text isn't reliably readable via the - // wdio API, but the active-tab title is — gate on the init tab being - // active before typing, then use longer settle waits between keystrokes. + // The init wizard runs inside an editor-hosted terminal. Two Windows + // races desync it into "Can't complete cli bundle init wizard": (1) + // keystrokes fired before the tab is active — or before the xterm holds + // keyboard focus — land in the wrong place, and (2) the Python extension + // can inject env-setup text into the freshly opened terminal that lands + // in the template *search filter* (see + // BundleInitWizard.bundleInitInTerminal), so a typed "default-python" + // appends to that text, matches no template, and the wizard stalls. The + // terminal buffer isn't reliably readable via the wdio API, but the + // active-tab title is — gate on the init tab being active, move focus + // into the terminal, then clear the filter before typing. await browser.waitUntil( async () => { const activeTab = await editorView.getActiveTab(); @@ -96,6 +101,20 @@ describe("Bundle Init", async function () { ); await sleep(3000); + // Move keyboard focus into the editor-hosted terminal's input so the + // wizard keystrokes below aren't swallowed by the editor-tab chrome. + await browser.executeWorkbench((vscode) => { + vscode.commands.executeCommand("workbench.action.terminal.focus"); + }); + await sleep(1000); + + // Clear any env-setup text the Python extension injected into the + // template search filter (a no-op when the filter is already empty) so + // the template name we type next matches. 50 backspaces comfortably + // covers a typical injected activate line. + await browser.keys(new Array(50).fill(Key.Backspace)); + await sleep(1000); + //select temaplate type await browser.keys("default-python".split("")); await sleep(3000); From e0c08501102c137d3e700ca2b06520f6dac4cae7 Mon Sep 17 00:00:00 2001 From: "@rugpanov" Date: Fri, 14 Aug 2026 22:15:50 +0200 Subject: [PATCH 2/2] test(e2e): harden the filter clear from review feedback ## Why Review (Codex + a devil's-advocate pass) flagged two robustness gaps in the first commit: a 50-backspace burst can leave a prefix when the Python extension injects a long activation line (a Windows venv/conda activate with an absolute path exceeds 50 chars), and the terminal-focus callback didn't return the command, so `executeWorkbench` resolved before focus completed and relied on the trailing sleep alone. ## What - Over-provision the filter clear to 200 backspaces. Backspacing an empty filter is a no-op, so a larger count only adds safety margin for long injected lines; it can't corrupt a clean run. - Return `executeCommand` from the focus callback so `executeWorkbench` awaits focus completing before the keystrokes are sent. - Trim the filter-clear comment so it no longer restates the block above it. Still test-only: no production code, settings, state, telemetry, or when-clause flags. ## Verification - `tsc -p src/test/e2e/tsconfig.json`: no new errors (only the pre-existing `assert {type: "json"}` in `wdio.conf.ts`). - `eslint` + `prettier -c` clean on the touched file. Co-authored-by: Isaac --- .../src/test/e2e/bundle_init.e2e.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/databricks-vscode/src/test/e2e/bundle_init.e2e.ts b/packages/databricks-vscode/src/test/e2e/bundle_init.e2e.ts index b32f5ec96..ea668246c 100644 --- a/packages/databricks-vscode/src/test/e2e/bundle_init.e2e.ts +++ b/packages/databricks-vscode/src/test/e2e/bundle_init.e2e.ts @@ -103,16 +103,20 @@ describe("Bundle Init", async function () { // Move keyboard focus into the editor-hosted terminal's input so the // wizard keystrokes below aren't swallowed by the editor-tab chrome. + // Return the command so executeWorkbench awaits focus completing. await browser.executeWorkbench((vscode) => { - vscode.commands.executeCommand("workbench.action.terminal.focus"); + return vscode.commands.executeCommand( + "workbench.action.terminal.focus" + ); }); await sleep(1000); - // Clear any env-setup text the Python extension injected into the - // template search filter (a no-op when the filter is already empty) so - // the template name we type next matches. 50 backspaces comfortably - // covers a typical injected activate line. - await browser.keys(new Array(50).fill(Key.Backspace)); + // Clear the filter before typing (see above); a no-op when it's empty. + // Over-provision the backspaces so even a long injected activation line + // (a Windows venv/conda activate command with an absolute path) is + // fully removed rather than leaving a prefix the template name appends + // to. + await browser.keys(new Array(200).fill(Key.Backspace)); await sleep(1000); //select temaplate type