Skip to content

Commit d80301e

Browse files
Copilotanupriya13
andcommitted
Fix missing testIDs for existing button containers and enhance dynamic style test
Co-authored-by: anupriya13 <[email protected]>
1 parent af5d124 commit d80301e

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

packages/@react-native/tester/js/examples/Button/ButtonExample.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ exports.examples = [
7272
<RNTesterThemeContext.Consumer>
7373
{theme => {
7474
return (
75-
<View style={styles.container}>
75+
<View style={styles.container} testID="two_button_container">
7676
<Button
7777
onPress={() => onButtonPress('cancelled')}
7878
testID="two_cancel_button"
@@ -101,7 +101,7 @@ exports.examples = [
101101
<RNTesterThemeContext.Consumer>
102102
{theme => {
103103
return (
104-
<View style={styles.container}>
104+
<View style={styles.container} testID="three_button_container">
105105
<Button
106106
onPress={() => onButtonPress('cancelled')}
107107
testID="three_cancel_button"
@@ -336,7 +336,7 @@ function DynamicStyleButton(): React.Node {
336336
return (
337337
<RNTesterThemeContext.Consumer>
338338
{theme => (
339-
<View style={[styles.dynamicContainer, isPressed && styles.pressedContainer]}>
339+
<View style={[styles.dynamicContainer, isPressed && styles.pressedContainer]} testID="dynamic_style_container">
340340
<Button
341341
onPress={onPress}
342342
testID="dynamic_style_button"

packages/e2e-test-app-fabric/test/ButtonComponentTest.test.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,11 @@ describe('Button Tests', () => {
215215
const component = await app.findElementByTestID('dynamic_style_button');
216216
await component.waitForDisplayed({timeout: 5000});
217217

218-
// Get initial state
218+
// Get initial state of both button and container
219219
const initialDump = await dumpVisualTree('dynamic_style_button');
220220
expect(initialDump).toMatchSnapshot('initial-styling');
221+
const initialContainerDump = await dumpVisualTree('dynamic_style_container');
222+
expect(initialContainerDump).toMatchSnapshot('initial-container-styling');
221223

222224
// Click to change styling
223225
await component.click();
@@ -226,5 +228,9 @@ describe('Button Tests', () => {
226228
const updatedDump = await dumpVisualTree('dynamic_style_button');
227229
expect(updatedDump).toMatchSnapshot('updated-styling');
228230
expect(updatedDump.Text).toContain('Style Button (1)');
231+
232+
// Also verify container styling changed
233+
const updatedContainerDump = await dumpVisualTree('dynamic_style_container');
234+
expect(updatedContainerDump).toMatchSnapshot('updated-container-styling');
229235
});
230236
});

0 commit comments

Comments
 (0)