stripANSI removes CSI escape sequences (`\x1b[…m`) so tests can match the visible text through glamour's per-word styling, which splits "foo bar" into ` foo bar ` and breaks a naive Contains("foo bar").
(s string)
| 2433 | t.Fatalf("long wrapped line should expand textarea past 1 row, got %d", got) |
| 2434 | } |
| 2435 | } |
| 2436 | |
| 2437 | // TestPromptAutoGrowsWithContent: the textarea starts at 1 line, grows with |
| 2438 | // newlines, and clamps to height - minViewport - 2 - popover, so big pastes use |
| 2439 | // most of the screen while chat keeps its floor. |
| 2440 | func TestPromptAutoGrowsWithContent(t *testing.T) { |
| 2441 | m := newTestModel(t, func(http.ResponseWriter, *http.Request) {}) |
| 2442 | if m.ta.Height() != 1 { |
| 2443 | t.Fatalf("empty prompt should be 1 line, got %d", m.ta.Height()) |
| 2444 | } |
| 2445 | |
| 2446 | m.ta.SetValue("line1\nline2\nline3\nline4") |
| 2447 | m.recomputeLayout() |
| 2448 | if got := m.ta.Height(); got != 4 { |
| 2449 | t.Fatalf("4 lines in textarea should produce height 4, got %d", got) |
| 2450 | } |
| 2451 | |
| 2452 | // Far past the cap, height must clamp to leave room for chat. With |
| 2453 | // newTestModel's 30-row terminal, cap = 30 - 5 - 2 - 0 = 23. |
no test coverage detected