From a28d53127f3ab0a66ab819ac18e0cd680ca0b44d Mon Sep 17 00:00:00 2001 From: M57 Date: Thu, 18 Jun 2026 02:25:45 +0300 Subject: [PATCH] test: update switchSession asserts for B3 isLoading fix loadSessionMessages now resets isLoading=false on its error branch (was previously stuck at true). Test was implicitly relying on the bug. --- .../m57/hermescontrol/ui/chat/ChatViewModelTest.kt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/src/test/java/com/m57/hermescontrol/ui/chat/ChatViewModelTest.kt b/app/src/test/java/com/m57/hermescontrol/ui/chat/ChatViewModelTest.kt index 12e996c9..2445c262 100644 --- a/app/src/test/java/com/m57/hermescontrol/ui/chat/ChatViewModelTest.kt +++ b/app/src/test/java/com/m57/hermescontrol/ui/chat/ChatViewModelTest.kt @@ -21,6 +21,7 @@ import kotlinx.coroutines.test.setMain import org.junit.After import org.junit.Assert.assertEquals import org.junit.Assert.assertFalse +import org.junit.Assert.assertNotNull import org.junit.Assert.assertNull import org.junit.Assert.assertTrue import org.junit.Before @@ -316,8 +317,15 @@ class ChatViewModelTest { val state = viewModel.uiState.value assertEquals("session-456", state.currentSessionId) - assertTrue(state.isLoading) - assertTrue(state.messages.isEmpty()) + // B3 (Jun 18 2026, kanban t_33da8a97): loadSessionMessages now + // sets isLoading=false on its error/success branches (previously + // never reset on error, leaving isLoading stuck at true). Since + // ApiClient.hermesApi is not mocked in this test suite, the real + // Retrofit call fails → catch branch sets isLoading=false and + // records errorMessage. Assert the new correct behavior. + assertFalse("isLoading should be false once loadSessionMessages settles", state.isLoading) + assertTrue("messages should be cleared by switchSession", state.messages.isEmpty()) + assertNotNull("errorMessage should be set on load failure", state.errorMessage) verify { HermesWsClient.send(WsMethods.SESSION_RESUME, mapOf("session_id" to "session-456")) } }