@@ -1240,7 +1240,7 @@ describe("AccountManager", () => {
12401240 } ) ;
12411241 } ) ;
12421242
1243- it ( "preserves the legacy setAccountEnabled account-or-null contract " , ( ) => {
1243+ it ( "ignores explicit disable-reason overrides for auth-failure disabled accounts " , ( ) => {
12441244 const now = Date . now ( ) ;
12451245 const stored = {
12461246 version : 3 as const ,
@@ -1258,14 +1258,50 @@ describe("AccountManager", () => {
12581258
12591259 const manager = new AccountManager ( undefined , stored ) ;
12601260
1261+ const disabled = manager . trySetAccountEnabled ( 0 , false , "user" ) ;
1262+ expect ( disabled ) . toMatchObject ( {
1263+ ok : true ,
1264+ account : {
1265+ enabled : false ,
1266+ disabledReason : "auth-failure" ,
1267+ } ,
1268+ } ) ;
1269+
1270+ expect ( manager . trySetAccountEnabled ( 0 , true ) ) . toEqual ( {
1271+ ok : false ,
1272+ reason : "auth-failure-blocked" ,
1273+ } ) ;
12611274 expect ( manager . setAccountEnabled ( 0 , true ) ) . toBeNull ( ) ;
1275+ } ) ;
1276+
1277+ it ( "preserves the legacy setAccountEnabled account-or-null contract" , ( ) => {
1278+ const now = Date . now ( ) ;
1279+ const stored = {
1280+ version : 3 as const ,
1281+ activeIndex : 0 ,
1282+ accounts : [
1283+ {
1284+ refreshToken : "token-1" ,
1285+ addedAt : now ,
1286+ lastUsed : now ,
1287+ } ,
1288+ ] ,
1289+ } ;
1290+
1291+ const manager = new AccountManager ( undefined , stored ) ;
1292+
12621293 expect ( manager . setAccountEnabled ( 99 , false ) ) . toBeNull ( ) ;
12631294
12641295 const userDisabled = manager . setAccountEnabled ( 0 , false , "user" ) ;
12651296 expect ( userDisabled ) . toMatchObject ( {
12661297 enabled : false ,
12671298 disabledReason : "user" ,
12681299 } ) ;
1300+
1301+ const reenabled = manager . setAccountEnabled ( 0 , true ) ;
1302+ expect ( reenabled ) . toMatchObject ( {
1303+ enabled : true ,
1304+ } ) ;
12691305 } ) ;
12701306 } ) ;
12711307
0 commit comments