|
4 | 4 | "strings" |
5 | 5 | "testing" |
6 | 6 |
|
7 | | - "charm.land/lipgloss/v2" |
8 | | - |
9 | 7 | "github.com/andyrewlee/amux/internal/ui/common" |
10 | 8 | ) |
11 | 9 |
|
@@ -84,15 +82,35 @@ func TestViewHidesTerminalCursorWhenToastCoversIt(t *testing.T) { |
84 | 82 | } |
85 | 83 |
|
86 | 84 | _ = h.app.toast.ShowInfo("copy complete") |
87 | | - toastView := h.app.toast.View() |
88 | | - if toastView == "" { |
89 | | - t.Fatal("expected visible toast") |
90 | | - } |
91 | | - toastWidth := lipgloss.Width(toastView) |
92 | | - toastX := (h.app.width - toastWidth) / 2 |
93 | | - toastY := h.app.height - 2 |
94 | | - h.tabs[0].Terminal.CursorX = toastX |
95 | | - h.tabs[0].Terminal.CursorY = toastY |
| 85 | + covered := false |
| 86 | + for width := 48; width <= 96 && !covered; width++ { |
| 87 | + for height := 8; height <= 18 && !covered; height++ { |
| 88 | + h.app.width = width |
| 89 | + h.app.height = height |
| 90 | + h.app.layout.Resize(width, height) |
| 91 | + h.app.updateLayout() |
| 92 | + |
| 93 | + termOffsetX, termOffsetY, termW, termH := h.app.center.TerminalViewport() |
| 94 | + centerX := h.app.layout.LeftGutter() + h.app.layout.DashboardWidth() + h.app.layout.GapX() |
| 95 | + termX := centerX + termOffsetX |
| 96 | + termY := h.app.layout.TopGutter() + termOffsetY |
| 97 | + |
| 98 | + for y := 0; y < termH && !covered; y++ { |
| 99 | + for x := 0; x < termW; x++ { |
| 100 | + if !h.app.toastCoversPoint(termX+x, termY+y) { |
| 101 | + continue |
| 102 | + } |
| 103 | + h.tabs[0].Terminal.CursorX = x |
| 104 | + h.tabs[0].Terminal.CursorY = y |
| 105 | + covered = true |
| 106 | + break |
| 107 | + } |
| 108 | + } |
| 109 | + } |
| 110 | + } |
| 111 | + if !covered { |
| 112 | + t.Fatal("expected a toast-covered point within the terminal viewport in test setup") |
| 113 | + } |
96 | 114 |
|
97 | 115 | view := h.Render() |
98 | 116 | if view.Cursor != nil { |
|
0 commit comments