






















@@ -22,6 +22,23 @@ const { resolveQueuedReplyExecutionConfig, resolveQueuedReplyRuntimeConfig } =
2222const { clearRuntimeConfigSnapshot, setRuntimeConfigSnapshot } =
2323await import("../../config/config.js");
242425+type ResolveCommandSecretRefsCall = {
26+config: OpenClawConfig;
27+commandName: string;
28+targetIds?: Set<string>;
29+allowedPaths?: Set<string>;
30+};
31+32+function resolveCommandSecretRefsCall(callIndex = 0): ResolveCommandSecretRefsCall {
33+const call = hoisted.resolveCommandSecretRefsViaGatewayMock.mock.calls[callIndex]?.[0] as
34+| ResolveCommandSecretRefsCall
35+| undefined;
36+if (!call) {
37+throw new Error(`expected command secret resolution call ${callIndex}`);
38+}
39+return call;
40+}
41+2542describe("resolveQueuedReplyExecutionConfig channel scope", () => {
2643beforeEach(() => {
2744clearRuntimeConfigSnapshot();
@@ -70,11 +87,7 @@ describe("resolveQueuedReplyExecutionConfig channel scope", () => {
70877188expect(resolved).toBe(scopedResolved);
7289expect(hoisted.resolveCommandSecretRefsViaGatewayMock).toHaveBeenCalledTimes(2);
73-const baseCall = hoisted.resolveCommandSecretRefsViaGatewayMock.mock.calls.at(0)?.[0] as {
74-config: OpenClawConfig;
75-commandName: string;
76-targetIds: Set<string>;
77-};
90+const baseCall = resolveCommandSecretRefsCall();
7891expect(baseCall.config).toBe(sourceConfig);
7992expect(baseCall.commandName).toBe("reply");
8093expect(baseCall.targetIds).toEqual(new Set(["skills.entries.*.apiKey"]));
@@ -83,12 +96,7 @@ describe("resolveQueuedReplyExecutionConfig channel scope", () => {
8396channel: "discord",
8497accountId: "work",
8598});
86-const scopedCall = hoisted.resolveCommandSecretRefsViaGatewayMock.mock.calls.at(1)?.[0] as {
87-config: OpenClawConfig;
88-commandName: string;
89-targetIds: Set<string>;
90-allowedPaths?: Set<string>;
91-};
99+const scopedCall = resolveCommandSecretRefsCall(1);
92100expect(scopedCall.config).toBe(baseResolved);
93101expect(scopedCall.commandName).toBe("reply");
94102expect(scopedCall.targetIds).toEqual(new Set(["channels.discord.token"]));
@@ -134,10 +142,7 @@ describe("resolveQueuedReplyExecutionConfig channel scope", () => {
134142messageProvider: "discord",
135143});
136144137-const baseCall = hoisted.resolveCommandSecretRefsViaGatewayMock.mock.calls.at(0)?.[0] as {
138-config: OpenClawConfig;
139-commandName: string;
140-};
145+const baseCall = resolveCommandSecretRefsCall();
141146expect(baseCall.config).toBe(runtimeConfig);
142147expect(baseCall.commandName).toBe("reply");
143148expect(hoisted.getScopedChannelsCommandSecretTargetsMock).toHaveBeenCalledWith({
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。