mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-19 09:54:45 +00:00
* fix(browser): request admin scope for CLI control * chore(changelog): note browser CLI scope fix
35 lines
1.0 KiB
TypeScript
35 lines
1.0 KiB
TypeScript
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
import type { callGatewayFromCli } from "./core-api.js";
|
|
|
|
type CallGatewayFromCliArgs = Parameters<typeof callGatewayFromCli>;
|
|
|
|
const gatewayMocks = vi.hoisted(() => ({
|
|
callGatewayFromCli: vi.fn(async () => ({ ok: true })),
|
|
}));
|
|
|
|
vi.mock("./core-api.js", () => ({
|
|
callGatewayFromCli: gatewayMocks.callGatewayFromCli,
|
|
}));
|
|
|
|
const { callBrowserRequest } = await import("./browser-cli-shared.js");
|
|
|
|
describe("callBrowserRequest", () => {
|
|
beforeEach(() => {
|
|
gatewayMocks.callGatewayFromCli.mockClear();
|
|
});
|
|
|
|
it("requests the browser.request admin scope explicitly", async () => {
|
|
await callBrowserRequest(
|
|
{ json: true },
|
|
{ method: "GET", path: "/status", query: { profile: "openclaw" } },
|
|
{ progress: true },
|
|
);
|
|
|
|
const call = gatewayMocks.callGatewayFromCli.mock.calls[0] as unknown as
|
|
| CallGatewayFromCliArgs
|
|
| undefined;
|
|
const extra = call?.[3];
|
|
expect(extra).toEqual({ progress: true, scopes: ["operator.admin"] });
|
|
});
|
|
});
|