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

foreign-client-tool.spec.ts

31 lines1002 Bytes

1import { expect, test } from '@playwright/test'
2​
3/**
4 * An AG-UI producer that is not TanStack AI ends a run that calls a frontend
5 * tool with a success outcome and leaves the call unanswered (issue #1464).
6 * The client runs the tool, then starts one more run with the tool result in
7 * its history.
8 */
9test.describe('frontend tool from a spec-compliant AG-UI server', () => {
10 test('runs the tool and continues with its result', async ({ page }) => {
11 const posts: Array<unknown> = []
12 page.on('request', (request) => {
13 if (
14 request.url().includes('/api/foreign-client-tool') &&
15 request.method() === 'POST'
16 ) {
17 posts.push(request.postDataJSON())
18 }
19 })
20​
21 await page.goto('/foreign-client-tool')
22​
23 await expect(page.getByTestId('ping-outputs')).toHaveText(
24 '{"reply":"pong"}',
25 )
26 await expect(page.getByTestId('assistant-text')).toHaveText(
27 'ping returned {"reply":"pong"}',
28 )
29 expect(posts).toHaveLength(2)
30 })
31})