@@ -2064,7 +2064,7 @@ describe("OpenAIOAuthPlugin persistAccountPool", () => {
20642064 expect ( mockStorage . accounts [ 0 ] ?. accessToken ) . toBe ( "access-no-org-update" ) ;
20652065 } ) ;
20662066
2067- it ( "does not merge ambiguous org-scoped matches when organization metadata is missing " , async ( ) => {
2067+ it ( "preserves org-scoped variants when organizationId differs despite shared account/refresh context " , async ( ) => {
20682068 const accountsModule = await import ( "../lib/accounts.js" ) ;
20692069 const authModule = await import ( "../lib/auth/auth.js" ) ;
20702070
@@ -2113,10 +2113,16 @@ describe("OpenAIOAuthPlugin persistAccountPool", () => {
21132113 expect ( mockStorage . accounts ) . toHaveLength ( 2 ) ;
21142114 const orgScopedEntries = mockStorage . accounts . filter ( ( account ) => account . organizationId ) ;
21152115 expect ( orgScopedEntries ) . toHaveLength ( 2 ) ;
2116+ expect ( orgScopedEntries . map ( ( account ) => account . organizationId ) . sort ( ) ) . toEqual ( [
2117+ "org-a" ,
2118+ "org-b" ,
2119+ ] ) ;
21162120 expect ( orgScopedEntries . some ( ( account ) => account . accessToken === "access-ambiguous" ) ) . toBe ( true ) ;
2121+ expect ( mockStorage . activeIndex ) . toBe ( 0 ) ;
2122+ expect ( mockStorage . activeIndexByFamily ) . toEqual ( { } ) ;
21172123 } ) ;
21182124
2119- it ( "remaps active indices to merged org account when fallback variant is pruned " , async ( ) => {
2125+ it ( "allows no-org fallback collision collapse and safely remaps active indices " , async ( ) => {
21202126 const accountsModule = await import ( "../lib/accounts.js" ) ;
21212127 const authModule = await import ( "../lib/auth/auth.js" ) ;
21222128
@@ -2180,9 +2186,9 @@ describe("OpenAIOAuthPlugin persistAccountPool", () => {
21802186 expect ( mockStorage . accounts ) . toHaveLength ( 3 ) ;
21812187 expect ( mockStorage . accounts . some ( ( account ) => account . accountId === "token-shared" ) ) . toBe ( false ) ;
21822188 expect ( mockStorage . accounts [ 1 ] ?. accountId ) . toBe ( "org-shared" ) ;
2189+ expect ( mockStorage . accounts [ 1 ] ?. organizationId ) . toBe ( "org-keep" ) ;
21832190 expect ( mockStorage . activeIndex ) . toBe ( 1 ) ;
2184- expect ( mockStorage . activeIndexByFamily . codex ) . toBe ( 1 ) ;
2185- expect ( mockStorage . activeIndexByFamily [ "gpt-5.1" ] ) . toBe ( 1 ) ;
2191+ expect ( mockStorage . activeIndexByFamily ) . toEqual ( { codex : 1 , "gpt-5.1" : 1 } ) ;
21862192 } ) ;
21872193
21882194 it ( "keeps latest rate-limit reset windows when collapsing refresh-token duplicates" , async ( ) => {
0 commit comments