chore: Fix types in tests 44/N.

This commit is contained in:
cpojer
2026-02-17 15:49:00 +09:00
parent 688f86bf28
commit 52ad28e097
20 changed files with 44 additions and 32 deletions

View File

@@ -33,7 +33,10 @@ describe("handleDiscordPresenceAction", () => {
status: "online",
afk: false,
});
const payload = JSON.parse(result.content[0].text ?? "");
const textBlock = result.content.find((block) => block.type === "text");
const payload = JSON.parse(
(textBlock as { type: "text"; text: string } | undefined)?.text ?? "{}",
);
expect(payload.ok).toBe(true);
expect(payload.activities[0]).toEqual({ type: 0, name: "with fire" });
});

View File

@@ -183,6 +183,7 @@ describe("image tool implicit imageModel config", () => {
models: {
providers: {
acme: {
baseUrl: "https://example.com",
models: [
makeModelDefinition("text-1", ["text"]),
makeModelDefinition("vision-1", ["text", "image"]),
@@ -228,6 +229,7 @@ describe("image tool implicit imageModel config", () => {
models: {
providers: {
acme: {
baseUrl: "https://example.com",
models: [makeModelDefinition("vision-1", ["text", "image"])],
},
},

View File

@@ -25,7 +25,7 @@ function mockSendResult(overrides: { channel?: string; to?: string } = {}) {
kind: "send",
action: "send",
channel: overrides.channel ?? "telegram",
...(overrides.to ? { to: overrides.to } : {}),
to: overrides.to ?? "telegram:123",
handledBy: "plugin",
payload: {},
dryRun: true,

View File

@@ -76,7 +76,7 @@ describe("handleTelegramAction", () => {
reactMessageTelegram.mockResolvedValueOnce({
ok: false,
warning: "Reaction unavailable: ✅",
});
} as unknown as Awaited<ReturnType<typeof reactMessageTelegram>>);
const result = await handleTelegramAction(defaultReactionAction, reactionConfig("minimal"));
const textPayload = result.content.find((item) => item.type === "text");
expect(textPayload?.type).toBe("text");

View File

@@ -27,7 +27,7 @@ describe("web_fetch response size limits", () => {
const tool = createWebFetchTool(baseToolConfig);
const result = await tool?.execute?.("call", { url: "https://example.com/stream" });
expect(result?.details?.warning).toContain("Response body truncated");
const details = result?.details as { warning?: string } | undefined;
expect(details?.warning).toContain("Response body truncated");
});
});