@@ -14,7 +14,14 @@ import {unstyled} from '@shopify/cli-kit/node/output'
1414import { openURL } from '@shopify/cli-kit/node/system'
1515import { Writable } from 'stream'
1616
17- vi . mock ( '@shopify/cli-kit/node/system' )
17+ vi . mock ( '@shopify/cli-kit/node/system' , async ( ) => {
18+ const actual : any = await vi . importActual ( '@shopify/cli-kit/node/system' )
19+ return {
20+ ...actual ,
21+ openURL : vi . fn ( ) ,
22+ terminalSupportsHyperlinks : mocks . terminalSupportsHyperlinks ,
23+ }
24+ } )
1825vi . mock ( '@shopify/cli-kit/node/context/local' )
1926vi . mock ( '@shopify/cli-kit/node/tree-kill' )
2027
@@ -23,6 +30,7 @@ const mocks = vi.hoisted(() => {
2330 useStdin : vi . fn ( ( ) => {
2431 return { isRawModeSupported : true }
2532 } ) ,
33+ terminalSupportsHyperlinks : vi . fn ( ( ) => false ) ,
2634 }
2735} )
2836
@@ -48,6 +56,8 @@ const onAbort = vi.fn()
4856
4957describe ( 'DevSessionUI' , ( ) => {
5058 beforeEach ( ( ) => {
59+ mocks . terminalSupportsHyperlinks . mockReturnValue ( false )
60+ mocks . useStdin . mockReturnValue ( { isRawModeSupported : true } )
5161 devSessionStatusManager = new DevSessionStatusManager ( )
5262 devSessionStatusManager . reset ( )
5363 devSessionStatusManager . updateStatus ( initialStatus )
@@ -544,6 +554,62 @@ describe('DevSessionUI', () => {
544554 renderInstance . unmount ( )
545555 } )
546556
557+ test ( 'hides URL list when terminal supports hyperlinks' , async ( ) => {
558+ // Given
559+ mocks . terminalSupportsHyperlinks . mockReturnValue ( true )
560+
561+ const renderInstance = render (
562+ < DevSessionUI
563+ processes = { [ ] }
564+ abortController = { new AbortController ( ) }
565+ devSessionStatusManager = { devSessionStatusManager }
566+ shopFqdn = "mystore.myshopify.com"
567+ onAbort = { onAbort }
568+ /> ,
569+ )
570+
571+ await waitForInputsToBeReady ( )
572+
573+ // Then - shortcuts with label text should be present but URL list should be hidden
574+ const output = unstyled ( renderInstance . lastFrame ( ) ! )
575+ expect ( output ) . toContain ( '(p) Open app preview' )
576+ expect ( output ) . toContain ( '(c) Open Dev Console for extension previews' )
577+ expect ( output ) . toContain ( '(g) Open GraphiQL (Admin API)' )
578+ expect ( output ) . not . toContain ( 'Preview URL:' )
579+ expect ( output ) . not . toContain ( 'Dev Console URL:' )
580+ expect ( output ) . not . toContain ( 'GraphiQL URL:' )
581+
582+ renderInstance . unmount ( )
583+ } )
584+
585+ test ( 'shows URL list when terminal does not support hyperlinks' , async ( ) => {
586+ // Given
587+ mocks . terminalSupportsHyperlinks . mockReturnValue ( false )
588+
589+ const renderInstance = render (
590+ < DevSessionUI
591+ processes = { [ ] }
592+ abortController = { new AbortController ( ) }
593+ devSessionStatusManager = { devSessionStatusManager }
594+ shopFqdn = "mystore.myshopify.com"
595+ onAbort = { onAbort }
596+ /> ,
597+ )
598+
599+ await waitForInputsToBeReady ( )
600+
601+ // Then - both shortcuts with label text and URL list should be present
602+ const output = unstyled ( renderInstance . lastFrame ( ) ! )
603+ expect ( output ) . toContain ( '(p) Open app preview' )
604+ expect ( output ) . toContain ( '(c) Open Dev Console for extension previews' )
605+ expect ( output ) . toContain ( '(g) Open GraphiQL (Admin API)' )
606+ expect ( output ) . toContain ( 'Preview URL: https://shopify.com' )
607+ expect ( output ) . toContain ( 'Dev Console URL: https://mystore.myshopify.com/admin?dev-console=show' )
608+ expect ( output ) . toContain ( 'GraphiQL URL: https://graphiql.shopify.com' )
609+
610+ renderInstance . unmount ( )
611+ } )
612+
547613 test ( 'shows non-interactive fallback when raw mode is not supported' , async ( ) => {
548614 // Given - mock useStdin to return false for isRawModeSupported
549615 mocks . useStdin . mockReturnValue ( { isRawModeSupported : false } )
@@ -570,8 +636,5 @@ describe('DevSessionUI', () => {
570636 expect ( output ) . toContain ( 'GraphiQL URL: https://graphiql.shopify.com' )
571637
572638 renderInstance . unmount ( )
573-
574- // Restore original mock for other tests
575- mocks . useStdin . mockReturnValue ( { isRawModeSupported : true } )
576639 } )
577640} )
0 commit comments