fix: remove derived testIDs - #5099
Draft
k0ndee wants to merge 1 commit into
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Many components generated "derived" testIDs by appending a hardcoded suffix to the user-supplied
testIDprop (e.g.${testID}-container,${testID}-outer-layer,${testID}-text) so that tests could reach into internal, non-public parts of a component's render tree.This PR removes every derived testID suffix from the library and updates the corresponding tests to assert public, user-visible behavior instead (accessible role/label/text queries, or the component's own real interactive element's
testID). Where a check was genuinely about an internal implementation detail with no public equivalent (e.g. which of Surface's two iOS shadow layers a style lands on, or an in-flight animated value), the test was converted to a full render (toJSON()) snapshot instead of reaching into a specific internal node. Tests that turned out to assert nothing observable once the derived testID was gone were removed.Affected components:
Surface,Button,IconButton,CrossFadeIcon,Appbar(AppbarHeader,AppbarContent),ProgressBar,Chip,ListItem,Card,FAB(Content,Shell,Menu),SegmentedButtonItem,CheckboxItem,DataTableCell,Searchbar,Snackbar,Banner,ToggleButton,Menu/MenuItem,Modal,Dialog,DrawerCollapsedItem,BottomNavigation/BottomNavigationBar.Related issue
None. This is an internal contributor task.
Test plan
yarn jest— full suite passes (55 suites, 729 tests, 299 snapshots).yarn eslint src— no violations (includingtesting-library/no-node-accessand the repo'sno-restricted-syntaxrule against raw.propsaccess).yarn typecheck— no type errors.testIDline, with no unrelated structural or style changes.testIDattributes themselves).