mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-26 04:45:13 +00:00
test: tighten outbound route assertions
This commit is contained in:
@@ -167,7 +167,9 @@ describe("agent delivery helpers", () => {
|
||||
},
|
||||
])("builds delivery plan for %j", ({ params, expected }) => {
|
||||
const plan = expectDeliveryPlan(params);
|
||||
expect(plan).toMatchObject(expected);
|
||||
for (const [key, value] of Object.entries(expected)) {
|
||||
expect((plan as Record<string, unknown>)[key]).toEqual(value);
|
||||
}
|
||||
});
|
||||
|
||||
it("resolves fallback targets when no explicit destination is provided", () => {
|
||||
|
||||
@@ -188,7 +188,9 @@ describe("bound delivery router", () => {
|
||||
failClosed,
|
||||
});
|
||||
|
||||
expect(route).toMatchObject(expected);
|
||||
for (const [key, value] of Object.entries(expected)) {
|
||||
expect((route as Record<string, unknown>)[key]).toEqual(value);
|
||||
}
|
||||
if (expectedConversationId !== undefined) {
|
||||
expect(route.binding?.conversation.conversationId).toBe(expectedConversationId);
|
||||
}
|
||||
|
||||
@@ -3,8 +3,13 @@ import type { OpenClawConfig } from "../../config/config.js";
|
||||
import { ensureOutboundSessionEntry, resolveOutboundSessionRoute } from "./outbound-session.js";
|
||||
import { setMinimalOutboundSessionPluginRegistryForTests } from "./outbound-session.test-helpers.js";
|
||||
|
||||
type InboundMetadataParams = {
|
||||
sessionKey?: string;
|
||||
storePath?: string;
|
||||
};
|
||||
|
||||
const mocks = vi.hoisted(() => ({
|
||||
recordSessionMetaFromInbound: vi.fn(async () => ({ ok: true })),
|
||||
recordSessionMetaFromInbound: vi.fn(async (_params: InboundMetadataParams) => ({ ok: true })),
|
||||
resolveStorePath: vi.fn(
|
||||
(_store: unknown, params?: { agentId?: string }) => `/stores/${params?.agentId ?? "main"}.json`,
|
||||
),
|
||||
@@ -394,7 +399,9 @@ describe("resolveOutboundSessionRoute", () => {
|
||||
resolvedTarget,
|
||||
});
|
||||
|
||||
expect(route).toMatchObject(expected);
|
||||
for (const [key, value] of Object.entries(expected)) {
|
||||
expect((route as Record<string, unknown>)[key]).toEqual(value);
|
||||
}
|
||||
});
|
||||
|
||||
it("rejects bare numeric GuildChat targets when the caller has no kind hint", async () => {
|
||||
@@ -436,11 +443,9 @@ describe("ensureOutboundSessionEntry", () => {
|
||||
expect(mocks.resolveStorePath).toHaveBeenCalledWith("/stores/{agentId}.json", {
|
||||
agentId: "main",
|
||||
});
|
||||
expect(mocks.recordSessionMetaFromInbound).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
storePath: "/stores/main.json",
|
||||
sessionKey: "agent:main:workspace:channel:c1",
|
||||
}),
|
||||
);
|
||||
expect(mocks.recordSessionMetaFromInbound).toHaveBeenCalledOnce();
|
||||
const metadata = mocks.recordSessionMetaFromInbound.mock.calls[0]?.[0];
|
||||
expect(metadata?.storePath).toBe("/stores/main.json");
|
||||
expect(metadata?.sessionKey).toBe("agent:main:workspace:channel:c1");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user