@@ -19,8 +19,7 @@ import {setManyAppConfigValues} from '../app/patch-app-configuration-file.js'
1919import { AppLinkedInterface } from '../../models/app/app.js'
2020import { beforeEach , describe , expect , vi , test } from 'vitest'
2121import { AbortError } from '@shopify/cli-kit/node/error'
22- import { checkPortAvailability , getAvailableTCPPort } from '@shopify/cli-kit/node/tcp'
23- import { isSpin , spinFqdn , appPort , appHost , fetchSpinPort } from '@shopify/cli-kit/node/context/spin'
22+ import { getAvailableTCPPort } from '@shopify/cli-kit/node/tcp'
2423import { codespacePortForwardingDomain , codespaceURL , gitpodURL , isUnitTest } from '@shopify/cli-kit/node/context/local'
2524import { renderConfirmationPrompt , renderSelectPrompt } from '@shopify/cli-kit/node/ui'
2625import { terminalSupportsPrompting } from '@shopify/cli-kit/node/system'
@@ -32,7 +31,6 @@ vi.mock('../app/patch-app-configuration-file.js', () => {
3231 }
3332} )
3433vi . mock ( '@shopify/cli-kit/node/tcp' )
35- vi . mock ( '@shopify/cli-kit/node/context/spin' )
3634vi . mock ( '@shopify/cli-kit/node/context/local' )
3735vi . mock ( '@shopify/cli-kit/node/plugins' )
3836vi . mock ( '@shopify/cli-kit/node/ui' )
@@ -487,96 +485,6 @@ describe('generateFrontendURL', () => {
487485 expect ( setCachedAppInfo ) . not . toBeCalled ( )
488486 expect ( renderSelectPrompt ) . not . toBeCalled ( )
489487 } )
490-
491- test ( 'Returns a cli spin url if we are in a spin environment running the cli manually' , async ( ) => {
492- // Given
493- vi . mocked ( isSpin ) . mockReturnValue ( true )
494- vi . mocked ( spinFqdn ) . mockResolvedValue ( 'spin.domain.dev' )
495- vi . mocked ( appPort ) . mockReturnValue ( undefined )
496- vi . mocked ( fetchSpinPort ) . mockResolvedValue ( 4040 )
497-
498- // When
499- const got = await generateFrontendURL ( defaultOptions )
500-
501- // Then
502- expect ( got ) . toEqual ( {
503- frontendUrl : 'https://cli.spin.domain.dev' ,
504- frontendPort : 4040 ,
505- usingLocalhost : false ,
506- } )
507- expect ( setCachedAppInfo ) . not . toBeCalled ( )
508- expect ( renderSelectPrompt ) . not . toBeCalled ( )
509- } )
510-
511- test ( 'Returns a 1p app spin url if we are in a spin environment running the cli as service' , async ( ) => {
512- // Given
513- vi . mocked ( isSpin ) . mockReturnValue ( true )
514- vi . mocked ( appPort ) . mockReturnValue ( 1234 )
515- vi . mocked ( appHost ) . mockReturnValue ( '1p-app-host.spin.domain.dev' )
516- vi . mocked ( checkPortAvailability ) . mockResolvedValue ( true )
517-
518- // When
519- const got = await generateFrontendURL ( defaultOptions )
520-
521- // Then
522- expect ( got ) . toEqual ( {
523- frontendUrl : 'https://1p-app-host.spin.domain.dev' ,
524- frontendPort : 1234 ,
525- usingLocalhost : false ,
526- } )
527- expect ( setCachedAppInfo ) . not . toBeCalled ( )
528- expect ( renderSelectPrompt ) . not . toBeCalled ( )
529- } )
530-
531- test ( 'Returns a cli spin url if we are in a spin environment running the cli manually with a 1p app backend running as service' , async ( ) => {
532- // Given
533- vi . mocked ( isSpin ) . mockReturnValue ( true )
534- vi . mocked ( appPort ) . mockReturnValue ( 1234 )
535- vi . mocked ( spinFqdn ) . mockResolvedValue ( 'spin.domain.dev' )
536- vi . mocked ( checkPortAvailability ) . mockResolvedValue ( false )
537- vi . mocked ( fetchSpinPort ) . mockResolvedValue ( 4040 )
538-
539- // When
540- const got = await generateFrontendURL ( defaultOptions )
541-
542- // Then
543- expect ( got ) . toEqual ( {
544- frontendUrl : 'https://cli.spin.domain.dev' ,
545- frontendPort : 4040 ,
546- usingLocalhost : false ,
547- } )
548- expect ( setCachedAppInfo ) . not . toBeCalled ( )
549- expect ( renderSelectPrompt ) . not . toBeCalled ( )
550- } )
551-
552- test ( 'Returns an error if we are in a spin environment with a 1p app backend is running as service and the partners port is not configured' , async ( ) => {
553- // Given
554- vi . mocked ( isSpin ) . mockReturnValue ( true )
555- vi . mocked ( appPort ) . mockReturnValue ( 1234 )
556- vi . mocked ( spinFqdn ) . mockResolvedValue ( 'spin.domain.dev' )
557- vi . mocked ( checkPortAvailability ) . mockResolvedValue ( false )
558- vi . mocked ( fetchSpinPort ) . mockResolvedValue ( undefined )
559-
560- // When
561- const got = generateFrontendURL ( defaultOptions )
562-
563- // Then
564- await expect ( got ) . rejects . toThrow (
565- 'Error building cli url in spin, cli as service port: 1234, manual cli port: undefined' ,
566- )
567- } )
568-
569- test ( 'Returns a custom tunnel url if we are in a spin environment but a custom tunnel option is active' , async ( ) => {
570- // Given
571- vi . mocked ( isSpin ) . mockReturnValue ( true )
572- const options = { ...defaultOptions , tunnelUrl : 'https://my-tunnel-provider.io:4242' }
573-
574- // When
575- const got = await generateFrontendURL ( options )
576-
577- // Then
578- expect ( got ) . toEqual ( { frontendUrl : 'https://my-tunnel-provider.io' , frontendPort : 4242 , usingLocalhost : false } )
579- } )
580488} )
581489
582490describe ( 'generatePartnersURLs' , ( ) => {
0 commit comments