test: add tests for interruptSession in ChatViewModel (#508)

Add unit tests to `ChatViewModelTest.kt` to cover the `interruptSession`
method. The tests verify that `interruptSession` correctly sends the
`SESSION_INTERRUPT` RPC via the WebSocket client when a session ID is
present, and that it safely does nothing when the session ID is missing.

This improves test coverage for the chat control logic.
This commit is contained in:
M57 authored and GitHub committed 2026-07-09 15:19:01 +03:00
1 parent 5aad806b8f
commit 2f5a841a03
1 file changed
+23
@@ -711,6 +711,29 @@ class ChatViewModelTest {
verify { HermesWsClient.send(WsMethods.SESSION_RESUME, mapOf("session_id" to "session-456"), any()) }
}
@Test
fun testInterruptSession_withSessionId_sendsRpc() =
runTest {
val (viewModel, sessionId) = createViewModelWithSession()
viewModel.interruptSession()
advanceUntilIdle()
verify { HermesWsClient.send(WsMethods.SESSION_INTERRUPT, mapOf("session_id" to sessionId), any()) }
}
@Test
fun testInterruptSession_withoutSessionId_doesNotSendRpc() =
runTest {
val viewModel = createViewModel()
advanceUntilIdle()
viewModel.interruptSession()
advanceUntilIdle()
verify(exactly = 0) { HermesWsClient.send(WsMethods.SESSION_INTERRUPT, any(), any()) }
}
// ── Error handling ───────────────────────────────────────────────────────
@Test