Fix testTui/ai test and add golden file for it

This commit is contained in:
David Dworken 2023-11-12 01:13:22 -08:00
parent e712d77f62
commit a8f47cf340
3 changed files with 34 additions and 5 deletions

View File

@ -1932,9 +1932,11 @@ func testTui_ai(t *testing.T) {
require.NoError(t, err)
// Test running an AI query
out := captureTerminalOutput(t, tester, []string{
"hishtory SPACE tquery ENTER",
"?myQuery",
tester.RunInteractiveShell(t, `hishtory config-set beta-mode true`)
out := captureTerminalOutputWithComplexCommands(t, tester, []TmuxCommand{
{Keys: "hishtory SPACE tquery ENTER"},
// ExtraDelay since AI queries are debounced and thus slower
{Keys: "'?myQuery'", ExtraDelay: 1.0},
})
out = stripTuiCommandPrefix(t, out)
testutils.CompareGoldens(t, out, "TestTui-AiQuery")

View File

@ -0,0 +1,27 @@
Search Query: > ?myQuery
┌────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Hostname CWD Timestamp Runtime Exit Code Command │
│────────────────────────────────────────────────────────────────────────────────────────────────────────│
│ OpenAI N/A N/A N/A 0 result 1 │
│ OpenAI N/A N/A N/A 0 result 2 │
│ OpenAI N/A N/A N/A 0 longer result 3 │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
└────────────────────────────────────────────────────────────────────────────────────────────────────────┘
hiSHtory: Search your shell history • ctrl+h help

View File

@ -236,9 +236,9 @@ func captureTerminalOutputComplex(t testing.TB, captureConfig TmuxCaptureConfig)
require.NotEmpty(t, captureConfig.complexCommands)
for _, cmd := range captureConfig.complexCommands {
if cmd.Keys != "" {
fullCommand += " tmux send -t foo -- '"
fullCommand += " tmux send -t foo -- "
fullCommand += cmd.Keys
fullCommand += "'\n"
fullCommand += "\n"
}
if cmd.ResizeX != 0 && cmd.ResizeY != 0 {
fullCommand += fmt.Sprintf(" tmux resize-window -t foo -x %d -y %d\n", cmd.ResizeX, cmd.ResizeY)