test: 修正两处断言旧行为的存量测试(患者→我 文案、lab 段归并)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -3,7 +3,7 @@ import Testing
|
||||
@testable import 康康
|
||||
|
||||
struct HealthExportDialogueTests {
|
||||
@Test func dialogueTranscriptKeepsTurnOrderAndRoles() {
|
||||
@Test func dialogueTranscriptKeepsTurnOrderAndRoles() throws {
|
||||
let turns: [HealthExportDialogueTurn] = [
|
||||
.user("我最近头晕,帮我看看"),
|
||||
.assistant("我会结合你的指标和日记整理。"),
|
||||
@@ -12,10 +12,13 @@ struct HealthExportDialogueTests {
|
||||
|
||||
let transcript = HealthExportDialogueTurn.transcript(from: turns)
|
||||
|
||||
#expect(transcript.contains("患者: 我最近头晕,帮我看看"))
|
||||
// 用户角色标签是「我」(产品红线:不出现「患者」,见 ca5a3fa)。
|
||||
#expect(transcript.contains("我: 我最近头晕,帮我看看"))
|
||||
#expect(transcript.contains("康康: 我会结合你的指标和日记整理。"))
|
||||
#expect(transcript.contains("患者: 重点看血压"))
|
||||
#expect(transcript.range(of: "患者: 我最近头晕")!.lowerBound < transcript.range(of: "患者: 重点看血压")!.lowerBound)
|
||||
#expect(transcript.contains("我: 重点看血压"))
|
||||
let first = try #require(transcript.range(of: "我: 我最近头晕"))
|
||||
let second = try #require(transcript.range(of: "我: 重点看血压"))
|
||||
#expect(first.lowerBound < second.lowerBound)
|
||||
}
|
||||
|
||||
@Test func dialogueTranscriptDropsEmptyTurns() {
|
||||
@@ -27,8 +30,8 @@ struct HealthExportDialogueTests {
|
||||
|
||||
let transcript = HealthExportDialogueTurn.transcript(from: turns)
|
||||
|
||||
#expect(!transcript.contains("患者: "))
|
||||
#expect(!transcript.contains("我: "))
|
||||
#expect(transcript.contains("康康: 请补充想看的问题"))
|
||||
#expect(transcript.contains("患者: 最近三个月"))
|
||||
#expect(transcript.contains("我: 最近三个月"))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,14 +18,17 @@ struct SeriesBucketTests {
|
||||
seriesKey: seriesKey)
|
||||
}
|
||||
|
||||
@Test func skipsIndicatorsWithoutSeriesKey() {
|
||||
@Test func indicatorsWithoutSeriesKeyFoldIntoLabBucket() {
|
||||
// 「lab 段」特性:无 seriesKey 的指标按 name+unit 归并,同名 ≥minPoints 次即成趋势。
|
||||
let now = Date()
|
||||
let items = [
|
||||
makeIndicator(value: "5.0", capturedAt: now, seriesKey: nil),
|
||||
makeIndicator(value: "5.0", capturedAt: now.addingTimeInterval(-86_400), seriesKey: nil),
|
||||
makeIndicator(value: "5.2", capturedAt: now, seriesKey: nil),
|
||||
]
|
||||
let buckets = SeriesBucket.build(from: items)
|
||||
#expect(buckets.isEmpty)
|
||||
#expect(buckets.count == 1)
|
||||
#expect(buckets.first?.kind == .lab)
|
||||
#expect(buckets.first?.lines.first?.points.count == 2)
|
||||
}
|
||||
|
||||
@Test func filtersOutSeriesWithFewerThanMinPoints() {
|
||||
|
||||
Reference in New Issue
Block a user