@@ -36,7 +36,7 @@ import {getEnvironmentVariables} from '@shopify/cli-kit/node/environment'
3636import { isStorefrontPasswordProtected } from '@shopify/theme'
3737import { fetchTheme } from '@shopify/cli-kit/node/themes/api'
3838import { firstPartyDev } from '@shopify/cli-kit/node/context/local'
39- import { adminFqdn } from '@shopify/cli-kit/node/context/fqdn'
39+ import { adminFqdn , normalizeStoreFqdn , storeAdminUrl } from '@shopify/cli-kit/node/context/fqdn'
4040
4141vi . mock ( '../../context/identifiers.js' )
4242vi . mock ( '@shopify/cli-kit/node/session.js' )
@@ -50,6 +50,8 @@ vi.mock('@shopify/cli-kit/node/context/fqdn', async (importOriginal) => {
5050 return {
5151 ...original ,
5252 adminFqdn : vi . fn ( ) ,
53+ normalizeStoreFqdn : vi . fn ( original . normalizeStoreFqdn ) ,
54+ storeAdminUrl : vi . fn ( original . storeAdminUrl ) ,
5355 }
5456} )
5557
@@ -312,6 +314,69 @@ describe('setup-dev-processes', () => {
312314 } )
313315 } )
314316
317+ test ( 'uses the admin-web preflight URL for local development stores' , async ( ) => {
318+ const developerPlatformClient : DeveloperPlatformClient = testDeveloperPlatformClient ( )
319+ const storeFqdn = 'test.my.shop.dev'
320+ const storeId = '123456789'
321+ const remoteAppUpdated = true
322+ const graphiqlPort = 1234
323+ const commandOptions : DevConfig [ 'commandOptions' ] = {
324+ ...appContextResult ,
325+ directory : '' ,
326+ update : false ,
327+ commandConfig : new Config ( { root : '' } ) ,
328+ skipDependenciesInstallation : false ,
329+ tunnel : { mode : 'auto' } ,
330+ }
331+ const network : DevConfig [ 'network' ] = {
332+ proxyUrl : 'https://example.com/proxy' ,
333+ proxyPort : 444 ,
334+ backendPort : 111 ,
335+ frontendPort : 222 ,
336+ currentUrls : {
337+ applicationUrl : 'https://example.com/application' ,
338+ redirectUrlWhitelist : [ 'https://example.com/redirect' ] ,
339+ } ,
340+ }
341+ const localApp = testAppWithConfig ( )
342+ vi . spyOn ( loader , 'reloadApp' ) . mockResolvedValue ( localApp )
343+ vi . mocked ( normalizeStoreFqdn ) . mockReturnValue ( 'test.my.shop.dev' )
344+ vi . mocked ( storeAdminUrl ) . mockReturnValue ( 'admin.shop.dev/store/test' )
345+
346+ const remoteApp : DevConfig [ 'remoteApp' ] = {
347+ apiKey : 'api-key' ,
348+ apiSecretKeys : [ { secret : 'api-secret' } ] ,
349+ id : '1234' ,
350+ title : 'App' ,
351+ organizationId : '5678' ,
352+ grantedScopes : [ ] ,
353+ flags : [ ] ,
354+ developerPlatformClient,
355+ }
356+
357+ const res = await setupDevProcesses ( {
358+ localApp,
359+ commandOptions,
360+ network,
361+ remoteApp,
362+ remoteAppUpdated,
363+ storeFqdn,
364+ storeId,
365+ developerPlatformClient,
366+ partnerUrlsUpdated : true ,
367+ graphiqlPort,
368+ graphiqlKey : 'somekey' ,
369+ } )
370+
371+ expect ( res . previewUrl ) . toBe ( 'https://admin.shop.dev/store/test/extensions-dev/preview?client_id=api-key' )
372+ expect ( res . processes [ 1 ] ) . toMatchObject ( {
373+ type : 'graphiql' ,
374+ options : {
375+ appUrl : 'https://admin.shop.dev/store/test/extensions-dev/preview?client_id=api-key' ,
376+ } ,
377+ } )
378+ } )
379+
315380 test ( 'process list includes dev-session when useDevSession is true' , async ( ) => {
316381 const developerPlatformClient : DeveloperPlatformClient = testDeveloperPlatformClient ( { supportsDevSessions : true } )
317382 const storeFqdn = 'store.myshopify.io'
0 commit comments