From b6f031c789db2051577671999edf1532ec0da036 Mon Sep 17 00:00:00 2001 From: Mohamed Boudra Date: Thu, 22 Oct 2026 11:07:16 +0200 Subject: [PATCH] test(app): wait for agent control rows before keying the Command Center Two Command Center agent-control tests typed a query and pressed Enter or ArrowDown immediately. The agent's mode and model rows register after the panel opens, so on a slow runner the keys landed while only file search had matched and the mode never changed. The CI trace for the failure shows no Mode or Model rows at the moment of the key press. The tests now wait until both groups are listed, which keeps what they check: the best match wins, and a stale arrow-key selection is dropped. --- .../command-center-agent-controls.spec.ts | 7 ++++--- .../helpers/command-center-agent-controls.ts | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/packages/app/e2e/browser/command-center-agent-controls.spec.ts b/packages/app/e2e/browser/command-center-agent-controls.spec.ts index 658e0e1123..a2082ac09b 100644 --- a/packages/app/e2e/browser/command-center-agent-controls.spec.ts +++ b/packages/app/e2e/browser/command-center-agent-controls.spec.ts @@ -5,6 +5,7 @@ import { applyCommandCenterAgentControls, chooseCommandCenterAgentControl, openCommandCenterForAgent, + searchAgentControls, expectCommandCenterAgentControlSelected, expectFocusedAgentControls, expectWorkspaceAgentConfiguration, @@ -111,8 +112,8 @@ test.describe("Command Center agent controls", () => { }); try { await workspace.client.setAgentMode(workspace.agentId, "approval-test"); - const input = await openCommandCenterForAgent(page, workspace); - await input.fill("load"); + await openCommandCenterForAgent(page, workspace); + await searchAgentControls(page, "load"); await page.keyboard.press("Enter"); await expectWorkspaceAgentConfiguration(workspace, { @@ -184,7 +185,7 @@ test.describe("Command Center agent controls", () => { try { await workspace.client.setAgentMode(workspace.agentId, "approval-test"); const input = await openCommandCenterForAgent(page, workspace); - await input.fill("loa"); + await searchAgentControls(page, "loa"); // Moves the highlight onto a model row, which still matches after the next keystroke. await page.keyboard.press("ArrowDown"); await input.fill("load"); diff --git a/packages/app/e2e/support/helpers/command-center-agent-controls.ts b/packages/app/e2e/support/helpers/command-center-agent-controls.ts index c460154d25..6b51b84609 100644 --- a/packages/app/e2e/support/helpers/command-center-agent-controls.ts +++ b/packages/app/e2e/support/helpers/command-center-agent-controls.ts @@ -22,6 +22,22 @@ export async function openCommandCenterForAgent( return panel.getByTestId("command-center-input"); } +/** + * Types a query that matches both the agent's modes and its models, and waits until rows from both + * groups are listed. The agent's controls register after the panel opens; a key pressed before + * then lands on whatever else matched, such as file search. + */ +export async function searchAgentControls(page: Page, query: string): Promise { + const panel = page.getByTestId("command-center-panel"); + await panel.getByTestId("command-center-input").fill(query); + await expect(panel.getByRole("button", { name: /^Mode › / }).first()).toBeVisible({ + timeout: 30_000, + }); + await expect(panel.getByRole("button", { name: /^Model › / }).first()).toBeVisible({ + timeout: 30_000, + }); +} + export async function chooseCommandCenterAgentControl(input: { page: Page; query: string;