@@ -46,7 +46,9 @@ describe('renderOperationResult', () => {
4646 renderOperationResult ( [ ...baseMsg ] , operation )
4747
4848 expect ( renderSuccess ) . toHaveBeenCalledWith ( {
49- body : [ 'Base message' , 'complete. ' ] ,
49+ headline : 'Copy completed' ,
50+ body : [ 'Base message' ] ,
51+ nextSteps : undefined ,
5052 } )
5153 expect ( renderWarning ) . not . toHaveBeenCalled ( )
5254 } )
@@ -90,11 +92,9 @@ describe('renderOperationResult', () => {
9092 renderOperationResult ( [ ...baseMsg ] , operation )
9193
9294 expect ( renderSuccess ) . toHaveBeenCalledWith ( {
93- body : [
94- 'Base message' ,
95- 'complete. ' ,
96- { link : { label : 'Results file can be downloaded for more details' , url : 'https://example.com/results' } } ,
97- ] ,
95+ headline : 'Copy completed' ,
96+ body : [ 'Base message' ] ,
97+ nextSteps : [ [ 'Download' , { link : { label : 'result data' , url : 'https://example.com/results' } } ] ] ,
9898 } )
9999 expect ( renderWarning ) . not . toHaveBeenCalled ( )
100100 } )
@@ -137,7 +137,9 @@ describe('renderOperationResult', () => {
137137 renderOperationResult ( [ ...baseMsg ] , operation )
138138
139139 expect ( renderWarning ) . toHaveBeenCalledWith ( {
140- body : [ 'Base message' , 'completed with' , { error : 'errors. ' } ] ,
140+ headline : 'Copy completed with errors' ,
141+ body : [ 'Base message' ] ,
142+ nextSteps : undefined ,
141143 } )
142144 expect ( renderSuccess ) . not . toHaveBeenCalled ( )
143145 } )
@@ -181,13 +183,187 @@ describe('renderOperationResult', () => {
181183 renderOperationResult ( [ ...baseMsg ] , operation )
182184
183185 expect ( renderWarning ) . toHaveBeenCalledWith ( {
184- body : [
185- 'Base message' ,
186- 'completed with' ,
187- { error : 'errors. ' } ,
188- { link : { label : 'Results file can be downloaded for more details' , url : 'https://example.com/results' } } ,
189- ] ,
186+ headline : 'Copy completed with errors' ,
187+ body : [ 'Base message' ] ,
188+ nextSteps : [ [ 'Download' , { link : { label : 'result data' , url : 'https://example.com/results' } } ] ] ,
190189 } )
191190 expect ( renderSuccess ) . not . toHaveBeenCalled ( )
192191 } )
192+
193+ test ( 'renders success with target store link for STORE_COPY operation' , ( ) => {
194+ const targetShop = {
195+ id : '2' ,
196+ domain : 'target-shop.myshopify.com' ,
197+ name : 'Target Shop' ,
198+ status : 'ACTIVE' ,
199+ webUrl : 'https://target-shop.myshopify.com' ,
200+ handle : 'target-shop' ,
201+ publicId : 'pub2' ,
202+ shortName : 'target' ,
203+ organizationId : 'org1' ,
204+ }
205+
206+ const operation : BulkDataOperationByIdResponse = {
207+ organization : {
208+ name : 'Test Organization' ,
209+ bulkData : {
210+ operation : {
211+ id : 'bulk-op-1' ,
212+ operationType : 'STORE_COPY' ,
213+ status : 'COMPLETED' ,
214+ sourceStore : {
215+ id : '1' ,
216+ name : 'Source Store' ,
217+ } ,
218+ targetStore : {
219+ id : '2' ,
220+ name : 'Target Store' ,
221+ } ,
222+ storeOperations : [
223+ {
224+ id : 'op1' ,
225+ store : {
226+ id : '1' ,
227+ name : 'Store 1' ,
228+ } ,
229+ remoteOperationType : 'EXPORT' ,
230+ remoteOperationStatus : 'COMPLETED' ,
231+ totalObjectCount : 100 ,
232+ completedObjectCount : 100 ,
233+ url : 'https://example.com/results' ,
234+ } ,
235+ ] ,
236+ } ,
237+ } ,
238+ } ,
239+ }
240+
241+ renderOperationResult ( [ ...baseMsg ] , operation , targetShop )
242+
243+ expect ( renderSuccess ) . toHaveBeenCalledWith ( {
244+ headline : 'Copy completed' ,
245+ body : [ 'Base message' ] ,
246+ nextSteps : [
247+ [ 'View' , { link : { label : 'target shop' , url : 'https://target-shop.myshopify.com' } } ] ,
248+ [ 'Download' , { link : { label : 'result data' , url : 'https://example.com/results' } } ] ,
249+ ] ,
250+ } )
251+ } )
252+
253+ test ( 'renders success with target store link for STORE_IMPORT operation' , ( ) => {
254+ const targetShop = {
255+ id : '2' ,
256+ domain : 'target-shop.myshopify.com' ,
257+ name : 'Target Shop' ,
258+ status : 'ACTIVE' ,
259+ webUrl : 'https://target-shop.myshopify.com' ,
260+ handle : 'target-shop' ,
261+ publicId : 'pub2' ,
262+ shortName : 'target' ,
263+ organizationId : 'org1' ,
264+ }
265+
266+ const operation : BulkDataOperationByIdResponse = {
267+ organization : {
268+ name : 'Test Organization' ,
269+ bulkData : {
270+ operation : {
271+ id : 'bulk-op-1' ,
272+ operationType : 'STORE_IMPORT' ,
273+ status : 'COMPLETED' ,
274+ sourceStore : {
275+ id : '2' ,
276+ name : 'Target Store' ,
277+ } ,
278+ targetStore : {
279+ id : '2' ,
280+ name : 'Target Store' ,
281+ } ,
282+ storeOperations : [
283+ {
284+ id : 'op1' ,
285+ store : {
286+ id : '2' ,
287+ name : 'Target Store' ,
288+ } ,
289+ remoteOperationType : 'IMPORT' ,
290+ remoteOperationStatus : 'COMPLETED' ,
291+ totalObjectCount : 100 ,
292+ completedObjectCount : 100 ,
293+ url : 'https://example.com/results' ,
294+ } ,
295+ ] ,
296+ } ,
297+ } ,
298+ } ,
299+ }
300+
301+ renderOperationResult ( [ ...baseMsg ] , operation , targetShop )
302+
303+ expect ( renderSuccess ) . toHaveBeenCalledWith ( {
304+ headline : 'Copy completed' ,
305+ body : [ 'Base message' ] ,
306+ nextSteps : [
307+ [ 'View' , { link : { label : 'target shop' , url : 'https://target-shop.myshopify.com' } } ] ,
308+ [ 'Download' , { link : { label : 'result data' , url : 'https://example.com/results' } } ] ,
309+ ] ,
310+ } )
311+ } )
312+
313+ test ( 'does not render target store link for STORE_EXPORT operation' , ( ) => {
314+ const targetShop = {
315+ id : '1' ,
316+ domain : 'source-shop.myshopify.com' ,
317+ name : 'Source Shop' ,
318+ status : 'ACTIVE' ,
319+ webUrl : 'https://source-shop.myshopify.com' ,
320+ handle : 'source-shop' ,
321+ publicId : 'pub1' ,
322+ shortName : 'source' ,
323+ organizationId : 'org1' ,
324+ }
325+
326+ const operation : BulkDataOperationByIdResponse = {
327+ organization : {
328+ name : 'Test Organization' ,
329+ bulkData : {
330+ operation : {
331+ id : 'bulk-op-1' ,
332+ operationType : 'STORE_EXPORT' ,
333+ status : 'COMPLETED' ,
334+ sourceStore : {
335+ id : '1' ,
336+ name : 'Source Store' ,
337+ } ,
338+ targetStore : {
339+ id : '1' ,
340+ name : 'Source Store' ,
341+ } ,
342+ storeOperations : [
343+ {
344+ id : 'op1' ,
345+ store : {
346+ id : '1' ,
347+ name : 'Source Store' ,
348+ } ,
349+ remoteOperationType : 'EXPORT' ,
350+ remoteOperationStatus : 'COMPLETED' ,
351+ totalObjectCount : 100 ,
352+ completedObjectCount : 100 ,
353+ url : 'https://example.com/results' ,
354+ } ,
355+ ] ,
356+ } ,
357+ } ,
358+ } ,
359+ }
360+
361+ renderOperationResult ( [ ...baseMsg ] , operation , targetShop )
362+
363+ expect ( renderSuccess ) . toHaveBeenCalledWith ( {
364+ headline : 'Copy completed' ,
365+ body : [ 'Base message' ] ,
366+ nextSteps : [ [ 'Download' , { link : { label : 'result data' , url : 'https://example.com/results' } } ] ] ,
367+ } )
368+ } )
193369} )
0 commit comments