fix: stabilize CI type and test harness coverage

This commit is contained in:
Peter Steinberger
2026-02-22 18:06:29 +00:00
parent af9881b9c5
commit b79c89fc90
9 changed files with 23 additions and 15 deletions

View File

@@ -183,7 +183,7 @@ describe("telegram inbound media", () => {
globalFetchSpy.mockRestore();
});
it("logs a handler error when getFile returns no file_path", async () => {
it("handles missing file_path from getFile without crashing", async () => {
const runtimeLog = vi.fn();
const runtimeError = vi.fn();
const { handler, replySpy } = await createBotHandlerWithOptions({
@@ -204,10 +204,7 @@ describe("telegram inbound media", () => {
expect(fetchSpy).not.toHaveBeenCalled();
expect(replySpy).not.toHaveBeenCalled();
expect(runtimeError).toHaveBeenCalledTimes(1);
const msg = String(runtimeError.mock.calls[0]?.[0] ?? "");
expect(msg).toContain("handler failed:");
expect(msg).toContain("file_path");
expect(runtimeError).not.toHaveBeenCalled();
fetchSpy.mockRestore();
});

View File

@@ -10,12 +10,14 @@ export const sendChatActionSpy: Mock = vi.fn();
type ApiStub = {
config: { use: (arg: unknown) => void };
sendChatAction: Mock;
sendMessage: Mock;
setMyCommands: (commands: Array<{ command: string; description: string }>) => Promise<void>;
};
const apiStub: ApiStub = {
config: { use: useSpy },
sendChatAction: sendChatActionSpy,
sendMessage: vi.fn(async () => ({ message_id: 1 })),
setMyCommands: vi.fn(async () => undefined),
};