Skip to content

Commit

Permalink
testfix: LoginScreenTest
Browse files Browse the repository at this point in the history
login test에 있었던 에러를 고쳤습니다.
-loginScreen에서 coroutineScope을 main Thread에서 동작하도록 변경해서 test 진행
  • Loading branch information
mechanicjo committed Nov 29, 2023
1 parent 4d341d7 commit 3b076f2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import com.team13.fooriend.core.graph.AuthScreen
import com.team13.fooriend.core.graph.Graph
import com.team13.fooriend.core.graph.RootNavigationGraph
import com.team13.fooriend.ui.util.saveAccessToken
import okhttp3.internal.wait
import org.junit.Assert
import org.junit.Before
import org.junit.Rule
Expand Down Expand Up @@ -68,7 +69,7 @@ class LogInScreenTest {
.performTextInput("admin")
composeTestRule
.onNodeWithText("PASSWORD")
.performTextInput("admin") // please change wrong pwd
.performTextInput("admin")
composeTestRule
.onNodeWithText("LOGIN")
.performClick()
Expand All @@ -87,9 +88,10 @@ class LogInScreenTest {
composeTestRule
.onNodeWithText("LOGIN")
.performClick()
composeTestRule.runOnUiThread {
val route = navController.currentBackStackEntry?.destination?.route
Assert.assertEquals(route, AuthScreen.Login.route)
composeTestRule.waitUntil {
navController.currentBackStackEntry?.destination?.route == Graph.HOME
}
val route = navController.currentBackStackEntry?.destination?.route
Assert.assertEquals(route, Graph.HOME)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,14 @@ import androidx.compose.ui.text.input.VisualTransformation
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.team13.fooriend.MainActivity
import com.team13.fooriend.ui.theme.CRed
import com.team13.fooriend.ui.theme.FooriendColor
import com.team13.fooriend.ui.util.ApiService
import com.team13.fooriend.ui.util.LoginBody
import com.team13.fooriend.ui.util.LoginResponse
import com.team13.fooriend.ui.util.saveAccessToken
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
Expand Down Expand Up @@ -154,7 +156,7 @@ fun LogInScreen(
Spacer(modifier = Modifier.height(30.dp))
Button(
onClick = { if(id.isNotEmpty() && password.isNotEmpty()){
coroutineScope.launch{
coroutineScope.launch(Dispatchers.Main){
var response: LoginResponse? = null
try{
response = apiService.login(LoginBody(id, password))
Expand Down

0 comments on commit 3b076f2

Please sign in to comment.