Files
paseo/packages/app/vitest.setup.ts
Mohamed Boudra 20385bdb50 Add opt-in browser tools for desktop tabs
* Add opt-in browser tools for desktop tabs

Adds the daemon opt-in, desktop tab routing, MCP tools, and real browser automation surfaces for Paseo desktop browser tabs.

* Fix browser tools CI expectations

* Address browser tools review findings

* Restrict browser file automation paths

* Fix browser upload test on Windows

* Harden browser navigation inputs

* Make browser tools create usable tabs

* Update browser MCP empty-state test

* Fail browser tab creation when registration times out

* Fix browser screenshots for agents

* Hide disabled browser tools from agents

* Address browser tools architecture review

* Replace browser tools review tests

* Wrap browser tab registration errors

* Mock Expo Router in app unit tests

* Handle invalid browser automation requests

* Return browser failure on desktop disconnect

* Update browser disconnect websocket test

* Relax browser timeout polling test

* Handle invalid browser responses

* Return browser failure when send fails

* Remove local diagnostics and fixture paths

* Fix dev service home fallback

* Use worktree home for dev services

* Use managed daemon in desktop dev

* fix(browser): keep agent tabs addressable

Track agent-active browser targets separately from human-focused tabs and keep resident webviews alive for automation. Browser tool visibility now comes from registration while the broker reports disabled execution.

* refactor(browser): register tools through catalog

Move browser tool registration onto the shared Paseo tool catalog so the MCP server remains only the transport adapter.

* fix(settings): translate browser tools host error
2026-06-30 22:33:18 +02:00

128 lines
2.8 KiB
TypeScript

// @ts-nocheck
import { vi } from "vitest";
import React from "react";
const globalWithTestShims = globalThis as typeof globalThis & Record<string, unknown>;
globalWithTestShims.__DEV__ = false;
if (typeof globalThis.self === "undefined") {
globalWithTestShims.self = globalThis;
}
if (typeof globalThis.expo === "undefined") {
class ExpoEventEmitter {
addListener() {
return {
remove() {},
};
}
removeListener() {}
removeAllListeners() {}
emit() {}
listenerCount() {
return 0;
}
}
class ExpoSharedObject extends ExpoEventEmitter {}
class ExpoSharedRef extends ExpoSharedObject {}
class ExpoNativeModule extends ExpoEventEmitter {}
globalWithTestShims.expo = {
EventEmitter: ExpoEventEmitter,
SharedObject: ExpoSharedObject,
SharedRef: ExpoSharedRef,
NativeModule: ExpoNativeModule,
modules: {},
};
}
if (typeof globalThis.requestAnimationFrame !== "function") {
globalThis.requestAnimationFrame = (callback: FrameRequestCallback) =>
setTimeout(() => callback(Date.now()), 0) as unknown as number;
}
if (typeof globalThis.cancelAnimationFrame !== "function") {
globalThis.cancelAnimationFrame = (handle: number) => {
clearTimeout(handle);
};
}
vi.mock("react-native-unistyles", () => ({
StyleSheet: {
create: <T>(styles: T) => styles,
},
useUnistyles: () => ({
theme: {},
rt: {},
breakpoint: undefined,
}),
UnistylesRuntime: {
setTheme: vi.fn(),
themeName: "light",
},
}));
vi.mock("@xterm/addon-ligatures", () => ({
LigaturesAddon: class LigaturesAddon {
dispose(): void {}
},
}));
vi.mock("react-native-svg", () => {
const Stub = () => null;
return {
__esModule: true,
default: Stub,
Circle: Stub,
Defs: Stub,
G: Stub,
Line: Stub,
LinearGradient: Stub,
Path: Stub,
Rect: Stub,
Stop: Stub,
SvgCss: Stub,
SvgCssUri: Stub,
SvgFromXml: Stub,
SvgUri: Stub,
SvgXml: Stub,
Use: Stub,
};
});
vi.mock("expo-linking", () => ({
openURL: vi.fn().mockResolvedValue(undefined),
}));
const RouterPassthrough = ({ children }: { children?: React.ReactNode }) => children;
vi.mock("expo-router", () => ({
Redirect: () => null,
Stack: Object.assign(RouterPassthrough, {
Screen: () => null,
Protected: RouterPassthrough,
}),
router: {
back: vi.fn(),
canGoBack: vi.fn(() => false),
navigate: vi.fn(),
push: vi.fn(),
replace: vi.fn(),
setParams: vi.fn(),
},
useGlobalSearchParams: vi.fn(() => ({})),
useLocalSearchParams: vi.fn(() => ({})),
usePathname: vi.fn(() => "/"),
useRootNavigationState: vi.fn(() => ({ key: "root" })),
useRouter: vi.fn(() => ({
back: vi.fn(),
canGoBack: vi.fn(() => false),
navigate: vi.fn(),
push: vi.fn(),
replace: vi.fn(),
setParams: vi.fn(),
})),
}));