You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Button: add a test that pins its Android ripple to the opaque label color #5367
#5177 made TouchableRipple apply the MD3 pressed opacity (0.10) itself, so components now pass it an opaque content color. Button passes its label color as rippleColor, which is right, but no Button test pins it. IconButton, FAB and FAB.Menu got such tests in #5177. Until #5177, Button baked 0.10 into its own ripple color. Doing that again on top of the ripple's 0.10 would draw the press at about 0.01, and nothing would catch it today.
Proposed test
A describe block at the end of src/components/__tests__/Button.test.tsx. It checks what the ripple gets on Android with React Native 0.86 (nativeForegroundAndroid), so it tests the rendered result rather than an internal helper.
Imports to add: processColor from react-native, beforeEach from @jest/globals, and TouchableRipple from ../TouchableRipple/TouchableRipple.native.
// Button passes its opaque label color as the ripple color, and// TouchableRipple applies the pressed opacity once, as the ripple's `alpha`.describe('ripple on Android',()=>{beforeEach(()=>{jest.replaceProperty(Platform,'OS','android');jest.replaceProperty(TouchableRipple,'supported',true);jest.spyOn(Platform,'Version','get').mockReturnValue(34);constconstants=Platform.constants;jest.spyOn(Platform,'constants','get').mockReturnValue({
...constants,reactNativeVersion: {major: 0,minor: 86,patch: 0,prerelease: undefined,},});});it.each([['text',LightTheme.colors.primary],['filled',LightTheme.colors.onPrimary],]asconst)('draws the %s button ripple in its opaque label color at the pressed alpha',async(mode,labelColor)=>{awaitrender(<Buttonmode={mode}testID="button"onPress={()=>{}}>
Save
</Button>);expect(screen.getByTestId('button')).toHaveProp('nativeForegroundAndroid',expect.objectContaining({type: 'RippleAndroid',color: processColor(labelColor),alpha: stateOpacity.pressed,}));});});
It passes on main (c05552f) with lint clean, and both cases fail if Button passes its label color at 0.10 as rippleColor.
Activity