mirror of
https://github.com/ddworken/hishtory.git
synced 2025-08-13 16:57:23 +02:00
Add support for full-screen rendering
This commit is contained in:
@ -119,6 +119,7 @@ func TestParam(t *testing.T) {
|
||||
t.Run("testTui/ai", wrapTestForSharding(testTui_ai))
|
||||
t.Run("testTui/defaultFilter", wrapTestForSharding(testTui_defaultFilter))
|
||||
t.Run("testTui/escaping", wrapTestForSharding(testTui_escaping))
|
||||
t.Run("testTui/fullscreen", wrapTestForSharding(testTui_fullscreen))
|
||||
|
||||
// Assert there are no leaked connections
|
||||
assertNoLeakedConnections(t)
|
||||
@ -1871,6 +1872,54 @@ func testTui_escaping(t *testing.T) {
|
||||
testutils.CompareGoldens(t, out, "TestTui-Escaping")
|
||||
}
|
||||
|
||||
func testTui_fullscreen(t *testing.T) {
|
||||
// Setup
|
||||
defer testutils.BackupAndRestore(t)()
|
||||
tester, _, _ := setupTestTui(t, Online)
|
||||
|
||||
// By default full-screen mode is disabled
|
||||
require.Equal(t, "false", strings.TrimSpace(tester.RunInteractiveShell(t, `hishtory config-get full-screen`)))
|
||||
require.Equal(t, "false", strings.TrimSpace(tester.RunInteractiveShell(t, `hishtory config-get compact-mode`)))
|
||||
|
||||
// Test that we can enable it
|
||||
tester.RunInteractiveShell(t, `hishtory config-set full-screen true`)
|
||||
require.Equal(t, "true", strings.TrimSpace(tester.RunInteractiveShell(t, `hishtory config-get full-screen`)))
|
||||
|
||||
// Test that it renders in full-screen mode taking up the entire terminal
|
||||
out := captureTerminalOutput(t, tester, []string{
|
||||
"echo foo ENTER",
|
||||
"hishtory SPACE tquery ENTER",
|
||||
})
|
||||
testutils.CompareGoldens(t, out, "TestTui-FullScreenRender")
|
||||
|
||||
// Test that it clears full-screen mode and restores the original terminal state
|
||||
out = captureTerminalOutput(t, tester, []string{
|
||||
"echo SPACE foo ENTER",
|
||||
"hishtory SPACE tquery ENTER",
|
||||
"Escape",
|
||||
})
|
||||
require.Contains(t, out, "echo foo\n")
|
||||
require.Contains(t, out, "hishtory tquery\n")
|
||||
require.NotContains(t, out, "Search Query")
|
||||
require.True(t, len(strings.Split(out, "\n")) <= 7)
|
||||
|
||||
// Test that it renders the help page fine
|
||||
out = captureTerminalOutput(t, tester, []string{
|
||||
"echo SPACE foo ENTER",
|
||||
"hishtory SPACE tquery ENTER",
|
||||
"C-h",
|
||||
})
|
||||
testutils.CompareGoldens(t, out, "TestTui-FullScreenHelp")
|
||||
|
||||
// Test that it renders fine in full-screen mode and compact-mode
|
||||
tester.RunInteractiveShell(t, `hishtory config-set compact-mode true`)
|
||||
out = captureTerminalOutput(t, tester, []string{
|
||||
"echo foo ENTER",
|
||||
"hishtory SPACE tquery ENTER",
|
||||
})
|
||||
testutils.CompareGoldens(t, out, "TestTui-FullScreenCompactRender")
|
||||
}
|
||||
|
||||
func testTui_defaultFilter(t *testing.T) {
|
||||
// Setup
|
||||
defer testutils.BackupAndRestore(t)()
|
||||
|
Reference in New Issue
Block a user