@@ -24,6 +24,7 @@ import {
2424} from '@sim/testing/mocks/organization-membership.mock'
2525import { schemaMock } from '@sim/testing/mocks/schema.mock'
2626import { beforeEach , describe , expect , it , vi } from 'vitest'
27+ import type { DbTransaction } from '@/lib/db/types'
2728
2829const {
2930 mockCreateOrganizationWithOwner,
@@ -77,6 +78,8 @@ const { mockAcquireOrganizationMutationLock } = organizationMembershipMockFns
7778const { mockAcquireUserBillingIdentityLock } = billingIdentityLockMockFns
7879const BILLING_WEBHOOK = { type : 'system' , name : 'Billing System' } as const
7980const ACCEPTOR = { type : 'user' , userId : 'acceptor-1' } as const
81+ /** The chain mock standing in for the acceptance transaction the Tx variant runs on. */
82+ const ACCEPTANCE_TX = dbChainMock . db as unknown as DbTransaction
8083billingPlanHelpersMockFns . mockIsPaid . mockImplementation ( ( plan ) => plan !== 'free' )
8184
8285function queueWhereResponses ( responses : unknown [ ] [ ] ) {
@@ -175,7 +178,7 @@ describe('ensureOrganizationForTeamSubscription', () => {
175178 mockAttachOwnedWorkspacesToOrganizationTx . mockResolvedValueOnce ( { usageLimitUserIds : [ ] } )
176179
177180 await ensureOrganizationForTeamSubscriptionTx (
178- dbChainMock . db ,
181+ ACCEPTANCE_TX ,
179182 {
180183 id : 'sub-1' ,
181184 plan : 'team' ,
@@ -204,7 +207,7 @@ describe('ensureOrganizationForTeamSubscription', () => {
204207
205208 await expect (
206209 ensureOrganizationForTeamSubscriptionTx (
207- dbChainMock . db ,
210+ ACCEPTANCE_TX ,
208211 {
209212 id : 'sub-1' ,
210213 plan : 'team' ,
@@ -267,16 +270,13 @@ describe('syncSubscriptionUsageLimits', () => {
267270 mockGetOrganizationIdForSubscriptionReference . mockResolvedValue ( 'org-1' )
268271 mockGetPlanPricing . mockReturnValue ( { basePrice : 25 } )
269272
270- await syncSubscriptionUsageLimits (
271- {
272- id : 'sub-1' ,
273- plan : 'team_6000' ,
274- referenceId : 'org-1' ,
275- status : 'active' ,
276- seats : 2 ,
277- } ,
278- BILLING_WEBHOOK
279- )
273+ await syncSubscriptionUsageLimits ( {
274+ id : 'sub-1' ,
275+ plan : 'team_6000' ,
276+ referenceId : 'org-1' ,
277+ status : 'active' ,
278+ seats : 2 ,
279+ } )
280280
281281 const update = dbChainMockFns . set . mock . calls [ 0 ] ?. [ 0 ]
282282 const expression = JSON . stringify ( update ?. orgUsageLimit )
0 commit comments