From f98e84f03f3a45c93624985abd2878188fffd0f5 Mon Sep 17 00:00:00 2001 From: Maryam Ariyan Date: Sat, 29 Nov 2025 20:22:56 -0800 Subject: [PATCH] test: Add verification for $schema property in settings schema (#13497) --- .../tests/generate-settings-schema.test.ts | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/scripts/tests/generate-settings-schema.test.ts b/scripts/tests/generate-settings-schema.test.ts index ed7919bba2..c899db9af2 100644 --- a/scripts/tests/generate-settings-schema.test.ts +++ b/scripts/tests/generate-settings-schema.test.ts @@ -5,6 +5,9 @@ */ import { describe, expect, it } from 'vitest'; +import { readFile } from 'node:fs/promises'; +import { fileURLToPath } from 'node:url'; +import { dirname, join } from 'node:path'; import { main as generateSchema } from '../generate-settings-schema.ts'; describe('generate-settings-schema', () => { @@ -13,4 +16,22 @@ describe('generate-settings-schema', () => { await expect(generateSchema(['--check'])).resolves.toBeUndefined(); expect(process.exitCode).toBe(previousExitCode); }); + + it('includes $schema property in generated schema', async () => { + const __dirname = dirname(fileURLToPath(import.meta.url)); + const schemaPath = join(__dirname, '../../schemas/settings.schema.json'); + const schemaContent = await readFile(schemaPath, 'utf-8'); + const schema = JSON.parse(schemaContent); + + // Verify $schema property exists in the schema's properties + expect(schema.properties).toHaveProperty('$schema'); + expect(schema.properties.$schema).toEqual({ + type: 'string', + title: 'Schema', + description: + 'The URL of the JSON schema for this settings file. Used by editors for validation and autocompletion.', + default: + 'https://raw.githubusercontent.com/google-gemini/gemini-cli/main/schemas/settings.schema.json', + }); + }); });