fix(tui): guard against late Progress/Log after DoneMsg; drop dead quitting field

This commit is contained in:
MDietermann
2026-04-13 22:09:08 +02:00
parent feb01242f2
commit 5c5076f1f1
2 changed files with 29 additions and 4 deletions

View File

@@ -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()