@@ -256,6 +256,43 @@ describe("AccountManager", () => {
256256 expect ( account . workspaces ?. map ( ( workspace ) => workspace . enabled ) ) . toEqual ( [ false , true ] ) ;
257257 } ) ;
258258
259+ it ( "re-enabling an exhausted account restores its workspaces" , ( ) => {
260+ const now = Date . now ( ) ;
261+ const stored = {
262+ version : 3 as const ,
263+ activeIndex : 0 ,
264+ accounts : [
265+ {
266+ refreshToken : "token-1" ,
267+ addedAt : now ,
268+ lastUsed : now ,
269+ enabled : false ,
270+ workspaces : [
271+ { id : "workspace-1" , name : "Workspace 1" , enabled : false , disabledAt : now - 2_000 } ,
272+ { id : "workspace-2" , name : "Workspace 2" , enabled : false , disabledAt : now - 1_000 } ,
273+ ] ,
274+ currentWorkspaceIndex : 1 ,
275+ } ,
276+ ] ,
277+ } ;
278+
279+ const manager = new AccountManager ( undefined , stored ) ;
280+ const account = manager . setAccountEnabled ( 0 , true ) ;
281+ expect ( account ) . not . toBeNull ( ) ;
282+ if ( ! account ) {
283+ throw new Error ( "account should exist" ) ;
284+ }
285+
286+ expect ( account . enabled ) . toBe ( true ) ;
287+ expect ( manager . hasEnabledWorkspaces ( account ) ) . toBe ( true ) ;
288+ expect ( manager . getEnabledWorkspaceCount ( account ) ) . toBe ( 2 ) ;
289+ expect ( manager . getCurrentWorkspace ( account ) ?. id ) . toBe ( "workspace-2" ) ;
290+ expect ( account . workspaces ) . toEqual ( [
291+ { id : "workspace-1" , name : "Workspace 1" , enabled : true } ,
292+ { id : "workspace-2" , name : "Workspace 2" , enabled : true } ,
293+ ] ) ;
294+ } ) ;
295+
259296 it ( "checks account availability by enabled/rate-limit/cooldown state" , ( ) => {
260297 const now = Date . now ( ) ;
261298 const stored = {
0 commit comments