mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-12 07:01:09 -07:00
fix(core): allow any preview model in quota access check (#19867)
This commit is contained in:
@@ -2198,6 +2198,21 @@ describe('Config Quota & Preview Model Access', () => {
|
|||||||
expect(config.getHasAccessToPreviewModel()).toBe(true);
|
expect(config.getHasAccessToPreviewModel()).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should update hasAccessToPreviewModel to true if quota includes Gemini 3.1 preview model', async () => {
|
||||||
|
mockCodeAssistServer.retrieveUserQuota.mockResolvedValue({
|
||||||
|
buckets: [
|
||||||
|
{
|
||||||
|
modelId: 'gemini-3.1-pro-preview',
|
||||||
|
remainingAmount: '100',
|
||||||
|
remainingFraction: 1.0,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
await config.refreshUserQuota();
|
||||||
|
expect(config.getHasAccessToPreviewModel()).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
it('should update hasAccessToPreviewModel to false if quota does not include preview model', async () => {
|
it('should update hasAccessToPreviewModel to false if quota does not include preview model', async () => {
|
||||||
mockCodeAssistServer.retrieveUserQuota.mockResolvedValue({
|
mockCodeAssistServer.retrieveUserQuota.mockResolvedValue({
|
||||||
buckets: [
|
buckets: [
|
||||||
|
|||||||
@@ -1500,7 +1500,8 @@ export class Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const hasAccess =
|
const hasAccess =
|
||||||
quota.buckets?.some((b) => b.modelId === PREVIEW_GEMINI_MODEL) ?? false;
|
quota.buckets?.some((b) => b.modelId && isPreviewModel(b.modelId)) ??
|
||||||
|
false;
|
||||||
this.setHasAccessToPreviewModel(hasAccess);
|
this.setHasAccessToPreviewModel(hasAccess);
|
||||||
return quota;
|
return quota;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ describe('isPreviewModel', () => {
|
|||||||
it('should return true for preview models', () => {
|
it('should return true for preview models', () => {
|
||||||
expect(isPreviewModel(PREVIEW_GEMINI_MODEL)).toBe(true);
|
expect(isPreviewModel(PREVIEW_GEMINI_MODEL)).toBe(true);
|
||||||
expect(isPreviewModel(PREVIEW_GEMINI_3_1_MODEL)).toBe(true);
|
expect(isPreviewModel(PREVIEW_GEMINI_3_1_MODEL)).toBe(true);
|
||||||
|
expect(isPreviewModel(PREVIEW_GEMINI_3_1_CUSTOM_TOOLS_MODEL)).toBe(true);
|
||||||
expect(isPreviewModel(PREVIEW_GEMINI_FLASH_MODEL)).toBe(true);
|
expect(isPreviewModel(PREVIEW_GEMINI_FLASH_MODEL)).toBe(true);
|
||||||
expect(isPreviewModel(PREVIEW_GEMINI_MODEL_AUTO)).toBe(true);
|
expect(isPreviewModel(PREVIEW_GEMINI_MODEL_AUTO)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -134,6 +134,7 @@ export function isPreviewModel(model: string): boolean {
|
|||||||
return (
|
return (
|
||||||
model === PREVIEW_GEMINI_MODEL ||
|
model === PREVIEW_GEMINI_MODEL ||
|
||||||
model === PREVIEW_GEMINI_3_1_MODEL ||
|
model === PREVIEW_GEMINI_3_1_MODEL ||
|
||||||
|
model === PREVIEW_GEMINI_3_1_CUSTOM_TOOLS_MODEL ||
|
||||||
model === PREVIEW_GEMINI_FLASH_MODEL ||
|
model === PREVIEW_GEMINI_FLASH_MODEL ||
|
||||||
model === PREVIEW_GEMINI_MODEL_AUTO
|
model === PREVIEW_GEMINI_MODEL_AUTO
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user