@@ -11,13 +11,15 @@ import {BulkDataStoreExportStartResponse, BulkDataOperationByIdResponse} from '.
1111import { renderCopyInfo } from '../../../prompts/copy_info.js'
1212import { renderExportResult } from '../../../prompts/export_results.js'
1313import { ValidationError , OperationError , ErrorCodes } from '../errors/errors.js'
14+ import { confirmExportPrompt } from '../../../prompts/confirm_export.js'
1415import { describe , vi , expect , test , beforeEach } from 'vitest'
1516import { renderTasks } from '@shopify/cli-kit/node/ui'
1617
1718vi . mock ( '../utils/result-file-handler.js' )
1819vi . mock ( '@shopify/cli-kit/node/ui' )
1920vi . mock ( '../../../prompts/copy_info.js' )
2021vi . mock ( '../../../prompts/export_results.js' )
22+ vi . mock ( '../../../prompts/confirm_export.js' )
2123
2224describe ( 'StoreExportOperation' , ( ) => {
2325 const mockBpSession = 'mock-bp-session-token'
@@ -55,9 +57,26 @@ describe('StoreExportOperation', () => {
5557 } )
5658 } )
5759
60+ test ( 'should show confirm prompt before export' , async ( ) => {
61+ vi . mocked ( confirmExportPrompt ) . mockResolvedValue ( true )
62+ await operation . execute ( 'source.myshopify.com' , 'export.sqlite' , { } )
63+
64+ expect ( confirmExportPrompt ) . toHaveBeenCalledWith ( 'source.myshopify.com' , 'export.sqlite' )
65+ expect ( renderExportResult ) . toHaveBeenCalled ( )
66+ } )
67+
68+ test ( 'should skip confirmation when --no-prompt flag is provided' , async ( ) => {
69+ await operation . execute ( 'source.myshopify.com' , 'export.sqlite' , { 'no-prompt' : true } )
70+
71+ expect ( confirmExportPrompt ) . not . toHaveBeenCalled ( )
72+ expect ( renderExportResult ) . toHaveBeenCalled ( )
73+ } )
74+
5875 test ( 'should successfully export data from source shop' , async ( ) => {
76+ vi . mocked ( confirmExportPrompt ) . mockResolvedValue ( true )
5977 await operation . execute ( 'source.myshopify.com' , 'output.sqlite' , { } )
6078
79+ expect ( confirmExportPrompt ) . toHaveBeenCalledWith ( 'source.myshopify.com' , 'output.sqlite' )
6180 expect ( renderCopyInfo ) . toHaveBeenCalledWith ( 'Export Operation' , 'source.myshopify.com' , 'output.sqlite' )
6281 expect ( renderExportResult ) . toHaveBeenCalledWith ( mockSourceShop , mockCompletedOperation )
6382 expect ( mockResultFileHandler . promptAndHandleResultFile ) . toHaveBeenCalledWith (
@@ -81,7 +100,7 @@ describe('StoreExportOperation', () => {
81100 } ,
82101 ] )
83102
84- const promise = operation . execute ( 'nonexistent.myshopify.com' , 'output.sqlite' , { } )
103+ const promise = operation . execute ( 'nonexistent.myshopify.com' , 'output.sqlite' , { 'no-prompt' : true } )
85104 await expect ( promise ) . rejects . toThrow ( ValidationError )
86105 await expect ( promise ) . rejects . toMatchObject ( {
87106 code : ErrorCodes . SHOP_NOT_FOUND ,
@@ -103,7 +122,7 @@ describe('StoreExportOperation', () => {
103122 const singleShopOrg : Organization = TEST_MOCK_DATA . singleShopOrganization
104123 mockApiClient . fetchOrganizations . mockResolvedValue ( [ mockOrganization , singleShopOrg ] )
105124
106- await operation . execute ( 'source.myshopify.com' , 'output.sqlite' , { } )
125+ await operation . execute ( 'source.myshopify.com' , 'output.sqlite' , { 'no-prompt' : true } )
107126
108127 expect ( renderExportResult ) . toHaveBeenCalled ( )
109128 } )
@@ -121,7 +140,7 @@ describe('StoreExportOperation', () => {
121140 return ctx
122141 } )
123142
124- const promise = operation . execute ( 'source.myshopify.com' , 'output.sqlite' , { } )
143+ const promise = operation . execute ( 'source.myshopify.com' , 'output.sqlite' , { 'no-prompt' : true } )
125144 await expect ( promise ) . rejects . toThrow ( OperationError )
126145 await expect ( promise ) . rejects . toMatchObject ( {
127146 operation : 'export' ,
@@ -153,7 +172,7 @@ describe('StoreExportOperation', () => {
153172 isComplete : true ,
154173 } )
155174
156- const promise = operation . execute ( 'source.myshopify.com' , 'output.sqlite' , { } )
175+ const promise = operation . execute ( 'source.myshopify.com' , 'output.sqlite' , { 'no-prompt' : true } )
157176 await expect ( promise ) . rejects . toThrow ( OperationError )
158177 await expect ( promise ) . rejects . toMatchObject ( {
159178 operation : 'export' ,
@@ -181,7 +200,7 @@ describe('StoreExportOperation', () => {
181200 isComplete : true ,
182201 } )
183202
184- const promise = operation . execute ( 'source.myshopify.com' , 'output.sqlite' , { } )
203+ const promise = operation . execute ( 'source.myshopify.com' , 'output.sqlite' , { 'no-prompt' : true } )
185204 await expect ( promise ) . rejects . toThrow ( OperationError )
186205 await expect ( promise ) . rejects . toMatchObject ( {
187206 operation : 'export' ,
@@ -218,7 +237,7 @@ describe('StoreExportOperation', () => {
218237 return ctx
219238 } )
220239
221- const promise = operation . execute ( 'source.myshopify.com' , 'output.sqlite' , { } )
240+ const promise = operation . execute ( 'source.myshopify.com' , 'output.sqlite' , { 'no-prompt' : true } )
222241 await expect ( promise ) . rejects . toThrow ( OperationError )
223242 await expect ( promise ) . rejects . toMatchObject ( {
224243 operation : 'export' ,
0 commit comments