mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-02 21:32:34 +00:00
Merge pull request #7439 from hayaksi1/fix/5153-sanitize-carriage-return
Exclude carriage returns from the login and password fields
This commit is contained in:
+2
-2
@@ -299,10 +299,10 @@ private fun Content(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ensure that the string does not contain any new line characters, which can happen when pasting values.
|
* Ensure that the string does not contain any line separator, which can happen when pasting values.
|
||||||
*/
|
*/
|
||||||
private fun String.sanitize(): String {
|
private fun String.sanitize(): String {
|
||||||
return replace("\n", "")
|
return filterNot { it == '\n' || it == '\r' }
|
||||||
}
|
}
|
||||||
|
|
||||||
@PreviewsDayNight
|
@PreviewsDayNight
|
||||||
|
|||||||
+2
-2
@@ -277,10 +277,10 @@ private fun LoginForm(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ensure that the string does not contain any new line characters, which can happen when pasting values.
|
* Ensure that the string does not contain any line separator, which can happen when pasting values.
|
||||||
*/
|
*/
|
||||||
private fun String.sanitize(): String {
|
private fun String.sanitize(): String {
|
||||||
return replace("\n", "")
|
return filterNot { it == '\n' || it == '\r' }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
|||||||
+30
@@ -81,6 +81,21 @@ class LoginPasswordViewTest : RobolectricTest() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `changing login removes carriage returns the expected event`() = runAndroidComposeUiTest {
|
||||||
|
val eventsRecorder = EventsRecorder<LoginPasswordEvents>()
|
||||||
|
setLoginPasswordView(
|
||||||
|
aLoginPasswordState(
|
||||||
|
eventSink = eventsRecorder,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
val userNameHint = activity!!.getString(CommonStrings.common_username)
|
||||||
|
onNodeWithText(userNameHint).performTextInput("a\r\nb")
|
||||||
|
eventsRecorder.assertSingle(
|
||||||
|
LoginPasswordEvents.SetLogin("ab")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `clearing login invokes the expected event`() = runAndroidComposeUiTest {
|
fun `clearing login invokes the expected event`() = runAndroidComposeUiTest {
|
||||||
val eventsRecorder = EventsRecorder<LoginPasswordEvents>()
|
val eventsRecorder = EventsRecorder<LoginPasswordEvents>()
|
||||||
@@ -112,6 +127,21 @@ class LoginPasswordViewTest : RobolectricTest() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `changing password removes carriage returns the expected event`() = runAndroidComposeUiTest {
|
||||||
|
val eventsRecorder = EventsRecorder<LoginPasswordEvents>()
|
||||||
|
setLoginPasswordView(
|
||||||
|
aLoginPasswordState(
|
||||||
|
eventSink = eventsRecorder,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
val passwordHint = activity!!.getString(CommonStrings.common_password)
|
||||||
|
onNodeWithText(passwordHint).performTextInput("a\r\nb")
|
||||||
|
eventsRecorder.assertSingle(
|
||||||
|
LoginPasswordEvents.SetPassword("ab")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `reveal password makes the password visible`() = runAndroidComposeUiTest {
|
fun `reveal password makes the password visible`() = runAndroidComposeUiTest {
|
||||||
val eventsRecorder = EventsRecorder<LoginPasswordEvents>(expectEvents = false)
|
val eventsRecorder = EventsRecorder<LoginPasswordEvents>(expectEvents = false)
|
||||||
|
|||||||
Reference in New Issue
Block a user