(t *testing.T)
| 1728 | } |
| 1729 | |
| 1730 | func testTui_resize(t *testing.T) { |
| 1731 | // Setup |
| 1732 | defer testutils.BackupAndRestore(t)() |
| 1733 | tester, userSecret, _ := setupTestTui(t, Online) |
| 1734 | |
| 1735 | // Check the output when the size is smaller |
| 1736 | out := captureTerminalOutputWithShellNameAndDimensions(t, tester, tester.ShellName(), 100, 20, []TmuxCommand{ |
| 1737 | {Keys: "hishtory SPACE tquery ENTER"}, |
| 1738 | }) |
| 1739 | out = stripTuiCommandPrefix(t, out) |
| 1740 | testutils.CompareGoldens(t, out, "TestTui-SmallTerminal") |
| 1741 | |
| 1742 | // Check the output when the size is tiny |
| 1743 | out = captureTerminalOutputWithShellNameAndDimensions(t, tester, tester.ShellName(), 100, 15, []TmuxCommand{ |
| 1744 | {Keys: "hishtory SPACE tquery ENTER"}, |
| 1745 | }) |
| 1746 | out = stripTuiCommandPrefix(t, out) |
| 1747 | testutils.CompareGoldens(t, out, "TestTui-TinyTerminal") |
| 1748 | |
| 1749 | // Check the output when the size is tiny and the help page is open |
| 1750 | out = captureTerminalOutputWithShellNameAndDimensions(t, tester, tester.ShellName(), 100, 15, []TmuxCommand{ |
| 1751 | {Keys: "hishtory SPACE tquery ENTER"}, |
| 1752 | {Keys: "C-h"}, |
| 1753 | }) |
| 1754 | out = stripTuiCommandPrefix(t, out) |
| 1755 | testutils.CompareGoldens(t, out, "TestTui-TinyTerminalHelp") |
| 1756 | |
| 1757 | // Check the output when the size is extra tiny |
| 1758 | out = captureTerminalOutputWithShellNameAndDimensions(t, tester, tester.ShellName(), 100, 11, []TmuxCommand{ |
| 1759 | {Keys: "hishtory SPACE tquery ENTER"}, |
| 1760 | }) |
| 1761 | testutils.CompareGoldens(t, out, "TestTui-TiniestTerminal") |
| 1762 | |
| 1763 | // Check the output when the size is tiny and the user tries to open the help page, which doesn't work |
| 1764 | out = captureTerminalOutputWithShellNameAndDimensions(t, tester, tester.ShellName(), 100, 11, []TmuxCommand{ |
| 1765 | {Keys: "hishtory SPACE tquery ENTER"}, |
| 1766 | {Keys: "C-h"}, |
| 1767 | }) |
| 1768 | testutils.CompareGoldens(t, out, "TestTui-TiniestTerminal") |
| 1769 | |
| 1770 | // Check that it resizes after the terminal size is adjusted |
| 1771 | manuallySubmitHistoryEntry(t, userSecret, testutils.MakeFakeHistoryEntry("echo 'cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc'")) |
| 1772 | out = captureTerminalOutputWithShellNameAndDimensions(t, tester, tester.ShellName(), 100, 20, []TmuxCommand{ |
| 1773 | {Keys: "hishtory SPACE tquery ENTER"}, |
| 1774 | {ResizeX: 300, ResizeY: 100}, |
| 1775 | }) |
| 1776 | out = stripTuiCommandPrefix(t, out) |
| 1777 | testutils.CompareGoldens(t, out, "TestTui-Resize") |
| 1778 | |
| 1779 | // Check that the cursor position is maintained after it is resized |
| 1780 | out = captureTerminalOutputWithShellNameAndDimensions(t, tester, tester.ShellName(), 100, 20, []TmuxCommand{ |
| 1781 | {Keys: "hishtory SPACE tquery ENTER"}, |
| 1782 | {Keys: "Down"}, |
| 1783 | {ResizeX: 300, ResizeY: 100, ExtraDelay: 1.0}, |
| 1784 | {Keys: "Enter"}, |
| 1785 | }) |
| 1786 | require.Contains(t, out, "\necho 'aaaaaa bbbb'\n") |
| 1787 |
nothing calls this directly
no test coverage detected