mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 03:10:21 +00:00
feat: add Chrome extension browser relay
This commit is contained in:
@@ -34,6 +34,41 @@ describe("browser client", () => {
|
||||
await expect(browserStatus("http://127.0.0.1:18791")).rejects.toThrow(/timed out/i);
|
||||
});
|
||||
|
||||
it("adds Authorization when CLAWDBOT_BROWSER_CONTROL_TOKEN is set", async () => {
|
||||
const prev = process.env.CLAWDBOT_BROWSER_CONTROL_TOKEN;
|
||||
process.env.CLAWDBOT_BROWSER_CONTROL_TOKEN = "t1";
|
||||
|
||||
const calls: Array<{ url: string; init?: RequestInit }> = [];
|
||||
vi.stubGlobal(
|
||||
"fetch",
|
||||
vi.fn(async (url: string, init?: RequestInit) => {
|
||||
calls.push({ url, init });
|
||||
return {
|
||||
ok: true,
|
||||
json: async () => ({
|
||||
enabled: true,
|
||||
controlUrl: "http://127.0.0.1:18791",
|
||||
running: false,
|
||||
pid: null,
|
||||
cdpPort: 18792,
|
||||
chosenBrowser: null,
|
||||
userDataDir: null,
|
||||
color: "#FF0000",
|
||||
headless: true,
|
||||
attachOnly: false,
|
||||
}),
|
||||
} as unknown as Response;
|
||||
}),
|
||||
);
|
||||
|
||||
await browserStatus("http://127.0.0.1:18791");
|
||||
const init = calls[0]?.init;
|
||||
const auth = new Headers(init?.headers ?? {}).get("Authorization");
|
||||
expect(auth).toBe("Bearer t1");
|
||||
|
||||
process.env.CLAWDBOT_BROWSER_CONTROL_TOKEN = prev;
|
||||
});
|
||||
|
||||
it("surfaces non-2xx responses with body text", async () => {
|
||||
vi.stubGlobal(
|
||||
"fetch",
|
||||
|
||||
Reference in New Issue
Block a user