(t *testing.T)
| 12 | ) |
| 13 | |
| 14 | func TestRenderMainScreen_LineCount(t *testing.T) { |
| 15 | appui.InitStyles() |
| 16 | m := newTestModel() |
| 17 | m.header = appui.NewHeaderModel(m.daemon, m.width) |
| 18 | |
| 19 | containers := m.daemon.Containers(nil, docker.SortByContainerID) |
| 20 | |
| 21 | result, _ := m.Update(containersLoadedMsg{containers: containers}) |
| 22 | m = result.(model) |
| 23 | |
| 24 | hdrLines := strings.Split(m.header.View(), "\n") |
| 25 | sepLines := strings.Split(m.header.SeparatorLine(""), "\n") |
| 26 | t.Logf("Header lines: %d, Separator lines: %d", len(hdrLines), len(sepLines)) |
| 27 | |
| 28 | contentLines := strings.Split(m.containers.View(), "\n") |
| 29 | t.Logf("Content lines: %d (expected contentHeight=%d)", len(contentLines), m.contentHeight()) |
| 30 | |
| 31 | v := m.renderMainScreen() |
| 32 | lines := strings.Split(v, "\n") |
| 33 | t.Logf("Terminal: %dx%d, Total lines: %d (expected %d)", m.width, m.height, len(lines), m.height) |
| 34 | |
| 35 | dataRows := 0 |
| 36 | for _, l := range contentLines { |
| 37 | if strings.Contains(l, "▶") || strings.Contains(l, "■") { |
| 38 | dataRows++ |
| 39 | } |
| 40 | } |
| 41 | t.Logf("Data rows: %d", dataRows) |
| 42 | |
| 43 | if len(lines) != m.height { |
| 44 | t.Errorf("Expected %d lines, got %d", m.height, len(lines)) |
| 45 | } |
| 46 | |
| 47 | result, _ = m.Update(tea.KeyPressMsg{Code: tea.KeyDown}) |
| 48 | m = result.(model) |
| 49 | contentLines2 := strings.Split(m.containers.View(), "\n") |
| 50 | dataRows2 := 0 |
| 51 | for _, l := range contentLines2 { |
| 52 | if strings.Contains(l, "▶") || strings.Contains(l, "■") { |
| 53 | dataRows2++ |
| 54 | } |
| 55 | } |
| 56 | t.Logf("Data rows after nav: %d", dataRows2) |
| 57 | if dataRows != dataRows2 { |
| 58 | t.Errorf("Data row count changed: %d -> %d", dataRows, dataRows2) |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | func TestRenderMainScreen_SmallTerminal(t *testing.T) { |
| 63 | // Simulate a small terminal where rows exceed viewport capacity |
nothing calls this directly
no test coverage detected