Skip to content

Commit 5a57498

Browse files
authored
test(e2e): defeat template-filter pollution in the bundle_init wizard (#2123)
## 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: 1. **Keystroke focus race** — the editor tab becoming *active* doesn't guarantee the xterm holds keyboard focus, so keys fired next can land in the tab chrome instead of the wizard. 2. **Template-filter pollution** — per `BundleInitWizard.bundleInitInTerminal` (see its own comment), the Python extension can inject env-setup text into the freshly opened terminal, and that text lands in the wizard's template **search filter**. The typed `default-python` then appends to that text, matches no template, and the wizard stalls until the 40s completion loop times out. The terminal buffer isn't reliably readable via the wdio API on this editor-hosted terminal, so the fix hardens the input path rather than reading state back. ## What - **Focus the terminal input** (`workbench.action.terminal.focus`) after the tab is active and 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 already empty, and it removes any injected env-setup text so `default-python` matches. - The Enter-hammering completion loop (which accepts the remaining default-python prompt defaults) 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 is verified via **isolated CI runs of `bundle_init`** on this branch (repeated, since one green run ≠ stable). This pull request and its description were written by Isaac.
1 parent f606d0a commit 5a57498

1 file changed

Lines changed: 29 additions & 6 deletions

File tree

packages/databricks-vscode/src/test/e2e/bundle_init.e2e.ts

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,17 @@ describe("Bundle Init", async function () {
7777
assert(initTab, "Can't find a tab for project-init terminal wizard");
7878
await initTab.select();
7979

80-
// The init wizard runs inside an editor-hosted terminal. Keystrokes sent
81-
// before the terminal prompt is ready land in the wrong place and desync
82-
// the wizard ("Can't complete cli bundle init wizard") on the slow
83-
// Windows shard. The terminal buffer text isn't reliably readable via the
84-
// wdio API, but the active-tab title is — gate on the init tab being
85-
// active before typing, then use longer settle waits between keystrokes.
80+
// The init wizard runs inside an editor-hosted terminal. Two Windows
81+
// races desync it into "Can't complete cli bundle init wizard": (1)
82+
// keystrokes fired before the tab is active — or before the xterm holds
83+
// keyboard focus — land in the wrong place, and (2) the Python extension
84+
// can inject env-setup text into the freshly opened terminal that lands
85+
// in the template *search filter* (see
86+
// BundleInitWizard.bundleInitInTerminal), so a typed "default-python"
87+
// appends to that text, matches no template, and the wizard stalls. The
88+
// terminal buffer isn't reliably readable via the wdio API, but the
89+
// active-tab title is — gate on the init tab being active, move focus
90+
// into the terminal, then clear the filter before typing.
8691
await browser.waitUntil(
8792
async () => {
8893
const activeTab = await editorView.getActiveTab();
@@ -96,6 +101,24 @@ describe("Bundle Init", async function () {
96101
);
97102
await sleep(3000);
98103

104+
// Move keyboard focus into the editor-hosted terminal's input so the
105+
// wizard keystrokes below aren't swallowed by the editor-tab chrome.
106+
// Return the command so executeWorkbench awaits focus completing.
107+
await browser.executeWorkbench((vscode) => {
108+
return vscode.commands.executeCommand(
109+
"workbench.action.terminal.focus"
110+
);
111+
});
112+
await sleep(1000);
113+
114+
// Clear the filter before typing (see above); a no-op when it's empty.
115+
// Over-provision the backspaces so even a long injected activation line
116+
// (a Windows venv/conda activate command with an absolute path) is
117+
// fully removed rather than leaving a prefix the template name appends
118+
// to.
119+
await browser.keys(new Array(200).fill(Key.Backspace));
120+
await sleep(1000);
121+
99122
//select temaplate type
100123
await browser.keys("default-python".split(""));
101124
await sleep(3000);

0 commit comments

Comments
 (0)