fix(chat): support batch clarify.request payload and route question_id on respond (fixes #1045) (#1046)
This commit is contained in:
6 files changed
+159
-1
No files matched your search
@@ -1217,6 +1217,54 @@ class ChatViewModelTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testClarifyRequestWithQuestionIdAndRespond() =
|
||||
runTest {
|
||||
val (viewModel, sessionId) = createViewModelWithSession()
|
||||
|
||||
mockEventsFlow.emit(
|
||||
WsEvent.ClarifyRequest(
|
||||
text = "Pick one:",
|
||||
options = listOf("Option 1"),
|
||||
clarifyId = "clarify-batch-1",
|
||||
sessionId = sessionId,
|
||||
questionId = "q0",
|
||||
),
|
||||
)
|
||||
advanceUntilIdle()
|
||||
|
||||
assertEquals(
|
||||
"Pick one:",
|
||||
viewModel.uiState.value.clarifyRequest
|
||||
?.text,
|
||||
)
|
||||
assertEquals(
|
||||
"q0",
|
||||
viewModel.uiState.value.clarifyRequest
|
||||
?.questionId,
|
||||
)
|
||||
|
||||
viewModel.respondToClarify("Option 1")
|
||||
advanceUntilIdle()
|
||||
|
||||
assertNull(viewModel.uiState.value.clarifyRequest)
|
||||
verify {
|
||||
HermesWsClient.send(
|
||||
method = WsMethods.CLARIFY_RESPOND,
|
||||
params =
|
||||
mapOf(
|
||||
"session_id" to sessionId,
|
||||
"response" to "Option 1",
|
||||
"answer" to "Option 1",
|
||||
"clarify_id" to "clarify-batch-1",
|
||||
"request_id" to "clarify-batch-1",
|
||||
"question_id" to "q0",
|
||||
),
|
||||
onSent = any(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testClarifyRequestCustomResponse() =
|
||||
runTest {
|
||||
@@ -1316,6 +1364,53 @@ class ChatViewModelTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testClarifyDismissWithQuestionIdInformsAgent() =
|
||||
runTest {
|
||||
val (viewModel, sessionId) = createViewModelWithSession()
|
||||
|
||||
mockEventsFlow.emit(
|
||||
WsEvent.ClarifyRequest(
|
||||
"Please choose:",
|
||||
listOf("Yes", "No"),
|
||||
"clarify-789",
|
||||
sessionId,
|
||||
questionId = "q0",
|
||||
),
|
||||
)
|
||||
advanceUntilIdle()
|
||||
assertEquals(
|
||||
"clarify-789",
|
||||
viewModel.uiState.value.clarifyRequest
|
||||
?.clarifyId,
|
||||
)
|
||||
assertEquals(
|
||||
"q0",
|
||||
viewModel.uiState.value.clarifyRequest
|
||||
?.questionId,
|
||||
)
|
||||
|
||||
viewModel.dismissClarify()
|
||||
advanceUntilIdle()
|
||||
|
||||
assertNull(viewModel.uiState.value.clarifyRequest)
|
||||
verify {
|
||||
HermesWsClient.send(
|
||||
method = WsMethods.CLARIFY_RESPOND,
|
||||
params =
|
||||
mapOf(
|
||||
"session_id" to sessionId,
|
||||
"response" to "The user cancelled — no answer provided.",
|
||||
"answer" to "The user cancelled — no answer provided.",
|
||||
"clarify_id" to "clarify-789",
|
||||
"request_id" to "clarify-789",
|
||||
"question_id" to "q0",
|
||||
),
|
||||
onSent = any(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// ── Attachments ──────────────────────────────────────────────────────────
|
||||
|
||||
/** Add [count] dummy attachments so a test starts with a populated list. */
|
||||
|
||||
Reference in new issue
Block a user