This commit is contained in:
gr
2026-10-30 13:43:29 +08:00
144 changed files with 16467 additions and 2457 deletions
+24 -15
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
@@ -269,7 +277,7 @@ def test_video_diagnosis_entry_uses_existing_permission_scoped_drawer() -> None:
assert "not modeless and not self._standalone_readonly" in diagnosis_source
compact_styles = styles.split("@media (max-width: 700px)", 1)[1]
assert ".consultation-rail { display: none; }" in compact_styles
assert ".capture-button { display: none; }" in compact_styles
assert ".capture-button { display: none; }" not in compact_styles
assert "on_open_diagnosis=on_open_diagnosis" in launcher_source
assert "event: 'open-diagnosis-request'" in main_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:
@@ -573,7 +581,8 @@ def test_companion_screenshot_requires_doctor_confirmation_before_upload() -> No
"watch(", 1
)[0]
assert "screenshotPreview.value = canvas.toDataURL" in capture
assert "await captureVideoStage(videoStage.value)" in capture
assert "generation === screenshotGeneration" in capture
assert "onSaveScreenshot" not in capture
assert "await props.onSaveScreenshot(screenshotPreview.value)" in confirm
assert "确认画面后再保存到患者资料" in source