|
1 | 1 | import { describe, expect, it } from 'vitest';
|
2 | 2 |
|
3 | 3 | import { initConfigs } from '../config/init';
|
| 4 | +import { mergeConfigs } from '../config/merge'; |
4 | 5 |
|
5 | 6 | describe('interactive config', () => {
|
6 | 7 | it('should default to false when not provided', async () => {
|
@@ -31,4 +32,38 @@ describe('interactive config', () => {
|
31 | 32 |
|
32 | 33 | expect(result.results[0].config.interactive).toBe(false);
|
33 | 34 | });
|
| 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 | + }); |
34 | 69 | });
|
0 commit comments