Files
windmill/chat-sdk/test/follow.test.ts
T
Ruben FiszelandClaude Fable 5.1 8b4f6220dc refactor: run the flow chat UI on the windmill-chat sdk (#11134)
* refactor: run the flow chat UI on the windmill-chat sdk

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* fix: structural answer check, poll option and latest run in the chat sdk

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* fix: count jobless tool rows and the loaded license in the flow chat

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-15 12:56:07 +00:00

26 lines
1.2 KiB
TypeScript

import { expect, test } from 'bun:test'
import { WindmillChatApi } from '../src/api'
import { followJob } from '../src/follow'
import { fetchMock, ndjson, sse } from './support'
test('a retried streaming step reports its offset as lost before the new sub-job is followed', async () => {
let streams = 0
const { fetch } = fetchMock((c) => {
if (!c.url.pathname.endsWith('/jobs_u/getupdate_sse/job-1')) return undefined
streams++
if (streams === 1) {
return sse([
{ type: 'update', new_result_stream: ndjson({ type: 'token_delta', content: 'a' }), stream_offset: 3, flow_stream_job_id: 'agent-1' },
{ type: 'update', new_result_stream: ndjson({ type: 'token_delta', content: 'b' }), stream_offset: 4, flow_stream_job_id: 'agent-2' }
])
}
return sse([{ type: 'update', stream_offset: 1, flow_stream_job_id: 'agent-2', completed: true, only_result: 'ok' }])
})
const api = new WindmillChatApi({ baseUrl: 'http://wm.test', workspace: 'ws', token: 'tok', fetch })
const offsets: (number | undefined)[] = []
for await (const _ of followJob(api, 'job-1', { onOffset: (o) => offsets.push(o) })) {
// A resumer that stored offset 3 must not reuse it against agent-2.
}
expect(offsets).toEqual([3, undefined, 1])
})