Skip to content

Commit 1ed2d11

Browse files
authored
Fix success message style for snapshot load (#326)
1 parent 888a3f1 commit 1ed2d11

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

internal/ui/app.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ func (a App) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
299299
a.addLine(styledLine{text: style.Render(text)})
300300
a.addLine(blank)
301301
return a, nil
302-
case output.InstanceInfoEvent, output.PodSnapshotSavedEvent:
302+
case output.InstanceInfoEvent, output.PodSnapshotSavedEvent, output.SnapshotLoadedEvent:
303303
if line, ok := output.FormatEventLine(msg.(output.Event)); ok {
304304
a.addSuccessLines(line)
305305
}

internal/ui/app_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,30 @@ func TestAppMessageEventRendering(t *testing.T) {
219219
}
220220
}
221221

222+
func TestAppSnapshotLoadedEventRendersGreen(t *testing.T) {
223+
// Mutates the global lipgloss color profile, so it must not run in parallel.
224+
original := lipgloss.ColorProfile()
225+
lipgloss.SetColorProfile(termenv.TrueColor)
226+
t.Cleanup(func() { lipgloss.SetColorProfile(original) })
227+
228+
app := NewApp("dev", "", "", nil)
229+
230+
model, _ := app.Update(output.SnapshotLoadedEvent{Source: "pod:my-baseline"})
231+
app = model.(App)
232+
233+
if len(app.lines) != 1 {
234+
t.Fatalf("expected 1 line, got %d", len(app.lines))
235+
}
236+
237+
wantMarker := styles.Success.Render(output.SuccessMarker())
238+
if !strings.Contains(app.lines[0].text, wantMarker) {
239+
t.Fatalf("expected green success marker %q in rendered line, got: %q", wantMarker, app.lines[0].text)
240+
}
241+
if !strings.Contains(app.lines[0].text, "Snapshot loaded from pod:my-baseline") {
242+
t.Fatalf("expected loaded message text, got: %q", app.lines[0].text)
243+
}
244+
}
245+
222246
func TestAppMessageEventWrapsOnVisibleWidth(t *testing.T) {
223247
t.Parallel()
224248

0 commit comments

Comments
 (0)