mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 19:58:27 +00:00
chore: Fix types in tests 33/N.
This commit is contained in:
@@ -19,6 +19,8 @@ describe("agent delivery helpers", () => {
|
||||
it("builds a delivery plan from session delivery context", () => {
|
||||
const plan = resolveAgentDeliveryPlan({
|
||||
sessionEntry: {
|
||||
sessionId: "s1",
|
||||
updatedAt: 1,
|
||||
deliveryContext: { channel: "whatsapp", to: "+1555", accountId: "work" },
|
||||
},
|
||||
requestedChannel: "last",
|
||||
@@ -36,6 +38,8 @@ describe("agent delivery helpers", () => {
|
||||
it("resolves fallback targets when no explicit destination is provided", () => {
|
||||
const plan = resolveAgentDeliveryPlan({
|
||||
sessionEntry: {
|
||||
sessionId: "s2",
|
||||
updatedAt: 2,
|
||||
deliveryContext: { channel: "whatsapp" },
|
||||
},
|
||||
requestedChannel: "last",
|
||||
@@ -58,6 +62,8 @@ describe("agent delivery helpers", () => {
|
||||
it("skips outbound target resolution when explicit target validation is disabled", () => {
|
||||
const plan = resolveAgentDeliveryPlan({
|
||||
sessionEntry: {
|
||||
sessionId: "s3",
|
||||
updatedAt: 3,
|
||||
deliveryContext: { channel: "whatsapp", to: "+1555" },
|
||||
},
|
||||
requestedChannel: "last",
|
||||
|
||||
@@ -54,7 +54,9 @@ const whatsappChunkConfig: OpenClawConfig = {
|
||||
};
|
||||
|
||||
async function deliverWhatsAppPayload(params: {
|
||||
sendWhatsApp: ReturnType<typeof vi.fn>;
|
||||
sendWhatsApp: NonNullable<
|
||||
NonNullable<Parameters<typeof deliverOutboundPayloads>[0]["deps"]>["sendWhatsApp"]
|
||||
>;
|
||||
payload: { text: string; mediaUrl?: string };
|
||||
cfg?: OpenClawConfig;
|
||||
}) {
|
||||
@@ -517,7 +519,7 @@ describe("deliverOutboundPayloads", () => {
|
||||
});
|
||||
|
||||
it("emits message_sent success for text-only deliveries", async () => {
|
||||
hookMocks.runner.hasHooks.mockImplementation((name: string) => name === "message_sent");
|
||||
hookMocks.runner.hasHooks.mockReturnValue(true);
|
||||
const sendWhatsApp = vi.fn().mockResolvedValue({ messageId: "w1", toJid: "jid" });
|
||||
|
||||
await deliverOutboundPayloads({
|
||||
@@ -537,7 +539,7 @@ describe("deliverOutboundPayloads", () => {
|
||||
});
|
||||
|
||||
it("emits message_sent success for sendPayload deliveries", async () => {
|
||||
hookMocks.runner.hasHooks.mockImplementation((name: string) => name === "message_sent");
|
||||
hookMocks.runner.hasHooks.mockReturnValue(true);
|
||||
const sendPayload = vi.fn().mockResolvedValue({ channel: "matrix", messageId: "mx-1" });
|
||||
const sendText = vi.fn();
|
||||
const sendMedia = vi.fn();
|
||||
@@ -570,7 +572,7 @@ describe("deliverOutboundPayloads", () => {
|
||||
});
|
||||
|
||||
it("emits message_sent failure when delivery errors", async () => {
|
||||
hookMocks.runner.hasHooks.mockImplementation((name: string) => name === "message_sent");
|
||||
hookMocks.runner.hasHooks.mockReturnValue(true);
|
||||
const sendWhatsApp = vi.fn().mockRejectedValue(new Error("downstream failed"));
|
||||
|
||||
await expect(
|
||||
|
||||
@@ -558,6 +558,9 @@ describe("runMessageAction sandboxed media validation", () => {
|
||||
});
|
||||
|
||||
expect(result.kind).toBe("send");
|
||||
if (result.kind !== "send") {
|
||||
throw new Error("expected send result");
|
||||
}
|
||||
expect(result.sendResult?.mediaUrl).toBe(path.join(sandboxDir, "data", "file.txt"));
|
||||
});
|
||||
});
|
||||
@@ -575,6 +578,9 @@ describe("runMessageAction sandboxed media validation", () => {
|
||||
});
|
||||
|
||||
expect(result.kind).toBe("send");
|
||||
if (result.kind !== "send") {
|
||||
throw new Error("expected send result");
|
||||
}
|
||||
expect(result.sendResult?.mediaUrl).toBe(path.join(sandboxDir, "data", "note.ogg"));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -446,7 +446,7 @@ describe("DirectoryCache", () => {
|
||||
describe("buildOutboundResultEnvelope", () => {
|
||||
it("flattens delivery-only payloads by default", () => {
|
||||
const delivery: OutboundDeliveryJson = {
|
||||
provider: "whatsapp",
|
||||
channel: "whatsapp",
|
||||
via: "gateway",
|
||||
to: "+1",
|
||||
messageId: "m1",
|
||||
@@ -468,7 +468,7 @@ describe("buildOutboundResultEnvelope", () => {
|
||||
|
||||
it("includes delivery when payloads are present", () => {
|
||||
const delivery: OutboundDeliveryJson = {
|
||||
provider: "telegram",
|
||||
channel: "telegram",
|
||||
via: "direct",
|
||||
to: "123",
|
||||
messageId: "m2",
|
||||
@@ -489,7 +489,7 @@ describe("buildOutboundResultEnvelope", () => {
|
||||
|
||||
it("can keep delivery wrapped when requested", () => {
|
||||
const delivery: OutboundDeliveryJson = {
|
||||
provider: "discord",
|
||||
channel: "discord",
|
||||
via: "gateway",
|
||||
to: "channel:C1",
|
||||
messageId: "m3",
|
||||
|
||||
@@ -31,7 +31,7 @@ describe("resolveMessagingTarget (directory fallback)", () => {
|
||||
});
|
||||
|
||||
it("uses live directory fallback and caches the result", async () => {
|
||||
const entry: ChannelDirectoryEntry = { id: "123456789", name: "support" };
|
||||
const entry: ChannelDirectoryEntry = { kind: "group", id: "123456789", name: "support" };
|
||||
mocks.listGroups.mockResolvedValue([]);
|
||||
mocks.listGroupsLive.mockResolvedValue([entry]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user