Chat tests: accept text deltas joined in a subscriber's queue
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -549,10 +549,12 @@ func TestChatPromptStreamsEvents(t *testing.T) {
|
||||
t.Fatalf("ack = %+v", ack)
|
||||
}
|
||||
frames := readChatTurn(t, ctx, conn)
|
||||
if len(frames) != 4 {
|
||||
t.Fatalf("got %d frames, want 4", len(frames))
|
||||
// The two text deltas may arrive joined into one frame.
|
||||
if len(frames) != 4 && len(frames) != 3 {
|
||||
t.Fatalf("got %d frames, want 4 (or 3 with the deltas joined)", len(frames))
|
||||
}
|
||||
sawText, sawStep := false, false
|
||||
var text strings.Builder
|
||||
for _, frame := range frames {
|
||||
if frame.SessionID != "ses_1" || frame.MessageID != "msg_1" {
|
||||
t.Fatalf("frame missing stable ids: %+v", frame)
|
||||
@@ -560,6 +562,7 @@ func TestChatPromptStreamsEvents(t *testing.T) {
|
||||
switch frame.Kind {
|
||||
case protocol.ChatEventText:
|
||||
sawText = true
|
||||
text.WriteString(frame.Delta)
|
||||
case protocol.ChatEventStep:
|
||||
sawStep = true
|
||||
if frame.Step == nil || frame.Step.Status != protocol.ChatStepEnded {
|
||||
@@ -567,8 +570,8 @@ func TestChatPromptStreamsEvents(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if !sawText || !sawStep {
|
||||
t.Fatalf("missing text or step frame: %+v", frames)
|
||||
if !sawText || !sawStep || text.String() != "hello world" {
|
||||
t.Fatalf("missing text or step frame (text %q): %+v", text.String(), frames)
|
||||
}
|
||||
if prompts, _, _ := broker.counts(); prompts != 1 {
|
||||
t.Fatalf("prompt forwarded %d times, want 1", prompts)
|
||||
|
||||
Reference in New Issue
Block a user