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

devtools-subagents.spec.ts

61 lines1.9 KB

1import { test, expect } from './fixtures'
2import {
3 devtoolsUrl,
4 openDevtools,
5 selectHook,
6 waitForDevtoolsHarness,
7} from './devtools-helpers'
8​
9test.beforeEach(async ({ page }) => {
10 await page.addInitScript(() => localStorage.clear())
11})
12​
13test('devtools shows a child agent reasoning, tool call, and reply', async ({
14 page,
15 testId,
16 aimockPort,
17}) => {
18 await page.goto(devtoolsUrl('/devtools-subagents', testId, aimockPort))
19 await waitForDevtoolsHarness(page)
20 await page.waitForLoadState('networkidle')
21 await expect(async () => {
22 await page.getByTestId('run').click()
23 await expect(page.getByTestId('message-count')).not.toHaveText('0', {
24 timeout: 2_000,
25 })
26 }).toPass({ timeout: 15_000 })
27 await expect(page.getByTestId('card-status-researcher')).toHaveText(
28 'finished',
29 )
30​
31 await openDevtools(page)
32 await selectHook(page, 'Blog Desk')
33​
34 // Left pane: the child's steps, with the same step cards as the root.
35 const steps = page.locator(
36 '[data-testid="ai-devtools-subagent-steps"][data-agent="researcher"]',
37 )
38 await expect(steps).toBeVisible()
39 await expect(steps).toContainText('finished')
40 await expect(steps).toContainText('Look up the facts first.')
41 await expect(steps).toContainText('lookupFacts')
42 await expect(steps).toContainText('Squids have three hearts.')
43​
44 // Right pane (user view): the child's text and tool output only.
45 const parts = page.getByTestId('ai-devtools-preview-part')
46 await expect(
47 parts.filter({ hasText: 'subagent researcher - finished' }),
48 ).toHaveCount(1)
49 await expect(
50 parts.filter({ hasText: 'researcher > tool result' }),
51 ).toContainText('three hearts')
52 await expect(
53 parts.filter({ hasText: 'researcher > text' }).last(),
54 ).toContainText('Squids have three hearts.')
55 await expect(parts.filter({ hasText: 'researcher > reasoning' })).toHaveCount(
56 0,
57 )
58 await expect(parts.filter({ hasText: 'researcher > tool call' })).toHaveCount(
59 0,
60 )
61})