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

text-tool-text.spec.ts

41 lines1.3 KB

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('text-tool-text')) {
12 test.describe(`${provider} — text-tool-text`, () => {
13 test('returns text and tool call in same response, then final text after tool execution', async ({
14 page,
15 testId,
16 aimockPort,
17 }) => {
18 await page.goto(
19 featureUrl(provider, 'text-tool-text', testId, aimockPort),
20 )
21​
22 await sendMessage(page, '[text-tool-text] check what guitars we have')
23 await waitForResponse(page)
24​
25 // Should have the initial text AND a tool call in the response
26 const toolCalls = await getToolCalls(page)
27 expect(toolCalls.length).toBeGreaterThanOrEqual(1)
28 expect(toolCalls[0].name).toBe('getGuitars')
29​
30 // Wait for the final text response after tool execution
31 await waitForAssistantText(page, 'Fender Stratocaster')
32​
33 // The initial "Let me check" text should also be present
34 const messages = page.getByTestId('assistant-message')
35 const allText = await messages.allInnerTexts()
36 const combined = allText.join(' ')
37 expect(combined).toContain('Let me check')
38 expect(combined).toContain('Fender Stratocaster')
39 })
40 })