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:
1 parent
adf63ef9f7
commit
3dd3fa5d05
1 file changed
+7
-2
@@ -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')
|
||||
|
||||
Reference in new issue
Block a user