diff --git a/src/services/index.test.ts b/src/services/index.test.ts index 9b0d422ba..446b50b77 100644 --- a/src/services/index.test.ts +++ b/src/services/index.test.ts @@ -2,9 +2,11 @@ import { jest } from '@jest/globals'; import { initializeServices } from './index.js'; import { modeService } from './ModeService.js'; +import { serviceContainer } from './ServiceContainer.js'; describe('initializeServices', () => { let mockModeService: any; + let mockServiceContainer: any; beforeEach(() => { // Reset all mocks @@ -16,9 +18,22 @@ describe('initializeServices', () => { getCurrentMode: jest.fn() }; + // Create mock service container to prevent actual service registration + mockServiceContainer = { + register: jest.fn(), + get: jest.fn(), + set: jest.fn(), + reload: jest.fn(), + isReady: jest.fn(), + getServiceStates: jest.fn() + }; + // Set up modeService mock (modeService as any).initialize = mockModeService.initialize; (modeService as any).getCurrentMode = mockModeService.getCurrentMode; + + // Set up serviceContainer mock to prevent actual service initialization + (serviceContainer as any).register = mockServiceContainer.register; }); afterEach(() => { @@ -28,6 +43,7 @@ describe('initializeServices', () => { describe('mode conversion', () => { it('should pass only readonly flag for plan mode', async () => { await initializeServices({ + headless: true, // Force headless mode to skip onboarding toolPermissionOverrides: { mode: 'plan', allow: ['tool1'], @@ -47,6 +63,7 @@ describe('initializeServices', () => { it('should pass only auto flag for auto mode', async () => { await initializeServices({ + headless: true, // Force headless mode to skip onboarding toolPermissionOverrides: { mode: 'auto', allow: ['tool1'], @@ -66,6 +83,7 @@ describe('initializeServices', () => { it('should pass no mode flags for normal mode', async () => { await initializeServices({ + headless: true, // Force headless mode to skip onboarding toolPermissionOverrides: { mode: 'normal', allow: ['tool1'], @@ -84,6 +102,7 @@ describe('initializeServices', () => { it('should pass no mode flags when mode is undefined', async () => { await initializeServices({ + headless: true, // Force headless mode to skip onboarding toolPermissionOverrides: { allow: ['tool1'], ask: ['tool2'], @@ -100,7 +119,7 @@ describe('initializeServices', () => { }); it('should not call initialize when no toolPermissionOverrides provided', async () => { - await initializeServices({}); + await initializeServices({ headless: true }); // Force headless mode to skip onboarding expect(mockModeService.initialize).not.toHaveBeenCalled(); });