Files
sshtermy/internal/ui/aiinput_test.go
T
Claude d665b00d69 KI-Eingaben brechen automatisch um und wachsen mit
Ziel (F2), Rückfrage, KI fragen (F3) und die Palette nutzen jetzt ein
mitwachsendes Textfeld (bubbles textarea) statt horizontal zu scrollen.
⏎ sendet wie bisher, Shift+⏎ / Alt+⏎ / Strg+J fügt eine neue Zeile ein.
Befehl bearbeiten (e) bricht ebenfalls um, bleibt aber einzeilig.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018i4GUj4Q8N5RRbpPpGwSVH
2026-11-05 10:09:28 +00:00

52 lines
1.3 KiB
Go

package ui
import (
"strings"
"testing"
tea "charm.land/bubbletea/v2"
"charm.land/lipgloss/v2"
)
func TestAIInputWrapsAndGrows(t *testing.T) {
in := newAIInput("")
in.SetWidth(20)
in.Focus()
in.SetValue(strings.Repeat("wort ", 12)) // 60 Zeichen → mehrere Zeilen
in.SetWidth(20)
v := in.View()
if h := lipgloss.Height(v); h < 3 {
t.Fatalf("Feld sollte mitwachsen, Höhe %d:\n%s", h, v)
}
for _, l := range strings.Split(v, "\n") {
if w := lipgloss.Width(l); w > 20 {
t.Fatalf("Zeile breiter als Feld (%d): %q", w, l)
}
}
}
func TestAIInputNewlineKeys(t *testing.T) {
in := newAIInput("")
in.Focus()
in.SetValue("a")
in, _ = in.Update(tea.KeyPressMsg{Code: tea.KeyEnter})
if in.Value() != "a" {
t.Fatalf("⏎ darf keine Zeile einfügen: %q", in.Value())
}
in, _ = in.Update(tea.KeyPressMsg{Code: tea.KeyEnter, Mod: tea.ModShift})
in, _ = in.Update(tea.KeyPressMsg{Code: tea.KeyEnter, Mod: tea.ModAlt})
if in.Value() != "a\n\n" {
t.Fatalf("Shift/Alt+⏎ sollte Zeilen einfügen: %q", in.Value())
}
}
func TestCommandInputSingleLine(t *testing.T) {
in := newCommandInput()
in.Focus()
in, _ = in.Update(tea.KeyPressMsg{Code: tea.KeyEnter, Mod: tea.ModShift})
in, _ = in.Update(tea.PasteMsg{Content: "ls\n-la"})
if strings.Contains(in.Value(), "\n") {
t.Fatalf("Befehl darf keine Zeilenumbrüche enthalten: %q", in.Value())
}
}