diff --git a/test/main/services/extensions/McpInstallationStateService.test.ts b/test/main/services/extensions/McpInstallationStateService.test.ts index c1a1c5d1..d9a2e8f2 100644 --- a/test/main/services/extensions/McpInstallationStateService.test.ts +++ b/test/main/services/extensions/McpInstallationStateService.test.ts @@ -13,6 +13,10 @@ vi.mock('@main/utils/pathDecoder', () => ({ vi.mock('node:fs/promises'); +function toPortablePath(filePath: unknown): string { + return String(filePath).replaceAll('\\', '/'); +} + describe('McpInstallationStateService', () => { let service: McpInstallationStateService; const mockedFs = vi.mocked(fs); @@ -31,7 +35,7 @@ describe('McpInstallationStateService', () => { describe('getInstalled', () => { it('includes local scope from the current project entry in ~/.claude.json', async () => { mockedFs.readFile.mockImplementation(async (filePath) => { - const normalizedPath = String(filePath); + const normalizedPath = toPortablePath(filePath); if (normalizedPath === '/tmp/mock-home/.claude.json') { return JSON.stringify({ mcpServers: { @@ -69,7 +73,7 @@ describe('McpInstallationStateService', () => { it('caches results within TTL for the same project path', async () => { mockedFs.readFile.mockImplementation(async (filePath) => { - const normalizedPath = String(filePath); + const normalizedPath = toPortablePath(filePath); if (normalizedPath === '/tmp/mock-home/.claude.json') { return JSON.stringify({ mcpServers: { @@ -97,7 +101,7 @@ describe('McpInstallationStateService', () => { it('caches results independently per project path', async () => { mockedFs.readFile.mockImplementation(async (filePath) => { - const normalizedPath = String(filePath); + const normalizedPath = toPortablePath(filePath); if (normalizedPath === '/tmp/mock-home/.claude.json') { return JSON.stringify({ mcpServers: { diff --git a/test/main/services/extensions/PluginInstallationStateService.test.ts b/test/main/services/extensions/PluginInstallationStateService.test.ts index 16f2d2e1..e0c74ca7 100644 --- a/test/main/services/extensions/PluginInstallationStateService.test.ts +++ b/test/main/services/extensions/PluginInstallationStateService.test.ts @@ -11,6 +11,10 @@ vi.mock('@main/utils/pathDecoder', () => ({ // Mock filesystem vi.mock('node:fs/promises'); +function toPortablePath(filePath: unknown): string { + return String(filePath).replaceAll('\\', '/'); +} + describe('PluginInstallationStateService', () => { let service: PluginInstallationStateService; const mockedFs = vi.mocked(fs); @@ -27,7 +31,7 @@ describe('PluginInstallationStateService', () => { describe('getInstalledPlugins', () => { it('returns user-scoped plugins enabled in user settings', async () => { mockedFs.readFile.mockImplementation(async (filePath) => { - const normalizedPath = String(filePath); + const normalizedPath = toPortablePath(filePath); if (normalizedPath.endsWith('/plugins/installed_plugins.json')) { return JSON.stringify({ version: 2, @@ -75,7 +79,7 @@ describe('PluginInstallationStateService', () => { it('includes project and local scopes only for the active project', async () => { mockedFs.readFile.mockImplementation(async (filePath) => { - const normalizedPath = String(filePath); + const normalizedPath = toPortablePath(filePath); if (normalizedPath.endsWith('/plugins/installed_plugins.json')) { return JSON.stringify({ version: 2, @@ -143,7 +147,7 @@ describe('PluginInstallationStateService', () => { it('does not leak another project scope into the current project', async () => { mockedFs.readFile.mockImplementation(async (filePath) => { - const normalizedPath = String(filePath); + const normalizedPath = toPortablePath(filePath); if (normalizedPath.endsWith('/plugins/installed_plugins.json')) { return JSON.stringify({ version: 2, @@ -182,7 +186,7 @@ describe('PluginInstallationStateService', () => { it('returns empty array for unexpected version', async () => { mockedFs.readFile.mockImplementation(async (filePath) => { - const normalizedPath = String(filePath); + const normalizedPath = toPortablePath(filePath); if (normalizedPath.endsWith('/plugins/installed_plugins.json')) { return JSON.stringify({ version: 1, plugins: {} }); } @@ -198,7 +202,7 @@ describe('PluginInstallationStateService', () => { it('caches within TTL', async () => { mockedFs.readFile.mockImplementation(async (filePath) => { - const normalizedPath = String(filePath); + const normalizedPath = toPortablePath(filePath); if (normalizedPath.endsWith('/plugins/installed_plugins.json')) { return JSON.stringify({ version: 2, plugins: {} }); } @@ -216,7 +220,7 @@ describe('PluginInstallationStateService', () => { it('caches results independently per project path', async () => { mockedFs.readFile.mockImplementation(async (filePath) => { - const normalizedPath = String(filePath); + const normalizedPath = toPortablePath(filePath); if (normalizedPath.endsWith('/plugins/installed_plugins.json')) { return JSON.stringify({ version: 2, plugins: {} }); }