11import { describe , it , expect , beforeEach , afterEach , vi } from 'vitest' ;
2+ import { Command } from 'commander' ;
23import * as fs from 'node:fs' ;
34import * as path from 'node:path' ;
45import * as os from 'node:os' ;
56
7+ async function runConfigCommand ( args : string [ ] ) : Promise < void > {
8+ const { registerConfigCommand } = await import ( '../../src/commands/config.js' ) ;
9+ const program = new Command ( ) ;
10+ registerConfigCommand ( program ) ;
11+ await program . parseAsync ( [ 'node' , 'openspec' , 'config' , ...args ] ) ;
12+ }
13+
614describe ( 'config command integration' , ( ) => {
715 // These tests use real file system operations with XDG_CONFIG_HOME override
816 let tempDir : string ;
917 let originalEnv : NodeJS . ProcessEnv ;
1018 let consoleErrorSpy : ReturnType < typeof vi . spyOn > ;
19+ let consoleLogSpy : ReturnType < typeof vi . spyOn > ;
1120
1221 beforeEach ( ( ) => {
1322 // Create unique temp directory for each test
@@ -20,6 +29,7 @@ describe('config command integration', () => {
2029
2130 // Spy on console.error
2231 consoleErrorSpy = vi . spyOn ( console , 'error' ) . mockImplementation ( ( ) => { } ) ;
32+ consoleLogSpy = vi . spyOn ( console , 'log' ) . mockImplementation ( ( ) => { } ) ;
2333 } ) ;
2434
2535 afterEach ( ( ) => {
@@ -31,6 +41,7 @@ describe('config command integration', () => {
3141
3242 // Restore spies
3343 consoleErrorSpy . mockRestore ( ) ;
44+ consoleLogSpy . mockRestore ( ) ;
3445
3546 // Reset module cache to pick up new XDG_CONFIG_HOME
3647 vi . resetModules ( ) ;
@@ -89,6 +100,22 @@ describe('config command integration', () => {
89100 expect ( config . featureFlags ) . toEqual ( { } ) ;
90101 expect ( consoleErrorSpy ) . toHaveBeenCalledWith ( expect . stringContaining ( 'Invalid JSON' ) ) ;
91102 } ) ;
103+
104+ it ( 'should set workflows from JSON array syntax' , async ( ) => {
105+ await runConfigCommand ( [
106+ 'set' ,
107+ 'workflows' ,
108+ '["new","ff","apply","archive"]' ,
109+ ] ) ;
110+
111+ const { getGlobalConfig } = await import ( '../../src/core/global-config.js' ) ;
112+ const config = getGlobalConfig ( ) ;
113+
114+ expect ( config . workflows ) . toEqual ( [ 'new' , 'ff' , 'apply' , 'archive' ] ) ;
115+ expect ( consoleLogSpy ) . toHaveBeenCalledWith (
116+ 'Set workflows = new,ff,apply,archive'
117+ ) ;
118+ } ) ;
92119} ) ;
93120
94121describe ( 'config command shell completion registry' , ( ) => {
0 commit comments