The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
test: simplify chat tool call assertions to use timeline
Steven Enamakel1271794f2890
diff --git a/app/test/playwright/specs/chat-multi-tool-round.spec.ts b/app/test/playwright/specs/chat-multi-tool-round.spec.tsindex 98943e66ee..c581852e7e 100644--- a/app/test/playwright/specs/chat-multi-tool-round.spec.ts+++ b/app/test/playwright/specs/chat-multi-tool-round.spec.ts@@ -35,12 +35,6 @@ const FORCED_RESPONSES = [{ content: `Found the content using both tools: ${CANARY_FINAL}` },];-interface MockRequest {- method: string;- url: string;- body?: string;-}-async function resetMock(): Promise<void> {await fetch(`${MOCK_ADMIN_BASE}/__admin/reset`, {method: 'POST',@@ -57,22 +51,6 @@ async function setMockBehavior(key: string, value: string): Promise<void> {});}-async function requests(): Promise<MockRequest[]> {- const response = await fetch(`${MOCK_ADMIN_BASE}/__admin/requests`);- const payload = (await response.json()) as { data?: MockRequest[] };- return Array.isArray(payload.data) ? payload.data : [];-}--function findToolInLlmLog(log: MockRequest[], toolName: string): boolean {- return log.some(- request =>- request.method === 'POST' &&- request.url.includes('/chat/completions') &&- typeof request.body === 'string' &&- request.body.includes(`"${toolName}"`)- );-}-async function openChat(page: Page): Promise<void> {await bootAuthenticatedPage(page, USER_ID, '/chat');await page.goto('/#/chat');@@ -179,36 +157,14 @@ test.describe('Chat Multi Tool Round', () => {await sendMessage(page, PROMPT);await expect(agentMessageText(page, CANARY_FINAL)).toBeVisible({ timeout: 50_000 });-- await expect- .poll(- async () => {- const names = await toolTimelineNames(page, threadId);- if (names.some(name => name.includes('web_fetch'))) return true;- return findToolInLlmLog(await requests(), 'web_fetch');- },- { timeout: 20_000 }- )- .toBe(true);-- await expect- .poll(- async () => {- const names = await toolTimelineNames(page, threadId);- if (names.some(name => name.includes('web_search'))) return true;- return findToolInLlmLog(await requests(), 'web_search_tool');- },- { timeout: 20_000 }- )- .toBe(true);-await expect- .poll(async () => {- const log = await requests();- return log.filter(- entry => entry.method === 'POST' && entry.url.includes('/openai/v1/chat/completions')- ).length;- })- .toBeGreaterThanOrEqual(3);+ .poll(async () => toolTimelineNames(page, threadId), { timeout: 20_000 })+ .toEqual(expect.arrayContaining([expect.stringContaining('web_fetch'), expect.stringContaining('web_search')]));++ const names = await toolTimelineNames(page, threadId);+ const fetchIndex = names.findIndex(name => name.includes('web_fetch'));+ const searchIndex = names.findIndex(name => name.includes('web_search'));+ expect(fetchIndex).toBeGreaterThanOrEqual(0);+ expect(searchIndex).toBeGreaterThan(fetchIndex);});});diff --git a/app/test/playwright/specs/chat-tool-call-flow.spec.ts b/app/test/playwright/specs/chat-tool-call-flow.spec.tsindex 5556e6c16e..fcdfbbd102 100644--- a/app/test/playwright/specs/chat-tool-call-flow.spec.ts+++ b/app/test/playwright/specs/chat-tool-call-flow.spec.ts@@ -27,12 +27,6 @@ const FORCED_RESPONSES = [{ content: FINAL_RESPONSE },];-interface MockRequest {- method: string;- url: string;- body?: string;-}-async function resetMock(): Promise<void> {await fetch(`${MOCK_ADMIN_BASE}/__admin/reset`, {method: 'POST',@@ -49,22 +43,6 @@ async function setMockBehavior(key: string, value: string): Promise<void> {});}-async function requests(): Promise<MockRequest[]> {- const response = await fetch(`${MOCK_ADMIN_BASE}/__admin/requests`);- const payload = (await response.json()) as { data?: MockRequest[] };- return Array.isArray(payload.data) ? payload.data : [];-}--function findToolInLlmLog(log: MockRequest[], toolName: string): boolean {- return log.some(- request =>- request.method === 'POST' &&- request.url.includes('/chat/completions') &&- typeof request.body === 'string' &&- request.body.includes(`"${toolName}"`)- );-}-async function openChat(page: Page): Promise<void> {await bootAuthenticatedPage(page, USER_ID, '/chat');await page.goto('/#/chat');@@ -201,24 +179,8 @@ test.describe('Chat Tool Call Flow', () => {await expect(toolCard.getByText('Input', { exact: true })).toBeVisible();await expect- .poll(- async () => {- const names = await toolTimelineNames(page, threadId);- if (names.some(name => name.includes('web_fetch'))) return true;- return findToolInLlmLog(await requests(), 'web_fetch');- },- { timeout: 20_000 }- )- .toBe(true);-- await expect- .poll(async () => {- const log = await requests();- return log.filter(- entry => entry.method === 'POST' && entry.url.includes('/openai/v1/chat/completions')- ).length;- })- .toBeGreaterThanOrEqual(2);+ .poll(async () => toolTimelineNames(page, threadId), { timeout: 20_000 })+ .toEqual(expect.arrayContaining([expect.stringContaining('web_fetch')]));expect(threadId.length).toBeGreaterThan(0);});