make equalsAnyTerms to not strip digits

This commit is contained in:
Andre Rosado committed 2026-09-17 16:21:58 +01:00
1 parent 276e360b44
commit 69a3ac3a48
3 files changed
+20 -3

No files matched your search

@@ -279,12 +279,12 @@ private fun List<String>.containsAnyTermsPreservingDigits(terms: List<String>):
}
/**
* Checks if any string in the list, once normalized, is exactly equal to one of the [terms]. Used
* for terms too generic to match safely as a substring (e.g. "address" -- see
* Checks if any string in the list, once normalized digit-preserving, is exactly equal to one of
* the [terms]. Used for terms too generic to match safely as a substring (e.g. "address" -- see
* [SUPPORTED_EXACT_ADDRESS_STREET_HINTS]).
*/
private fun List<String>.equalsAnyTerms(terms: List<String>): Boolean =
this.any { string -> string.toLowerCaseAndStripNonAlpha() in terms }
this.any { string -> string.toLowerCaseAndStripNonAlphanumeric() in terms }
/**
* The supported attribute keys whose value can represent an autofill hint.
@@ -224,6 +224,7 @@ val SUPPORTED_RAW_ADDRESS_STREET_HINTS: List<String> = listOf(
*/
val SUPPORTED_EXACT_ADDRESS_STREET_HINTS: List<String> = listOf(
"address",
"address1",
)
/**
@@ -1970,6 +1970,22 @@ class ViewNodeExtensionsTest {
assertFalse(viewNode.isAddressStreetField)
}
@Test
fun `isAddressStreetField returns true when htmlInfo hint is address1`() {
setupUnsupportedInputFieldViewNode()
every { viewNode.htmlInfo.hints() } returns listOf("address1")
assertTrue(viewNode.isAddressStreetField)
}
@Test
fun `isAddressStreetField returns false when htmlInfo hint is address3`() {
setupUnsupportedInputFieldViewNode()
every { viewNode.htmlInfo.hints() } returns listOf("address3")
assertFalse(viewNode.isAddressStreetField)
}
@Test
fun `isAddressExtendedField returns true when idEntry is supported`() {
setupUnsupportedInputFieldViewNode()