test(ci): normalize extension path mocks on windows
This commit is contained in:
parent
18d9f2b4a4
commit
94f41ed5a5
2 changed files with 17 additions and 9 deletions
|
|
@ -13,6 +13,10 @@ vi.mock('@main/utils/pathDecoder', () => ({
|
||||||
|
|
||||||
vi.mock('node:fs/promises');
|
vi.mock('node:fs/promises');
|
||||||
|
|
||||||
|
function toPortablePath(filePath: unknown): string {
|
||||||
|
return String(filePath).replaceAll('\\', '/');
|
||||||
|
}
|
||||||
|
|
||||||
describe('McpInstallationStateService', () => {
|
describe('McpInstallationStateService', () => {
|
||||||
let service: McpInstallationStateService;
|
let service: McpInstallationStateService;
|
||||||
const mockedFs = vi.mocked(fs);
|
const mockedFs = vi.mocked(fs);
|
||||||
|
|
@ -31,7 +35,7 @@ describe('McpInstallationStateService', () => {
|
||||||
describe('getInstalled', () => {
|
describe('getInstalled', () => {
|
||||||
it('includes local scope from the current project entry in ~/.claude.json', async () => {
|
it('includes local scope from the current project entry in ~/.claude.json', async () => {
|
||||||
mockedFs.readFile.mockImplementation(async (filePath) => {
|
mockedFs.readFile.mockImplementation(async (filePath) => {
|
||||||
const normalizedPath = String(filePath);
|
const normalizedPath = toPortablePath(filePath);
|
||||||
if (normalizedPath === '/tmp/mock-home/.claude.json') {
|
if (normalizedPath === '/tmp/mock-home/.claude.json') {
|
||||||
return JSON.stringify({
|
return JSON.stringify({
|
||||||
mcpServers: {
|
mcpServers: {
|
||||||
|
|
@ -69,7 +73,7 @@ describe('McpInstallationStateService', () => {
|
||||||
|
|
||||||
it('caches results within TTL for the same project path', async () => {
|
it('caches results within TTL for the same project path', async () => {
|
||||||
mockedFs.readFile.mockImplementation(async (filePath) => {
|
mockedFs.readFile.mockImplementation(async (filePath) => {
|
||||||
const normalizedPath = String(filePath);
|
const normalizedPath = toPortablePath(filePath);
|
||||||
if (normalizedPath === '/tmp/mock-home/.claude.json') {
|
if (normalizedPath === '/tmp/mock-home/.claude.json') {
|
||||||
return JSON.stringify({
|
return JSON.stringify({
|
||||||
mcpServers: {
|
mcpServers: {
|
||||||
|
|
@ -97,7 +101,7 @@ describe('McpInstallationStateService', () => {
|
||||||
|
|
||||||
it('caches results independently per project path', async () => {
|
it('caches results independently per project path', async () => {
|
||||||
mockedFs.readFile.mockImplementation(async (filePath) => {
|
mockedFs.readFile.mockImplementation(async (filePath) => {
|
||||||
const normalizedPath = String(filePath);
|
const normalizedPath = toPortablePath(filePath);
|
||||||
if (normalizedPath === '/tmp/mock-home/.claude.json') {
|
if (normalizedPath === '/tmp/mock-home/.claude.json') {
|
||||||
return JSON.stringify({
|
return JSON.stringify({
|
||||||
mcpServers: {
|
mcpServers: {
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,10 @@ vi.mock('@main/utils/pathDecoder', () => ({
|
||||||
// Mock filesystem
|
// Mock filesystem
|
||||||
vi.mock('node:fs/promises');
|
vi.mock('node:fs/promises');
|
||||||
|
|
||||||
|
function toPortablePath(filePath: unknown): string {
|
||||||
|
return String(filePath).replaceAll('\\', '/');
|
||||||
|
}
|
||||||
|
|
||||||
describe('PluginInstallationStateService', () => {
|
describe('PluginInstallationStateService', () => {
|
||||||
let service: PluginInstallationStateService;
|
let service: PluginInstallationStateService;
|
||||||
const mockedFs = vi.mocked(fs);
|
const mockedFs = vi.mocked(fs);
|
||||||
|
|
@ -27,7 +31,7 @@ describe('PluginInstallationStateService', () => {
|
||||||
describe('getInstalledPlugins', () => {
|
describe('getInstalledPlugins', () => {
|
||||||
it('returns user-scoped plugins enabled in user settings', async () => {
|
it('returns user-scoped plugins enabled in user settings', async () => {
|
||||||
mockedFs.readFile.mockImplementation(async (filePath) => {
|
mockedFs.readFile.mockImplementation(async (filePath) => {
|
||||||
const normalizedPath = String(filePath);
|
const normalizedPath = toPortablePath(filePath);
|
||||||
if (normalizedPath.endsWith('/plugins/installed_plugins.json')) {
|
if (normalizedPath.endsWith('/plugins/installed_plugins.json')) {
|
||||||
return JSON.stringify({
|
return JSON.stringify({
|
||||||
version: 2,
|
version: 2,
|
||||||
|
|
@ -75,7 +79,7 @@ describe('PluginInstallationStateService', () => {
|
||||||
|
|
||||||
it('includes project and local scopes only for the active project', async () => {
|
it('includes project and local scopes only for the active project', async () => {
|
||||||
mockedFs.readFile.mockImplementation(async (filePath) => {
|
mockedFs.readFile.mockImplementation(async (filePath) => {
|
||||||
const normalizedPath = String(filePath);
|
const normalizedPath = toPortablePath(filePath);
|
||||||
if (normalizedPath.endsWith('/plugins/installed_plugins.json')) {
|
if (normalizedPath.endsWith('/plugins/installed_plugins.json')) {
|
||||||
return JSON.stringify({
|
return JSON.stringify({
|
||||||
version: 2,
|
version: 2,
|
||||||
|
|
@ -143,7 +147,7 @@ describe('PluginInstallationStateService', () => {
|
||||||
|
|
||||||
it('does not leak another project scope into the current project', async () => {
|
it('does not leak another project scope into the current project', async () => {
|
||||||
mockedFs.readFile.mockImplementation(async (filePath) => {
|
mockedFs.readFile.mockImplementation(async (filePath) => {
|
||||||
const normalizedPath = String(filePath);
|
const normalizedPath = toPortablePath(filePath);
|
||||||
if (normalizedPath.endsWith('/plugins/installed_plugins.json')) {
|
if (normalizedPath.endsWith('/plugins/installed_plugins.json')) {
|
||||||
return JSON.stringify({
|
return JSON.stringify({
|
||||||
version: 2,
|
version: 2,
|
||||||
|
|
@ -182,7 +186,7 @@ describe('PluginInstallationStateService', () => {
|
||||||
|
|
||||||
it('returns empty array for unexpected version', async () => {
|
it('returns empty array for unexpected version', async () => {
|
||||||
mockedFs.readFile.mockImplementation(async (filePath) => {
|
mockedFs.readFile.mockImplementation(async (filePath) => {
|
||||||
const normalizedPath = String(filePath);
|
const normalizedPath = toPortablePath(filePath);
|
||||||
if (normalizedPath.endsWith('/plugins/installed_plugins.json')) {
|
if (normalizedPath.endsWith('/plugins/installed_plugins.json')) {
|
||||||
return JSON.stringify({ version: 1, plugins: {} });
|
return JSON.stringify({ version: 1, plugins: {} });
|
||||||
}
|
}
|
||||||
|
|
@ -198,7 +202,7 @@ describe('PluginInstallationStateService', () => {
|
||||||
|
|
||||||
it('caches within TTL', async () => {
|
it('caches within TTL', async () => {
|
||||||
mockedFs.readFile.mockImplementation(async (filePath) => {
|
mockedFs.readFile.mockImplementation(async (filePath) => {
|
||||||
const normalizedPath = String(filePath);
|
const normalizedPath = toPortablePath(filePath);
|
||||||
if (normalizedPath.endsWith('/plugins/installed_plugins.json')) {
|
if (normalizedPath.endsWith('/plugins/installed_plugins.json')) {
|
||||||
return JSON.stringify({ version: 2, plugins: {} });
|
return JSON.stringify({ version: 2, plugins: {} });
|
||||||
}
|
}
|
||||||
|
|
@ -216,7 +220,7 @@ describe('PluginInstallationStateService', () => {
|
||||||
|
|
||||||
it('caches results independently per project path', async () => {
|
it('caches results independently per project path', async () => {
|
||||||
mockedFs.readFile.mockImplementation(async (filePath) => {
|
mockedFs.readFile.mockImplementation(async (filePath) => {
|
||||||
const normalizedPath = String(filePath);
|
const normalizedPath = toPortablePath(filePath);
|
||||||
if (normalizedPath.endsWith('/plugins/installed_plugins.json')) {
|
if (normalizedPath.endsWith('/plugins/installed_plugins.json')) {
|
||||||
return JSON.stringify({ version: 2, plugins: {} });
|
return JSON.stringify({ version: 2, plugins: {} });
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue