This commit is contained in:
Your Name
2026-10-30 13:41:35 +08:00
parent 28ba9b97f2
commit e2fc30e1f7
69 changed files with 8702 additions and 252 deletions
+21 -13
View File
@@ -62,7 +62,7 @@ def test_companion_archives_cloud_video_local_mixed_audio_and_transcript() -> No
assert "operations.push(stopLocalRecording())" in source
assert "operations.push(stopTranscription('completed'))" in source
assert "Promise.allSettled(operations)" in source
assert "腾讯云混流视频、本机语音录音和实时转写均已启动" in source
assert "本机录音已启动" in source
def test_companion_watches_room_id_for_the_entire_call_cycle() -> None:
@@ -83,7 +83,7 @@ def test_companion_watches_room_id_for_the_entire_call_cycle() -> None:
assert "diagnosisId: activeConfig.diagnosisId" in room_source
def test_room_binding_is_acknowledged_and_transcriber_room_is_a_fallback() -> None:
def test_room_binding_is_acknowledged_independently_of_cloud_transcription() -> None:
companion_source = (
PROJECT_ROOT / "video_companion" / "src" / "main.ts"
).read_text(encoding="utf-8")
@@ -91,8 +91,11 @@ def test_room_binding_is_acknowledged_and_transcriber_room_is_a_fallback() -> No
PROJECT_ROOT / "src" / "doctor_workstation" / "video" / "window.py"
).read_text(encoding="utf-8")
assert "observeRoomId(roomId)" in companion_source
assert "onRealtimeTranscriberStarted: (roomId)" in companion_source
assert "observeRoomId(readRoomId())" in companion_source
assert "getAITranscriberManager" in companion_source
assert "startRealtimeTranscriber" in companion_source
assert "sourceLanguage: 'zh'" in companion_source
assert "LocalPcmCapture" not in companion_source
assert "function roomBindingResult(" in companion_source
assert "if (boundRoomId) return" in companion_source
assert "roomBindingResult?.(" in window_source
@@ -186,7 +189,7 @@ def test_local_audio_capture_keeps_and_persists_its_own_call_room_identity() ->
assert "store.bind_identity(" in source
def test_companion_shows_incremental_subtitles_but_only_persists_final_segments() -> None:
def test_companion_displays_only_native_normalized_cloud_transcript_acks() -> None:
main_source = (
PROJECT_ROOT / "video_companion" / "src" / "main.ts"
).read_text(encoding="utf-8")
@@ -196,13 +199,18 @@ def test_companion_shows_incremental_subtitles_but_only_persists_final_segments(
handler = main_source.split("function handleTranscriberMessage", 1)[1].split(
"function subscribeTranscriber", 1
)[0]
acknowledgement = main_source.split("function transcriptionResult", 1)[1].split(
"function videoAiAction", 1
)[0]
assert "showLiveCaption(message)" in handler
assert "if (message.isCompleted !== true) return" in handler
assert handler.index("showLiveCaption(message)") < handler.index(
"if (message.isCompleted !== true) return"
)
assert 'aria-label="实时语音字幕"' in component_source
assert "transcription-segment" in handler
assert "showLiveCaption(" not in handler
assert "message.isCompleted !== true" in handler
assert "sessionId === transcriptionSessionId" in acknowledgement
assert "normalizedSegment?.segmentId === segmentId" in acknowledgement
assert "normalizedSegment.isCompleted === true" in acknowledgement
assert "showLiveCaption(normalizedSegment)" in acknowledgement
assert 'aria-label="腾讯云实时转写的对话原文"' in component_source
assert "liveCaptions.value" in component_source
assert "caption.speaker" in component_source
assert "caption.text" in component_source
@@ -219,7 +227,7 @@ def test_companion_keeps_transcript_and_patient_case_visible_in_a_side_rail() ->
assert "liveCaptions.value = [...previous, caption].slice(-120)" in main_source
assert "liveCaptionClearTimer" not in main_source
assert 'aria-label="患者病例与实时对话"' in component_source
assert 'aria-label="AI辅助、对话原文与患者资料"' in component_source
assert 'id="patient-case-title"' in component_source
assert 'id="live-transcript-title"' in component_source
assert 'aria-label="打开完整诊单"' in component_source
@@ -559,7 +567,7 @@ def test_built_video_companion_contains_the_patient_case_rail() -> None:
assert ".consultation-rail" in styles
assert ".video-layer--with-rail" in styles
assert "patientCase" in scripts
assert "患者病例与实时对话" in scripts
assert "AI辅助、对话原文与患者资料" in scripts
def test_companion_screenshot_requires_doctor_confirmation_before_upload() -> None: