@@ -40,6 +40,8 @@ const initialStatus: DevSessionStatus = {
4040 isReady : true ,
4141 previewURL : 'https://shopify.com' ,
4242 graphiqlURL : 'https://graphiql.shopify.com' ,
43+ appEmbedded : false ,
44+ hasExtensions : true ,
4345}
4446
4547const onAbort = vi . fn ( )
@@ -121,10 +123,12 @@ describe('DevSessionUI', () => {
121123 expect ( output ) . toContain ( '(q) Quit' )
122124
123125 // Shortcuts and URLs should be visible
124- expect ( output ) . toContain ( '(g) Open GraphiQL' )
125- expect ( output ) . toContain ( '(p) Preview in your browser' )
126+ expect ( output ) . toContain ( '(g) Open GraphiQL (Admin API)' )
127+ expect ( output ) . toContain ( '(p) Open app preview' )
128+ expect ( output ) . toContain ( '(c) Open Dev Console for extension previews' )
126129 expect ( output ) . toContain ( 'Preview URL: https://shopify.com' )
127130 expect ( output ) . toContain ( 'GraphiQL URL: https://graphiql.shopify.com' )
131+ expect ( output ) . toContain ( 'Dev Console URL: https://mystore.myshopify.com/admin?dev-console=show' )
128132
129133 renderInstance . unmount ( )
130134 } )
@@ -171,6 +175,80 @@ describe('DevSessionUI', () => {
171175 renderInstance . unmount ( )
172176 } )
173177
178+ test ( 'opens the dev console URL when c is pressed for non-embedded apps' , async ( ) => {
179+ // Given
180+ devSessionStatusManager . updateStatus ( { appEmbedded : false } )
181+
182+ // When
183+ const renderInstance = render (
184+ < DevSessionUI
185+ processes = { [ ] }
186+ abortController = { new AbortController ( ) }
187+ devSessionStatusManager = { devSessionStatusManager }
188+ shopFqdn = "mystore.myshopify.com"
189+ onAbort = { onAbort }
190+ /> ,
191+ )
192+
193+ await waitForInputsToBeReady ( )
194+ await sendInputAndWait ( renderInstance , 10 , 'c' )
195+
196+ // Then
197+ expect ( vi . mocked ( openURL ) ) . toHaveBeenNthCalledWith ( 1 , 'https://mystore.myshopify.com/admin?dev-console=show' )
198+
199+ renderInstance . unmount ( )
200+ } )
201+
202+ test ( 'does not show dev console shortcut when app is embedded' , async ( ) => {
203+ // Given
204+ devSessionStatusManager . updateStatus ( { appEmbedded : true } )
205+
206+ // When
207+ const renderInstance = render (
208+ < DevSessionUI
209+ processes = { [ ] }
210+ abortController = { new AbortController ( ) }
211+ devSessionStatusManager = { devSessionStatusManager }
212+ shopFqdn = "mystore.myshopify.com"
213+ onAbort = { onAbort }
214+ /> ,
215+ )
216+
217+ await waitForInputsToBeReady ( )
218+
219+ // Then
220+ const output = unstyled ( renderInstance . lastFrame ( ) ! )
221+ expect ( output ) . not . toContain ( '(c) Open Dev Console' )
222+ expect ( output ) . not . toContain ( 'Dev Console URL' )
223+
224+ renderInstance . unmount ( )
225+ } )
226+
227+ test ( 'does not show dev console shortcut when app has no extensions' , async ( ) => {
228+ // Given
229+ devSessionStatusManager . updateStatus ( { hasExtensions : false } )
230+
231+ // When
232+ const renderInstance = render (
233+ < DevSessionUI
234+ processes = { [ ] }
235+ abortController = { new AbortController ( ) }
236+ devSessionStatusManager = { devSessionStatusManager }
237+ shopFqdn = "mystore.myshopify.com"
238+ onAbort = { onAbort }
239+ /> ,
240+ )
241+
242+ await waitForInputsToBeReady ( )
243+
244+ // Then
245+ const output = unstyled ( renderInstance . lastFrame ( ) ! )
246+ expect ( output ) . not . toContain ( '(c) Open Dev Console' )
247+ expect ( output ) . not . toContain ( 'Dev Console URL' )
248+
249+ renderInstance . unmount ( )
250+ } )
251+
174252 test ( 'quits when q is pressed' , async ( ) => {
175253 // Given
176254 const abortController = new AbortController ( )
@@ -356,7 +434,7 @@ describe('DevSessionUI', () => {
356434 await waitForInputsToBeReady ( )
357435
358436 // Initial state
359- expect ( unstyled ( renderInstance . lastFrame ( ) ! ) ) . not . toContain ( 'preview in your browser ' )
437+ expect ( unstyled ( renderInstance . lastFrame ( ) ! ) ) . not . toContain ( 'Open app preview ' )
360438
361439 // When status updates
362440 devSessionStatusManager . updateStatus ( {
@@ -365,7 +443,7 @@ describe('DevSessionUI', () => {
365443 graphiqlURL : 'https://new-graphiql.shopify.com' ,
366444 } )
367445
368- await waitForContent ( renderInstance , 'Preview in your browser ' )
446+ await waitForContent ( renderInstance , 'Open app preview ' )
369447
370448 // Then
371449 expect ( unstyled ( renderInstance . lastFrame ( ) ! ) ) . toContain ( 'Preview URL: https://new-preview-url.shopify.com' )
0 commit comments