Skip to content
Source
Sign inSign up
TanStack/ai
Open History to see the last commit

tool-calling.spec.ts

31 lines947 Bytes

1import { test, expect } from './fixtures'
2import {
3 sendMessage,
4 waitForResponse,
5 getToolCalls,
6 waitForAssistantText,
7 featureUrl,
8} from './helpers'
9import { providersFor } from './test-matrix'
10​
11for (const provider of providersFor('tool-calling')) {
12 test.describe(`${provider} — tool-calling`, () => {
13 test('calls getGuitars and displays result', async ({
14 page,
15 testId,
16 aimockPort,
17 }) => {
18 await page.goto(featureUrl(provider, 'tool-calling', testId, aimockPort))
19​
20 await sendMessage(page, '[toolcall] what guitars do you have in stock')
21 await waitForResponse(page)
22​
23 const toolCalls = await getToolCalls(page)
24 expect(toolCalls.length).toBeGreaterThanOrEqual(1)
25 expect(toolCalls[0].name).toBe('getGuitars')
26​
27 // Wait for the text response after tool execution (agentic loop's second LLM call)
28 await waitForAssistantText(page, 'Fender Stratocaster')
29 })
30 })