Skip to content

[Polls] Add unit tests for TimelineItemContentPollFactory #1161

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

Merged
merged 2 commits into from
Aug 30, 2023

Conversation

Florian14
Copy link
Contributor

Type of change

  • Feature
  • Bugfix
  • Technical
  • Other : add missing tests

Content

Add unit tests for TimelineItemContentPollFactory.

Motivation and context

Ensure the TimelineItemContentPollFactory produces the expected UI models from a PollContent.
Check that correct answers are detected as winners and that votes are only disclosed when they are supposed to be.

Checklist

@Florian14 Florian14 requested a review from a team as a code owner August 28, 2023 16:55
@Florian14 Florian14 requested review from bmarty and removed request for a team August 28, 2023 16:55
@github-actions
Copy link
Contributor

github-actions bot commented Aug 28, 2023

📱 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/YteP46

@codecov
Copy link

codecov bot commented Aug 28, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.14% 🎉

Comparison is base (5a85459) 56.87% compared to head (992050c) 57.01%.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1161      +/-   ##
===========================================
+ Coverage    56.87%   57.01%   +0.14%     
===========================================
  Files         1039     1039              
  Lines        26812    26817       +5     
  Branches      5544     5544              
===========================================
+ Hits         15248    15291      +43     
+ Misses        9168     9127      -41     
- Partials      2396     2399       +3     
Files Changed Coverage Δ
.../factories/event/TimelineItemContentPollFactory.kt 91.42% <ø> (+83.09%) ⬆️
...pl/timeline/model/event/TimelineItemPollContent.kt 100.00% <ø> (ø)
...ine/model/event/TimelineItemPollContentProvider.kt 100.00% <ø> (ø)
.../element/android/libraries/matrix/test/TestData.kt 100.00% <100.00%> (ø)

... and 2 files with indirect coverage changes

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

Copy link
Member

@bmarty bmarty 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 adding tests on this area. Some non-blocking remarks.

A_POLL_ANSWER_4.id to listOf(A_USER_ID_10),
)
Truth.assertThat(
factory.create(aPollContent(PollKind.Disclosed).copy(votes = votes))
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Instead of copying, maybe add more parameters with default values to the fun aPollContent? Same remark for aTimelineItemPollContent and aPollAnswerItem.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, I tried to factorize a bit. I chose to duplicate the parameters to have a better view of the initial state and the resulting state at the same time.
Let me know if you prefer this format. I could not find a way to deduplicate the expected results since there are some differences on each test case :/

@Florian14 Florian14 force-pushed the feature/fre/polls_timeline_item_tests branch from 18645c3 to fb6a036 Compare August 29, 2023 14:00
@Florian14 Florian14 force-pushed the feature/fre/polls_timeline_item_tests branch from fb6a036 to 992050c Compare August 29, 2023 14:02
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

Copy link
Member

@bmarty bmarty 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 the update!

@Florian14 Florian14 merged commit 48413bd into develop Aug 30, 2023
@Florian14 Florian14 deleted the feature/fre/polls_timeline_item_tests branch August 30, 2023 06:32
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