Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(in-app-messaging): add in-app messaging component and context unit tests #9551

Conversation

calebpollman
Copy link
Member

Description of changes

  • add unit tests for InAppMessaging UI components and React context

Issue #, if available

NA

Description of how you validated changes

yarn test

Checklist

  • PR description included
  • yarn test passes
  • Tests are changed or added
  • Relevant documentation is changed or added (and PR referenced)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@calebpollman calebpollman requested review from cshfang, reesscot and elorzafe and removed request for Ashish-Nanda February 3, 2022 17:18
@codecov-commenter
Copy link

Codecov Report

Merging #9551 (49b3e2c) into in-app-messaging/staging (5bba396) will increase coverage by 0.34%.
The diff coverage is 100.00%.

Impacted file tree graph

@@                     Coverage Diff                      @@
##           in-app-messaging/staging    #9551      +/-   ##
============================================================
+ Coverage                     74.36%   74.70%   +0.34%     
============================================================
  Files                           312      312              
  Lines                         20219    20223       +4     
  Branches                       4406     4410       +4     
============================================================
+ Hits                          15036    15108      +72     
+ Misses                         5044     4977      -67     
+ Partials                        139      138       -1     
Impacted Files Coverage Δ
...ges/aws-amplify-react-native/src/AmplifyTestIDs.js 100.00% <ø> (+100.00%) ⬆️
...ssaging/components/BannerMessage/BannerMessage.tsx 100.00% <100.00%> (+100.00%) ⬆️
...components/FullScreenMessage/FullScreenMessage.tsx 100.00% <100.00%> (+100.00%) ⬆️
.../InAppMessaging/context/InAppMessagingProvider.tsx 100.00% <100.00%> (+100.00%) ⬆️
.../InAppMessaging/components/BannerMessage/styles.ts 100.00% <0.00%> (+33.33%) ⬆️
...-native/src/InAppMessaging/ui/IconButton/styles.ts 100.00% <0.00%> (+50.00%) ⬆️
...ppMessaging/components/FullScreenMessage/styles.ts 100.00% <0.00%> (+50.00%) ⬆️
... and 7 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5bba396...49b3e2c. Read the comment docs.

Copy link
Contributor

@elorzafe elorzafe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall, just a few questions.

@@ -19,7 +19,7 @@ import {
} from '../types';

export interface BannerMessageProps extends InAppMessageComponentBaseProps {
position: InAppMessageComponentPosition;
position?: InAppMessageComponentPosition;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would happen if position is missing? Probably is protected wherever it is used. Just to check after

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏽 There is a default value in the BannerMessage component

>
{children}
</InAppMessagingContext.Provider>
const value = useMemo(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you see an improvement in terms of performance? How did you measure it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After looking in to perf again, not sure we need it at this time. Will remove for now

Comment on lines +39 to +46
<Text
style={
Array [
Object {
"alignSelf": "center",
},
undefined,
]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the default child component when passing a String as child?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes - React Native will crash on a string pass a child that is not wrapped inside a Text component. Button has a conditional checking for whether the child is a string, and wrapping with a center aligned Text if not

Comment on lines +56 to +63
TestRenderer.act(() => {
renderer = TestRenderer.create(
<InAppMessagingProvider>
<TestComponent />
</InAppMessagingProvider>
);
});
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a little odd, I didnt get completely how all tests are using this renderervariable

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can see that. If you feel strongly will move inside each it block

Copy link
Contributor

@david-mcafee david-mcafee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🎉

Copy link
Contributor

@elorzafe elorzafe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks @calebpollman 🌮 🎉

@calebpollman calebpollman merged commit 9b33c04 into aws-amplify:in-app-messaging/staging Feb 7, 2022
@github-actions
Copy link

github-actions bot commented Feb 8, 2023

This pull request has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels or Discussions for those types of questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants