mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-06 00:27:24 +00:00
Remove legacy migrations from configUtils, parse with zod
This commit is contained in:
4 files changed
+201
-171
No files matched your search
@@ -61,7 +61,7 @@ describe('configUtils', () => {
|
||||
apiKey: 'sk-test123',
|
||||
},
|
||||
],
|
||||
recentlyUsedModels: ['gpt-4', 'gpt-3.5-turbo'],
|
||||
recentlyUsedModels: ['openai/gpt-4', 'openai/gpt-3.5-turbo'],
|
||||
};
|
||||
|
||||
describe('readAISettings', () => {
|
||||
@@ -97,26 +97,6 @@ describe('configUtils', () => {
|
||||
recentlyUsedModels: [],
|
||||
});
|
||||
});
|
||||
|
||||
it('should migrate from localStorage if VFS file does not exist', async () => {
|
||||
vi.mocked(mockFS.readFile).mockRejectedValue(new Error('File not found'));
|
||||
vi.mocked(mockFS.stat).mockRejectedValue(new Error('Directory not found'));
|
||||
vi.mocked(mockFS.mkdir).mockResolvedValue(undefined);
|
||||
vi.mocked(mockFS.writeFile).mockResolvedValue(undefined);
|
||||
|
||||
mockLocalStorage.getItem.mockReturnValue(JSON.stringify(sampleAISettings));
|
||||
|
||||
const result = await readAISettings(mockFS);
|
||||
|
||||
expect(result).toEqual(sampleAISettings);
|
||||
expect(mockLocalStorage.getItem).toHaveBeenCalledWith('ai-settings');
|
||||
expect(mockLocalStorage.removeItem).toHaveBeenCalledWith('ai-settings');
|
||||
expect(mockFS.writeFile).toHaveBeenCalledWith(
|
||||
'/config/ai.json',
|
||||
JSON.stringify(sampleAISettings, null, 2),
|
||||
'utf8'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('writeAISettings', () => {
|
||||
@@ -188,26 +168,6 @@ describe('configUtils', () => {
|
||||
corsProxy: 'https://proxy.shakespeare.diy/?url={href}',
|
||||
});
|
||||
});
|
||||
|
||||
it('should migrate from localStorage if VFS file does not exist', async () => {
|
||||
vi.mocked(mockFS.readFile).mockRejectedValue(new Error('File not found'));
|
||||
vi.mocked(mockFS.stat).mockRejectedValue(new Error('Directory not found'));
|
||||
vi.mocked(mockFS.mkdir).mockResolvedValue(undefined);
|
||||
vi.mocked(mockFS.writeFile).mockResolvedValue(undefined);
|
||||
|
||||
mockLocalStorage.getItem.mockReturnValue(JSON.stringify(sampleGitSettings));
|
||||
|
||||
const result = await readGitSettings(mockFS);
|
||||
|
||||
expect(result).toEqual(sampleGitSettings);
|
||||
expect(mockLocalStorage.getItem).toHaveBeenCalledWith('git-settings');
|
||||
expect(mockLocalStorage.removeItem).toHaveBeenCalledWith('git-settings');
|
||||
expect(mockFS.writeFile).toHaveBeenCalledWith(
|
||||
'/config/git.json',
|
||||
JSON.stringify(sampleGitSettings, null, 2),
|
||||
'utf8'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('writeGitSettings', () => {
|
||||
|
||||
Reference in new issue
Block a user