Files
openclaw/extensions/telegram/src/voice.test.ts
scoootscooob e5bca0832f refactor: move Telegram channel implementation to extensions/ (#45635)
* refactor: move Telegram channel implementation to extensions/telegram/src/

Move all Telegram channel code (123 files + 10 bot/ files + 8 channel plugin
files) from src/telegram/ and src/channels/plugins/*/telegram.ts to
extensions/telegram/src/. Leave thin re-export shims at original locations so
cross-cutting src/ imports continue to resolve.

- Fix all relative import paths in moved files (../X/ -> ../../../src/X/)
- Fix vi.mock paths in 60 test files
- Fix inline typeof import() expressions
- Update tsconfig.plugin-sdk.dts.json rootDir to "." for cross-directory DTS
- Update write-plugin-sdk-entry-dts.ts for new rootDir structure
- Move channel plugin files with correct path remapping

* fix: support keyed telegram send deps

* fix: sync telegram extension copies with latest main

* fix: correct import paths and remove misplaced files in telegram extension

* fix: sync outbound-adapter with main (add sendTelegramPayloadMessages) and fix delivery.test import path
2026-03-14 02:50:17 -07:00

58 lines
1.7 KiB
TypeScript

import { describe, expect, it, vi } from "vitest";
import { resolveTelegramVoiceSend } from "./voice.js";
describe("resolveTelegramVoiceSend", () => {
it("skips voice when wantsVoice is false", () => {
const logFallback = vi.fn();
const result = resolveTelegramVoiceSend({
wantsVoice: false,
contentType: "audio/ogg",
fileName: "voice.ogg",
logFallback,
});
expect(result.useVoice).toBe(false);
expect(logFallback).not.toHaveBeenCalled();
});
it("logs fallback for incompatible media", () => {
const logFallback = vi.fn();
const result = resolveTelegramVoiceSend({
wantsVoice: true,
contentType: "audio/wav",
fileName: "track.wav",
logFallback,
});
expect(result.useVoice).toBe(false);
expect(logFallback).toHaveBeenCalledWith(
"Telegram voice requested but media is audio/wav (track.wav); sending as audio file instead.",
);
});
it("keeps voice when compatible", () => {
const logFallback = vi.fn();
const result = resolveTelegramVoiceSend({
wantsVoice: true,
contentType: "audio/ogg",
fileName: "voice.ogg",
logFallback,
});
expect(result.useVoice).toBe(true);
expect(logFallback).not.toHaveBeenCalled();
});
it.each([
{ contentType: "audio/mpeg", fileName: "track.mp3" },
{ contentType: "audio/mp4", fileName: "track.m4a" },
])("keeps voice for compatible MIME $contentType", ({ contentType, fileName }) => {
const logFallback = vi.fn();
const result = resolveTelegramVoiceSend({
wantsVoice: true,
contentType,
fileName,
logFallback,
});
expect(result.useVoice).toBe(true);
expect(logFallback).not.toHaveBeenCalled();
});
});