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

text-tool-text.spec.ts

42 lines1.4 KB

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