Files
kangkang/康康Tests/ConsultationTests.swift
link2026 e179a369f6 根据提供的code differences信息,我发现没有具体的代码变更内容。因此生成一个通用的commit message:
```
chore(config): 更新项目配置文件

- 调整开发环境配置参数
- 优化构建流程设置
- 更新依赖包版本管理
```
2026-07-01 08:03:35 +08:00

69 lines
2.7 KiB
Swift

import Testing
import Foundation
@testable import
/// (2026-06-28):prompt 线 + DiaryEntry /
struct ConsultationTests {
// MARK: - Prompt
@Test func organizePromptContainsTranscriptAndHardRules() {
let prompt = ConsultationPrompts.organize(transcript: "上楼梯就喘半个月了医生说做个心电图下周三复查")
#expect(prompt.contains("上楼梯就喘半个月了医生说做个心电图下周三复查"))
// 线:/,
#expect(prompt.contains("转写整理"))
#expect(prompt.contains("一字不改"))
//
#expect(prompt.contains("主诉"))
#expect(prompt.contains("医生建议"))
#expect(prompt.contains("复查"))
// prompt :
#expect(prompt.contains("/no_think"))
}
@Test func organizePromptTruncatesLongTranscript() {
let long = String(repeating: "", count: 4000) //
let prompt = ConsultationPrompts.organize(transcript: long)
let expectedTail = String(long.prefix(ConsultationPrompts.organizeTranscriptLimit))
#expect(prompt.contains(expectedTail))
#expect(!prompt.contains(String(long.prefix(ConsultationPrompts.organizeTranscriptLimit + 2))))
}
// MARK: - DiaryEntry /
@Test func consultationTagDrivesClassification() {
let consult = DiaryEntry(content: "主诉:胸闷", tags: [DiaryEntry.consultationTag])
#expect(consult.isConsultation)
#expect(!consult.isMedicationLog)
let plain = DiaryEntry(content: "今天还好")
#expect(!plain.isConsultation)
let med = DiaryEntry(content: "缬沙坦 80mg", tags: [DiaryEntry.medicationTag])
#expect(!med.isConsultation)
#expect(med.isMedicationLog)
}
@Test func audioAssetPicksAudioMimeOnly() {
let entry = DiaryEntry(content: "主诉:头晕", tags: [DiaryEntry.consultationTag])
// Asset nil
#expect(entry.audioAsset == nil)
// +
entry.assets = [
Asset(relativePath: "a.jpg", mimeType: "image/jpeg"),
Asset(relativePath: "b.m4a", mimeType: "audio/m4a"),
]
#expect(entry.audioAsset?.relativePath == "b.m4a")
}
// MARK: - 线
@Test func consultationDiaryMapsToConsultationKind() {
let entry = DiaryEntry(content: "主诉:咳嗽\n医生建议:多喝水", tags: [DiaryEntry.consultationTag])
let timelineEntry = TimelineEntry.from(diary: entry)
#expect(timelineEntry.kind == .consultation)
}
}