TestWrapRowsMatchesBubblesBehaviour: wrapRows must match the row count of bubbles/textarea's internal wrap(): word-boundary aware, hard-wrap fallback for over-wide single words, and a trailing cursor-anchor row when content exactly fills the width.
(t *testing.T)
| 2328 | |
| 2329 | // TestCancelMidStreamPreservesStreamedText: Ctrl+C while content is streaming |
| 2330 | // keeps the partial response visible (flushed to scroll) and appends the |
| 2331 | // cancelled marker. The user never loses context they've already read. |
| 2332 | func TestCancelMidStreamPreservesStreamedText(t *testing.T) { |
| 2333 | m := newTestModel(t, func(http.ResponseWriter, *http.Request) {}) |
| 2334 | ctx, cancel := context.WithCancel(context.Background()) |
| 2335 | m.turnCtx = ctx |
| 2336 | m.cancel = cancel |
| 2337 | m.phase = phaseStreaming |
| 2338 | m.streaming.WriteString("partial response before cancel") |
| 2339 | |
| 2340 | out, _ := m.Update(tea.KeyMsg{Type: tea.KeyCtrlC}) |
| 2341 | om := out.(Model) |
| 2342 | |
| 2343 | if om.streaming.Len() != 0 { |
| 2344 | t.Fatal("streaming buffer should be flushed by cancel") |
| 2345 | } |
| 2346 | if !strings.Contains(stripANSI(om.scroll.String()), "partial response before cancel") { |
| 2347 | t.Fatalf("streamed text must survive cancel, got: %q", om.scroll.String()) |
| 2348 | } |
| 2349 | if !strings.Contains(stripANSI(om.scroll.String()), "cancelled") { |
| 2350 | t.Fatalf("cancelled marker missing from scroll: %q", om.scroll.String()) |
| 2351 | } |
| 2352 | if om.phase.active() { |
| 2353 | t.Fatal("phase must return to idle after cancel") |
| 2354 | } |
| 2355 | } |
nothing calls this directly
no test coverage detected