package app import ( "strings" "testing" "glint/internal/help" tea "github.com/charmbracelet/bubbletea" ) // ctrlSlash is what the terminal sends for Ctrl+/ (the unit separator, 0x1f). var ctrlSlash = tea.KeyMsg{Type: tea.KeyCtrlUnderscore} func TestHelpToggleOpensAndCloses(t *testing.T) { a := statusApp() a.Update(ctrlSlash) if a.mode != ModeHelp { t.Fatalf("Ctrl+/ did not open help: mode = %v", a.mode) } a.Update(ctrlSlash) if a.mode != ModeEditor { t.Fatalf("second Ctrl+/ did not close help: mode = %v", a.mode) } } func TestHelpEscCloses(t *testing.T) { a := statusApp() a.Update(ctrlSlash) a.Update(tea.KeyMsg{Type: tea.KeyEsc}) if a.mode != ModeEditor { t.Fatalf("Esc did not close help: mode = %v", a.mode) } } func TestHelpViewShowsHelpContent(t *testing.T) { a := statusApp() a.Update(tea.WindowSizeMsg{Width: 120, Height: 40}) a.Update(ctrlSlash) got := a.View() if !strings.Contains(got, "USAGE") { t.Fatalf("help view missing content from help.Text:\n%s", got) } } func TestHelpUsesSharedSource(t *testing.T) { if !strings.Contains(help.Text, "EDITOR KEYS") || !strings.Contains(help.Text, "Ctrl+S") { t.Fatalf("help.Text is not the full reference:\n%s", help.Text) } } func TestStatusBarShowsToggleKey(t *testing.T) { a := statusApp() if got := a.statusBar(); !strings.Contains(got, "ctrl+/") { t.Fatalf("status bar missing help toggle key:\n%s", got) } }