|
1 | 1 | import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' |
2 | | -import { eventBus } from '@/eventbus' |
3 | | -import { CONFIG_EVENTS } from '../../../../src/main/events' |
4 | 2 |
|
5 | 3 | vi.mock('@/eventbus', () => ({ |
6 | 4 | eventBus: { |
@@ -153,72 +151,3 @@ describe('getAnthropicModelSelectionKeysToClear', () => { |
153 | 151 | expect(keysToClear).toEqual([]) |
154 | 152 | }) |
155 | 153 | }) |
156 | | - |
157 | | -describe('migrateLegacyDefaultVisionModelToBuiltinAgent', () => { |
158 | | - beforeEach(() => { |
159 | | - vi.clearAllMocks() |
160 | | - }) |
161 | | - |
162 | | - it('migrates a valid legacy vision model with trimmed ids', () => { |
163 | | - const store = { |
164 | | - get: vi.fn().mockReturnValue({ providerId: ' openai ', modelId: ' gpt-4o ' }), |
165 | | - delete: vi.fn() |
166 | | - } |
167 | | - const updateBuiltinDeepChatConfig = vi.fn() |
168 | | - const presenter = Object.assign(Object.create(ConfigPresenter.prototype), { |
169 | | - store, |
170 | | - getBuiltinDeepChatConfig: vi.fn().mockReturnValue({}), |
171 | | - updateBuiltinDeepChatConfig |
172 | | - }) |
173 | | - |
174 | | - expect(() => |
175 | | - ( |
176 | | - presenter as ConfigPresenter & { |
177 | | - migrateLegacyDefaultVisionModelToBuiltinAgent: () => void |
178 | | - } |
179 | | - ).migrateLegacyDefaultVisionModelToBuiltinAgent() |
180 | | - ).not.toThrow() |
181 | | - |
182 | | - expect(updateBuiltinDeepChatConfig).toHaveBeenCalledWith({ |
183 | | - visionModel: { |
184 | | - providerId: 'openai', |
185 | | - modelId: 'gpt-4o' |
186 | | - } |
187 | | - }) |
188 | | - expect(store.delete).toHaveBeenCalledWith('defaultVisionModel') |
189 | | - expect(eventBus.sendToMain).toHaveBeenCalledWith( |
190 | | - CONFIG_EVENTS.SETTING_CHANGED, |
191 | | - 'defaultVisionModel', |
192 | | - undefined |
193 | | - ) |
194 | | - }) |
195 | | - |
196 | | - it('cleans up malformed legacy vision model without throwing', () => { |
197 | | - const store = { |
198 | | - get: vi.fn().mockReturnValue({ providerId: { bad: true }, modelId: 'gpt-4o' }), |
199 | | - delete: vi.fn() |
200 | | - } |
201 | | - const updateBuiltinDeepChatConfig = vi.fn() |
202 | | - const presenter = Object.assign(Object.create(ConfigPresenter.prototype), { |
203 | | - store, |
204 | | - getBuiltinDeepChatConfig: vi.fn().mockReturnValue({}), |
205 | | - updateBuiltinDeepChatConfig |
206 | | - }) |
207 | | - |
208 | | - expect(() => |
209 | | - ( |
210 | | - presenter as ConfigPresenter & { |
211 | | - migrateLegacyDefaultVisionModelToBuiltinAgent: () => void |
212 | | - } |
213 | | - ).migrateLegacyDefaultVisionModelToBuiltinAgent() |
214 | | - ).not.toThrow() |
215 | | - |
216 | | - expect(updateBuiltinDeepChatConfig).not.toHaveBeenCalled() |
217 | | - expect(store.delete).toHaveBeenCalledWith('defaultVisionModel') |
218 | | - expect(eventBus.sendToMain).toHaveBeenCalledWith( |
219 | | - CONFIG_EVENTS.SETTING_CHANGED, |
220 | | - 'defaultVisionModel', |
221 | | - undefined |
222 | | - ) |
223 | | - }) |
224 | | -}) |
0 commit comments