fix(frontend): refine streamed presentation and resolve stream edge cases
This commit is contained in:
parent
a3af8f45cc
commit
2cc33a721c
18 changed files with 450 additions and 46 deletions
|
|
@ -128,8 +128,23 @@ describe('streamRecommendations', () => {
|
|||
expect(wasCancelled).toBe(true)
|
||||
})
|
||||
|
||||
it('accepts a terminal error as the only event', async () => {
|
||||
const error = { type: 'error', code: 'first_stage_failed', message: 'Planning failed.' }
|
||||
stubResponse(streamResponse([encoder.encode(`${JSON.stringify(error)}\n`)]))
|
||||
const events: StreamEvent[] = []
|
||||
|
||||
await streamRecommendations(
|
||||
{ schema_version: 1, query: 'focus', history: [], prior_recommendations: [] },
|
||||
new AbortController().signal,
|
||||
(event) => events.push(event),
|
||||
)
|
||||
|
||||
expect(events).toEqual([error])
|
||||
})
|
||||
|
||||
it.each([
|
||||
['an event before metadata', [{ type: 'warning', code: 'early', message: 'No metadata.' }]],
|
||||
['done before metadata', [{ type: 'done', track_count: 0, total_ms: 4 }]],
|
||||
[
|
||||
'duplicate metadata',
|
||||
[
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue