|
|
@@ -11,7 +11,6 @@ import { ProviderSettingsManager } from "../ProviderSettingsManager"
|
|
|
import { ContextProxy } from "../ContextProxy"
|
|
|
import { CustomModesManager } from "../CustomModesManager"
|
|
|
|
|
|
-// Mock VSCode modules
|
|
|
jest.mock("vscode", () => ({
|
|
|
window: {
|
|
|
showOpenDialog: jest.fn(),
|
|
|
@@ -22,14 +21,12 @@ jest.mock("vscode", () => ({
|
|
|
},
|
|
|
}))
|
|
|
|
|
|
-// Mock fs/promises
|
|
|
jest.mock("fs/promises", () => ({
|
|
|
readFile: jest.fn(),
|
|
|
mkdir: jest.fn(),
|
|
|
writeFile: jest.fn(),
|
|
|
}))
|
|
|
|
|
|
-// Mock os module
|
|
|
jest.mock("os", () => ({
|
|
|
homedir: jest.fn(() => "/mock/home"),
|
|
|
}))
|
|
|
@@ -41,17 +38,14 @@ describe("importExport", () => {
|
|
|
let mockCustomModesManager: jest.Mocked<CustomModesManager>
|
|
|
|
|
|
beforeEach(() => {
|
|
|
- // Reset all mocks
|
|
|
jest.clearAllMocks()
|
|
|
|
|
|
- // Setup providerSettingsManager mock
|
|
|
mockProviderSettingsManager = {
|
|
|
export: jest.fn(),
|
|
|
import: jest.fn(),
|
|
|
listConfig: jest.fn(),
|
|
|
} as unknown as jest.Mocked<ProviderSettingsManager>
|
|
|
|
|
|
- // Setup contextProxy mock with properly typed export method
|
|
|
mockContextProxy = {
|
|
|
setValues: jest.fn(),
|
|
|
setValue: jest.fn(),
|
|
|
@@ -59,10 +53,7 @@ describe("importExport", () => {
|
|
|
setProviderSettings: jest.fn(),
|
|
|
} as unknown as jest.Mocked<ContextProxy>
|
|
|
|
|
|
- // Setup customModesManager mock
|
|
|
- mockCustomModesManager = {
|
|
|
- updateCustomMode: jest.fn(),
|
|
|
- } as unknown as jest.Mocked<CustomModesManager>
|
|
|
+ mockCustomModesManager = { updateCustomMode: jest.fn() } as unknown as jest.Mocked<CustomModesManager>
|
|
|
|
|
|
const map = new Map<string, string>()
|
|
|
|
|
|
@@ -76,7 +67,6 @@ describe("importExport", () => {
|
|
|
|
|
|
describe("importSettings", () => {
|
|
|
it("should return success: false when user cancels file selection", async () => {
|
|
|
- // Mock user canceling file selection
|
|
|
;(vscode.window.showOpenDialog as jest.Mock).mockResolvedValue(undefined)
|
|
|
|
|
|
const result = await importSettings({
|
|
|
@@ -86,63 +76,43 @@ describe("importExport", () => {
|
|
|
})
|
|
|
|
|
|
expect(result).toEqual({ success: false })
|
|
|
+
|
|
|
expect(vscode.window.showOpenDialog).toHaveBeenCalledWith({
|
|
|
filters: { JSON: ["json"] },
|
|
|
canSelectMany: false,
|
|
|
})
|
|
|
+
|
|
|
expect(fs.readFile).not.toHaveBeenCalled()
|
|
|
expect(mockProviderSettingsManager.import).not.toHaveBeenCalled()
|
|
|
expect(mockContextProxy.setValues).not.toHaveBeenCalled()
|
|
|
})
|
|
|
|
|
|
it("should import settings successfully from a valid file", async () => {
|
|
|
- // Mock successful file selection
|
|
|
;(vscode.window.showOpenDialog as jest.Mock).mockResolvedValue([{ fsPath: "/mock/path/settings.json" }])
|
|
|
|
|
|
- // Valid settings content
|
|
|
const mockFileContent = JSON.stringify({
|
|
|
providerProfiles: {
|
|
|
currentApiConfigName: "test",
|
|
|
- apiConfigs: {
|
|
|
- test: {
|
|
|
- apiProvider: "openai" as ProviderName,
|
|
|
- apiKey: "test-key",
|
|
|
- id: "test-id",
|
|
|
- },
|
|
|
- },
|
|
|
- },
|
|
|
- globalSettings: {
|
|
|
- mode: "code",
|
|
|
- autoApprovalEnabled: true,
|
|
|
+ apiConfigs: { test: { apiProvider: "openai" as ProviderName, apiKey: "test-key", id: "test-id" } },
|
|
|
},
|
|
|
+ globalSettings: { mode: "code", autoApprovalEnabled: true },
|
|
|
})
|
|
|
|
|
|
- // Mock reading file
|
|
|
;(fs.readFile as jest.Mock).mockResolvedValue(mockFileContent)
|
|
|
|
|
|
- // Mock export returning previous provider profiles
|
|
|
const previousProviderProfiles = {
|
|
|
currentApiConfigName: "default",
|
|
|
- apiConfigs: {
|
|
|
- default: {
|
|
|
- apiProvider: "anthropic" as ProviderName,
|
|
|
- id: "default-id",
|
|
|
- },
|
|
|
- },
|
|
|
+ apiConfigs: { default: { apiProvider: "anthropic" as ProviderName, id: "default-id" } },
|
|
|
}
|
|
|
|
|
|
mockProviderSettingsManager.export.mockResolvedValue(previousProviderProfiles)
|
|
|
|
|
|
- // Mock listConfig
|
|
|
mockProviderSettingsManager.listConfig.mockResolvedValue([
|
|
|
{ name: "test", id: "test-id", apiProvider: "openai" as ProviderName },
|
|
|
{ name: "default", id: "default-id", apiProvider: "anthropic" as ProviderName },
|
|
|
])
|
|
|
|
|
|
- // Mock contextProxy.export
|
|
|
- mockContextProxy.export.mockResolvedValue({
|
|
|
- mode: "code",
|
|
|
- })
|
|
|
+ mockContextProxy.export.mockResolvedValue({ mode: "code" })
|
|
|
|
|
|
const result = await importSettings({
|
|
|
providerSettingsManager: mockProviderSettingsManager,
|
|
|
@@ -153,22 +123,16 @@ describe("importExport", () => {
|
|
|
expect(result.success).toBe(true)
|
|
|
expect(fs.readFile).toHaveBeenCalledWith("/mock/path/settings.json", "utf-8")
|
|
|
expect(mockProviderSettingsManager.export).toHaveBeenCalled()
|
|
|
+
|
|
|
expect(mockProviderSettingsManager.import).toHaveBeenCalledWith({
|
|
|
...previousProviderProfiles,
|
|
|
currentApiConfigName: "test",
|
|
|
- apiConfigs: {
|
|
|
- test: {
|
|
|
- apiProvider: "openai" as ProviderName,
|
|
|
- apiKey: "test-key",
|
|
|
- id: "test-id",
|
|
|
- },
|
|
|
- },
|
|
|
- })
|
|
|
- expect(mockContextProxy.setValues).toHaveBeenCalledWith({
|
|
|
- mode: "code",
|
|
|
- autoApprovalEnabled: true,
|
|
|
+ apiConfigs: { test: { apiProvider: "openai" as ProviderName, apiKey: "test-key", id: "test-id" } },
|
|
|
})
|
|
|
+
|
|
|
+ expect(mockContextProxy.setValues).toHaveBeenCalledWith({ mode: "code", autoApprovalEnabled: true })
|
|
|
expect(mockContextProxy.setValue).toHaveBeenCalledWith("currentApiConfigName", "test")
|
|
|
+
|
|
|
expect(mockContextProxy.setValue).toHaveBeenCalledWith("listApiConfigMeta", [
|
|
|
{ name: "test", id: "test-id", apiProvider: "openai" as ProviderName },
|
|
|
{ name: "default", id: "default-id", apiProvider: "anthropic" as ProviderName },
|
|
|
@@ -176,16 +140,14 @@ describe("importExport", () => {
|
|
|
})
|
|
|
|
|
|
it("should return success: false when file content is invalid", async () => {
|
|
|
- // Mock successful file selection
|
|
|
;(vscode.window.showOpenDialog as jest.Mock).mockResolvedValue([{ fsPath: "/mock/path/settings.json" }])
|
|
|
|
|
|
- // Invalid content (missing required fields)
|
|
|
+ // Invalid content (missing required fields).
|
|
|
const mockInvalidContent = JSON.stringify({
|
|
|
providerProfiles: { apiConfigs: {} },
|
|
|
globalSettings: {},
|
|
|
})
|
|
|
|
|
|
- // Mock reading file
|
|
|
;(fs.readFile as jest.Mock).mockResolvedValue(mockInvalidContent)
|
|
|
|
|
|
const result = await importSettings({
|
|
|
@@ -194,20 +156,67 @@ describe("importExport", () => {
|
|
|
customModesManager: mockCustomModesManager,
|
|
|
})
|
|
|
|
|
|
- expect(result).toEqual({ success: false })
|
|
|
+ expect(result).toEqual({ success: false, error: "[providerProfiles.currentApiConfigName]: Required" })
|
|
|
expect(fs.readFile).toHaveBeenCalledWith("/mock/path/settings.json", "utf-8")
|
|
|
expect(mockProviderSettingsManager.import).not.toHaveBeenCalled()
|
|
|
expect(mockContextProxy.setValues).not.toHaveBeenCalled()
|
|
|
})
|
|
|
|
|
|
- it("should return success: false when file content is not valid JSON", async () => {
|
|
|
- // Mock successful file selection
|
|
|
+ it("should import settings successfully when globalSettings key is missing", async () => {
|
|
|
;(vscode.window.showOpenDialog as jest.Mock).mockResolvedValue([{ fsPath: "/mock/path/settings.json" }])
|
|
|
|
|
|
- // Invalid JSON
|
|
|
- const mockInvalidJson = "{ this is not valid JSON }"
|
|
|
+ const mockFileContent = JSON.stringify({
|
|
|
+ providerProfiles: {
|
|
|
+ currentApiConfigName: "test",
|
|
|
+ apiConfigs: { test: { apiProvider: "openai" as ProviderName, apiKey: "test-key", id: "test-id" } },
|
|
|
+ },
|
|
|
+ })
|
|
|
+
|
|
|
+ ;(fs.readFile as jest.Mock).mockResolvedValue(mockFileContent)
|
|
|
+
|
|
|
+ const previousProviderProfiles = {
|
|
|
+ currentApiConfigName: "default",
|
|
|
+ apiConfigs: { default: { apiProvider: "anthropic" as ProviderName, id: "default-id" } },
|
|
|
+ }
|
|
|
+
|
|
|
+ mockProviderSettingsManager.export.mockResolvedValue(previousProviderProfiles)
|
|
|
|
|
|
- // Mock reading file
|
|
|
+ mockProviderSettingsManager.listConfig.mockResolvedValue([
|
|
|
+ { name: "test", id: "test-id", apiProvider: "openai" as ProviderName },
|
|
|
+ { name: "default", id: "default-id", apiProvider: "anthropic" as ProviderName },
|
|
|
+ ])
|
|
|
+
|
|
|
+ mockContextProxy.export.mockResolvedValue({ mode: "code" })
|
|
|
+
|
|
|
+ const result = await importSettings({
|
|
|
+ providerSettingsManager: mockProviderSettingsManager,
|
|
|
+ contextProxy: mockContextProxy,
|
|
|
+ customModesManager: mockCustomModesManager,
|
|
|
+ })
|
|
|
+
|
|
|
+ expect(result.success).toBe(true)
|
|
|
+ expect(fs.readFile).toHaveBeenCalledWith("/mock/path/settings.json", "utf-8")
|
|
|
+ expect(mockProviderSettingsManager.export).toHaveBeenCalled()
|
|
|
+ expect(mockProviderSettingsManager.import).toHaveBeenCalledWith({
|
|
|
+ ...previousProviderProfiles,
|
|
|
+ currentApiConfigName: "test",
|
|
|
+ apiConfigs: {
|
|
|
+ test: { apiProvider: "openai" as ProviderName, apiKey: "test-key", id: "test-id" },
|
|
|
+ },
|
|
|
+ })
|
|
|
+
|
|
|
+ // Should call setValues with an empty object since globalSettings is missing.
|
|
|
+ expect(mockContextProxy.setValues).toHaveBeenCalledWith({})
|
|
|
+ expect(mockContextProxy.setValue).toHaveBeenCalledWith("currentApiConfigName", "test")
|
|
|
+ expect(mockContextProxy.setValue).toHaveBeenCalledWith("listApiConfigMeta", [
|
|
|
+ { name: "test", id: "test-id", apiProvider: "openai" as ProviderName },
|
|
|
+ { name: "default", id: "default-id", apiProvider: "anthropic" as ProviderName },
|
|
|
+ ])
|
|
|
+ })
|
|
|
+
|
|
|
+ it("should return success: false when file content is not valid JSON", async () => {
|
|
|
+ ;(vscode.window.showOpenDialog as jest.Mock).mockResolvedValue([{ fsPath: "/mock/path/settings.json" }])
|
|
|
+ const mockInvalidJson = "{ this is not valid JSON }"
|
|
|
;(fs.readFile as jest.Mock).mockResolvedValue(mockInvalidJson)
|
|
|
|
|
|
const result = await importSettings({
|
|
|
@@ -216,17 +225,14 @@ describe("importExport", () => {
|
|
|
customModesManager: mockCustomModesManager,
|
|
|
})
|
|
|
|
|
|
- expect(result).toEqual({ success: false })
|
|
|
+ expect(result).toEqual({ success: false, error: "Expected property name or '}' in JSON at position 2" })
|
|
|
expect(fs.readFile).toHaveBeenCalledWith("/mock/path/settings.json", "utf-8")
|
|
|
expect(mockProviderSettingsManager.import).not.toHaveBeenCalled()
|
|
|
expect(mockContextProxy.setValues).not.toHaveBeenCalled()
|
|
|
})
|
|
|
|
|
|
it("should return success: false when reading file fails", async () => {
|
|
|
- // Mock successful file selection
|
|
|
;(vscode.window.showOpenDialog as jest.Mock).mockResolvedValue([{ fsPath: "/mock/path/settings.json" }])
|
|
|
-
|
|
|
- // Mock file read error
|
|
|
;(fs.readFile as jest.Mock).mockRejectedValue(new Error("File read error"))
|
|
|
|
|
|
const result = await importSettings({
|
|
|
@@ -235,7 +241,7 @@ describe("importExport", () => {
|
|
|
customModesManager: mockCustomModesManager,
|
|
|
})
|
|
|
|
|
|
- expect(result).toEqual({ success: false })
|
|
|
+ expect(result).toEqual({ success: false, error: "File read error" })
|
|
|
expect(fs.readFile).toHaveBeenCalledWith("/mock/path/settings.json", "utf-8")
|
|
|
expect(mockProviderSettingsManager.import).not.toHaveBeenCalled()
|
|
|
expect(mockContextProxy.setValues).not.toHaveBeenCalled()
|
|
|
@@ -277,43 +283,35 @@ describe("importExport", () => {
|
|
|
|
|
|
it("should call updateCustomMode for each custom mode in config", async () => {
|
|
|
;(vscode.window.showOpenDialog as jest.Mock).mockResolvedValue([{ fsPath: "/mock/path/settings.json" }])
|
|
|
+
|
|
|
const customModes = [
|
|
|
- {
|
|
|
- slug: "mode1",
|
|
|
- name: "Mode One",
|
|
|
- roleDefinition: "Custom role one",
|
|
|
- groups: [],
|
|
|
- },
|
|
|
- {
|
|
|
- slug: "mode2",
|
|
|
- name: "Mode Two",
|
|
|
- roleDefinition: "Custom role two",
|
|
|
- groups: [],
|
|
|
- },
|
|
|
+ { slug: "mode1", name: "Mode One", roleDefinition: "Custom role one", groups: [] },
|
|
|
+ { slug: "mode2", name: "Mode Two", roleDefinition: "Custom role two", groups: [] },
|
|
|
]
|
|
|
+
|
|
|
const mockFileContent = JSON.stringify({
|
|
|
- providerProfiles: {
|
|
|
- currentApiConfigName: "test",
|
|
|
- apiConfigs: {},
|
|
|
- },
|
|
|
- globalSettings: {
|
|
|
- mode: "code",
|
|
|
- customModes,
|
|
|
- },
|
|
|
+ providerProfiles: { currentApiConfigName: "test", apiConfigs: {} },
|
|
|
+ globalSettings: { mode: "code", customModes },
|
|
|
})
|
|
|
+
|
|
|
;(fs.readFile as jest.Mock).mockResolvedValue(mockFileContent)
|
|
|
+
|
|
|
mockProviderSettingsManager.export.mockResolvedValue({
|
|
|
currentApiConfigName: "test",
|
|
|
apiConfigs: {},
|
|
|
})
|
|
|
+
|
|
|
mockProviderSettingsManager.listConfig.mockResolvedValue([])
|
|
|
+
|
|
|
const result = await importSettings({
|
|
|
providerSettingsManager: mockProviderSettingsManager,
|
|
|
contextProxy: mockContextProxy,
|
|
|
customModesManager: mockCustomModesManager,
|
|
|
})
|
|
|
+
|
|
|
expect(result.success).toBe(true)
|
|
|
expect(mockCustomModesManager.updateCustomMode).toHaveBeenCalledTimes(customModes.length)
|
|
|
+
|
|
|
customModes.forEach((mode) => {
|
|
|
expect(mockCustomModesManager.updateCustomMode).toHaveBeenCalledWith(mode.slug, mode)
|
|
|
})
|
|
|
@@ -321,7 +319,6 @@ describe("importExport", () => {
|
|
|
|
|
|
describe("exportSettings", () => {
|
|
|
it("should not export settings when user cancels file selection", async () => {
|
|
|
- // Mock user canceling file selection
|
|
|
;(vscode.window.showSaveDialog as jest.Mock).mockResolvedValue(undefined)
|
|
|
|
|
|
await exportSettings({
|
|
|
@@ -333,37 +330,25 @@ describe("importExport", () => {
|
|
|
filters: { JSON: ["json"] },
|
|
|
defaultUri: expect.anything(),
|
|
|
})
|
|
|
+
|
|
|
expect(mockProviderSettingsManager.export).not.toHaveBeenCalled()
|
|
|
expect(mockContextProxy.export).not.toHaveBeenCalled()
|
|
|
expect(fs.writeFile).not.toHaveBeenCalled()
|
|
|
})
|
|
|
|
|
|
it("should export settings to the selected file location", async () => {
|
|
|
- // Mock successful file location selection
|
|
|
;(vscode.window.showSaveDialog as jest.Mock).mockResolvedValue({
|
|
|
fsPath: "/mock/path/roo-code-settings.json",
|
|
|
})
|
|
|
|
|
|
- // Mock providerProfiles data
|
|
|
const mockProviderProfiles = {
|
|
|
currentApiConfigName: "test",
|
|
|
- apiConfigs: {
|
|
|
- test: {
|
|
|
- apiProvider: "openai" as ProviderName,
|
|
|
- id: "test-id",
|
|
|
- },
|
|
|
- },
|
|
|
- migrations: {
|
|
|
- rateLimitSecondsMigrated: false,
|
|
|
- },
|
|
|
+ apiConfigs: { test: { apiProvider: "openai" as ProviderName, id: "test-id" } },
|
|
|
+ migrations: { rateLimitSecondsMigrated: false },
|
|
|
}
|
|
|
- mockProviderSettingsManager.export.mockResolvedValue(mockProviderProfiles)
|
|
|
|
|
|
- // Mock globalSettings data
|
|
|
- const mockGlobalSettings = {
|
|
|
- mode: "code",
|
|
|
- autoApprovalEnabled: true,
|
|
|
- }
|
|
|
+ mockProviderSettingsManager.export.mockResolvedValue(mockProviderProfiles)
|
|
|
+ const mockGlobalSettings = { mode: "code", autoApprovalEnabled: true }
|
|
|
mockContextProxy.export.mockResolvedValue(mockGlobalSettings)
|
|
|
|
|
|
await exportSettings({
|
|
|
@@ -375,52 +360,32 @@ describe("importExport", () => {
|
|
|
filters: { JSON: ["json"] },
|
|
|
defaultUri: expect.anything(),
|
|
|
})
|
|
|
+
|
|
|
expect(mockProviderSettingsManager.export).toHaveBeenCalled()
|
|
|
expect(mockContextProxy.export).toHaveBeenCalled()
|
|
|
expect(fs.mkdir).toHaveBeenCalledWith("/mock/path", { recursive: true })
|
|
|
+
|
|
|
expect(fs.writeFile).toHaveBeenCalledWith(
|
|
|
"/mock/path/roo-code-settings.json",
|
|
|
- JSON.stringify(
|
|
|
- {
|
|
|
- providerProfiles: mockProviderProfiles,
|
|
|
- globalSettings: mockGlobalSettings,
|
|
|
- },
|
|
|
- null,
|
|
|
- 2,
|
|
|
- ),
|
|
|
+ JSON.stringify({ providerProfiles: mockProviderProfiles, globalSettings: mockGlobalSettings }, null, 2),
|
|
|
"utf-8",
|
|
|
)
|
|
|
})
|
|
|
|
|
|
it("should handle errors during the export process", async () => {
|
|
|
- // Mock successful file location selection
|
|
|
;(vscode.window.showSaveDialog as jest.Mock).mockResolvedValue({
|
|
|
fsPath: "/mock/path/roo-code-settings.json",
|
|
|
})
|
|
|
|
|
|
- // Mock provider profiles
|
|
|
mockProviderSettingsManager.export.mockResolvedValue({
|
|
|
currentApiConfigName: "test",
|
|
|
- apiConfigs: {
|
|
|
- test: {
|
|
|
- apiProvider: "openai" as ProviderName,
|
|
|
- id: "test-id",
|
|
|
- },
|
|
|
- },
|
|
|
- migrations: {
|
|
|
- rateLimitSecondsMigrated: false,
|
|
|
- },
|
|
|
+ apiConfigs: { test: { apiProvider: "openai" as ProviderName, id: "test-id" } },
|
|
|
+ migrations: { rateLimitSecondsMigrated: false },
|
|
|
})
|
|
|
|
|
|
- // Mock global settings
|
|
|
- mockContextProxy.export.mockResolvedValue({
|
|
|
- mode: "code",
|
|
|
- })
|
|
|
-
|
|
|
- // Mock file write error
|
|
|
+ mockContextProxy.export.mockResolvedValue({ mode: "code" })
|
|
|
;(fs.writeFile as jest.Mock).mockRejectedValue(new Error("Write error"))
|
|
|
|
|
|
- // The function catches errors internally and doesn't throw or return anything
|
|
|
await exportSettings({
|
|
|
providerSettingsManager: mockProviderSettingsManager,
|
|
|
contextProxy: mockContextProxy,
|
|
|
@@ -431,38 +396,23 @@ describe("importExport", () => {
|
|
|
expect(mockContextProxy.export).toHaveBeenCalled()
|
|
|
expect(fs.mkdir).toHaveBeenCalledWith("/mock/path", { recursive: true })
|
|
|
expect(fs.writeFile).toHaveBeenCalled()
|
|
|
- // The error is caught and the function exits silently
|
|
|
+ // The error is caught and the function exits silently.
|
|
|
})
|
|
|
|
|
|
it("should handle errors during directory creation", async () => {
|
|
|
- // Mock successful file location selection
|
|
|
;(vscode.window.showSaveDialog as jest.Mock).mockResolvedValue({
|
|
|
fsPath: "/mock/path/roo-code-settings.json",
|
|
|
})
|
|
|
|
|
|
- // Mock provider profiles
|
|
|
mockProviderSettingsManager.export.mockResolvedValue({
|
|
|
currentApiConfigName: "test",
|
|
|
- apiConfigs: {
|
|
|
- test: {
|
|
|
- apiProvider: "openai" as ProviderName,
|
|
|
- id: "test-id",
|
|
|
- },
|
|
|
- },
|
|
|
- migrations: {
|
|
|
- rateLimitSecondsMigrated: false,
|
|
|
- },
|
|
|
+ apiConfigs: { test: { apiProvider: "openai" as ProviderName, id: "test-id" } },
|
|
|
+ migrations: { rateLimitSecondsMigrated: false },
|
|
|
})
|
|
|
|
|
|
- // Mock global settings
|
|
|
- mockContextProxy.export.mockResolvedValue({
|
|
|
- mode: "code",
|
|
|
- })
|
|
|
-
|
|
|
- // Mock directory creation error
|
|
|
+ mockContextProxy.export.mockResolvedValue({ mode: "code" })
|
|
|
;(fs.mkdir as jest.Mock).mockRejectedValue(new Error("Directory creation error"))
|
|
|
|
|
|
- // The function catches errors internally and doesn't throw or return anything
|
|
|
await exportSettings({
|
|
|
providerSettingsManager: mockProviderSettingsManager,
|
|
|
contextProxy: mockContextProxy,
|
|
|
@@ -472,26 +422,22 @@ describe("importExport", () => {
|
|
|
expect(mockProviderSettingsManager.export).toHaveBeenCalled()
|
|
|
expect(mockContextProxy.export).toHaveBeenCalled()
|
|
|
expect(fs.mkdir).toHaveBeenCalled()
|
|
|
- expect(fs.writeFile).not.toHaveBeenCalled() // Should not be called since mkdir failed
|
|
|
+ expect(fs.writeFile).not.toHaveBeenCalled() // Should not be called since mkdir failed.
|
|
|
})
|
|
|
|
|
|
it("should use the correct default save location", async () => {
|
|
|
- // Mock user cancels to avoid full execution
|
|
|
;(vscode.window.showSaveDialog as jest.Mock).mockResolvedValue(undefined)
|
|
|
|
|
|
- // Call the function
|
|
|
await exportSettings({
|
|
|
providerSettingsManager: mockProviderSettingsManager,
|
|
|
contextProxy: mockContextProxy,
|
|
|
})
|
|
|
|
|
|
- // Verify the default save location
|
|
|
expect(vscode.window.showSaveDialog).toHaveBeenCalledWith({
|
|
|
filters: { JSON: ["json"] },
|
|
|
defaultUri: expect.anything(),
|
|
|
})
|
|
|
|
|
|
- // Verify Uri.file was called with the correct path
|
|
|
expect(vscode.Uri.file).toHaveBeenCalledWith(path.join("/mock/home", "Documents", "roo-code-settings.json"))
|
|
|
})
|
|
|
})
|