Fix username/password filling in signal login.

This commit is contained in:
Greyson Parrelli
2026-09-02 16:11:30 -03:00
committed by Alex Hart
parent 57af6d4177
commit 4408ab3386
2 changed files with 26 additions and 0 deletions
@@ -41,6 +41,8 @@ import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.autofill.ContentType
import androidx.compose.ui.autofill.contentType
import androidx.compose.ui.focus.onFocusChanged
import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.platform.LocalContext
@@ -315,6 +317,7 @@ private fun AccountIdTextField(
visualTransformation = AccountIdVisualTransformation,
modifier = modifier
.fillMaxWidth()
.contentType(ContentType.Username)
.testTag(TestTags.SIGNAL_LOGIN_CREDENTIAL_ACCOUNT_ID_FIELD)
)
}
@@ -377,6 +380,7 @@ private fun RecoveryKeyTextField(
visualTransformation = visualTransformation,
modifier = modifier
.fillMaxWidth()
.contentType(ContentType.Password)
.testTag(TestTags.SIGNAL_LOGIN_CREDENTIAL_RECOVERY_KEY_FIELD)
.attachPasswordAutoFillHelper(autoFillHelper)
)
@@ -6,6 +6,9 @@
package org.signal.registration.screens.signallogincredentials
import android.app.Application
import androidx.compose.ui.autofill.ContentType
import androidx.compose.ui.semantics.SemanticsProperties
import androidx.compose.ui.semantics.getOrNull
import androidx.compose.ui.test.assertIsEnabled
import androidx.compose.ui.test.assertIsNotEnabled
import androidx.compose.ui.test.junit4.createComposeRule
@@ -16,6 +19,7 @@ import androidx.compose.ui.test.performTextInput
import androidx.test.core.app.ApplicationProvider
import assertk.assertThat
import assertk.assertions.contains
import assertk.assertions.isEqualTo
import io.mockk.coEvery
import io.mockk.coVerify
import io.mockk.every
@@ -78,6 +82,20 @@ class SignalLoginCredentialEntryScreenTest {
coVerify(exactly = 0) { SignalCredentialManager.getCredential(any()) }
}
@Test
fun `the account ID field is tagged for autofill as the username`() {
setContent(SignalLoginCredentialEntryState())
assertThat(contentTypeOf(TestTags.SIGNAL_LOGIN_CREDENTIAL_ACCOUNT_ID_FIELD)).isEqualTo(ContentType.Username)
}
@Test
fun `the recovery key field is tagged for autofill as the password`() {
setContent(SignalLoginCredentialEntryState())
assertThat(contentTypeOf(TestTags.SIGNAL_LOGIN_CREDENTIAL_RECOVERY_KEY_FIELD)).isEqualTo(ContentType.Password)
}
@Test
fun `when text is typed into the account ID field, AccountIdChanged is emitted`() {
setContent(SignalLoginCredentialEntryState())
@@ -165,6 +183,10 @@ class SignalLoginCredentialEntryScreenTest {
composeTestRule.onNodeWithTag(TestTags.SIGNAL_LOGIN_CREDENTIAL_NEXT_BUTTON).assertIsNotEnabled()
}
private fun contentTypeOf(tag: String): ContentType? {
return composeTestRule.onNodeWithTag(tag).fetchSemanticsNode().config.getOrNull(SemanticsProperties.ContentType)
}
private fun stubPasswordManager() {
mockkObject(SignalCredentialManager)
every { SignalCredentialManager.isSupported(any()) } returns true