fix(tui): guard against late Progress/Log after DoneMsg; drop dead quitting field
This commit is contained in:
@@ -45,6 +45,28 @@ func TestDoneMsgFlipsIcons(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestProgressAfterDoneDoesNotRevertIcon(t *testing.T) {
|
||||
m := NewModel([]string{"a"}, nil)
|
||||
m.Update(DoneMsg{Summary: engine.Summary{Results: []engine.ModuleResult{
|
||||
{ID: "a", Status: engine.StatusSucceeded},
|
||||
}}})
|
||||
if got := m.rowIndex["a"].StatusIcon; got != "✓" {
|
||||
t.Fatalf("after Done icon = %q, want ✓", got)
|
||||
}
|
||||
// Late Progress event — tea.Program.Send has no ordering guarantee across goroutines.
|
||||
m.Update(tui.ProgressMsg{ModuleID: "a", Current: 9, Total: 10, Message: "late"})
|
||||
if got := m.rowIndex["a"].StatusIcon; got != "✓" {
|
||||
t.Fatalf("late Progress reverted icon to %q", got)
|
||||
}
|
||||
// Late Log event must also be dropped — it would otherwise pollute the
|
||||
// log tail of a completed row.
|
||||
before := len(m.rowIndex["a"].LogTail)
|
||||
m.Update(tui.LogMsg{ModuleID: "a", Line: "late log"})
|
||||
if after := len(m.rowIndex["a"].LogTail); after != before {
|
||||
t.Fatalf("late Log appended to tail: before=%d after=%d", before, after)
|
||||
}
|
||||
}
|
||||
|
||||
func TestViewMentionsModules(t *testing.T) {
|
||||
m := NewModel([]string{"alpha", "bravo"}, nil)
|
||||
out := m.View()
|
||||
|
||||
Reference in New Issue
Block a user