Skip to content

Commit ebafe03

Browse files
RyanDJLeeclaude
andcommitted
Add service-level regression test for space-separated scopes
Exercises the full authenticateStoreWithApp flow with space-separated input ('read_products read_inventory') and comma-separated server response, asserting the scopes resolve correctly and persist to the session store. Addresses review feedback from dmerand. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent f4c0785 commit ebafe03

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

packages/cli/src/cli/services/store/auth/index.test.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)