@@ -2,6 +2,7 @@ package ui
22
33import (
44 "context"
5+ "fmt"
56 "strings"
67 "testing"
78 "time"
@@ -201,6 +202,46 @@ func TestAppErrorEventStopsSpinner(t *testing.T) {
201202 }
202203}
203204
205+ func TestAppSilentErrorDoesNotOverwriteErrorDisplay (t * testing.T ) {
206+ t .Parallel ()
207+
208+ app := NewApp ("dev" , "" , "" , nil )
209+
210+ // Simulate EmitUnhealthyError: sink emits a nice ErrorEvent first.
211+ model , _ := app .Update (output.ErrorEvent {Title : "Docker is not available" })
212+ app = model .(App )
213+
214+ // Simulate runErrMsg arriving with a SilentError (already displayed).
215+ silentErr := output .NewSilentError (fmt .Errorf ("runtime not healthy: cannot connect to Docker daemon" ))
216+ model , _ = app .Update (runErrMsg {err : silentErr })
217+ app = model .(App )
218+
219+ view := app .errorDisplay .View (200 )
220+ if ! strings .Contains (view , "Docker is not available" ) {
221+ t .Fatalf ("expected original error to be preserved, got: %q" , view )
222+ }
223+ if strings .Contains (view , "runtime not healthy" ) {
224+ t .Fatalf ("expected silent error not to overwrite display, got: %q" , view )
225+ }
226+ }
227+
228+ func TestAppNonSilentErrorShowsInErrorDisplay (t * testing.T ) {
229+ t .Parallel ()
230+
231+ app := NewApp ("dev" , "" , "" , nil )
232+
233+ model , _ := app .Update (runErrMsg {err : fmt .Errorf ("something unexpected" )})
234+ app = model .(App )
235+
236+ if ! app .errorDisplay .Visible () {
237+ t .Fatal ("expected error display to be visible for non-silent error" )
238+ }
239+ view := app .errorDisplay .View (200 )
240+ if ! strings .Contains (view , "something unexpected" ) {
241+ t .Fatalf ("expected error title in display, got: %q" , view )
242+ }
243+ }
244+
204245func TestAppEnterPrefersExplicitEnterOption (t * testing.T ) {
205246 t .Parallel ()
206247
0 commit comments