@@ -107,16 +107,97 @@ describe('ConfigManager', () => {
107107 it ( 'returns default llm refine config' , async ( ) => {
108108 const configManager = await createManager ( )
109109 const config = configManager . getLLMRefineConfig ( )
110- expect ( config . enabled ) . toBe ( LLM_REFINE . ENABLED )
110+ expect ( config ) . toEqual ( {
111+ enabled : LLM_REFINE . ENABLED ,
112+ endpoint : LLM_REFINE . ENDPOINT ,
113+ model : LLM_REFINE . MODEL ,
114+ apiKey : LLM_REFINE . API_KEY ,
115+ } )
111116 } )
112117
113118 it ( 'persists partial llm refine config' , async ( ) => {
114119 const configManager = await createManager ( )
115120 configManager . setLLMRefineConfig ( {
116121 enabled : false ,
122+ endpoint : 'https://example.com/v1' ,
123+ model : 'gpt-4.1-mini' ,
124+ apiKey : 'test-key' ,
125+ } )
126+ expect ( configManager . getLLMRefineConfig ( ) ) . toMatchObject ( {
127+ enabled : false ,
128+ endpoint : 'https://example.com/v1' ,
129+ model : 'gpt-4.1-mini' ,
130+ apiKey : 'test-key' ,
131+ } )
132+ } )
133+
134+ it ( 'migrates legacy openai-compatible refine config to flat schema' , async ( ) => {
135+ seedData = {
136+ llmRefine : {
137+ enabled : true ,
138+ provider : 'openai-compatible' ,
139+ openaiCompatible : {
140+ endpoint : 'https://example.com/v1' ,
141+ model : 'gpt-4.1-mini' ,
142+ apiKey : 'test-key' ,
143+ } ,
144+ } ,
145+ }
146+ const configManager = await createManager ( )
147+ expect ( configManager . getLLMRefineConfig ( ) ) . toMatchObject ( {
148+ enabled : true ,
149+ endpoint : 'https://example.com/v1' ,
150+ model : 'gpt-4.1-mini' ,
151+ apiKey : 'test-key' ,
117152 } )
153+ } )
154+
155+ it ( 'migrates legacy glm-shared refine config to disabled manual config' , async ( ) => {
156+ seedData = {
157+ llmRefine : {
158+ enabled : true ,
159+ provider : 'glm-shared' ,
160+ } ,
161+ }
162+ const configManager = await createManager ( )
118163 expect ( configManager . getLLMRefineConfig ( ) ) . toMatchObject ( {
119164 enabled : false ,
165+ endpoint : '' ,
166+ model : '' ,
167+ apiKey : '' ,
168+ } )
169+ } )
170+
171+ it ( 'migrates legacy boolean-only refine config to disabled manual config' , async ( ) => {
172+ seedData = {
173+ llmRefine : {
174+ enabled : true ,
175+ } ,
176+ }
177+ const configManager = await createManager ( )
178+ expect ( configManager . getLLMRefineConfig ( ) ) . toMatchObject ( {
179+ enabled : false ,
180+ endpoint : '' ,
181+ model : '' ,
182+ apiKey : '' ,
183+ } )
184+ } )
185+
186+ it ( 'decrypts encrypted llm refine api keys on read' , async ( ) => {
187+ seedData = {
188+ llmRefine : {
189+ enabled : true ,
190+ endpoint : 'https://example.com/v1' ,
191+ model : 'gpt-4.1-mini' ,
192+ apiKey : `enc:${ Buffer . from ( 'encrypted:refine-key' ) . toString ( 'base64' ) } ` ,
193+ } ,
194+ }
195+ const configManager = await createManager ( )
196+ expect ( configManager . getLLMRefineConfig ( ) ) . toMatchObject ( {
197+ enabled : true ,
198+ endpoint : 'https://example.com/v1' ,
199+ model : 'gpt-4.1-mini' ,
200+ apiKey : 'refine-key' ,
120201 } )
121202 } )
122203
0 commit comments