Skip to content

Commit

Permalink
Add maestro e2e test for Legacy Style Event (#46784)
Browse files Browse the repository at this point in the history
Summary:
part of #46757
closes ME2E0006, ME2E0007

## Changelog:

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[Internal] - add e2e test for Legacy Style Event

Pull Request resolved: #46784

Test Plan:
```
yarn e2e-test-ios
yarn e2e-test-android
```

Reviewed By: cortinico

Differential Revision: D64172277

Pulled By: cipolleschi

fbshipit-source-id: adf3a55b354f1a293c4620dc617a6a08e3aebd2b
  • Loading branch information
tarunrajput authored and facebook-github-bot committed Oct 15, 2024
1 parent 118c1f7 commit 3f63347
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
5 changes: 5 additions & 0 deletions packages/rn-tester/.maestro/new-arch-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,8 @@ appId: ${APP_ID} # iOS: com.meta.RNTester.localDevelopment | Android: com.facebo
text: "InWindow x: 0, y: 0, width: 0, height: 0"
- assertNotVisible:
text: "InLayout x: 0, y: 0, width: 0, height: 0"
- assertVisible: "Legacy Style Event Fired 0 times"
- tapOn:
text: "Fire Legacy Style Event"
repeat: 10
- assertVisible: "Legacy Style Event Fired 10 times"
23 changes: 14 additions & 9 deletions packages/rn-tester/NativeComponentExample/js/MyNativeView.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export default function MyNativeView(props: {}): React.Node {
useState<MeasureStruct>(MeasureStructZero);
const [legacyMeasureLayout, setLegacyMeasureLayout] =
useState<MeasureStruct>(MeasureStructZero);
const [legacyStyleEventCount, setLegacyStyleEventCount] = useState<number>(0);

return (
<View ref={containerRef} style={{flex: 1}}>
Expand All @@ -130,6 +131,7 @@ export default function MyNativeView(props: {}): React.Node {
console.log(event.nativeEvent.multiArrays);
}}
onLegacyStyleEvent={event => {
setLegacyStyleEventCount(prevCount => prevCount + 1);
console.log(event.nativeEvent.string);
}}
/>
Expand Down Expand Up @@ -242,15 +244,6 @@ export default function MyNativeView(props: {}): React.Node {
}
}}
/>
<Button
title="Fire Legacy Style Event"
onPress={() => {
RNTMyNativeViewCommands.fireLagacyStyleEvent(
// $FlowFixMe[incompatible-call]
ref.current,
);
}}
/>
<Text style={{color: 'green', textAlign: 'center'}}>
&gt; Interop Layer Measurements &lt;
</Text>
Expand All @@ -263,6 +256,18 @@ export default function MyNativeView(props: {}): React.Node {
<Text style={{color: 'green', textAlign: 'center'}}>
InLayout {getTextFor(legacyMeasureLayout)}
</Text>
<Button
title="Fire Legacy Style Event"
onPress={() => {
RNTMyNativeViewCommands.fireLagacyStyleEvent(
// $FlowFixMe[incompatible-call]
ref.current,
);
}}
/>
<Text style={{color: 'green', textAlign: 'center'}}>
Legacy Style Event Fired {legacyStyleEventCount} times
</Text>
<Button
title="Test setNativeProps"
onPress={() => {
Expand Down

0 comments on commit 3f63347

Please sign in to comment.