mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-11 22:51:00 -07:00
fix(core): make showNotice optional in PrivacyNoticeSchema
This commit is contained in:
51
packages/core/src/code_assist/schema.test.ts
Normal file
51
packages/core/src/code_assist/schema.test.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2025 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { LoadCodeAssistResponseSchema } from './types.js';
|
||||
|
||||
describe('LoadCodeAssistResponseSchema', () => {
|
||||
it('should allow missing showNotice in privacyNotice and default to false', () => {
|
||||
const data = {
|
||||
currentTier: {
|
||||
id: 'standard-tier',
|
||||
privacyNotice: {
|
||||
noticeText: 'Some notice',
|
||||
},
|
||||
},
|
||||
allowedTiers: [
|
||||
{
|
||||
id: 'free-tier',
|
||||
privacyNotice: {},
|
||||
},
|
||||
{
|
||||
id: 'standard-tier',
|
||||
privacyNotice: {
|
||||
showNotice: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const parsed = LoadCodeAssistResponseSchema.parse(data);
|
||||
|
||||
expect(parsed.currentTier?.privacyNotice?.showNotice).toBe(false);
|
||||
expect(parsed.allowedTiers?.[0].privacyNotice?.showNotice).toBe(false);
|
||||
expect(parsed.allowedTiers?.[1].privacyNotice?.showNotice).toBe(true);
|
||||
});
|
||||
|
||||
it('should allow missing privacyNotice altogether', () => {
|
||||
const data = {
|
||||
currentTier: {
|
||||
id: 'standard-tier',
|
||||
},
|
||||
};
|
||||
|
||||
const parsed = LoadCodeAssistResponseSchema.parse(data);
|
||||
|
||||
expect(parsed.currentTier?.privacyNotice).toBeUndefined();
|
||||
});
|
||||
});
|
||||
@@ -63,7 +63,7 @@ export type UserTierId = (typeof UserTierId)[keyof typeof UserTierId] | string;
|
||||
* privacy notice.
|
||||
*/
|
||||
export const PrivacyNoticeSchema = z.object({
|
||||
showNotice: z.boolean(),
|
||||
showNotice: z.boolean().optional().default(false),
|
||||
noticeText: z.string().optional(),
|
||||
});
|
||||
export type PrivacyNotice = z.infer<typeof PrivacyNoticeSchema>;
|
||||
|
||||
Reference in New Issue
Block a user