mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-18 16:47:27 +00:00
test(browser): cover headless default profile fallback
This commit is contained in:
73
src/browser/server-context.headless-default-profile.test.ts
Normal file
73
src/browser/server-context.headless-default-profile.test.ts
Normal file
@@ -0,0 +1,73 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { createBrowserRouteContext } from "./server-context.js";
|
||||
import type { BrowserServerState } from "./server-context.js";
|
||||
|
||||
function makeState(defaultProfile: string): BrowserServerState {
|
||||
return {
|
||||
server: null,
|
||||
port: 0,
|
||||
resolved: {
|
||||
enabled: true,
|
||||
evaluateEnabled: true,
|
||||
controlPort: 18791,
|
||||
cdpPortRangeStart: 18800,
|
||||
cdpPortRangeEnd: 18899,
|
||||
cdpProtocol: "http",
|
||||
cdpHost: "127.0.0.1",
|
||||
cdpIsLoopback: true,
|
||||
remoteCdpTimeoutMs: 1500,
|
||||
remoteCdpHandshakeTimeoutMs: 3000,
|
||||
color: "#FF4500",
|
||||
headless: true,
|
||||
noSandbox: true,
|
||||
attachOnly: false,
|
||||
defaultProfile,
|
||||
profiles: {
|
||||
openclaw: {
|
||||
cdpPort: 18800,
|
||||
color: "#FF4500",
|
||||
},
|
||||
user: {
|
||||
driver: "existing-session",
|
||||
attachOnly: true,
|
||||
color: "#00AA00",
|
||||
},
|
||||
"chrome-relay": {
|
||||
driver: "extension",
|
||||
cdpUrl: "http://127.0.0.1:18792",
|
||||
color: "#00AA00",
|
||||
},
|
||||
},
|
||||
extraArgs: [],
|
||||
ssrfPolicy: { dangerouslyAllowPrivateNetwork: true },
|
||||
},
|
||||
profiles: new Map(),
|
||||
};
|
||||
}
|
||||
|
||||
describe("browser server-context headless implicit default profile", () => {
|
||||
it("falls back from extension relay to openclaw when no profile is specified", () => {
|
||||
const ctx = createBrowserRouteContext({
|
||||
getState: () => makeState("chrome-relay"),
|
||||
});
|
||||
|
||||
expect(ctx.forProfile().profile.name).toBe("openclaw");
|
||||
});
|
||||
|
||||
it("falls back from existing-session to openclaw when no profile is specified", () => {
|
||||
const ctx = createBrowserRouteContext({
|
||||
getState: () => makeState("user"),
|
||||
});
|
||||
|
||||
expect(ctx.forProfile().profile.name).toBe("openclaw");
|
||||
});
|
||||
|
||||
it("keeps explicit interactive profile requests unchanged in headless mode", () => {
|
||||
const ctx = createBrowserRouteContext({
|
||||
getState: () => makeState("chrome-relay"),
|
||||
});
|
||||
|
||||
expect(ctx.forProfile("chrome-relay").profile.name).toBe("chrome-relay");
|
||||
expect(ctx.forProfile("user").profile.name).toBe("user");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user