Skip to content
This repository has been archived by the owner on Jan 10, 2025. It is now read-only.

nsc-events-android_6_239_login-page-unit-test #235

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions app/src/androidTest/java/com/example/nsc_events/LoginTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.example.nsc_events

import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.test.assertCountEquals
import androidx.compose.ui.test.assertHasClickAction
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onAllNodesWithText
import androidx.compose.ui.test.onNodeWithText
import androidx.navigation.compose.ComposeNavigator
import androidx.navigation.testing.TestNavHostController
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.example.nsc_events.screen.LoginPage
import org.junit.Before import org.junit.Rule
import org.junit.Test import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class) class LoginTest {

@get: Rule val rule = createComposeRule()

private lateinit var navController: TestNavHostController

@Before fun setUp() { rule.setContent { navController = TestNavHostController(LocalContext.current)
navController.navigatorProvider.addNavigator(ComposeNavigator())
LoginPage(navController = navController) } }

@Test
fun checkNumberOfMatchedNodesOnLoginPage()
{ rule .onAllNodesWithText("Login") .assertCountEquals(1) }

@Test
fun assertEmailTextFieldIsPresentOnLoginPage()
{ rule .onNodeWithText("Email") .assertExists() }

@Test
fun assertPasswordTextFieldIsPresentOnLoginPage()
{ rule .onNodeWithText("Password") .assertExists() }

@Test
fun assertLoginButtonIsClickableOnLoginPage()
{ rule .onNodeWithText("Login") .assertHasClickAction() }

@Test
fun assertForgotPasswordIsClickableOnLoginPage()
{ rule .onNodeWithText("Forgot password?") .assertHasClickAction() }

@Test
fun assertCreateAccountIsClickableOnLoginPage()
{ rule .onNodeWithText("Create account") .assertHasClickAction() } }
1 change: 1 addition & 0 deletions app/src/main/java/com/example/nsc_events/Routes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ sealed class Routes(val route: String) {
object CreatorView: Routes("Creator View")
object AdminView: Routes("Admin View")
object EditUserRole: Routes("Edit User Role")

}
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ fun AdminView(navController: NavHostController) {
Spacer(modifier = Modifier.height(16.dp))

Button(onClick = { navController.navigate(Routes.HomePage.route) }) {
Text(text = "View Events",
Text(text = "View All Events",
style = TextStyle(
fontSize = 14.sp,
fontFamily = FontFamily.Default,
Expand Down
Loading