import Testing
@testable import 康康

struct DiaryOrganizePromptTests {
    @Test func organizePromptContainsTranscriptAndHardRules() {
        let prompt = DiaryAssistPrompts.organize(transcript: "今天早上头晕量了血压140 90")

        #expect(prompt.contains("今天早上头晕量了血压140 90"))
        // 健康数据红线:数值/单位/药名/时间不许改,必须写进 prompt
        #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: 2000)   // 4000 字符,超过上限
        let prompt = DiaryAssistPrompts.organize(transcript: long)

        // 整条 prompt 里口述部分被截断到 organizeTranscriptLimit
        let expectedTail = String(long.prefix(DiaryAssistPrompts.organizeTranscriptLimit))
        #expect(prompt.contains(expectedTail))
        #expect(!prompt.contains(String(long.prefix(DiaryAssistPrompts.organizeTranscriptLimit + 2))))
    }
}
