@@ -19,7 +19,7 @@ describe('image service authentication routing', () => {
1919 const result = withImageServiceAuth ( legacyService , { type : 'subscription' , provider : 'codex' } ) ;
2020 expect ( result ) . toMatchObject ( { id : 'saved-service' , dialect : 'chatgpt_codex' , model_name : '' , params : { n : 1 } } ) ;
2121 expect ( resolveImageEndpoint ( result . base_url , result . request_url , result . dialect ) )
22- . toBe ( 'https://chatgpt.com/backend-api/codex/responses ' ) ;
22+ . toBe ( 'https://chatgpt.com/backend-api/codex/images/generations ' ) ;
2323 expect ( legacyService . request_url ) . toBe ( 'https://api.openai.com/v1/images/generations' ) ;
2424 } ) ;
2525
@@ -36,10 +36,23 @@ describe('image service authentication routing', () => {
3636 expect ( resolveImageEndpoint ( result . base_url , result . request_url , result . dialect ) ) . toBe ( 'https://api.openai.com/v1/images/generations' ) ;
3737 } ) ;
3838
39- it ( 'preserves custom API-key gateways and explicitly chosen subscription models ' , ( ) => {
39+ it ( 'preserves custom API-key gateways and legacy subscription model slots ' , ( ) => {
4040 expect ( withImageServiceAuth ( legacyService , { type : 'api_key' } ) ) . toEqual ( legacyService ) ;
4141 const auth = { type : 'subscription' as const , provider : 'codex' as const } ;
4242 const service = { ...withImageServiceAuth ( legacyService , auth ) , model_name : 'account-model' } ;
4343 expect ( withImageServiceAuth ( service , auth ) . model_name ) . toBe ( 'account-model' ) ;
4444 } ) ;
45+
46+ it ( 'resolves old subscription endpoints without rewriting serialized settings' , ( ) => {
47+ const root = 'https://chatgpt.com/backend-api/codex' ;
48+ const auth = { type : 'subscription' as const , provider : 'codex' as const } ;
49+ const saved = JSON . parse ( JSON . stringify ( { ...withImageServiceAuth ( legacyService , auth ) ,
50+ request_url : `${ root } /responses` , model_name : 'gpt-6.1-sol' } ) ) ;
51+ const snapshot = JSON . stringify ( saved ) ;
52+ expect ( resolveImageEndpoint ( saved . base_url , saved . request_url , saved . dialect ) ) . toBe ( `${ root } /images/generations` ) ;
53+ expect ( resolveImageEndpoint ( `${ root } /responses/` , undefined , 'chatgpt_codex' ) ) . toBe ( `${ root } /images/generations` ) ;
54+ expect ( resolveImageEndpoint ( `${ root } /images/generations` , undefined , 'chatgpt_codex' ) ) . toBe ( `${ root } /images/generations` ) ;
55+ expect ( JSON . stringify ( saved ) ) . toBe ( snapshot ) ;
56+ expect ( resolveImageEndpoint ( root , `${ root } /responses` , 'openai_images' ) ) . toBe ( `${ root } /responses` ) ;
57+ } ) ;
4558} ) ;
0 commit comments