From ebe4d164703aad13b4d04e35c02bee0e05cb7469 Mon Sep 17 00:00:00 2001 From: Danny Avila Date: Mon, 27 Jul 2026 00:14:43 -0400 Subject: [PATCH] test: make the UI schedule spec's agent selection cache-independent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The picker reads useListAgentsQuery, but ensureAgent creates the agent over raw fetch, which never invalidates that cache — so a just-created agent existed server-side and was absent from the dropdown, and filtering by its name could never match. Reload so the query refetches, and select whatever the virtualized list renders first: this test is about the cadence round-tripping, not about which agent is attached. --- e2e/specs/mock/schedules-execution.spec.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/e2e/specs/mock/schedules-execution.spec.ts b/e2e/specs/mock/schedules-execution.spec.ts index bf89ed3be5..79a899ca32 100644 --- a/e2e/specs/mock/schedules-execution.spec.ts +++ b/e2e/specs/mock/schedules-execution.spec.ts @@ -197,7 +197,11 @@ test.describe('scheduled chat execution', () => { test.setTimeout(120000); await page.goto('/c/new', { timeout: 15000 }); const token = await getAccessToken(page); - const agent = await ensureAgent(page, token); + await ensureAgent(page, token); + // The dialog's picker reads useListAgentsQuery, and ensureAgent creates the agent + // over raw fetch — which never invalidates that cache. Without this reload a + // just-created agent exists server-side but is absent from the dropdown. + await page.reload(); await openSchedulesPanel(page); await page.getByRole('button', { name: 'New schedule' }).click(); @@ -207,12 +211,14 @@ test.describe('scheduled chat execution', () => { await dialog.locator('#schedule-name').fill(name); await dialog.locator('#schedule-prompt').fill('Daily standup summary'); - // agent_id is required, so the submit stays disabled until one is picked. The list - // is virtualized, so the target row is only in the DOM once the search narrows to - // it — clicking the option directly races the renderer on a populated account. + // agent_id is required, so the submit stays disabled until one is picked. Any agent + // will do — this test is about the cadence round-tripping, not about which agent — + // so take whatever the (virtualized) list renders first rather than depending on a + // specific name being present and in view. await dialog.getByRole('combobox', { name: 'Agent' }).click(); - await page.getByPlaceholder('Search agents by name').fill(agent.name!); - await page.getByRole('option', { name: agent.name!, exact: true }).first().click(); + const firstAgent = page.getByRole('option').first(); + await expect(firstAgent).toBeVisible({ timeout: 15000 }); + await firstAgent.click(); // Weekly rather than the default so the assertion proves the cadence round-tripped // rather than matching whatever the form happened to default to. await dialog.getByRole('group', { name: 'Frequency' }).getByText('Weekly').click();