MCPcopy Create free account
hub / github.com/codehamr/codehamr / TestStreamContentShowsLiveInViewport

Function TestStreamContentShowsLiveInViewport

internal/tui/tui_test.go:2455–2472  ·  view source on GitHub ↗

TestStreamContentShowsLiveInViewport: a mid-turn content event populates the streaming buffer, promotes phase thinking→streaming, and is visible in View() before any EventDone: the "tokens stream immediately" promise.

(t *testing.T)

Source from the content-addressed store, hash-verified

2453 // newTestModel's 30-row terminal, cap = 30 - 5 - 2 - 0 = 23.
2454 m.ta.SetValue(strings.Repeat("x\n", 40) + "end")
2455 m.recomputeLayout()
2456 want := m.height - minViewport - 2
2457 if got := m.ta.Height(); got != want {
2458 t.Fatalf("height should clamp to %d (h=%d - minViewport=%d - chrome=2), got %d",
2459 want, m.height, minViewport, got)
2460 }
2461}
2462
2463// TestPromptShrinksAfterSubmit: after Enter submits a multi-line prompt the
2464// textarea resets to empty and the height snaps back to 1 line.
2465func TestPromptShrinksAfterSubmit(t *testing.T) {
2466 m := newTestModel(t, func(w http.ResponseWriter, _ *http.Request) {
2467 fmt.Fprint(w, "data: "+`{"choices":[{"delta":{"content":"ok"}}]}`+"\n\n")
2468 fmt.Fprint(w, "data: [DONE]\n\n")
2469 })
2470 m.ta.SetValue("line1\nline2\nline3\nline4")
2471 m.recomputeLayout()
2472 if m.ta.Height() != 4 {
2473 t.Fatalf("precondition: 4-line draft, got height %d", m.ta.Height())
2474 }
2475 // Enter at idle submits the current textarea value and calls ta.Reset;

Callers

nothing calls this directly

Calls 4

newTestModelFunction · 0.85
handleStreamMethod · 0.80
StringMethod · 0.80
ViewMethod · 0.45

Tested by

no test coverage detected