Skip to content

Commit

Permalink
Merge pull request #307 from SwEnt-Group13/chore/figma-adaptations
Browse files Browse the repository at this point in the history
Chore/figma adaptations
  • Loading branch information
Zafouche authored Dec 18, 2024
2 parents c7a0fd7 + c8514d7 commit c34c12a
Show file tree
Hide file tree
Showing 15 changed files with 276 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package com.android.unio.components.authentication

import androidx.compose.ui.test.assert
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.assertIsNotDisplayed
import androidx.compose.ui.test.assertTextContains
import androidx.compose.ui.test.assertTextEquals
import androidx.compose.ui.test.hasText
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.performClick
Expand Down Expand Up @@ -125,6 +128,27 @@ class AccountDetailsTest : TearDown() {
.assertTextContains("I am a student")
}

@Test
fun testClearButtonFunctionality() {
composeTestRule
.onNodeWithTag(AccountDetailsTestTags.FIRST_NAME_TEXT_FIELD)
.performTextInput("John")
composeTestRule
.onNodeWithTag(AccountDetailsTestTags.FIRST_NAME_TEXT_FIELD, useUnmergedTree = true)
.assertTextEquals("John", includeEditableText = true)
composeTestRule.onNodeWithTag(AccountDetailsTestTags.FIRST_NAME_CLEAR_BUTTON).performClick()
composeTestRule.onNodeWithTag(AccountDetailsTestTags.FIRST_NAME_TEXT_FIELD).assert(hasText(""))

composeTestRule
.onNodeWithTag(AccountDetailsTestTags.LAST_NAME_TEXT_FIELD)
.performTextInput("Doe")
composeTestRule
.onNodeWithTag(AccountDetailsTestTags.LAST_NAME_TEXT_FIELD, useUnmergedTree = true)
.assertTextEquals("Doe", includeEditableText = true)
composeTestRule.onNodeWithTag(AccountDetailsTestTags.LAST_NAME_CLEAR_BUTTON).performClick()
composeTestRule.onNodeWithTag(AccountDetailsTestTags.LAST_NAME_TEXT_FIELD).assert(hasText(""))
}

@Test
fun testInterestsButtonWorksCorrectly() {
composeTestRule
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.android.unio.components.event

import androidx.compose.ui.test.assert
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.assertTextEquals
import androidx.compose.ui.test.hasText
import androidx.compose.ui.test.isDisplayed
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithTag
Expand Down Expand Up @@ -281,6 +283,48 @@ class EventCreationTest : TearDown() {
composeTestRule.onNodeWithTag(EventCreationTestTags.DESCRIPTION).performTextClearance()
}

@Test
fun testClearButtonFunctionality() {
nominatimLocationSearchViewModel =
NominatimLocationSearchViewModel(nominatimLocationRepositoryWithoutFunctionality)
composeTestRule.setContent {
EventCreationScreen(
navigationAction,
searchViewModel,
associationViewModel,
eventViewModel,
nominatimLocationSearchViewModel)
}

composeTestRule.waitForIdle()

composeTestRule
.onNodeWithTag(EventCreationTestTags.EVENT_TITLE)
.performScrollTo()
.performTextClearance()
composeTestRule.onNodeWithTag(EventCreationTestTags.EVENT_TITLE).performTextInput("Test Title")
composeTestRule
.onNodeWithTag(EventCreationTestTags.EVENT_TITLE, useUnmergedTree = true)
.assertTextEquals("Test Title", includeEditableText = true)
composeTestRule.onNodeWithTag(EventCreationTestTags.EVENT_TITLE_CLEAR_BUTTON).performClick()
composeTestRule.onNodeWithTag(EventCreationTestTags.EVENT_TITLE).assert(hasText(""))

composeTestRule
.onNodeWithTag(EventCreationTestTags.SHORT_DESCRIPTION)
.performScrollTo()
.performTextClearance()
composeTestRule
.onNodeWithTag(EventCreationTestTags.SHORT_DESCRIPTION)
.performTextInput("Test Short Description")
composeTestRule
.onNodeWithTag(EventCreationTestTags.SHORT_DESCRIPTION, useUnmergedTree = true)
.assertTextEquals("Test Short Description", includeEditableText = true)
composeTestRule
.onNodeWithTag(EventCreationTestTags.EVENT_SHORT_DESCRIPTION_CLEAR_BUTTON)
.performClick()
composeTestRule.onNodeWithTag(EventCreationTestTags.SHORT_DESCRIPTION).assert(hasText(""))
}

@Test
fun testLocationInputFunctionality() {
server = MockWebServer()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
package com.android.unio.components.event

import androidx.compose.ui.test.assert
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.assertIsNotEnabled
import androidx.compose.ui.test.assertTextEquals
import androidx.compose.ui.test.hasText
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
import androidx.compose.ui.test.performScrollTo
import androidx.compose.ui.test.performTextClearance
import androidx.compose.ui.test.performTextInput
import androidx.compose.ui.test.performTextReplacement
import com.android.unio.TearDown
import com.android.unio.assertDisplayComponentInScroll
Expand Down Expand Up @@ -281,4 +285,42 @@ class EventEditTests : TearDown() {
assert(result.title != mockEvent.title)
assert(result.description == mockEvent.description)
}

@Test
fun testClearButtonFunctionality() {
nominatimLocationSearchViewModel =
NominatimLocationSearchViewModel(nominatimLocationRepositoryWithoutFunctionality)
composeTestRule.setContent {
EventEditScreen(
navigationAction,
searchViewModel,
associationViewModel,
eventViewModel,
nominatimLocationSearchViewModel)
}

composeTestRule
.onNodeWithTag(EventEditTestTags.EVENT_TITLE)
.performScrollTo()
.performTextClearance()
composeTestRule.onNodeWithTag(EventEditTestTags.EVENT_TITLE).performTextInput("New Event Title")
composeTestRule
.onNodeWithTag(EventEditTestTags.EVENT_TITLE, useUnmergedTree = true)
.assertTextEquals("New Event Title", includeEditableText = true)
composeTestRule.onNodeWithTag(EventEditTestTags.EVENT_TITLE_CLEAR_BUTTON).performClick()
composeTestRule.onNodeWithTag(EventEditTestTags.EVENT_TITLE).assert(hasText(""))

composeTestRule
.onNodeWithTag(EventEditTestTags.SHORT_DESCRIPTION)
.performScrollTo()
.performTextClearance()
composeTestRule
.onNodeWithTag(EventEditTestTags.SHORT_DESCRIPTION)
.performTextInput("New Short Description")
composeTestRule
.onNodeWithTag(EventEditTestTags.SHORT_DESCRIPTION, useUnmergedTree = true)
.assertTextEquals("New Short Description", includeEditableText = true)
composeTestRule.onNodeWithTag(EventEditTestTags.SHORT_DESCRIPTION_CLEAR_BUTTON).performClick()
composeTestRule.onNodeWithTag(EventEditTestTags.SHORT_DESCRIPTION).assert(hasText(""))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ package com.android.unio.components.user

import android.net.ConnectivityManager
import android.net.Network
import androidx.compose.ui.test.assert
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.assertIsNotDisplayed
import androidx.compose.ui.test.assertTextEquals
import androidx.compose.ui.test.hasText
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.performClick
Expand Down Expand Up @@ -313,6 +316,29 @@ class UserProfileEditionTest : TearDown() {
composeTestRule.onNodeWithTag(UserEditionTestTags.BIOGRAPHY_TEXT_FIELD).performTextClearance()
}

@Test
fun testClearButtonFunctionality() {
composeTestRule.onNodeWithTag(UserEditionTestTags.FIRST_NAME_TEXT_FIELD).performTextClearance()
composeTestRule
.onNodeWithTag(UserEditionTestTags.FIRST_NAME_TEXT_FIELD)
.performTextInput(UserUpdate.FIRST_NAME)
composeTestRule
.onNodeWithTag(UserEditionTestTags.FIRST_NAME_TEXT_FIELD, useUnmergedTree = true)
.assertTextEquals(UserUpdate.FIRST_NAME, includeEditableText = true)
composeTestRule.onNodeWithTag(UserEditionTestTags.FIRST_NAME_CLEAR_BUTTON).performClick()
composeTestRule.onNodeWithTag(UserEditionTestTags.FIRST_NAME_TEXT_FIELD).assert(hasText(""))

composeTestRule.onNodeWithTag(UserEditionTestTags.LAST_NAME_TEXT_FIELD).performTextClearance()
composeTestRule
.onNodeWithTag(UserEditionTestTags.LAST_NAME_TEXT_FIELD)
.performTextInput(UserUpdate.LAST_NAME)
composeTestRule
.onNodeWithTag(UserEditionTestTags.LAST_NAME_TEXT_FIELD, useUnmergedTree = true)
.assertTextEquals(UserUpdate.LAST_NAME, includeEditableText = true)
composeTestRule.onNodeWithTag(UserEditionTestTags.LAST_NAME_CLEAR_BUTTON).performClick()
composeTestRule.onNodeWithTag(UserEditionTestTags.LAST_NAME_TEXT_FIELD).assert(hasText(""))
}

object UserUpdate {
const val FIRST_NAME = "Johnny"
const val LAST_NAME = "Däpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class EventCreationE2ETest : EndToEndTest() {
val dateToSelect = LocalDate.of(currentDate.year, currentDate.month, day)
val dateString = dateToSelect.format(dateFormatter)

composeTestRule.onNodeWithText(dateString, true).performClick()
composeTestRule.onNodeWithText(text = dateString, substring = true).performClick()

composeTestRule
.onNodeWithText(context.getString(R.string.event_creation_dialog_ok))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ object AccountDetailsTestTags {
const val FIRST_NAME_TEXT = "accountDetailsFirstNameText"
const val FIRST_NAME_ERROR_TEXT = "accountDetailsFirstNameErrorText"
const val FIRST_NAME_CHARACTER_COUNTER = "accountDetailsFirstNameCharacterCounter"
const val FIRST_NAME_CLEAR_BUTTON = "accountDetailsFirstNameClearButton"

// LAST NAME TEXT FIELD
const val LAST_NAME_TEXT_FIELD = "accountDetailsLastNameTextField"
const val LAST_NAME_TEXT = "accountDetailsLastNameText"
const val LAST_NAME_ERROR_TEXT = "accountDetailsLastNameErrorText"
const val LAST_NAME_CHARACTER_COUNTER = "accountDetailsLastNameCharacterCounter"
const val LAST_NAME_CLEAR_BUTTON = "accountDetailsLastNameClearButton"

// BIOGRAPHY TEXT FIELD
const val BIOGRAPHY_TEXT_FIELD = "accountDetailsBioTextField"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ object EventCreationTestTags {
const val SCREEN = "eventCreationScreen"
const val TITLE = "eventCreationTitle"
const val EVENT_TITLE = "eventCreationEventTitle"
const val EVENT_TITLE_CLEAR_BUTTON = "eventCreationEventTitleClearButton"
const val SHORT_DESCRIPTION = "eventCreationShortDescription"
const val EVENT_SHORT_DESCRIPTION_CLEAR_BUTTON = "eventCreationShortDescriptionClearButton"
const val COAUTHORS = "eventCreationCoauthors"
const val TAGGED_ASSOCIATIONS = "eventCreationTaggedAssociations"
const val DESCRIPTION = "eventCreationDescription"
Expand Down Expand Up @@ -56,7 +58,9 @@ object EventEditTestTags {
const val SCREEN = "eventEditScreen"
const val TITLE = "eventEditTitle"
const val EVENT_TITLE = "eventEditEventTitle"
const val EVENT_TITLE_CLEAR_BUTTON = "eventEditEventTitleClearButton"
const val SHORT_DESCRIPTION = "eventEditShortDescription"
const val SHORT_DESCRIPTION_CLEAR_BUTTON = "eventEditShortDescriptionClearButton"
const val COAUTHORS = "eventEditCoauthors"
const val TAGGED_ASSOCIATIONS = "eventEditTaggedAssociations"
const val DESCRIPTION = "eventEditDescription"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ object UserEditionTestTags {
const val FIRST_NAME_TEXT = "userSettingsFirstNameText"
const val FIRST_NAME_ERROR_TEXT = "userSettingsFirstNameErrorText"
const val FIRST_NAME_CHARACTER_COUNTER = "userSettingsFirstNameCharacterCounter"
const val FIRST_NAME_CLEAR_BUTTON = "userSettingsFirstNameClearButton"

// LAST NAME TEXT FIELD
const val LAST_NAME_TEXT_FIELD = "userSettingsLastNameTextField"
const val LAST_NAME_TEXT = "userSettingsLastNameText"
const val LAST_NAME_ERROR_TEXT = "userSettingsLastNameErrorText"
const val LAST_NAME_CHARACTER_COUNTER = "userSettingsLastNameCharacterCounter"
const val LAST_NAME_CLEAR_BUTTON = "userSettingsLastNameClearButton"

// BIOGRAPHY TEXT FIELD
const val BIOGRAPHY_TEXT_FIELD = "userSettingsBioTextField"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Add
import androidx.compose.material.icons.outlined.Clear
import androidx.compose.material3.Button
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.OutlinedButton
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Scaffold
Expand Down Expand Up @@ -306,7 +308,19 @@ private fun UserTextFields(
onFirstNameChange(it)
}
},
value = firstName)
value = firstName,
trailingIcon = {
IconButton(
onClick = { onFirstNameChange("") },
enabled = firstName.isNotEmpty(),
modifier = Modifier.testTag(AccountDetailsTestTags.FIRST_NAME_CLEAR_BUTTON)) {
Icon(
imageVector = Icons.Outlined.Clear,
contentDescription =
context.getString(
R.string.account_details_content_description_clear_first_name))
}
})

OutlinedTextField(
modifier =
Expand Down Expand Up @@ -340,7 +354,19 @@ private fun UserTextFields(
onLastNameChange(it)
}
},
value = lastName)
value = lastName,
trailingIcon = {
IconButton(
onClick = { onLastNameChange("") },
enabled = lastName.isNotEmpty(),
modifier = Modifier.testTag(AccountDetailsTestTags.LAST_NAME_CLEAR_BUTTON)) {
Icon(
imageVector = Icons.Outlined.Clear,
contentDescription =
context.getString(
R.string.account_details_content_description_clear_last_name))
}
})

OutlinedTextField(
modifier =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.AccessTime
import androidx.compose.material.icons.filled.Close
import androidx.compose.material.icons.filled.DateRange
import androidx.compose.material.icons.outlined.LocationOn
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.DatePicker
import androidx.compose.material3.DatePickerDialog
Expand Down Expand Up @@ -122,7 +123,12 @@ fun NominatimLocationPicker(
},
label = { Text(context.getString(R.string.event_creation_location_label)) },
placeholder = { Text(context.getString(R.string.event_creation_location_input_label)) },
modifier = Modifier.fillMaxWidth().testTag(textFieldTestTag))
modifier = Modifier.fillMaxWidth().testTag(textFieldTestTag),
trailingIcon = {
Icon(
imageVector = Icons.Outlined.LocationOn,
contentDescription = context.getString(R.string.event_creation_location_icon))
})

DropdownMenu(
expanded = showDropdown && locationSuggestions.isNotEmpty(),
Expand Down
29 changes: 29 additions & 0 deletions app/src/main/java/com/android/unio/ui/event/EventCreation.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material.icons.filled.Add
import androidx.compose.material.icons.outlined.Clear
import androidx.compose.material.icons.rounded.Clear
import androidx.compose.material3.Button
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
Expand Down Expand Up @@ -145,6 +147,18 @@ fun EventCreationScreen(
Modifier.testTag(EventCreationTestTags.TITLE_CHARACTER_COUNTER))
}
}
},
trailingIcon = {
IconButton(
onClick = { name = "" },
enabled = name.isNotEmpty(),
modifier = Modifier.testTag(EventCreationTestTags.EVENT_TITLE_CLEAR_BUTTON)) {
Icon(
imageVector = Icons.Outlined.Clear,
contentDescription =
context.getString(
R.string.event_creation_content_description_clear_title))
}
})

OutlinedTextField(
Expand Down Expand Up @@ -177,6 +191,21 @@ fun EventCreationScreen(
EventCreationTestTags.SHORT_DESCRIPTION_CHARACTER_COUNTER))
}
}
},
trailingIcon = {
IconButton(
onClick = { shortDescription = "" },
enabled = shortDescription.isNotEmpty(),
modifier =
Modifier.testTag(
EventCreationTestTags.EVENT_SHORT_DESCRIPTION_CLEAR_BUTTON)) {
Icon(
imageVector = Icons.Outlined.Clear,
contentDescription =
context.getString(
R.string
.event_creation_content_description_clear_short_description))
}
})

BannerImagePicker(
Expand Down
Loading

0 comments on commit c34c12a

Please sign in to comment.