@@ -3355,6 +3355,77 @@ func TestHandleImmediateSlashCommandCompactBranches(t *testing.T) {
33553355 }
33563356}
33573357
3358+ func TestHandleImmediateSlashCommandWebBranches (t * testing.T ) {
3359+ app , _ := newTestApp (t )
3360+
3361+ handled , cmd := app .handleImmediateSlashCommand ("/web now" )
3362+ if ! handled || cmd != nil {
3363+ t .Fatalf ("expected /web with args to be handled without cmd" )
3364+ }
3365+ if ! strings .Contains (app .state .StatusText , "usage:" ) {
3366+ t .Fatalf ("expected usage error for /web with args" )
3367+ }
3368+
3369+ prevStart := startWebUIProcess
3370+ defer func () {
3371+ startWebUIProcess = prevStart
3372+ }()
3373+
3374+ capturedWorkdir := ""
3375+ startWebUIProcess = func (workdir string ) error {
3376+ capturedWorkdir = workdir
3377+ return nil
3378+ }
3379+
3380+ app .state .CurrentWorkdir = t .TempDir ()
3381+ handled , cmd = app .handleImmediateSlashCommand ("/web" )
3382+ if ! handled || cmd == nil {
3383+ t .Fatalf ("expected /web to return command" )
3384+ }
3385+
3386+ msg := cmd ()
3387+ result , ok := msg .(localCommandResultMsg )
3388+ if ! ok {
3389+ t .Fatalf ("expected localCommandResultMsg, got %T" , msg )
3390+ }
3391+ if result .Err != nil {
3392+ t .Fatalf ("expected nil error, got %v" , result .Err )
3393+ }
3394+ if ! strings .Contains (result .Notice , "Web UI startup requested" ) {
3395+ t .Fatalf ("expected web startup notice, got %q" , result .Notice )
3396+ }
3397+ if capturedWorkdir != app .state .CurrentWorkdir {
3398+ t .Fatalf ("captured workdir = %q, want %q" , capturedWorkdir , app .state .CurrentWorkdir )
3399+ }
3400+ }
3401+
3402+ func TestHandleImmediateSlashCommandWebStartError (t * testing.T ) {
3403+ app , _ := newTestApp (t )
3404+
3405+ prevStart := startWebUIProcess
3406+ defer func () {
3407+ startWebUIProcess = prevStart
3408+ }()
3409+ startWebUIProcess = func (workdir string ) error {
3410+ _ = workdir
3411+ return errors .New ("web start failed" )
3412+ }
3413+
3414+ handled , cmd := app .handleImmediateSlashCommand ("/web" )
3415+ if ! handled || cmd == nil {
3416+ t .Fatalf ("expected /web to return command" )
3417+ }
3418+
3419+ msg := cmd ()
3420+ result , ok := msg .(localCommandResultMsg )
3421+ if ! ok {
3422+ t .Fatalf ("expected localCommandResultMsg, got %T" , msg )
3423+ }
3424+ if result .Err == nil || ! strings .Contains (result .Err .Error (), "web start failed" ) {
3425+ t .Fatalf ("expected web start error, got %v" , result .Err )
3426+ }
3427+ }
3428+
33583429func TestHandleMemoCommandsRouteToSystemTools (t * testing.T ) {
33593430 app , runtime := newTestApp (t )
33603431
0 commit comments