mirror of
https://github.com/ddworken/hishtory.git
synced 2025-06-23 21:41:38 +02:00
Add test for smaller terminal
This commit is contained in:
parent
3abc3092fe
commit
f69460422a
@ -1808,6 +1808,13 @@ func TestTui(t *testing.T) {
|
|||||||
if diff := cmp.Diff(expected, out); diff != "" {
|
if diff := cmp.Diff(expected, out); diff != "" {
|
||||||
t.Fatalf("hishtory export mismatch (-expected +got):\n%s", diff)
|
t.Fatalf("hishtory export mismatch (-expected +got):\n%s", diff)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check the output when the size is adjusted
|
||||||
|
out = captureTerminalOutputWithShellNameAndDimensions(t, tester, tester.ShellName(), 100, 20, []string{
|
||||||
|
"hishtory SPACE tquery ENTER",
|
||||||
|
})
|
||||||
|
out = strings.TrimSpace(strings.Split(out, "hishtory tquery")[1])
|
||||||
|
compareGoldens(t, out, "TestTui-SmallTerminal")
|
||||||
}
|
}
|
||||||
|
|
||||||
func captureTerminalOutput(t *testing.T, tester shellTester, commands []string) string {
|
func captureTerminalOutput(t *testing.T, tester shellTester, commands []string) string {
|
||||||
@ -1815,6 +1822,10 @@ func captureTerminalOutput(t *testing.T, tester shellTester, commands []string)
|
|||||||
}
|
}
|
||||||
|
|
||||||
func captureTerminalOutputWithShellName(t *testing.T, tester shellTester, overriddenShellName string, commands []string) string {
|
func captureTerminalOutputWithShellName(t *testing.T, tester shellTester, overriddenShellName string, commands []string) string {
|
||||||
|
return captureTerminalOutputWithShellNameAndDimensions(t, tester, overriddenShellName, 200, 50, commands)
|
||||||
|
}
|
||||||
|
|
||||||
|
func captureTerminalOutputWithShellNameAndDimensions(t *testing.T, tester shellTester, overriddenShellName string, width, height int, commands []string) string {
|
||||||
sleepAmount := "0.1"
|
sleepAmount := "0.1"
|
||||||
if runtime.GOOS == "linux" {
|
if runtime.GOOS == "linux" {
|
||||||
sleepAmount = "0.2"
|
sleepAmount = "0.2"
|
||||||
@ -1825,7 +1836,7 @@ func captureTerminalOutputWithShellName(t *testing.T, tester shellTester, overri
|
|||||||
}
|
}
|
||||||
fullCommand := ""
|
fullCommand := ""
|
||||||
fullCommand += " tmux kill-session -t foo || true\n"
|
fullCommand += " tmux kill-session -t foo || true\n"
|
||||||
fullCommand += " tmux -u new-session -d -x 200 -y 50 -s foo " + overriddenShellName + "\n"
|
fullCommand += fmt.Sprintf(" tmux -u new-session -d -x %d -y %d -s foo %s\n", width, height, overriddenShellName)
|
||||||
fullCommand += " sleep 1\n"
|
fullCommand += " sleep 1\n"
|
||||||
if overriddenShellName == "bash" {
|
if overriddenShellName == "bash" {
|
||||||
fullCommand += " tmux send -t foo source SPACE ~/.bashrc ENTER\n"
|
fullCommand += " tmux send -t foo source SPACE ~/.bashrc ENTER\n"
|
||||||
|
14
client/lib/goldens/TestTui-SmallTerminal
Normal file
14
client/lib/goldens/TestTui-SmallTerminal
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
Search Query: > ls
|
||||||
|
|
||||||
|
┌────────────────────────────────────────────────────────────────────────────────────────┐
|
||||||
|
│ Hostname CWD Timestamp Runtime Exit Code Command │
|
||||||
|
│────────────────────────────────────────────────────────────────────────────────────────│
|
||||||
|
│ localhost /tmp/ Oct 17 2022 21:43:21 PDT 3s 2 echo 'aaaaaa bbbb' │
|
||||||
|
│ localhost /tmp/ Oct 17 2022 21:43:16 PDT 3s 2 ls ~/ │
|
||||||
|
│ │
|
||||||
|
│ │
|
||||||
|
│ │
|
||||||
|
│ │
|
||||||
|
│ │
|
||||||
|
│ │
|
||||||
|
└────────────────────────────────────────────────────────────────────────────────────────┘
|
@ -358,8 +358,7 @@ func makeTable(ctx *context.Context, rows []table.Row) (table.Model, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return table.Model{}, err
|
return table.Model{}, err
|
||||||
}
|
}
|
||||||
// panic(terminalHeight)
|
tableHeight := min(TABLE_HEIGHT, terminalHeight-12)
|
||||||
tableHeight := min(TABLE_HEIGHT, terminalHeight-10)
|
|
||||||
t := table.New(
|
t := table.New(
|
||||||
table.WithColumns(columns),
|
table.WithColumns(columns),
|
||||||
table.WithRows(rows),
|
table.WithRows(rows),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user