test: read SSE chunks until session.updated arrives

session.status and session.updated are two separate res.write calls, so the
test failed whenever TCP delivered them in different chunks.
This commit is contained in:
evandro committed 2026-10-10 04:23:16 -03:00
1 parent adf63ef9f7
commit 3dd3fa5d05
1 file changed
+7 -2
+7 -2
View File
@@ -1025,8 +1025,13 @@ describe('PiAgentUi Extension Server', () => {
// Trigger agent_start - should broadcast session.status and session.updated!
await listeners['agent_start']()
const chunk3 = await reader?.read()
const text3 = new TextDecoder().decode(chunk3?.value)
// The two events are separate writes, so TCP may deliver them in different chunks.
let text3 = ''
while (!text3.includes('session.updated')) {
const chunk = await reader?.read()
if (!chunk || chunk.done) break
text3 += new TextDecoder().decode(chunk.value)
}
expect(text3).toContain('session.status')
expect(text3).toContain('working')
expect(text3).toContain('session.updated')