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

Ensure that Presenters do not depend on other presenters. #3618

Merged
merged 16 commits into from
Oct 7, 2024

Conversation

bmarty
Copy link
Member

@bmarty bmarty commented Oct 7, 2024

Content

Do not inject presenter instance in constructor of presenter, but rather inject parameter with type Presenter<State> and provide the implementation in module.

This allow more isolated presenter tests.

Motivation and context

Cleaner code.

Screenshots / GIFs

Should not have any impact

Tests

Does not contain functional change, smoke test on the application should be enough, but please review carefully, maybe commit per commit.

Tested devices

  • Physical
  • Emulator
  • OS version(s):

Checklist

  • Changes have been tested on an Android device or Android emulator with API 23
  • UI change has been tested on both light and dark themes
  • Accessibility has been taken into account. See https://github.com/element-hq/element-x-android/blob/develop/CONTRIBUTING.md#accessibility
  • Pull request is based on the develop branch
  • Pull request title will be used in the release note, it clearly define what will change for the user
  • Pull request includes screenshots or videos if containing UI changes
  • Pull request includes a sign off
  • You've made a self review of your PR

@bmarty bmarty added the PR-Misc For other changes label Oct 7, 2024
@bmarty bmarty requested a review from a team as a code owner October 7, 2024 15:49
@bmarty bmarty requested review from jmartinesp and removed request for a team October 7, 2024 15:49
Copy link
Contributor

github-actions bot commented Oct 7, 2024

📱 Scan the QR code below to install the build (arm64 only) for this PR.
QR code
If you can't scan the QR code you can install the build via this link: https://i.diawi.com/LVcYRT

Copy link

sonarcloud bot commented Oct 7, 2024

Copy link
Member

@jmartinesp jmartinesp left a comment

Choose a reason for hiding this comment

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

LGTM, just a couple of questions.

Also, it's a shame we can't use some typealias and keep using the @ContributeBinding annotation, having to manually define the bindings in modules instead, which is a bit of a PITA. But it's trivial compared to building the fake presenters, so I think the change is for the better.

Also maybe @ganfra should take a look too?

.withoutAnnotationOf(Ignore::class)
.size
println("Number of unit tests: $numberOfTests")
assertThat(numberOfTests).isGreaterThan(2000)
Copy link
Member

Choose a reason for hiding this comment

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

Won't this be obsolete if we keep creating tests?

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, actually, it's just a way to ensure that tests are detected and also a way to show that we have many tests :)


package io.element.android.libraries.fullscreenintent.api

fun aFullScreenIntentPermissionsState(
Copy link
Member

Choose a reason for hiding this comment

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

Should this be public and in the api module? It feels a bit dangerous 🫤 . Maybe it could be part of the fixtures sourceset? Also, the file name doesn't really match the contents.

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, I hesitated, but all our StateProvider files contains a function which create state class instances (for instance aMessageComposerState) and those function are in production code, but I admit, generally in impl modules.

So that's maybe not a big deal?

Copy link
Member Author

Choose a reason for hiding this comment

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

For the name, I keep the name we usually have for state provider... That does not exist, but I could create one, which could be used here:

But since the View is only using the lambda, I guess it does not worth it?

Copy link

codecov bot commented Oct 7, 2024

Codecov Report

Attention: Patch coverage is 91.89189% with 9 lines in your changes missing coverage. Please review.

Project coverage is 82.65%. Comparing base (dd60eaf) to head (d390b4f).
Report is 17 commits behind head on develop.

Files with missing lines Patch % Lines
...mbers/moderation/RoomMembersModerationPresenter.kt 86.95% 2 Missing and 7 partials ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3618      +/-   ##
===========================================
- Coverage    82.67%   82.65%   -0.02%     
===========================================
  Files         1736     1735       -1     
  Lines        41199    41187      -12     
  Branches      5001     5000       -1     
===========================================
- Hits         34060    34042      -18     
- Misses        5372     5380       +8     
+ Partials      1767     1765       -2     

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

@bmarty bmarty added the Run-Maestro Starts a Maestro Cloud session to run integration tests label Oct 7, 2024
@bmarty bmarty enabled auto-merge October 7, 2024 16:51
@github-actions github-actions bot removed the Run-Maestro Starts a Maestro Cloud session to run integration tests label Oct 7, 2024
@bmarty bmarty merged commit 51ee5bf into develop Oct 7, 2024
30 checks passed
@bmarty bmarty deleted the feature/bma/injectPresenter branch October 7, 2024 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR-Misc For other changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants