@@ -3,9 +3,10 @@ package com.monstarlab.features.login.ui
3
3
import androidx.compose.ui.test.assert
4
4
import androidx.compose.ui.test.assertIsDisplayed
5
5
import androidx.compose.ui.test.assertIsEnabled
6
+ import androidx.compose.ui.test.hasClickAction
6
7
import androidx.compose.ui.test.hasText
7
8
import androidx.compose.ui.test.junit4.createComposeRule
8
- import androidx.compose.ui.test.onNodeWithTag
9
+ import androidx.compose.ui.test.onNodeWithText
9
10
import androidx.compose.ui.test.performClick
10
11
import androidx.compose.ui.test.performTextReplacement
11
12
import androidx.test.ext.junit.runners.AndroidJUnit4
@@ -44,18 +45,18 @@ class LoginScreenTest {
44
45
@Test
45
46
fun testInitialState () {
46
47
composeTestRule
47
- .onNodeWithTag( " email " )
48
+ .onNodeWithText( " E-Mail " )
48
49
.assertIsEnabled()
49
50
.assertIsDisplayed()
50
51
.assert (hasText(" eve.holt@reqres.in" ))
51
52
52
53
composeTestRule
53
- .onNodeWithTag( " password " )
54
+ .onNodeWithText( " Password " )
54
55
.assertIsEnabled()
55
56
.assertIsDisplayed()
56
57
57
58
composeTestRule
58
- .onNodeWithTag( " login " )
59
+ .onNode(hasText( " Login " ) and hasClickAction() )
59
60
.assertIsEnabled()
60
61
.assertIsDisplayed()
61
62
}
@@ -72,7 +73,7 @@ class LoginScreenTest {
72
73
@Test
73
74
fun testEmailInput () {
74
75
composeTestRule
75
- .onNodeWithTag( " email " )
76
+ .onNodeWithText( " E-Mail " )
76
77
.performTextReplacement(" test@test.com" )
77
78
78
79
verify { mockActions.onEmailChange(" test@test.com" ) }
@@ -90,7 +91,7 @@ class LoginScreenTest {
90
91
@Test
91
92
fun testPasswordInput () {
92
93
composeTestRule
93
- .onNodeWithTag( " password " )
94
+ .onNodeWithText( " Password " )
94
95
.performTextReplacement(" secret" )
95
96
96
97
verify { mockActions.onPasswordChange(" secret" ) }
@@ -106,7 +107,9 @@ class LoginScreenTest {
106
107
*/
107
108
@Test
108
109
fun testLoginButtonClick () {
109
- composeTestRule.onNodeWithTag(" login" ).performClick()
110
+ composeTestRule
111
+ .onNode(hasText(" Login" ) and hasClickAction())
112
+ .performClick()
110
113
111
114
verify { mockActions.onLoginClick() }
112
115
}
0 commit comments