Skip to content

Commit 769269f

Browse files
Copilotmrlubos
andcommitted
Add test demonstrating the config merge behavior that would fail with the bug
Co-authored-by: mrlubos <[email protected]>
1 parent 319fea7 commit 769269f

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

packages/openapi-ts/src/__tests__/interactive.test.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { describe, expect, it } from 'vitest';
22

33
import { initConfigs } from '../config/init';
4+
import { mergeConfigs } from '../config/merge';
45

56
describe('interactive config', () => {
67
it('should default to false when not provided', async () => {
@@ -31,4 +32,38 @@ describe('interactive config', () => {
3132

3233
expect(result.results[0].config.interactive).toBe(false);
3334
});
35+
36+
it('should allow file config to set interactive when CLI does not provide it', () => {
37+
// This simulates what happens when:
38+
// 1. User has a config file with interactive: false
39+
// 2. CLI doesn't provide interactive (undefined)
40+
// 3. The bug was: bin script would set interactive = isInteractive (true in TTY)
41+
42+
const fileConfig = {
43+
input: 'test.json',
44+
interactive: false,
45+
output: './test',
46+
};
47+
48+
// CLI config without interactive (correct behavior after fix)
49+
const cliConfigWithoutInteractive = {
50+
input: 'test.json',
51+
output: './test',
52+
};
53+
54+
// CLI config with interactive set to true (simulating the bug)
55+
const cliConfigWithInteractiveBug = {
56+
input: 'test.json',
57+
interactive: true,
58+
output: './test', // Bug: bin script was setting this even when user didn't provide it
59+
};
60+
61+
// After fix: file config's interactive should be preserved
62+
const mergedCorrect = mergeConfigs(fileConfig, cliConfigWithoutInteractive);
63+
expect(mergedCorrect.interactive).toBe(false);
64+
65+
// Before fix: CLI's auto-detected interactive would override file config
66+
const mergedWithBug = mergeConfigs(fileConfig, cliConfigWithInteractiveBug);
67+
expect(mergedWithBug.interactive).toBe(true); // This was the bug - it overrode the file config
68+
});
3469
});

0 commit comments

Comments
 (0)