@@ -11,7 +11,8 @@ import {accountInfo} from '../packages/cli/src/account.js';
1111import { createProvider , loadCredentials , CLI_CLIENT_ID } from '../packages/cli/src/auth.js' ;
1212
1313const endpoint = 'https://api.example.com/api/mcp' ;
14- const user = { user_uuid : 'user-1' , username : 'fixture' , balance : 125 , frozen : 5 } ;
14+ const user = { user_uuid : 'user-1' , username : 'fixture' , balance : 125 , frozen : 5 ,
15+ subscriptions : { active_subscriptions : [ { wallet_balance : 40 } , { wallet_balance : 60 } ] } } ;
1516const json = ( body , status = 200 ) => new Response ( JSON . stringify ( body ) , {
1617 status, headers : { 'Content-Type' : 'application/json' } ,
1718} ) ;
@@ -44,7 +45,7 @@ test('personal account status uses the account HTTP API and its authorized walle
4445 } } ) ;
4546 assert . deepEqual ( calls , [ 'https://api.example.com/api/user/get_info' ] ) ;
4647 assert . deepEqual ( result , { authenticated : true , user : { uuid : 'user-1' , username : 'fixture' } ,
47- wallet : { type : 'personal' , balance : 125 , frozen : 5 } } ) ;
48+ wallet : { type : 'personal' , balance : 12.5 , subscription_balance : 10 , frozen : 0. 5} } ) ;
4849} ) ;
4950
5051test ( 'team account status requests only the team bound to the grant' , async ( ) => {
@@ -56,7 +57,7 @@ test('team account status requests only the team bound to the grant', async () =
5657 : json ( { group_meta : { uuid : 'team-1' , name : 'Fixture team' , frozen : 9 } , balance : 800 } ) ;
5758 } } ) ;
5859 assert . deepEqual ( calls , [ [ '/api/user/get_info' , { } ] , [ '/api/group/group_info' , { group_uuid : 'team-1' } ] ] ) ;
59- assert . deepEqual ( result . wallet , { type : 'group' , group_uuid : 'team-1' , name : 'Fixture team' , balance : 800 , frozen : 9 } ) ;
60+ assert . deepEqual ( result . wallet , { type : 'group' , group_uuid : 'team-1' , name : 'Fixture team' , balance : 80 , frozen : 0. 9} ) ;
6061} ) ;
6162
6263test ( 'account status reports HTTP, server and network errors without treating them as logout' , async ( ) => {
@@ -74,6 +75,8 @@ test('account status rejects missing workspace, invalid identity and invalid wal
7475 [ { meta : user } , / a u t h o r i z e d b i l l i n g w o r k s p a c e / ] ,
7576 [ { meta : { ...user , user_uuid : '' } , billing_workspace : { type : 'personal' } } , / I n v a l i d u s e r i n f o r m a t i o n / ] ,
7677 [ { meta : { ...user , balance : '125' } , billing_workspace : { type : 'personal' } } , / v a l i d b a l a n c e / ] ,
78+ [ { meta : { ...user , subscriptions : null } , billing_workspace : { type : 'personal' } } , / v a l i d s u b s c r i p t i o n b a l a n c e s / ] ,
79+ [ { meta : { ...user , subscriptions : { active_subscriptions : [ { wallet_balance : null } ] } } , billing_workspace : { type : 'personal' } } , / v a l i d s u b s c r i p t i o n b a l a n c e s / ] ,
7780 [ { meta : { ...user , frozen : null } , billing_workspace : { type : 'personal' } } , / v a l i d b a l a n c e / ] ,
7881 ] ) await assert . rejects ( accountInfo ( endpoint , { token : 'fixture-token' , fetchFn : async ( ) => json ( body ) } ) , message ) ;
7982 let calls = 0 ;
@@ -127,7 +130,8 @@ test('auth status and info alias return JSON over real HTTP; authorization error
127130 try {
128131 for ( const command of [ 'status' , 'info' ] ) {
129132 const result = await run ( command , 'fixture-token' ) ;
130- assert . equal ( JSON . parse ( result . stdout ) . wallet . balance , 125 ) ;
133+ assert . deepEqual ( JSON . parse ( result . stdout ) . wallet , {
134+ type : 'personal' , balance : 12.5 , subscription_balance : 10 , frozen : 0.5 } ) ;
131135 assert . equal ( result . stderr , '' ) ;
132136 }
133137 assert . equal ( JSON . parse ( ( await run ( 'status' , '' ) ) . stdout ) . authenticated , false ) ;
0 commit comments