mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-11 02:44:34 +00:00
test: merge direct announce origin variants
This commit is contained in:
@@ -795,16 +795,31 @@ describe("subagent announce formatting", () => {
|
|||||||
expect(accountIds).toEqual(expect.arrayContaining(["acct-a", "acct-b"]));
|
expect(accountIds).toEqual(expect.arrayContaining(["acct-a", "acct-b"]));
|
||||||
});
|
});
|
||||||
|
|
||||||
it("uses requester origin for direct announce when not queued", async () => {
|
it.each([
|
||||||
|
{
|
||||||
|
testName: "uses requester origin for direct announce when not queued",
|
||||||
|
childRunId: "run-direct",
|
||||||
|
requesterOrigin: { channel: "whatsapp", accountId: "acct-123" },
|
||||||
|
expectedChannel: "whatsapp",
|
||||||
|
expectedAccountId: "acct-123",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
testName: "normalizes requesterOrigin for direct announce delivery",
|
||||||
|
childRunId: "run-direct-origin",
|
||||||
|
requesterOrigin: { channel: " whatsapp ", accountId: " acct-987 " },
|
||||||
|
expectedChannel: "whatsapp",
|
||||||
|
expectedAccountId: "acct-987",
|
||||||
|
},
|
||||||
|
] as const)("$testName", async (testCase) => {
|
||||||
const { runSubagentAnnounceFlow } = await import("./subagent-announce.js");
|
const { runSubagentAnnounceFlow } = await import("./subagent-announce.js");
|
||||||
embeddedRunMock.isEmbeddedPiRunActive.mockReturnValue(false);
|
embeddedRunMock.isEmbeddedPiRunActive.mockReturnValue(false);
|
||||||
embeddedRunMock.isEmbeddedPiRunStreaming.mockReturnValue(false);
|
embeddedRunMock.isEmbeddedPiRunStreaming.mockReturnValue(false);
|
||||||
|
|
||||||
const didAnnounce = await runSubagentAnnounceFlow({
|
const didAnnounce = await runSubagentAnnounceFlow({
|
||||||
childSessionKey: "agent:main:subagent:test",
|
childSessionKey: "agent:main:subagent:test",
|
||||||
childRunId: "run-direct",
|
childRunId: testCase.childRunId,
|
||||||
requesterSessionKey: "agent:main:main",
|
requesterSessionKey: "agent:main:main",
|
||||||
requesterOrigin: { channel: "whatsapp", accountId: "acct-123" },
|
requesterOrigin: testCase.requesterOrigin,
|
||||||
requesterDisplayKey: "main",
|
requesterDisplayKey: "main",
|
||||||
...defaultOutcomeAnnounce,
|
...defaultOutcomeAnnounce,
|
||||||
});
|
});
|
||||||
@@ -814,8 +829,8 @@ describe("subagent announce formatting", () => {
|
|||||||
params?: Record<string, unknown>;
|
params?: Record<string, unknown>;
|
||||||
expectFinal?: boolean;
|
expectFinal?: boolean;
|
||||||
};
|
};
|
||||||
expect(call?.params?.channel).toBe("whatsapp");
|
expect(call?.params?.channel).toBe(testCase.expectedChannel);
|
||||||
expect(call?.params?.accountId).toBe("acct-123");
|
expect(call?.params?.accountId).toBe(testCase.expectedAccountId);
|
||||||
expect(call?.expectFinal).toBe(true);
|
expect(call?.expectFinal).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -998,26 +1013,6 @@ describe("subagent announce formatting", () => {
|
|||||||
expect(agentSpy).not.toHaveBeenCalled();
|
expect(agentSpy).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("normalizes requesterOrigin for direct announce delivery", async () => {
|
|
||||||
const { runSubagentAnnounceFlow } = await import("./subagent-announce.js");
|
|
||||||
embeddedRunMock.isEmbeddedPiRunActive.mockReturnValue(false);
|
|
||||||
embeddedRunMock.isEmbeddedPiRunStreaming.mockReturnValue(false);
|
|
||||||
|
|
||||||
const didAnnounce = await runSubagentAnnounceFlow({
|
|
||||||
childSessionKey: "agent:main:subagent:test",
|
|
||||||
childRunId: "run-direct-origin",
|
|
||||||
requesterSessionKey: "agent:main:main",
|
|
||||||
requesterOrigin: { channel: " whatsapp ", accountId: " acct-987 " },
|
|
||||||
requesterDisplayKey: "main",
|
|
||||||
...defaultOutcomeAnnounce,
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(didAnnounce).toBe(true);
|
|
||||||
const call = agentSpy.mock.calls[0]?.[0] as { params?: Record<string, unknown> };
|
|
||||||
expect(call?.params?.channel).toBe("whatsapp");
|
|
||||||
expect(call?.params?.accountId).toBe("acct-987");
|
|
||||||
});
|
|
||||||
|
|
||||||
it("prefers requesterOrigin channel over stale session lastChannel in queued announce", async () => {
|
it("prefers requesterOrigin channel over stale session lastChannel in queued announce", async () => {
|
||||||
const { runSubagentAnnounceFlow } = await import("./subagent-announce.js");
|
const { runSubagentAnnounceFlow } = await import("./subagent-announce.js");
|
||||||
embeddedRunMock.isEmbeddedPiRunActive.mockReturnValue(true);
|
embeddedRunMock.isEmbeddedPiRunActive.mockReturnValue(true);
|
||||||
|
|||||||
Reference in New Issue
Block a user