@@ -24,11 +24,11 @@ const mocks = vi.hoisted(() => ({
2424 getUsageLogs : vi . fn ( ) ,
2525 getWorkspaceUsageLogs : vi . fn ( ) ,
2626 recordAudit : vi . fn ( ) ,
27- canManageWorkspaceBilling : vi . fn ( ) ,
27+ canUserManageWorkspaceBilling : vi . fn ( ) ,
2828} ) )
2929
3030vi . mock ( '@/lib/billing/core/workspace-billing-authority' , ( ) => ( {
31- canUserManageWorkspaceBilling : mocks . canManageWorkspaceBilling ,
31+ canUserManageWorkspaceBilling : mocks . canUserManageWorkspaceBilling ,
3232} ) )
3333
3434vi . mock ( '@/lib/workspaces/application/workspace-context' , ( ) => ( {
@@ -99,7 +99,7 @@ describe('billing application use cases', () => {
9999 vi . clearAllMocks ( )
100100 mocks . loadWorkspace . mockResolvedValue ( workspaceContext )
101101 mocks . resolvePermission . mockResolvedValue ( 'read' )
102- mocks . canManageWorkspaceBilling . mockResolvedValue ( false )
102+ mocks . canUserManageWorkspaceBilling . mockResolvedValue ( false )
103103 mocks . checkUsageStatus . mockResolvedValue ( { currentUsage : 1 , limit : 10 , isExceeded : false } )
104104 mocks . checkAttributedBlocks . mockResolvedValue ( { blocked : false } )
105105 mocks . toUsageLimitSubscription . mockReturnValue ( null )
@@ -188,7 +188,7 @@ describe('billing application use cases', () => {
188188
189189 expect ( result . credits ) . toBeNull ( )
190190 expect ( result . storage ) . toBeNull ( )
191- expect ( mocks . canManageWorkspaceBilling ) . not . toHaveBeenCalled ( )
191+ expect ( mocks . canUserManageWorkspaceBilling ) . not . toHaveBeenCalled ( )
192192 } )
193193
194194 it ( 'never reads the payer storage pool it may not disclose' , async ( ) => {
@@ -216,7 +216,7 @@ describe('billing application use cases', () => {
216216
217217 it ( 'withholds the payer pool from a workspace member who cannot manage billing' , async ( ) => {
218218 mocks . resolvePermission . mockResolvedValue ( 'read' )
219- mocks . canManageWorkspaceBilling . mockResolvedValue ( false )
219+ mocks . canUserManageWorkspaceBilling . mockResolvedValue ( false )
220220
221221 const result = await getBillingStatus . execute ( {
222222 principal : personalPrincipal ,
@@ -226,12 +226,12 @@ describe('billing application use cases', () => {
226226 expect ( result . credits ) . toBeNull ( )
227227 expect ( result . storage ) . toBeNull ( )
228228 expect ( result ) . toMatchObject ( { workspaceId : 'workspace-1' , plan : 'free' , status : 'active' } )
229- expect ( mocks . canManageWorkspaceBilling ) . toHaveBeenCalledWith ( workspaceContext , 'user-1' )
229+ expect ( mocks . canUserManageWorkspaceBilling ) . toHaveBeenCalledWith ( workspaceContext , 'user-1' )
230230 } )
231231
232232 it ( 'withholds the payer pool from a workspace admin who cannot manage billing' , async ( ) => {
233233 mocks . resolvePermission . mockResolvedValue ( 'admin' )
234- mocks . canManageWorkspaceBilling . mockResolvedValue ( false )
234+ mocks . canUserManageWorkspaceBilling . mockResolvedValue ( false )
235235
236236 const result = await getBillingStatus . execute ( {
237237 principal : personalPrincipal ,
@@ -243,7 +243,7 @@ describe('billing application use cases', () => {
243243 } )
244244
245245 it ( 'still reports an exceeded payer limit without disclosing the pool' , async ( ) => {
246- mocks . canManageWorkspaceBilling . mockResolvedValue ( false )
246+ mocks . canUserManageWorkspaceBilling . mockResolvedValue ( false )
247247 mocks . checkUsageStatus . mockResolvedValue ( { currentUsage : 40 , limit : 10 , isExceeded : true } )
248248
249249 const result = await getBillingStatus . execute ( {
@@ -256,7 +256,7 @@ describe('billing application use cases', () => {
256256 } )
257257
258258 it ( 'projects the payer pool to a member who can manage billing' , async ( ) => {
259- mocks . canManageWorkspaceBilling . mockResolvedValue ( true )
259+ mocks . canUserManageWorkspaceBilling . mockResolvedValue ( true )
260260
261261 const result = await getBillingStatus . execute ( {
262262 principal : personalPrincipal ,
@@ -272,7 +272,7 @@ describe('billing application use cases', () => {
272272 } )
273273
274274 it ( 'always reports the account-scoped pool the caller owns' , async ( ) => {
275- mocks . canManageWorkspaceBilling . mockResolvedValue ( false )
275+ mocks . canUserManageWorkspaceBilling . mockResolvedValue ( false )
276276 mocks . getSubscription . mockResolvedValue ( { plan : 'pro' } )
277277 mocks . deriveBillingContext . mockReturnValue ( {
278278 billingEntity : { type : 'user' , id : 'user-1' } ,
0 commit comments