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

custom-events.spec.ts

33 lines958 Bytes

1import { test, expect } from './fixtures'
2import {
3 selectScenario,
4 runTest,
5 waitForTestComplete,
6 getEventLog,
7} from './tools-test/helpers'
8​
9test.describe('Custom Event Emitting', () => {
10 test('server tool emits custom events received by client', async ({
11 page,
12 testId,
13 aimockPort,
14 }) => {
15 await selectScenario(page, 'custom-events', testId, aimockPort)
16 await runTest(page)
17 await waitForTestComplete(page, 15000, 1)
18​
19 const events = await getEventLog(page)
20 const customEvents = events.filter((e: any) => e.type === 'custom-event')
21​
22 expect(customEvents.length).toBeGreaterThanOrEqual(2)
23​
24 const progressEvents = customEvents.filter(
25 (e: any) => e.toolName === 'order:progress',
26 )
27 expect(progressEvents.length).toBe(2)
28​
29 const details = progressEvents.map((e: any) => JSON.parse(e.details))
30 expect(details[0].step).toBe('validating')
31 expect(details[1].step).toBe('processing')
32 })
33})