Skip to content

Commit ba1043f

Browse files
committed
test(quickbooks): cover tokenless disconnect claims
1 parent f0090df commit ba1043f

2 files changed

Lines changed: 31 additions & 0 deletions

File tree

apps/sim/lib/credentials/application/oauth-accounts.test.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,35 @@ describe('OAuth account application operations', () => {
324324
expect(dbChainMockFns.delete).not.toHaveBeenCalled()
325325
})
326326

327+
it('claims a tokenless QuickBooks account before deleting local credentials', async () => {
328+
queueTableRows(account, [
329+
{
330+
id: 'account-1',
331+
providerId: 'quickbooks',
332+
accessToken: null,
333+
refreshToken: null,
334+
oauthConfig: 'encrypted-config',
335+
updatedAt: new Date('2026-08-01T00:00:00.000Z'),
336+
},
337+
])
338+
queueTableRows(credential, [
339+
{ ...firstCredential, providerId: 'quickbooks', accountId: 'account-1' },
340+
])
341+
dbChainMockFns.returning.mockResolvedValueOnce([])
342+
343+
await expect(
344+
disconnectOAuthUseCase.execute({
345+
principal: { kind: 'session', userId: 'user-1', sessionId: 'session-1' },
346+
input: { provider: 'quickbooks', accountId: 'account-1' },
347+
})
348+
).resolves.toMatchObject({ success: true, credentials: [] })
349+
350+
expect(mocks.revokeQuickBooksToken).not.toHaveBeenCalled()
351+
expect(dbChainMockFns.update).toHaveBeenCalledWith(account)
352+
expect(mocks.deleteCredential).not.toHaveBeenCalled()
353+
expect(dbChainMockFns.delete).not.toHaveBeenCalled()
354+
})
355+
327356
it('records a successful Intuit revocation so a local-delete retry does not revoke twice', async () => {
328357
const linkedCredential = {
329358
...firstCredential,

packages/testing/src/mocks/schema.mock.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ export const schemaMock = {
179179
refreshTokenExpiresAt: 'account.refreshTokenExpiresAt',
180180
scope: 'account.scope',
181181
password: 'account.password',
182+
oauthConfig: 'account.oauthConfig',
182183
createdAt: 'account.createdAt',
183184
updatedAt: 'account.updatedAt',
184185
},
@@ -1332,6 +1333,7 @@ export const schemaMock = {
13321333
displayName: 'pendingCredentialDraft.displayName',
13331334
description: 'pendingCredentialDraft.description',
13341335
credentialId: 'pendingCredentialDraft.credentialId',
1336+
oauthConfig: 'pendingCredentialDraft.oauthConfig',
13351337
expiresAt: 'pendingCredentialDraft.expiresAt',
13361338
createdAt: 'pendingCredentialDraft.createdAt',
13371339
},

0 commit comments

Comments
 (0)