package wang.yaojia.webterm.screens

import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertNull
import org.junit.jupiter.api.Test

/**
 * The new-session-in-cwd routing decision (plan §1, §5 A21 Verify): the phone toolbar action and the
 * exit-/replay-too-large banner action both produce `attach(null, cwd)` — a fresh spawn (sessionId null)
 * in the current session's directory. Pure JVM — no device.
 */
class NewSessionInCwdTest {

    @Test
    fun `requestFor carries the current cwd and always spawns a new session`() {
        val request = NewSessionInCwd.requestFor("/home/dev/project")
        assertNull(request.sessionId, "a new session never re-attaches — sessionId must be null")
        assertEquals("/home/dev/project", request.cwd)
    }

    @Test
    fun `requestFor passes a null cwd through unchanged`() {
        val request = NewSessionInCwd.requestFor(null)
        assertNull(request.sessionId)
        assertNull(request.cwd)
    }

    @Test
    fun `the produced request equals attach null cwd`() {
        assertEquals(NewSessionRequest(sessionId = null, cwd = "/srv/app"), NewSessionInCwd.requestFor("/srv/app"))
    }
}
