summaryrefslogtreecommitdiff
path: root/tests/test-transcription-paths.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2025-11-04 14:35:50 -0600
committerCraig Jennings <c@cjennings.net>2025-11-04 14:35:50 -0600
commit45cab5c38dc089935416a89d36b461d9127094ac (patch)
treeccfb33579de009c8c8694f2a79d10e487d74de8f /tests/test-transcription-paths.el
parentefbcd0b7de7993b9fde29297daad1154711a3e81 (diff)
feat: Add complete async audio transcription workflow
Implemented full transcription system with local Whisper and OpenAI API support. Includes comprehensive test suite (60 tests) and reorganized keybindings for better discoverability. Features: - Async transcription (non-blocking workflow) - Desktop notifications (started/complete/error) - Output: audio.txt (transcript) + audio.log (process logs) - Modeline integration showing active transcription count - Dired integration (press T on audio files) - Process management and tracking Scripts: - install-whisper.sh: Install Whisper via AUR or pip - uninstall-whisper.sh: Clean removal with cache cleanup - local-whisper: Offline transcription using installed Whisper - oai-transcribe: Cloud transcription via OpenAI API Tests (60 passing): - Audio file detection (16 tests) - Path generation logic (11 tests) - Log cleanup behavior (5 tests) - Duration formatting (9 tests) - Active counter & modeline (11 tests) - Integration workflows (8 tests) Keybindings: - Reorganized gcal to C-; g submenu (s/t/r/c) - Added C-; t transcription submenu (t/b/k) - Dired: T to transcribe file at point 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat (limited to 'tests/test-transcription-paths.el')
-rw-r--r--tests/test-transcription-paths.el80
1 files changed, 80 insertions, 0 deletions
diff --git a/tests/test-transcription-paths.el b/tests/test-transcription-paths.el
new file mode 100644
index 00000000..5ee80e67
--- /dev/null
+++ b/tests/test-transcription-paths.el
@@ -0,0 +1,80 @@
+;;; test-transcription-paths.el --- Tests for transcription file path logic -*- lexical-binding: t; -*-
+
+;;; Commentary:
+;; Tests for cj/--transcription-output-files and cj/--transcription-script-path
+;; Categories: Normal cases, Boundary cases, Error cases
+
+;;; Code:
+
+(require 'ert)
+(require 'transcription-config)
+
+;; ----------------------------- Normal Cases ----------------------------------
+
+(ert-deftest test-cj/--transcription-output-files-simple ()
+ "Test output file paths for simple filename."
+ (let ((result (cj/--transcription-output-files "meeting.m4a")))
+ (should (string= (car result) "meeting.txt"))
+ (should (string= (cdr result) "meeting.log"))))
+
+(ert-deftest test-cj/--transcription-output-files-with-path ()
+ "Test output file paths with full path."
+ (let ((result (cj/--transcription-output-files "/home/user/audio/podcast.mp3")))
+ (should (string= (car result) "/home/user/audio/podcast.txt"))
+ (should (string= (cdr result) "/home/user/audio/podcast.log"))))
+
+(ert-deftest test-cj/--transcription-output-files-different-extensions ()
+ "Test output files for various audio extensions."
+ (dolist (ext '("m4a" "mp3" "wav" "flac" "ogg"))
+ (let* ((input (format "audio.%s" ext))
+ (result (cj/--transcription-output-files input)))
+ (should (string= (car result) "audio.txt"))
+ (should (string= (cdr result) "audio.log")))))
+
+;; ----------------------------- Boundary Cases --------------------------------
+
+(ert-deftest test-cj/--transcription-output-files-multiple-dots ()
+ "Test output files for filename with multiple dots."
+ (let ((result (cj/--transcription-output-files "meeting.2025-11-04.final.m4a")))
+ (should (string= (car result) "meeting.2025-11-04.final.txt"))
+ (should (string= (cdr result) "meeting.2025-11-04.final.log"))))
+
+(ert-deftest test-cj/--transcription-output-files-no-extension ()
+ "Test output files for filename without extension."
+ (let ((result (cj/--transcription-output-files "meeting")))
+ (should (string= (car result) "meeting.txt"))
+ (should (string= (cdr result) "meeting.log"))))
+
+(ert-deftest test-cj/--transcription-output-files-spaces-in-name ()
+ "Test output files for filename with spaces."
+ (let ((result (cj/--transcription-output-files "team meeting 2025.m4a")))
+ (should (string= (car result) "team meeting 2025.txt"))
+ (should (string= (cdr result) "team meeting 2025.log"))))
+
+(ert-deftest test-cj/--transcription-output-files-special-chars ()
+ "Test output files for filename with special characters."
+ (let ((result (cj/--transcription-output-files "meeting_(final).m4a")))
+ (should (string= (car result) "meeting_(final).txt"))
+ (should (string= (cdr result) "meeting_(final).log"))))
+
+;; ----------------------------- Script Path Tests -----------------------------
+
+(ert-deftest test-cj/--transcription-script-path-local-whisper ()
+ "Test script path for local-whisper backend."
+ (let ((cj/transcribe-backend 'local-whisper))
+ (should (string-suffix-p "scripts/local-whisper"
+ (cj/--transcription-script-path)))))
+
+(ert-deftest test-cj/--transcription-script-path-openai-api ()
+ "Test script path for openai-api backend."
+ (let ((cj/transcribe-backend 'openai-api))
+ (should (string-suffix-p "scripts/oai-transcribe"
+ (cj/--transcription-script-path)))))
+
+(ert-deftest test-cj/--transcription-script-path-absolute ()
+ "Test that script path is absolute."
+ (let ((path (cj/--transcription-script-path)))
+ (should (file-name-absolute-p path))))
+
+(provide 'test-transcription-paths)
+;;; test-transcription-paths.el ends here