Files
sshtermy/internal/ui/clickzone/zones_test.go
T
db9979andClaude Opus 5.5 d315d06e77 Stabilität: Absturzschutz, Zeitgrenzen, Selbstprüfung, mehr Tests, Dauerlauf (#175)
* Absturzschutz: Fehler in Hintergrundarbeit beenden sshTermy nicht mehr; Zeitgrenzen für Update-Download und Team-Abo; Gast-Tasten über Warteschlange

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018i4GUkBzZ657Au6Rz4BPXj

* CI: Zeitgrenzen je Job, alte Läufe abbrechen, Tests in zufälliger Reihenfolge; make check; Bibliotheken aktualisiert

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018i4GUkBzZ657Au6Rz4BPXj

* update: Stillstand auch ohne Lesefehler erkennen

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018i4GUkBzZ657Au6Rz4BPXj

* Zufallstests für Teilen, Vermittler, MCP, Syslog, KI-Antworten, Sync und Fenster-Rahmen; Syslog-Empfang übersteht kaputte Pakete; MCP antwortet auch nach Fehler

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018i4GUkBzZ657Au6Rz4BPXj

* Tests: Tresor (Passwortwechsel, Sperre, Blobs, KDF-Grenzen), SFTP-Rundreise, serielle Konsole mit Ersatzkabel

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018i4GUkBzZ657Au6Rz4BPXj

* Dauerlauf-Test (make soak) und nächtlicher Lauf mit langen Zufallstests

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018i4GUkBzZ657Au6Rz4BPXj

* Fuzz: Zeitlimit je Eingabe auch für die neuen Tests

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018i4GUkBzZ657Au6Rz4BPXj

* Selbstprüfung: sshtermy doctor und Palette › Hilfe › Fehlersuche; versehentlich eingecheckte Programmdatei entfernt

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018i4GUkBzZ657Au6Rz4BPXj

* Oberfläche aufteilen, erster Schritt: Mausbereiche (ui/clickzone) und abgelegte Dateien (ui/dropped) als eigene Pakete

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018i4GUkBzZ657Au6Rz4BPXj

* Doku: Absturzschutz und Selbstprüfung in README, Webseite und Handbuch; Plan zur Aufteilung von internal/ui; Zusehen-WASM neu gebaut

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018i4GUkBzZ657Au6Rz4BPXj

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-20 12:23:50 +01:00

51 lines
1.6 KiB
Go

package clickzone
import (
"strings"
"testing"
tea "charm.land/bubbletea/v2"
"charm.land/lipgloss/v2"
"github.com/charmbracelet/x/ansi"
)
func TestZonesSurviveLayout(t *testing.T) {
var z Map
hit := ""
mk := func(name, s string) string {
return z.Click(s, func(tea.Mouse, bool) tea.Cmd { hit = name; return nil })
}
st := lipgloss.NewStyle().Background(lipgloss.Color("#333")).Padding(0, 1)
left := lipgloss.NewStyle().Width(20).Render("Liste\n" + st.Render(mk("a", "Eintrag A")) + "\n" + mk("b", "Eintrag B"))
right := lipgloss.NewStyle().Width(30).Render("Detail " + mk("c", lipgloss.NewStyle().Bold(true).Render("Knopf")))
body := lipgloss.JoinHorizontal(lipgloss.Top, left, "│", right)
body = lipgloss.Place(60, 6, lipgloss.Center, lipgloss.Center, body)
clean := z.Scan(body, 0, 0)
if strings.Contains(clean, "71000z") || strings.Contains(clean, "\x1b[710") {
t.Fatalf("Marker nicht entfernt: %q", clean)
}
lines := strings.Split(ansi.Strip(clean), "\n")
find := func(word string) (int, int) {
for y, l := range lines {
if i := strings.Index(l, word); i >= 0 {
return ansi.StringWidth(l[:i]), y
}
}
t.Fatalf("%q nicht gefunden", word)
return 0, 0
}
for _, c := range []struct{ word, want string }{{"Eintrag A", "a"}, {"Eintrag B", "b"}, {"Knopf", "c"}} {
x, y := find(c.word)
hit = ""
if act := z.At(x+2, y, false); act != nil {
act.Click(tea.Mouse{}, false)
}
if hit != c.want {
t.Errorf("%s bei %d,%d: Treffer %q, erwartet %q", c.word, x+2, y, hit, c.want)
}
}
if act := z.At(0, 0, false); act != nil {
t.Errorf("Treffer außerhalb aller Zonen")
}
}