Skip to content

Commit e7505ab

Browse files
committed
test(billing): cover the legacy-account subscription read failing closed
1 parent e52d9ce commit e7505ab

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

‎apps/sim/app/api/copilot/api-keys/validate/route.test.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,20 @@ describe('POST /api/copilot/api-keys/validate billing protocols', () => {
297297
expect(mockCheckAttributedUsageLimits).not.toHaveBeenCalled()
298298
})
299299

300+
it('fails account admission closed when its subscription cannot be read', async () => {
301+
mockGetHighestPrioritySubscription.mockImplementationOnce(
302+
async (_userId: string, options?: { onError?: 'throw' | 'return-null' }) => {
303+
if (options?.onError === 'throw') throw new Error('database unavailable')
304+
return null
305+
}
306+
)
307+
308+
const res = await POST(request(SELF_HOSTED_WORKSPACELESS_VALIDATE_BODY))
309+
310+
expect(res.status).toBe(500)
311+
expect(mockCheckServerSideUsageLimits).not.toHaveBeenCalled()
312+
})
313+
300314
it('rejects markerless admission on hosted Sim', async () => {
301315
setEnvFlags({ isHosted: true })
302316
const res = await POST(request(SELF_HOSTED_VALIDATE_BODY))

0 commit comments

Comments
 (0)