feat(#125): add free-form text input and option tap/long-press behavior to ClarifyDialog

This commit is contained in:
Hy4ri committed 2026-06-20 12:28:14 +03:00
1 parent 42f8cfe509
commit 8d31e37baa
2 files changed
+90 -8

No files matched your search

@@ -323,6 +323,47 @@ class ChatViewModelTest {
assertEquals(MessageRole.USER, state.messages[1].role)
}
@Test
fun testClarifyRequestCustomResponse() =
runTest {
var createReqId = ""
every { HermesWsClient.send(WsMethods.SESSION_CREATE, any(), any()) } answers {
createReqId = "create-req-clarify-custom"
val onSent = arg<((String) -> Unit)?>(2)
onSent?.invoke(createReqId)
createReqId
}
val viewModel = ChatViewModel(app, startCleanup = false)
advanceUntilIdle()
// Set session ID
mockEventsFlow.emit(WsEvent.GatewayReady(null))
advanceUntilIdle()
mockEventsFlow.emit(WsEvent.RpcResult(createReqId, mapOf("session_id" to "session-123")))
advanceUntilIdle()
mockEventsFlow.emit(WsEvent.ClarifyRequest("Please explain:", emptyList()))
advanceUntilIdle()
var state = viewModel.uiState.value
assertEquals("Please explain:", state.clarifyRequest?.text)
assertTrue(state.clarifyRequest?.options.isNullOrEmpty())
// Respond to clarify with custom text
viewModel.respondToClarify("This is my custom response text")
advanceUntilIdle()
// verify clarify request is dismissed, and user message is sent
state = viewModel.uiState.value
assertNull(state.clarifyRequest)
assertEquals(2, state.messages.size)
assertEquals("Session created", state.messages[0].content)
assertEquals("This is my custom response text", state.messages[1].content)
assertEquals(MessageRole.USER, state.messages[1].role)
}
@Test
fun testSendMessage() =
runTest {