From f87b511ec1cabd9804c321b47360241ec5262ce3 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sun, 27 Jul 2025 16:41:01 +0200 Subject: [PATCH] Fix web test failures - Update notification preferences test to expect enabled: false as default (matching macOS defaults) - Add PtyManager.initialize() calls to integration tests to fix initialization errors - Make createTestServer async to properly initialize PtyManager - Fix formatting issues in test files This fixes the failing tests in config-service.test.ts, worktree-workflows.test.ts, and socket-protocol-integration.test.ts. --- web/src/server/services/config-service.test.ts | 2 +- web/src/test/helpers/test-server.ts | 5 ++++- .../test/integration/socket-protocol-integration.test.ts | 6 +++++- web/src/test/integration/worktree-workflows.test.ts | 2 +- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/web/src/server/services/config-service.test.ts b/web/src/server/services/config-service.test.ts index b7bb8f6a..3e70cb88 100644 --- a/web/src/server/services/config-service.test.ts +++ b/web/src/server/services/config-service.test.ts @@ -425,7 +425,7 @@ describe('ConfigService', () => { const preferences = configService.getNotificationPreferences(); // Should return DEFAULT_NOTIFICATION_PREFERENCES instead of undefined expect(preferences).toEqual({ - enabled: true, + enabled: false, // Master switch is OFF by default sessionStart: true, sessionExit: true, commandCompletion: true, diff --git a/web/src/test/helpers/test-server.ts b/web/src/test/helpers/test-server.ts index 3e289b0c..fda61214 100644 --- a/web/src/test/helpers/test-server.ts +++ b/web/src/test/helpers/test-server.ts @@ -39,7 +39,7 @@ export interface TestServerResult { /** * Create a test server with properly initialized services */ -export function createTestServer(options: TestServerOptions = {}): TestServerResult { +export async function createTestServer(options: TestServerOptions = {}): Promise { const { controlPath, isHQMode = false, @@ -51,6 +51,9 @@ export function createTestServer(options: TestServerOptions = {}): TestServerRes }, } = options; + // Initialize PtyManager before creating instance + await PtyManager.initialize(); + // Initialize services const ptyManager = new PtyManager(controlPath); const terminalManager = new TerminalManager(); diff --git a/web/src/test/integration/socket-protocol-integration.test.ts b/web/src/test/integration/socket-protocol-integration.test.ts index 28ff1d24..f7dfea46 100644 --- a/web/src/test/integration/socket-protocol-integration.test.ts +++ b/web/src/test/integration/socket-protocol-integration.test.ts @@ -23,7 +23,7 @@ describe('Socket Protocol Integration', () => { let ptyManager: PtyManager; let sessionHelper: SessionTestHelper; - beforeEach(() => { + beforeEach(async () => { // IMPORTANT: macOS has a 104 character limit for Unix socket paths (103 usable). // The full socket path will be: testDir + sessionId (36 chars UUID) + '/ipc.sock' (9 chars) // Example: /tmp/vt-1234567890/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/ipc.sock @@ -31,6 +31,10 @@ describe('Socket Protocol Integration', () => { // Using /tmp/vt-timestamp keeps us well under the limit. testDir = `/tmp/vt-${Date.now()}`; fs.mkdirSync(testDir, { recursive: true }); + + // Initialize PtyManager before creating instance + await PtyManager.initialize(); + ptyManager = new PtyManager(testDir); sessionHelper = new SessionTestHelper(ptyManager); }); diff --git a/web/src/test/integration/worktree-workflows.test.ts b/web/src/test/integration/worktree-workflows.test.ts index a4b80025..0e23d9dc 100644 --- a/web/src/test/integration/worktree-workflows.test.ts +++ b/web/src/test/integration/worktree-workflows.test.ts @@ -17,7 +17,7 @@ describe('Worktree Workflows Integration Tests', () => { gitRepo = await createStandardTestRepo(); // Create test server with all services properly initialized - testServer = createTestServer({ + testServer = await createTestServer({ includeRoutes: { sessions: true, worktrees: true,