@@ -4,6 +4,7 @@ import Share from './share.js'
44import { executeThemePush } from '../../services/push.js'
55import { executeThemePull } from '../../services/pull.js'
66import { withCapturedStandardStreams } from '@shopify/cli-kit/node/testing/output'
7+ import { addPublicMetadata } from '@shopify/cli-kit/node/metadata'
78import { loadEnvironment } from '@shopify/cli-kit/node/environments'
89import { ensureAuthenticatedThemes } from '@shopify/cli-kit/node/session'
910import { inTemporaryDirectory } from '@shopify/cli-kit/node/fs'
@@ -20,17 +21,15 @@ vi.mock('@shopify/cli-kit/node/metadata')
2021class TestPush extends Push {
2122 public parse = vi . fn ( )
2223}
23-
2424class TestPull extends Pull {
2525 public parse = vi . fn ( )
2626}
27-
2827class TestShare extends Share {
2928 public parse = vi . fn ( )
3029}
3130
3231describe . each ( [ TestPush , TestPull , TestShare ] ) ( '%s' , ( Command ) => {
33- test . each ( [ 'none' , 'partial' , 'total' , 'cancelled' ] as const ) (
32+ test . each ( [ 'none' , 'partial' , 'total' , 'cancelled' , 'analytics' ] as const ) (
3433 'retains all environments in request order with %s failures' ,
3534 async ( failures ) => {
3635 await inTemporaryDirectory ( async ( path ) => {
@@ -45,6 +44,11 @@ describe.each([TestPush, TestPull, TestShare])('%s', (Command) => {
4544 const secondStarted = new Promise < void > ( ( resolve ) => {
4645 releaseFirst = resolve
4746 } )
47+ vi . mocked ( addPublicMetadata ) . mockImplementation ( async ( collect ) => {
48+ const metadata = await collect ( )
49+ if ( failures === 'analytics' && metadata ?. store_domain === 'second.myshopify.com' )
50+ throw new Error ( 'analytics failed' )
51+ } )
4852 const executionOrder : string [ ] = [ ]
4953 const execute = async ( flags : { environment ?: string [ ] } , session ?: { storeFqdn : string } ) => {
5054 const environment = flags . environment ! [ 0 ] !
@@ -73,7 +77,6 @@ describe.each([TestPush, TestPull, TestShare])('%s', (Command) => {
7377 }
7478 vi . mocked ( executeThemePush ) . mockImplementation ( execute )
7579 vi . mocked ( executeThemePull ) . mockImplementation ( execute )
76-
7780 const config = new Config ( { root : __dirname } )
7881 await config . load ( )
7982 const command = new Command (
@@ -114,7 +117,7 @@ describe.each([TestPush, TestPull, TestShare])('%s', (Command) => {
114117 . map ( ( line ) => JSON . parse ( line ) )
115118 : [ ]
116119 expect ( events . filter ( ( event ) => event . level === 'error' ) ) . toHaveLength (
117- { none : 0 , partial : 1 , total : 3 , cancelled : 0 } [ failures ] ,
120+ { none : 0 , partial : 1 , total : 3 , cancelled : 0 , analytics : 0 } [ failures ] ,
118121 )
119122 } )
120123 } finally {
@@ -151,7 +154,6 @@ describe.each([TestPush, TestPull, TestShare])('%s', (Command) => {
151154 ] )
152155 expect ( executeThemePush ) . not . toHaveBeenCalled ( )
153156 expect ( executeThemePull ) . not . toHaveBeenCalled ( )
154-
155157 expect ( process . exitCode ) . toBe ( 1 )
156158 } )
157159 } finally {
0 commit comments