@@ -15,12 +15,17 @@ import type { Config } from '../config/config.js';
1515import {
1616 DEFAULT_GEMINI_FLASH_LITE_MODEL ,
1717 DEFAULT_GEMINI_MODEL_AUTO ,
18+ PREVIEW_GEMINI_3_1_CUSTOM_TOOLS_MODEL ,
19+ PREVIEW_GEMINI_3_1_MODEL ,
1820} from '../config/models.js' ;
21+ import { AuthType } from '../core/contentGenerator.js' ;
1922
2023const createMockConfig = ( overrides : Partial < Config > = { } ) : Config =>
2124 ( {
2225 getUserTier : ( ) => undefined ,
2326 getModel : ( ) => 'gemini-2.5-pro' ,
27+ getGemini31LaunchedSync : ( ) => false ,
28+ getContentGeneratorConfig : ( ) => ( { authType : undefined } ) ,
2429 ...overrides ,
2530 } ) as unknown as Config ;
2631
@@ -115,6 +120,43 @@ describe('policyHelpers', () => {
115120 expect ( chain [ 0 ] ?. model ) . toBe ( 'gemini-2.5-flash' ) ;
116121 expect ( chain [ 1 ] ?. model ) . toBe ( 'gemini-2.5-pro' ) ;
117122 } ) ;
123+ < < < << << HEAD
124+ = === ===
125+
126+ it ( 'proactively returns Gemini 2.5 chain if Gemini 3 requested but user lacks access' , ( ) => {
127+ const config = createMockConfig ( {
128+ getModel : ( ) => 'auto-gemini-3' ,
129+ getHasAccessToPreviewModel : ( ) => false ,
130+ } ) ;
131+ const chain = resolvePolicyChain ( config ) ;
132+
133+ // Should downgrade to [Pro 2.5, Flash 2.5]
134+ expect ( chain ) . toHaveLength ( 2 ) ;
135+ expect ( chain [ 0 ] ?. model ) . toBe ( 'gemini-2.5-pro' ) ;
136+ expect ( chain [ 1 ] ?. model ) . toBe ( 'gemini-2.5-flash' ) ;
137+ } ) ;
138+
139+ it ( 'returns Gemini 3.1 Pro chain when launched and auto-gemini-3 requested' , ( ) => {
140+ const config = createMockConfig ( {
141+ getModel : ( ) => 'auto-gemini-3' ,
142+ getGemini31LaunchedSync : ( ) => true ,
143+ } ) ;
144+ const chain = resolvePolicyChain ( config ) ;
145+ expect ( chain [ 0 ] ?. model ) . toBe ( PREVIEW_GEMINI_3_1_MODEL ) ;
146+ expect ( chain [ 1 ] ?. model ) . toBe ( 'gemini-3-flash-preview' ) ;
147+ } ) ;
148+
149+ it ( 'returns Gemini 3.1 Pro Custom Tools chain when launched, auth is Gemini, and auto-gemini-3 requested' , ( ) => {
150+ const config = createMockConfig ( {
151+ getModel : ( ) => 'auto-gemini-3' ,
152+ getGemini31LaunchedSync : ( ) => true ,
153+ getContentGeneratorConfig : ( ) => ( { authType : AuthType . USE_GEMINI } ) ,
154+ } ) ;
155+ const chain = resolvePolicyChain ( config ) ;
156+ expect ( chain [ 0 ] ?. model ) . toBe ( PREVIEW_GEMINI_3_1_CUSTOM_TOOLS_MODEL ) ;
157+ expect ( chain [ 1 ] ?. model ) . toBe ( 'gemini-3-flash-preview' ) ;
158+ } ) ;
159+ > >>> >>> aa9163da6 ( feat ( core ) : add policy chain support for Gemini 3.1 ( #19991 ) )
118160 } ) ;
119161
120162 describe ( 'buildFallbackPolicyContext' , ( ) => {
0 commit comments