android: add compose ui tests for auth and chat list states
Some checks failed
CI / test (push) Failing after 2m14s

This commit is contained in:
Codex
2026-03-09 15:37:10 +03:00
parent ffa2205a30
commit b5cd371f8b
5 changed files with 95 additions and 1 deletions

View File

@@ -358,3 +358,8 @@
- Added global Coil image loader cache policy in `MessengerApplication` (memory + disk cache). - Added global Coil image loader cache policy in `MessengerApplication` (memory + disk cache).
- Added Media3 `SimpleCache` singleton module for media stream/file caching foundation. - Added Media3 `SimpleCache` singleton module for media stream/file caching foundation.
- Added Media3/Coil core dependencies and configured cache sizes for mobile usage. - Added Media3/Coil core dependencies and configured cache sizes for mobile usage.
### Step 61 - Compose UI tests baseline
- Added instrumented Compose UI tests for login and chat list states.
- Added Android test dependencies for Compose test runner (`ui-test-junit4`) and test infra.
- Covered key visual states: auth error rendering, chat list loading state, and empty state.

View File

@@ -106,6 +106,9 @@ dependencies {
testImplementation("androidx.test:core:1.6.1") testImplementation("androidx.test:core:1.6.1")
testImplementation("org.robolectric:robolectric:4.13") testImplementation("org.robolectric:robolectric:4.13")
testImplementation("com.squareup.okhttp3:mockwebserver:4.12.0") testImplementation("com.squareup.okhttp3:mockwebserver:4.12.0")
androidTestImplementation("androidx.compose.ui:ui-test-junit4:1.7.6")
androidTestImplementation("androidx.test.ext:junit:1.2.1")
androidTestImplementation("androidx.test.espresso:espresso-core:3.6.1")
debugImplementation("androidx.compose.ui:ui-tooling:1.7.6") debugImplementation("androidx.compose.ui:ui-tooling:1.7.6")
debugImplementation("androidx.compose.ui:ui-test-manifest:1.7.6") debugImplementation("androidx.compose.ui:ui-test-manifest:1.7.6")

View File

@@ -0,0 +1,35 @@
package ru.daemonlord.messenger.ui.auth
import androidx.activity.ComponentActivity
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.junit4.createAndroidComposeRule
import androidx.compose.ui.test.onNodeWithText
import org.junit.Rule
import org.junit.Test
class LoginScreenTest {
@get:Rule
val composeRule = createAndroidComposeRule<ComponentActivity>()
@Test
fun loginScreen_showsErrorMessage() {
composeRule.setContent {
LoginScreen(
state = AuthUiState(
email = "demo@daemonlord.ru",
password = "123456",
errorMessage = "Invalid email or password.",
),
onEmailChanged = {},
onPasswordChanged = {},
onLoginClick = {},
)
}
composeRule.onNodeWithText("Messenger Login").assertIsDisplayed()
composeRule.onNodeWithText("Invalid email or password.").assertIsDisplayed()
composeRule.onNodeWithText("Login").assertIsDisplayed()
}
}

View File

@@ -0,0 +1,51 @@
package ru.daemonlord.messenger.ui.chats
import androidx.activity.ComponentActivity
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.junit4.createAndroidComposeRule
import androidx.compose.ui.test.onNodeWithText
import org.junit.Rule
import org.junit.Test
class ChatListScreenTest {
@get:Rule
val composeRule = createAndroidComposeRule<ComponentActivity>()
@Test
fun chatListScreen_loadingState_showsLoadingText() {
composeRule.setContent {
ChatListScreen(
state = ChatListUiState(isLoading = true),
onTabSelected = {},
onFilterSelected = {},
onSearchChanged = {},
onRefresh = {},
onOpenSettings = {},
onOpenProfile = {},
onOpenChat = {},
)
}
composeRule.onNodeWithText("Loading chats...").assertIsDisplayed()
}
@Test
fun chatListScreen_emptyState_showsPlaceholder() {
composeRule.setContent {
ChatListScreen(
state = ChatListUiState(isLoading = false, chats = emptyList()),
onTabSelected = {},
onFilterSelected = {},
onSearchChanged = {},
onRefresh = {},
onOpenSettings = {},
onOpenProfile = {},
onOpenChat = {},
)
}
composeRule.onNodeWithText("No chats found").assertIsDisplayed()
}
}

View File

@@ -110,7 +110,7 @@
## 15. Качество ## 15. Качество
- [x] Unit tests (domain/data) - [x] Unit tests (domain/data)
- [ ] UI tests (Compose test) - [x] UI tests (Compose test)
- [ ] Integration tests для auth/chat/realtime - [ ] Integration tests для auth/chat/realtime
- [x] Performance baseline (startup, scroll, media) - [x] Performance baseline (startup, scroll, media)
- [ ] ANR/crash budget + monitoring - [ ] ANR/crash budget + monitoring