Skip to content

Commit dbc841c

Browse files
committed
fix: stabilize bun tests for timers and module mocks
Change-Id: Ib691f6831627e0e03ecfb26339a6bd9b4a4c310c Signed-off-by: Thomas Kosiewski <tk@coder.com> # Conflicts: # src/browser/utils/RefreshController.test.ts
1 parent 406f5b1 commit dbc841c

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

src/browser/contexts/API.test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ void mock.module("@orpc/client/message-port", () => ({
6666
}));
6767

6868
void mock.module("@/browser/components/AuthTokenModal", () => ({
69+
AuthTokenModal: () => null,
6970
getStoredAuthToken: () => null,
7071
// eslint-disable-next-line @typescript-eslint/no-empty-function
7172
clearStoredAuthToken: () => {},

src/browser/hooks/useVoiceInput.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ export interface UseVoiceInputResult {
5757
*/
5858
function hasTouchDictation(): boolean {
5959
if (typeof window === "undefined") return false;
60-
const hasTouch = "ontouchstart" in window || navigator.maxTouchPoints > 0;
60+
const hasTouch =
61+
"ontouchstart" in window || (typeof navigator !== "undefined" && navigator.maxTouchPoints > 0);
6162
// Touch-only check: most touch devices have native dictation.
6263
// We don't check screen size because iPads are large but still have dictation.
6364
return hasTouch;
@@ -66,7 +67,9 @@ function hasTouchDictation(): boolean {
6667
const HAS_TOUCH_DICTATION = hasTouchDictation();
6768
const HAS_MEDIA_RECORDER = typeof window !== "undefined" && typeof MediaRecorder !== "undefined";
6869
const HAS_GET_USER_MEDIA =
69-
typeof window !== "undefined" && typeof navigator.mediaDevices?.getUserMedia === "function";
70+
typeof window !== "undefined" &&
71+
typeof navigator !== "undefined" &&
72+
typeof navigator.mediaDevices?.getUserMedia === "function";
7073

7174
// =============================================================================
7275
// Global Key State Tracking
@@ -79,7 +82,7 @@ const HAS_GET_USER_MEDIA =
7982
*/
8083
let isSpaceCurrentlyHeld = false;
8184

82-
if (typeof window !== "undefined") {
85+
if (typeof window !== "undefined" && typeof window.addEventListener === "function") {
8386
window.addEventListener(
8487
"keydown",
8588
(e) => {

src/browser/utils/RefreshController.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, jest } from "@jest/globals";
1+
import { describe, it, expect, beforeEach, afterEach, jest } from "bun:test";
22
import { RefreshController } from "./RefreshController";
33

44
describe("RefreshController", () => {

src/node/services/tools/task.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ describe("task tool", () => {
7575
taskId: "child-task",
7676
reportMarkdown: "Hello from child",
7777
title: "Result",
78+
agentId: "explore",
7879
agentType: "explore",
7980
});
8081
});

0 commit comments

Comments
 (0)