W-23159884: Add stable test tags to login screen and server/account picker#2940
Conversation
…icker Introduce a public LoginViewTestTags object as the single source of truth for locale-invariant test-tag resource-ids, replacing the localized contentDescription/text anchors used by SDK tests, AuthFlowTester page objects, and external UTAM. Migrate PickerBottomSheetTest and AuthFlowTester LoginPageObject to anchor on the tags.
| * IMPORTANT: These are test anchors only. Do NOT localize them and do NOT reuse them as | ||
| * user-facing strings. | ||
| */ | ||
| object LoginViewTestTags { |
There was a problem hiding this comment.
This might appear to be an over investment given our future Login UX plans, but I actually see it being a useful bridge. If/when we introduce a new SDK provided default UI in 15.0 we can ensure these tags are used. And since they are public consuming apps can use them in their UI implementation if they chose to create their own. This make UI tests easier to migrate and hopefully ease the transition.
| const val SERVER_DELETE_BUTTON = "sf__server_delete_button" | ||
|
|
||
| /** Revealed confirm-delete target on a custom server row. */ | ||
| const val SERVER_CONFIRM_DELETE_BUTTON = "sf__server_confirm_delete_button" |
There was a problem hiding this comment.
Both SERVER_DELETE_BUTTON and SERVER_CONFIRM_DELETE_BUTTON are shared by every row in the list — all delete buttons get the same tag by design. That's expected Compose behaviour, but it will surprise the first person writing a test that targets a specific server row. Worth adding a one-liner KDoc note here (and on SERVER_DELETE_BUTTON above) pointing to the row-identity pattern:
// To target a specific row, combine with a content matcher:
// onNode(hasTestTag(SERVER_DELETE_BUTTON) and hasAncestor(hasText("MyOrg")))|
Tests will fail on the latest run because the test org goes down for maintenance every day ~4 PST. All test passed on the first commit and my second commit only added comments. |
W-23159884: Add stable test tags to login screen and server/account picker
What & why
Login-screen and server/account-picker UI tests previously anchored on localized
contentDescription/text strings (thesf__*string resources). Those anchors break under non-English locales and right-to-left layouts, which is the accessibility-anchor concern tracked by the parent story.This change introduces stable, locale-invariant
Modifier.testTaganchors and routes all test/page-object code through them.Changes
LoginViewTestTagsobject (com.salesforce.androidsdk.ui.components): the single source of truth for the locale-invariant test-tag resource-ids. Intentionally public so SDK instrumented tests, sample-app page objects (AuthFlowTester), and external UTAM page objects all reference the same constants. Replaces the formerinternal const val TAG_*block inLoginView.kt.LoginView.kt(more-options button, back button, the 6 overflow menu items, loading indicator, login button),PickerBottomSheet.kt(server/account picker containers, back/close buttons, add-connection button, custom label/URL fields, apply button), andLoginServerListItem.kt(server delete + confirm-delete targets).PickerBottomSheetTest.kt(SalesforceSDKTest) andLoginPageObject.kt(AuthFlowTester) to anchor on the tags. Row-identity matchers that assert rendered content (hasText(name) and hasText(url)) are intentionally retained; Espresso WebView fields and the native AlertDialog path are untouched (not Compose / not taggable).Reviewer notes
LoginViewTestTags) — flagged per SDK escalation rules. No metalava/API-validator dump exists in the repo, so nothing to regenerate.sf__strings.xmlchange — these are resource-id test anchors, not user-facing localized strings.testTagsAsResourceId = true, so the tags surface to UIAutomator2/UTAM as Androidresource-ids.Testing