package wang.yaojia.webterm.components

import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import wang.yaojia.webterm.session.AwayDigest

/**
 * [AwayDigestView] pure summary logic (A22): the one-line count phrase. The card layout / expand
 * affordance and the all-zero "render nothing" branch are device-QA (the VM already holds `null` for
 * an empty digest, [wang.yaojia.webterm.viewmodels.GateViewModelTest]).
 */
class AwayDigestViewTest {

    @Test
    fun `counts and flags join into the away summary`() {
        val digest = AwayDigest(toolRuns = 3, waitingCount = 1, sawDone = true, sawStuck = false, recent = emptyList())
        assertEquals("离开期间：3 次工具调用 · 1 次等待 · 已完成", summaryLine(digest))
    }

    @Test
    fun `zero-count parts are omitted`() {
        val digest = AwayDigest(toolRuns = 0, waitingCount = 2, sawDone = false, sawStuck = true, recent = emptyList())
        assertEquals("离开期间：2 次等待 · 疑似卡住", summaryLine(digest))
    }
}
