MCPcopy Index your code
hub / github.com/codehamr/codehamr / TestSplashEmittedOnFirstSize

Function TestSplashEmittedOnFirstSize

internal/tui/tui_test.go:2801–2827  ·  view source on GitHub ↗

TestSplashEmittedOnFirstSize: the splash prints once into scrollback on the first WindowSizeMsg, then scrolls up as content arrives. We verify the lines reach the outbox (drained via tea.Println by the Update wrapper in production).

(t *testing.T)

Source from the content-addressed store, hash-verified

2799 rendered := stripANSI(mm.renderPopover())
2800 for line := range strings.SplitSeq(rendered, "\n") {
2801 if strings.HasPrefix(line, "▸ ") || strings.HasPrefix(line, " /") {
2802 t.Fatalf("popover row must not carry a marker prefix: %q", line)
2803 }
2804 }
2805}
2806
2807// TestPopoverSelectionStaysVisible: with more than popoverCap suggestions the
2808// popover renders a window; when the selection moves past it, renderPopover must
2809// scroll so the highlighted row stays shown, else Enter commits an unseen row.
2810func TestPopoverSelectionStaysVisible(t *testing.T) {
2811 m := Model{width: 80, suggestOpen: true}
2812 for i := 0; i < popoverCap+4; i++ {
2813 m.suggest = append(m.suggest, argOption{value: fmt.Sprintf("profile%d", i)})
2814 }
2815 m.suggestIdx = len(m.suggest) - 1 // last row, well past the first window
2816 rendered := stripANSI(m.renderPopover())
2817 if !strings.Contains(rendered, m.suggest[m.suggestIdx].value) {
2818 t.Fatalf("selected row %q not visible in popover:\n%s",
2819 m.suggest[m.suggestIdx].value, rendered)
2820 }
2821}
2822
2823// TestSplashEmittedOnFirstSize: the splash prints once into scrollback on the
2824// first WindowSizeMsg, then scrolls up as content arrives. We verify the lines
2825// reach the outbox (drained via tea.Println by the Update wrapper in production).
2826func TestSplashEmittedOnFirstSize(t *testing.T) {
2827 cfg, _, _ := config.Bootstrap(t.TempDir())
2828 m := New(cfg, llm.New("http://x", cfg.ActiveProfile().LLM, ""), t.TempDir(), "test")
2829 out, _ := m.update(tea.WindowSizeMsg{Width: 100, Height: 30})
2830 om := out.(Model)

Callers

nothing calls this directly

Calls 6

BootstrapFunction · 0.92
NewFunction · 0.92
stripANSIFunction · 0.85
ActiveProfileMethod · 0.80
updateMethod · 0.80
NewFunction · 0.70

Tested by

no test coverage detected