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

Fix some test and non-test warnings #5294

Merged
merged 2 commits into from
Jan 10, 2025

Conversation

julienw
Copy link
Contributor

@julienw julienw commented Jan 6, 2025

This fixes 2 warnings:

  1. When running ProfileName.test. Here the problem was that we were calling button.click instead of fireEvent.click. The former isn't wrapped by act while the latter is.
  2. When running MenuButtons.test. Here the problem was the change in the order of the state changes apply (redux vs react components); see the comment in the component for more information.

@julienw julienw requested a review from canova January 6, 2025 18:58
Copy link

codecov bot commented Jan 6, 2025

Codecov Report

Attention: Patch coverage is 87.50000% with 1 line in your changes missing coverage. Please review.

Project coverage is 88.61%. Comparing base (64e89aa) to head (61f1010).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
src/components/app/MenuButtons/index.js 87.50% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5294      +/-   ##
==========================================
- Coverage   88.61%   88.61%   -0.01%     
==========================================
  Files         308      308              
  Lines       28125    28122       -3     
  Branches     7621     7620       -1     
==========================================
- Hits        24923    24920       -3     
  Misses       2987     2987              
  Partials      215      215              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@canova canova left a comment

Choose a reason for hiding this comment

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

Thanks for fixing the warnings! Looks good to me, but let me know what you think about the comment below. It's fine by me if you choose to go with the current approach too.

Comment on lines 134 to 146
// As of React 18, If the action dispatch isn't delayed, the component will
// get rerendered with the redux changes before the react state changes are
// applied. As a result CurrentProfileUploadedInformationLoader could reset
// the profile information faster than this metaInfoPanelState was applied,
// and we were getting an error in _renderMetaInfoButton.
// Using requestAnimationFrame ensures that this component's state
// is properly applied before changing the redux state. Note that if we were
// using a function component, we could use useLayoutEffect instead.
// Note that this might not be necessary in future versions of React or
// React-Redux, so be sure to revisit this choice in the future.
requestAnimationFrame(() => {
this.props.profileRemotelyDeleted();
});
Copy link
Member

@canova canova Jan 8, 2025

Choose a reason for hiding this comment

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

Hm this is a bit hacky, but if it works it's okay for me I guess. Do we always know for sure that requestAnimationFrame will be enough for it to update the state?

Another solution might be to have a componentDidUpdate that checks if the metaInfoPanelState state has changed, and calls profileRemotelyDeleted only if it's changed.

@julienw julienw force-pushed the fix-some-test-warnings branch from 48da62f to 61f1010 Compare January 9, 2025 14:34
@julienw julienw requested a review from canova January 9, 2025 14:38
@julienw
Copy link
Contributor Author

julienw commented Jan 9, 2025

Hey @canova , I updated the code like we discussed, this looks better to me, thanks for the feedback!

Copy link
Member

@canova canova 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 to me! Also tested it and it works well, thanks!

@julienw julienw merged commit 6366efb into firefox-devtools:main Jan 10, 2025
17 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants