From a8f47cf340a98c42d5b22dc0e60f3c1bc8907e78 Mon Sep 17 00:00:00 2001 From: David Dworken Date: Sun, 12 Nov 2023 01:13:22 -0800 Subject: [PATCH] Fix testTui/ai test and add golden file for it --- client/client_test.go | 8 +++++--- client/lib/goldens/TestTui-AiQuery | 27 +++++++++++++++++++++++++++ client/testutils.go | 4 ++-- 3 files changed, 34 insertions(+), 5 deletions(-) create mode 100644 client/lib/goldens/TestTui-AiQuery diff --git a/client/client_test.go b/client/client_test.go index dcd9ef0..76c7aa7 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -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") diff --git a/client/lib/goldens/TestTui-AiQuery b/client/lib/goldens/TestTui-AiQuery new file mode 100644 index 0000000..3ae466e --- /dev/null +++ b/client/lib/goldens/TestTui-AiQuery @@ -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 \ No newline at end of file diff --git a/client/testutils.go b/client/testutils.go index 36fe869..58db3b8 100644 --- a/client/testutils.go +++ b/client/testutils.go @@ -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)