package app

import (
	"strings"
	"testing"
)

// Every key the TUI binds (normal mode, approval band, and the diff/preview viewer) must
// have a row in the ? overlay. Keyed by a distinctive description phrase so deleting a row
// fails loudly here — keep this list in step with handleNormalKey / handleApprovalKey and
// the OverlayDiff handler whenever a binding is added or changed.
func TestHelpCoversEveryKeybind(t *testing.T) {
	m := inSessionModel(120, 80)
	help := strings.Join(m.helpBody(), "\n")

	want := []string{
		// navigate
		"move the session / list selection",    // ↑↓ / j k
		"open the selected session",            // enter
		"cycle launch target",                  // Tab / w
		"filter the session list",              // /
		"jump to your previous / next message", // ^↑ / ^↓
		"scroll output",                        // PgUp / PgDn (+ ^u / ^d)
		"drop selection",                       // esc
		"back to the session list",             // l
		// session
		"compose a message",                 // i
		"right panel: events / changes",     // d
		"toggle chat / steering mode",       // s
		"show workflows",                    // w
		"copy the selected message",         // y
		"open the latest diff / preview",    // ^x
		"cancel the running session",        // c
		"re-open a dismissed approval gate", // a
		"quit",                              // q
		// overlays
		"command palette",          // p
		"this keybindings help",    // ?
		"event inspector",          // e
		"tools / artifacts",        // t / v
		"resume past sessions",     // S / R
		"swap model / edit config", // m / g
		"grants / idea board",      // G / I
		// approval band
		"approve once",                          // y / a / enter
		"reject",                                // n / r
		"steer (add a note)",                    // e / s
		"approve-always",                        // A
		"walk the pending queue",                // ↑ / ↓
		"fullscreen the diff / command preview", // ^x
		"dismiss for now",                       // esc
		// diff / preview viewer
		"scroll a line",     // ↑ / ↓
		"scroll a page",     // PgUp / PgDn
		"jump to top / end", // g / G
	}
	for _, w := range want {
		if !strings.Contains(help, w) {
			t.Errorf("? help is missing a row for %q", w)
		}
	}
}
