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 | } |
| 2434 | } |
| 2435 | |
| 2436 | // TestPromptShrinksAfterSubmit: after Enter submits a multi-line prompt the |
| 2437 | // textarea resets to empty and the height snaps back to 1 line. |
| 2438 | func TestPromptShrinksAfterSubmit(t *testing.T) { |
| 2439 | m := newTestModel(t, func(w http.ResponseWriter, _ *http.Request) { |
| 2440 | fmt.Fprint(w, "data: "+`{"choices":[{"delta":{"content":"ok"}}]}`+"\n\n") |
| 2441 | fmt.Fprint(w, "data: [DONE]\n\n") |
| 2442 | }) |
| 2443 | m.ta.SetValue("line1\nline2\nline3\nline4") |
| 2444 | m.recomputeLayout() |
| 2445 | if m.ta.Height() != 4 { |
| 2446 | t.Fatalf("precondition: 4-line draft, got height %d", m.ta.Height()) |
| 2447 | } |
| 2448 | // Enter at idle submits the current textarea value and calls ta.Reset; |
| 2449 | // recomputeLayout after handleKey then snaps the height back down. |
| 2450 | out, cmd := m.Update(tea.KeyMsg{Type: tea.KeyEnter}) |
| 2451 | final, _ := drain(out, cmd) |
| 2452 | if got := final.(Model).ta.Height(); got != 1 { |
| 2453 | t.Fatalf("after submit the textarea should collapse to 1 line, got %d", got) |
no test coverage detected