mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-26 04:15:48 -06:00
test: guard group policy warning call
This commit is contained in:
@@ -6,6 +6,14 @@ import {
|
||||
resolveToolsBySender,
|
||||
} from "./group-policy.js";
|
||||
|
||||
function firstWarningCall(warningSpy: ReturnType<typeof vi.spyOn>): [unknown, { code?: unknown }?] {
|
||||
const [call] = warningSpy.mock.calls;
|
||||
if (!call) {
|
||||
throw new Error("expected process.emitWarning call");
|
||||
}
|
||||
return call as [unknown, { code?: unknown }?];
|
||||
}
|
||||
|
||||
describe("resolveChannelGroupPolicy", () => {
|
||||
it("fails closed when groupPolicy=allowlist and groups are missing", () => {
|
||||
const cfg = {
|
||||
@@ -337,8 +345,8 @@ describe("resolveToolsBySender", () => {
|
||||
});
|
||||
|
||||
expect(warningSpy).toHaveBeenCalledTimes(1);
|
||||
expect(String(warningSpy.mock.calls[0]?.[0])).toContain(`toolsBySender key "${legacyKey}"`);
|
||||
const warningMeta = warningSpy.mock.calls[0]?.[1] as { code?: unknown } | undefined;
|
||||
const [warningMessage, warningMeta] = firstWarningCall(warningSpy);
|
||||
expect(String(warningMessage)).toContain(`toolsBySender key "${legacyKey}"`);
|
||||
expect(warningMeta?.code).toBe("OPENCLAW_TOOLS_BY_SENDER_UNTYPED_KEY");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user