import { describe, expect, it } from 'vitest'
import { heartbeatMessageBody } from '../src/ui/heartbeat-message'
describe('heartbeat presentation', () => {
const reply = '\ndsh\nNOTIFY\n18:29 巡检:**可用**\n队列 0→670KB→1.62MB。\n'
it('extracts Markdown prose without changing the source', () => {
expect(heartbeatMessageBody(reply, 'assistant')).toBe('18:29 巡检:**可用**\n队列 0→670KB→1.62MB。')
expect(reply).toContain('NOTIFY')
})
it('unwraps the scheduled prompt instructions', () => {
expect(heartbeatMessageBody('dsh检查 TURN 和 Relay', 'user')).toBe('检查 TURN 和 Relay')
})
it('keeps incomplete, quoted, unknown and ambiguous content visible verbatim', () => {
for (const text of [reply.slice(0, -12), `示例:${reply}`, `\`\`\`xml\n${reply}\n\`\`\``, reply.replace('', 'x'), reply.replace('', 'other'), reply.replace('dsh', ''), reply.replace(/[\s\S]*?<\/message>/, '')]) {
expect(heartbeatMessageBody(text, 'assistant')).toBeUndefined()
}
expect(heartbeatMessageBody(reply, 'user')).toBeUndefined()
})
})