Skip to content

Commit 27d9bc3

Browse files
committed
fix(shopify): scope ownership backfill to Shopify credentials
1 parent 57bc872 commit 27d9bc3

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

‎apps/sim/lib/oauth/shopify.integration.ts‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -822,12 +822,18 @@ describe('Shopify offline installation tokens against PostgreSQL and HTTP', () =
822822
).toBe(true)
823823
})
824824

825-
it('rolls back every ownership-history page when a later association fails and retries the complete capture', async () => {
826-
const owners = Array.from({ length: 101 }, () => ({
825+
it('rolls back every ownership-history page on failure and retries only Shopify associations', async () => {
826+
const owners = Array.from({ length: 102 }, (_, index) => ({
827827
workspaceId: generateId(),
828828
credentialId: generateId(),
829+
providerId: index === 0 ? 'google-email' : 'shopify',
829830
}))
830-
const lastCredentialId = [...owners.map((owner) => owner.credentialId), credentialId]
831+
const lastCredentialId = [
832+
...owners
833+
.filter((owner) => owner.providerId === 'shopify')
834+
.map((owner) => owner.credentialId),
835+
credentialId,
836+
]
831837
.sort()
832838
.at(-1)
833839
await db.insert(workspace).values(
@@ -843,7 +849,7 @@ describe('Shopify offline installation tokens against PostgreSQL and HTTP', () =
843849
id: owner.credentialId,
844850
workspaceId: owner.workspaceId,
845851
type: 'oauth' as const,
846-
providerId: 'shopify',
852+
providerId: owner.providerId,
847853
accountId: rowIds[0],
848854
displayName: 'History page fixture',
849855
createdBy: userIds[0],

‎apps/sim/lib/shopify/privacy/installation-scopes.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ export async function rememberShopifyAccountScopes(accountId: string): Promise<v
120120
and(
121121
eq(credential.accountId, accountId),
122122
eq(credential.type, 'oauth'),
123+
eq(credential.providerId, 'shopify'),
123124
cursor ? gt(credential.id, cursor) : undefined
124125
)
125126
)

0 commit comments

Comments
 (0)