This commit is contained in:
A.K.M. Adib
2026-04-23 09:07:30 -04:00
parent 891e62f6e7
commit 296802c359
3 changed files with 11 additions and 4 deletions
+2 -2
View File
@@ -3344,8 +3344,8 @@ export const SETTINGS_SCHEMA_DEFINITIONS: Record<
export function getSettingsSchema(): SettingsSchemaType {
// Force enablePermanentToolApproval to false in Vitest to keep snapshots stable,
// unless explicitly overridden in tests.
if (process.env['VITEST']) {
// unless explicitly overridden in tests or during doc generation.
if (process.env['VITEST'] && !process.env['GENERATE_DOCS']) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const schema = JSON.parse(JSON.stringify(SETTINGS_SCHEMA));
schema.security.properties.enablePermanentToolApproval.default = false;
@@ -17,6 +17,7 @@ vi.mock('fs', () => ({
describe('generate-settings-doc', () => {
it('keeps documentation in sync in check mode', async () => {
vi.stubEnv('GENERATE_DOCS', 'true');
const previousExitCode = process.exitCode;
try {
process.exitCode = 0;
@@ -24,6 +25,7 @@ describe('generate-settings-doc', () => {
expect(process.exitCode).toBe(0);
} finally {
process.exitCode = previousExitCode;
vi.unstubAllEnvs();
}
});
});
@@ -21,9 +21,14 @@ vi.mock('fs', () => ({
describe('generate-settings-schema', () => {
it('keeps schema in sync in check mode', async () => {
vi.stubEnv('GENERATE_DOCS', 'true');
const previousExitCode = process.exitCode;
await expect(generateSchema(['--check'])).resolves.toBeUndefined();
expect(process.exitCode).toBe(previousExitCode);
try {
await expect(generateSchema(['--check'])).resolves.toBeUndefined();
expect(process.exitCode).toBe(previousExitCode);
} finally {
vi.unstubAllEnvs();
}
});
it('includes $schema property in generated schema', async () => {