Compact graph columns and branch spacing and simplify Home hints
This commit is contained in:
@@ -28,8 +28,8 @@ func press(m Model, key string) Model {
|
||||
func TestPaletteAndUnreadLogs(t *testing.T) {
|
||||
m := New(context.Background(), "ws://localhost/connect")
|
||||
m.height = 18
|
||||
if !strings.Contains(ansi.Strip(m.footerContent()), "LOGS 0 · :logs") {
|
||||
t.Fatal("expected empty log count and command hint")
|
||||
if !strings.Contains(ansi.Strip(m.footerContent()), "LOGS 0") {
|
||||
t.Fatal("expected empty log count")
|
||||
}
|
||||
for i := 0; i < 35; i++ {
|
||||
m.appendLine(fmt.Sprintf("line %02d", i))
|
||||
@@ -95,14 +95,14 @@ func TestPaletteAndUnreadLogs(t *testing.T) {
|
||||
func TestLogBadgeRetainsReadLogs(t *testing.T) {
|
||||
m := New(context.Background(), "ws://localhost/connect")
|
||||
m.appendLine("connection lost")
|
||||
if !strings.Contains(ansi.Strip(m.footerContent()), "● 1 NEW · LOGS 1 · :logs") {
|
||||
if !strings.Contains(ansi.Strip(m.footerContent()), "● 1 NEW · LOGS 1") {
|
||||
t.Fatal("unread logs need an explicit badge")
|
||||
}
|
||||
m = press(m, ":")
|
||||
m = press(m, "logs")
|
||||
m = press(m, "enter")
|
||||
m = press(m, "esc")
|
||||
if m.unread != 0 || !strings.Contains(ansi.Strip(m.footerContent()), "LOGS 1 · :logs") || strings.Contains(ansi.Strip(m.footerContent()), "NEW") {
|
||||
if m.unread != 0 || !strings.Contains(ansi.Strip(m.footerContent()), "LOGS 1") || strings.Contains(ansi.Strip(m.footerContent()), "NEW") {
|
||||
t.Fatal("read logs must remain discoverable")
|
||||
}
|
||||
for _, width := range []int{1, 12, 40, 80} {
|
||||
@@ -120,7 +120,7 @@ func TestHomeShowsEmptyLatestRunsBeforePipelines(t *testing.T) {
|
||||
m.loaded = true
|
||||
m.pipelines = []protocol.PipelineSummary{{Name: "bug fix", Version: 3, Stages: 5}}
|
||||
view := ansi.Strip(m.View())
|
||||
for _, text := range []string{"Latest runs", "Outcome", "No runs yet.", "Inspect with :runs", "Existing pipelines", "bug fix"} {
|
||||
for _, text := range []string{"Latest runs", "Outcome", "No runs yet.", "Existing pipelines", "bug fix"} {
|
||||
if !strings.Contains(view, text) {
|
||||
t.Fatalf("missing %q", text)
|
||||
}
|
||||
@@ -133,6 +133,42 @@ func TestHomeShowsEmptyLatestRunsBeforePipelines(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestHomeOnlyAdvertisesSearchAndCommands(t *testing.T) {
|
||||
for _, populated := range []bool{false, true} {
|
||||
m := New(context.Background(), "ws://localhost/connect")
|
||||
m.width, m.height = 120, 40
|
||||
m.loaded = true
|
||||
if populated {
|
||||
m.pipelines = []protocol.PipelineSummary{{Name: "demo", Version: 1, Stages: 3}}
|
||||
m.usage = &protocol.UsageStats{}
|
||||
}
|
||||
view := ansi.Strip(m.View())
|
||||
for _, hint := range []string{"/ search", ": commands"} {
|
||||
if !strings.Contains(view, hint) {
|
||||
t.Fatal("missing home hint", hint, view)
|
||||
}
|
||||
}
|
||||
for _, hint := range []string{"r all runs", "n new", "d drafts", "b templates", "test ping", ":quit", ":status", ":logs", "Press b"} {
|
||||
if strings.Contains(view, hint) {
|
||||
t.Fatal("home advertises extra shortcut", hint, view)
|
||||
}
|
||||
}
|
||||
if len(m.keys.ShortHelp()) != 2 {
|
||||
t.Fatal("home help contains extra shortcuts")
|
||||
}
|
||||
available := m.pageCommands()
|
||||
for _, command := range []string{":new", ":drafts", ":templates", ":runs", ":status", ":logs", ":quit"} {
|
||||
if !strings.Contains(strings.Join(available, " "), command) {
|
||||
t.Fatal("home action missing from commands", command)
|
||||
}
|
||||
}
|
||||
m = press(m, ":")
|
||||
if !m.paletteOpen {
|
||||
t.Fatal("command palette inaccessible")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestDashboardAndModalDimensions(t *testing.T) {
|
||||
for _, size := range []tea.WindowSizeMsg{{Width: 100, Height: 30}, {Width: 40, Height: 10}, {Width: 12, Height: 5}, {Width: 1, Height: 1}} {
|
||||
for _, mode := range []string{"home", "palette", "logs"} {
|
||||
|
||||
Reference in New Issue
Block a user