-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'refs/heads/main' into feat/map/ui
# Conflicts: # app/src/main/java/com/android/periodpals/MainActivity.kt
- Loading branch information
Showing
10 changed files
with
344 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
app/src/androidTest/java/com/android/periodpals/ui/profile/CreateProfileTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package com.android.periodpals.ui.profile | ||
|
||
import androidx.compose.ui.test.assertIsDisplayed | ||
import androidx.compose.ui.test.junit4.createComposeRule | ||
import androidx.compose.ui.test.onNodeWithTag | ||
import androidx.compose.ui.test.performClick | ||
import androidx.compose.ui.test.performTextInput | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import junit.framework.TestCase.assertFalse | ||
import junit.framework.TestCase.assertTrue | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
class CreateProfileTest { | ||
|
||
@get:Rule val composeTestRule = createComposeRule() | ||
|
||
@Test | ||
fun testProfileImageDisplayed() { | ||
composeTestRule.setContent { CreateProfile() } | ||
|
||
// Check if the profile image is displayed | ||
composeTestRule.onNodeWithTag("profile_image").assertIsDisplayed() | ||
} | ||
|
||
@Test | ||
fun testFormFieldsDisplayed() { | ||
composeTestRule.setContent { CreateProfile() } | ||
|
||
// Check if the form fields are displayed | ||
composeTestRule.onNodeWithTag("email_field").assertIsDisplayed() | ||
composeTestRule.onNodeWithTag("dob_field").assertIsDisplayed() | ||
composeTestRule.onNodeWithTag("name_field").assertIsDisplayed() | ||
composeTestRule.onNodeWithTag("description_field").assertIsDisplayed() | ||
} | ||
|
||
@Test | ||
fun testSaveButtonClickWithValidDate() { | ||
composeTestRule.setContent { CreateProfile() } | ||
|
||
// Input valid date | ||
composeTestRule.onNodeWithTag("dob_field").performTextInput("01/01/2000") | ||
|
||
// Perform click on the save button | ||
composeTestRule.onNodeWithTag("save_button").performClick() | ||
composeTestRule.waitForIdle() | ||
|
||
assertTrue(validateDate("01/01/2000")) | ||
assertTrue(validateDate("31/12/1999")) | ||
} | ||
|
||
@Test | ||
fun testSaveButtonClickWithInvalidDate() { | ||
composeTestRule.setContent { CreateProfile() } | ||
|
||
// Input invalid date | ||
composeTestRule.onNodeWithTag("dob_field").performTextInput("invalid_date") | ||
|
||
// Perform click on the save button | ||
composeTestRule.onNodeWithTag("save_button").performClick() | ||
composeTestRule.waitForIdle() | ||
|
||
assertFalse(validateDate("32/01/2000")) // Invalid day | ||
assertFalse(validateDate("01/13/2000")) // Invalid month | ||
assertFalse(validateDate("01/01/abcd")) // Invalid year | ||
assertFalse(validateDate("01-01-2000")) // Invalid format | ||
assertFalse(validateDate("01/01")) // Incomplete date | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.