@@ -52,122 +52,4 @@ describe("account pool helper", () => {
5252 activeIndexByFamily : { codex : 0 } ,
5353 } ) ;
5454 } ) ;
55-
56- it ( "advances lastUsed when updating an existing account by default" , async ( ) => {
57- const persist = vi . fn ( async ( ) => undefined ) ;
58- const originalLastUsed = 456 ;
59- const nowSpy = vi . spyOn ( Date , "now" ) . mockReturnValue ( 789 ) ;
60-
61- try {
62- await persistAccountPoolResults ( {
63- results : [
64- {
65- type : "success" ,
66- access : "access-token-next" ,
67- refresh : "refresh-token" ,
68- expires : 999 ,
69- } ,
70- ] ,
71- replaceAll : false ,
72- modelFamilies : [ "codex" ] ,
73- withAccountStorageTransaction : async ( handler ) =>
74- handler (
75- {
76- version : 3 ,
77- activeIndex : 0 ,
78- activeIndexByFamily : { codex : 0 } ,
79- accounts : [
80- {
81- accountId : "acct_1" ,
82- email : "user@example.com" ,
83- refreshToken : "refresh-token" ,
84- accessToken : "access-token-old" ,
85- expiresAt : 123 ,
86- addedAt : 111 ,
87- lastUsed : originalLastUsed ,
88- enabled : true ,
89- } ,
90- ] ,
91- } ,
92- persist ,
93- ) ,
94- findMatchingAccountIndex : ( ) => 0 ,
95- extractAccountId : ( ) => "acct_1" ,
96- extractAccountEmail : ( ) => "user@example.com" ,
97- sanitizeEmail : ( email ) => email ,
98- } ) ;
99- } finally {
100- nowSpy . mockRestore ( ) ;
101- }
102-
103- expect ( persist ) . toHaveBeenCalledWith (
104- expect . objectContaining ( {
105- accounts : [
106- expect . objectContaining ( {
107- refreshToken : "refresh-token" ,
108- accessToken : "access-token-next" ,
109- expiresAt : 999 ,
110- lastUsed : 789 ,
111- } ) ,
112- ] ,
113- } ) ,
114- ) ;
115- } ) ;
116-
117- it ( "preserves lastUsed for report-style updates when requested" , async ( ) => {
118- const persist = vi . fn ( async ( ) => undefined ) ;
119- const originalLastUsed = 456 ;
120-
121- await persistAccountPoolResults ( {
122- results : [
123- {
124- type : "success" ,
125- access : "access-token-next" ,
126- refresh : "refresh-token" ,
127- expires : 999 ,
128- } ,
129- ] ,
130- replaceAll : false ,
131- preserveLastUsedOnUpdate : true ,
132- modelFamilies : [ "codex" ] ,
133- withAccountStorageTransaction : async ( handler ) =>
134- handler (
135- {
136- version : 3 ,
137- activeIndex : 0 ,
138- activeIndexByFamily : { codex : 0 } ,
139- accounts : [
140- {
141- accountId : "acct_1" ,
142- email : "user@example.com" ,
143- refreshToken : "refresh-token" ,
144- accessToken : "access-token-old" ,
145- expiresAt : 123 ,
146- addedAt : 111 ,
147- lastUsed : originalLastUsed ,
148- enabled : true ,
149- } ,
150- ] ,
151- } ,
152- persist ,
153- ) ,
154- findMatchingAccountIndex : ( ) => 0 ,
155- extractAccountId : ( ) => "acct_1" ,
156- extractAccountEmail : ( ) => "user@example.com" ,
157- sanitizeEmail : ( email ) => email ,
158- } ) ;
159-
160- expect ( persist ) . toHaveBeenCalledWith (
161- expect . objectContaining ( {
162- accounts : [
163- expect . objectContaining ( {
164- refreshToken : "refresh-token" ,
165- accessToken : "access-token-next" ,
166- expiresAt : 999 ,
167- lastUsed : originalLastUsed ,
168- } ) ,
169- ] ,
170- } ) ,
171- ) ;
172- } ) ;
17355} ) ;
0 commit comments