Files
nanoclaw/.claude/skills/add-voice-transcription/modify/src/channels/whatsapp.test.ts.intent.md
glifocat 03f792bfce feat(skills): add use-local-whisper skill package (#702)
Thanks for the great contribution @glifocat! This is a really well-structured skill — clean package, thorough docs, and solid test coverage. Hope to see more skills like this from you!
2026-03-04 15:56:31 +02:00

1.5 KiB

Intent: src/channels/whatsapp.test.ts modifications

What changed

Added mock for the transcription module and 3 new test cases for voice message handling.

Key sections

Mocks (top of file)

  • Added: vi.mock('../transcription.js', ...) with isVoiceMessage and transcribeAudioMessage mocks
  • Added: import { transcribeAudioMessage } from '../transcription.js' for test assertions
  • Updated: Baileys mock to include fetchLatestWaWebVersion and normalizeMessageContent exports (required by current upstream whatsapp.ts)

Test cases (inside "message handling" describe block)

  • Changed: "handles message with no extractable text (e.g. voice note without caption)" → "transcribes voice messages"
    • Now expects [Voice: Hello this is a voice message] instead of empty content
  • Added: "falls back when transcription returns null" — expects [Voice Message - transcription unavailable]
  • Added: "falls back when transcription throws" — expects [Voice Message - transcription failed]

Invariants (must-keep)

  • All existing test cases for text, extendedTextMessage, imageMessage, videoMessage unchanged
  • All connection lifecycle tests unchanged
  • All LID translation tests unchanged
  • All outgoing queue tests unchanged
  • All group metadata sync tests unchanged
  • All ownsJid and setTyping tests unchanged
  • All existing mocks (config, logger, db, fs, child_process, baileys) unchanged
  • Test helpers (createTestOpts, triggerConnection, triggerDisconnect, triggerMessages, connectChannel) unchanged