ai-agent/internal/tui/helpers_test.go
admin 8dc496b626
Some checks failed
CI / test (push) Has been cancelled
Release / release (push) Failing after 4m36s
first commit
2026-03-08 15:40:34 +07:00

74 lines
1.7 KiB
Go

package tui
import (
"testing"
"time"
"ai-agent/internal/agent"
"ai-agent/internal/command"
tea "charm.land/bubbletea/v2"
)
var (
testTime = time.Now()
testDuration = 100 * time.Millisecond
)
func newTestModel(t *testing.T) *Model {
t.Helper()
reg := command.NewRegistry()
command.RegisterBuiltins(reg)
completer := NewCompleter(reg, []string{"model-a", "model-b"}, []string{"skill-a"}, []string{"agent-x"}, nil)
ag := agent.New(nil, nil, 0)
m := New(ag, reg, nil, completer, nil, nil, nil)
m.promptHistoryPath = ""
m.promptHistory = nil
m.lang = LangEn
m.initializing = false
updated, _ := m.Update(tea.WindowSizeMsg{Width: 80, Height: 24})
return updated.(*Model)
}
func escKey() tea.KeyPressMsg {
return tea.KeyPressMsg{Code: tea.KeyEscape}
}
func enterKey() tea.KeyPressMsg {
return tea.KeyPressMsg{Code: tea.KeyEnter}
}
func tabKey() tea.KeyPressMsg {return tea.KeyPressMsg{Code: tea.KeyTab} }
func upKey() tea.KeyPressMsg {
return tea.KeyPressMsg{Code: tea.KeyUp}
}
func downKey() tea.KeyPressMsg {
return tea.KeyPressMsg{Code: tea.KeyDown}
}
func leftKey() tea.KeyPressMsg {
return tea.KeyPressMsg{Code: tea.KeyLeft}
}
func rightKey() tea.KeyPressMsg {
return tea.KeyPressMsg{Code: tea.KeyRight}
}
func spaceKey() tea.KeyPressMsg {
return tea.KeyPressMsg{Code: tea.KeySpace}
}
func charKey(r rune) tea.KeyPressMsg {
return tea.KeyPressMsg{Code: r, Text: string(r)}
}
func ctrlKey(r rune) tea.KeyPressMsg {
return tea.KeyPressMsg{Code: r, Mod: tea.ModCtrl}
}
func shiftTabKey() tea.KeyPressMsg {
return tea.KeyPressMsg{Code: tea.KeyTab, Mod: tea.ModShift}
}