@@ -306,6 +306,42 @@ describe('store auth service', () => {
306306 expect ( setStoredStoreAppSession ) . not . toHaveBeenCalled ( )
307307 } )
308308
309+ test ( 'authenticateStoreWithApp succeeds when scopes input is space-separated' , async ( ) => {
310+ const waitForStoreAuthCodeMock = vi . fn ( ) . mockImplementation ( async ( options ) => {
311+ await options . onListening ?.( )
312+ return 'abc123'
313+ } )
314+
315+ const result = await authenticateStoreWithApp (
316+ {
317+ store : 'shop.myshopify.com' ,
318+ scopes : 'read_products read_inventory' ,
319+ } ,
320+ {
321+ openURL : vi . fn ( ) . mockResolvedValue ( true ) ,
322+ waitForStoreAuthCode : waitForStoreAuthCodeMock ,
323+ exchangeStoreAuthCodeForToken : vi . fn ( ) . mockResolvedValue ( {
324+ access_token : 'token' ,
325+ scope : 'read_products,read_inventory' ,
326+ expires_in : 86400 ,
327+ associated_user : { id : 42 , email : 'test@example.com' } ,
328+ } ) ,
329+ presenter : {
330+ openingBrowser : vi . fn ( ) ,
331+ manualAuthUrl : vi . fn ( ) ,
332+ success : vi . fn ( ) ,
333+ } ,
334+ } ,
335+ )
336+
337+ expect ( result . scopes ) . toEqual ( [ 'read_products' , 'read_inventory' ] )
338+ expect ( setStoredStoreAppSession ) . toHaveBeenCalledWith (
339+ expect . objectContaining ( {
340+ scopes : [ 'read_products' , 'read_inventory' ] ,
341+ } ) ,
342+ )
343+ } )
344+
309345 test ( 'authenticateStoreWithApp accepts compressed write scopes that imply requested read scopes' , async ( ) => {
310346 const waitForStoreAuthCodeMock = vi . fn ( ) . mockImplementation ( async ( options ) => {
311347 await options . onListening ?.( )
0 commit comments