Skip to content

Commit 009d35c

Browse files
committed
Fix test imports and missing test deps after rebase
1 parent b7e6ed2 commit 009d35c

File tree

11 files changed

+28
-19
lines changed

11 files changed

+28
-19
lines changed

src/browser/api.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Tests the invokeIPC function to ensure it behaves consistently with Electron's ipcRenderer.invoke()
44
*/
55

6-
import { describe, test, expect } from "bun:test";
6+
import { describe, test, expect } from "@jest/globals";
77

88
// Helper to create a mock fetch that returns a specific response
99
function createMockFetch(responseData: unknown) {

src/hooks/useReviewState.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* The hook itself is a thin wrapper around usePersistedState with manual testing.
77
*/
88

9-
import { describe, it, expect } from "bun:test";
9+
import { describe, it, expect } from "@jest/globals";
1010
import type { HunkReadState } from "@/types/review";
1111
import { evictOldestReviews } from "./useReviewState";
1212

src/runtime/initHook.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { describe, it, expect } from "bun:test";
1+
import { describe, it, expect } from "@jest/globals";
22
import { LineBuffer, createLineBufferedLoggers } from "./initHook";
33
import type { InitLogger } from "./Runtime";
44

src/services/aiService.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// These tests would need to be rewritten to work with Bun's test runner
33
// For now, the commandProcessor tests demonstrate our testing approach
44

5-
import { describe, it, expect, beforeEach } from "bun:test";
5+
import { describe, it, expect, beforeEach } from "@jest/globals";
66
import { AIService } from "./aiService";
77
import { HistoryService } from "./historyService";
88
import { PartialService } from "./partialService";

src/services/historyService.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { describe, it, expect, beforeEach, afterEach } from "bun:test";
1+
import { describe, it, expect, beforeEach, afterEach } from "@jest/globals";
22
import { HistoryService } from "./historyService";
33
import { Config } from "@/config";
44
import { createCmuxMessage } from "@/types/message";

src/services/initStateManager.test.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as fs from "fs/promises";
22
import * as path from "path";
33
import * as os from "os";
4-
import { describe, it, expect, beforeEach, afterEach } from "bun:test";
4+
import { describe, it, expect, beforeEach, afterEach } from "@jest/globals";
55
import { Config } from "@/config";
66
import { InitStateManager } from "./initStateManager";
77
import type { WorkspaceInitEvent } from "@/types/ipc";
@@ -53,8 +53,8 @@ describe("InitStateManager", () => {
5353
manager.appendOutput(workspaceId, "Installing deps...", false);
5454
manager.appendOutput(workspaceId, "Done!", false);
5555
expect(manager.getInitState(workspaceId)?.lines).toEqual([
56-
{ line: "Installing deps...", isError: false, timestamp: expect.any(Number) as number },
57-
{ line: "Done!", isError: false, timestamp: expect.any(Number) as number },
56+
{ line: "Installing deps...", isError: false, timestamp: expect.any(Number) },
57+
{ line: "Done!", isError: false, timestamp: expect.any(Number) },
5858
]);
5959

6060
// End init (await to ensure event fires)
@@ -79,8 +79,8 @@ describe("InitStateManager", () => {
7979

8080
const state = manager.getInitState(workspaceId);
8181
expect(state?.lines).toEqual([
82-
{ line: "stdout line", isError: false, timestamp: expect.any(Number) as number },
83-
{ line: "stderr line", isError: true, timestamp: expect.any(Number) as number },
82+
{ line: "stdout line", isError: false, timestamp: expect.any(Number) },
83+
{ line: "stderr line", isError: true, timestamp: expect.any(Number) },
8484
]);
8585
});
8686

@@ -109,8 +109,8 @@ describe("InitStateManager", () => {
109109
expect(diskState?.status).toBe("success");
110110
expect(diskState?.exitCode).toBe(0);
111111
expect(diskState?.lines).toEqual([
112-
{ line: "Line 1", isError: false, timestamp: expect.any(Number) as number },
113-
{ line: "Line 2", isError: true, timestamp: expect.any(Number) as number },
112+
{ line: "Line 1", isError: false, timestamp: expect.any(Number) },
113+
{ line: "Line 2", isError: true, timestamp: expect.any(Number) },
114114
]);
115115
});
116116

@@ -221,15 +221,23 @@ describe("InitStateManager", () => {
221221
expect(stateAfterDelete).toBeNull();
222222
});
223223

224-
it("should clear in-memory state", () => {
224+
it("should clear in-memory state", async () => {
225225
const workspaceId = "test-workspace";
226226
manager.startInit(workspaceId, "/path/to/hook");
227227

228228
expect(manager.getInitState(workspaceId)).toBeTruthy();
229229

230+
// Get the init promise before clearing
231+
const initPromise = manager.waitForInit(workspaceId);
232+
233+
// Clear in-memory state (should reject pending promises)
230234
manager.clearInMemoryState(workspaceId);
231235

236+
// Verify state is cleared
232237
expect(manager.getInitState(workspaceId)).toBeUndefined();
238+
239+
// Verify the promise was rejected
240+
await expect(initPromise).rejects.toThrow("Workspace test-workspace was deleted");
233241
});
234242
});
235243

src/services/partialService.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable @typescript-eslint/unbound-method */
2-
import { describe, test, expect, beforeEach, mock } from "bun:test";
2+
import { describe, test, expect, beforeEach, mock } from "@jest/globals";
33
import { PartialService } from "./partialService";
44
import type { HistoryService } from "./historyService";
55
import type { Config } from "@/config";

src/services/streamManager.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { describe, test, expect, beforeEach, mock } from "bun:test";
1+
import { describe, test, expect, beforeEach, mock } from "@jest/globals";
22
import { StreamManager } from "./streamManager";
33
import type { HistoryService } from "./historyService";
44
import type { PartialService } from "./partialService";

src/services/systemMessage.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import * as os from "os";
33
import * as path from "path";
44
import { buildSystemMessage } from "./systemMessage";
55
import type { WorkspaceMetadata } from "@/types/workspace";
6-
import { spyOn, describe, test, expect, beforeEach, afterEach } from "bun:test";
7-
import type { Mock } from "bun:test";
6+
import { spyOn, describe, test, expect, beforeEach, afterEach } from "@jest/globals";
7+
import type { Mock } from "@jest/globals";
88
import { LocalRuntime } from "@/runtime/LocalRuntime";
99

1010
describe("buildSystemMessage", () => {

src/services/tools/file_edit_operation.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { WRITE_DENIED_PREFIX } from "@/types/tools";
44
import { createRuntime } from "@/runtime/runtimeFactory";
55
import type { Runtime } from "@/runtime/Runtime";
66

7-
import { createTestToolConfig } from "./testHelpers";
7+
import { createTestToolConfig, getTestDeps } from "./testHelpers";
88

99
const TEST_CWD = "/tmp";
1010

@@ -69,6 +69,7 @@ describe("executeFileEditOperation", () => {
6969
cwd: testCwd,
7070
runtime: mockRuntime,
7171
runtimeTempDir: "/tmp",
72+
...getTestDeps(),
7273
},
7374
filePath: testFilePath,
7475
operation: () => ({ success: true, newContent: "test", metadata: {} }),

0 commit comments

Comments
 (0)