Files
can1357 92c79d80c7 feat: introduced OMP Browser Relay extension with CDP RPC execution
- Implement the OMP Browser Relay extension with WebSocket communication and CDP RPC execution.
- Add browser relay server, daemon management, and bridge multiplexing in the coding agent.
- Introduce CLI commands and settings schema options for configuring and installing the relay.
- Add utility functions and test suites supporting environment parsing and relay lifecycle handling.
2026-08-02 05:33:07 +02:00

39 lines
1.3 KiB
TypeScript

import { describe, expect, it } from "bun:test";
import { DEFAULT_RELAY_URL, resolveRelayKind } from "@oh-my-pi/pi-coding-agent/tools/browser";
describe("resolveRelayKind", () => {
it("is disabled by default", () => {
expect(resolveRelayKind(null, {})).toBeNull();
expect(resolveRelayKind({}, {})).toBeNull();
});
it("resolves the default endpoint when the setting enables it", () => {
expect(resolveRelayKind({ settingEnabled: true }, {})).toEqual({ kind: "relay", cdpUrl: DEFAULT_RELAY_URL });
});
it("uses the configured URL and trims trailing slashes", () => {
expect(resolveRelayKind({ settingEnabled: true, url: "http://127.0.0.1:9333///" }, {})).toEqual({
kind: "relay",
cdpUrl: "http://127.0.0.1:9333",
});
});
it("falls back to the default endpoint for a blank URL", () => {
expect(resolveRelayKind({ settingEnabled: true, url: " " }, {})).toEqual({
kind: "relay",
cdpUrl: DEFAULT_RELAY_URL,
});
});
it("PI_BROWSER_RELAY=0 disables the relay even when the setting enables it", () => {
expect(resolveRelayKind({ settingEnabled: true }, { PI_BROWSER_RELAY: "0" })).toBeNull();
});
it("PI_BROWSER_RELAY=1 enables the relay when the setting is off", () => {
expect(resolveRelayKind({ settingEnabled: false }, { PI_BROWSER_RELAY: "1" })).toEqual({
kind: "relay",
cdpUrl: DEFAULT_RELAY_URL,
});
});
});