-
Notifications
You must be signed in to change notification settings - Fork 200
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
Add tests to verify DroidKaigi2024Day and the initially displayed timetable tab #482
Add tests to verify DroidKaigi2024Day and the initially displayed timetable tab #482
Conversation
.height(64.dp), | ||
selected = false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what I was referencing earlier with the "hardcoded selected = false
". I want to make sure that I'm not overlooking anything by changing this, so I'm highlighting it here again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I think that was my mistake. 😭
public val start: Instant, | ||
public val end: Instant, | ||
private val visibleForUsers: Boolean, | ||
private val date: LocalDate, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Elegant solution 🎉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clean and readable! I would like to add some tests, but the test codes and refactoring look great.
|
||
@Test | ||
fun `returns Day1 on September 12 2024`() { | ||
val day1 = LocalDate(2024, 9, 12) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. This is just our conference domain language, but we don't say 'day1' because it could cause confusion this year. How about sep12Date or some other name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Understood. I think I prefer the more neutral date
for all of the test cases then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Test | ||
fun `initialSelectedTabDay returns Day1 on any date except for the second conference day`() { | ||
runTest( | ||
expected = DroidKaigi2024Day.ConferenceDay1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
@@ -46,6 +48,7 @@ class TimetableScreenTest(private val testCase: DescribedBehavior<TimetableScree | |||
captureScreenWithChecks(checks = { | |||
checkTimetableListDisplayed() | |||
checkTimetableListItemsDisplayed() | |||
checkTimetableTabSelected(DroidKaigi2024Day.ConferenceDay1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. My main concern is the potential for the app to crash on the day of the event. If we could conduct tests on 9/11 and 9/12 as well, that would be great. We might implement features such as a timeline for the timetable grid view or an "ongoing" label for the sessions, which could potentially cause issues on the event day.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call! It's very easy to set up with robospec, kudos for that: be8b056
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had to make another commit because the generated screenshot files had an unexpected intermediary folder when I added e.g. 9/12
to the output (because of the slash). 😆 I guess this is expected, but threw me off for a minute. Fixed in d4ccfa2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have never thought of this! 👍 This code rocks!
Introduce kotlin-test to allow for multiplatform unit tests of logic that doesn't require any UI components
The current declaration makes the day "end" at 23:59:59, but in the 999 milliseconds afterwards the behavior would've been undefined. Declare the end time explicitly with 999_999_999 nanoseconds to cover the entirety of each day
This required a change in how the tabs store their selection state (not sure why it was hardcoded at `selected = false` before...)
577139f
to
be8b056
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clean and readable! Thank you for your awesome contribution.
Issue
Overview (Required)
Introduce
kotlin-test
to allow for multiplatform unit tests of logic that doesn't require any UI componentsThe current declaration makes the day "end" at 23:59:59, but in the last second the behavior would've been undefined.
Declare the end time explicitly with 999_999_999 nanoseconds to cover the entirety of each day
This required a change in how the tabs store their selection state (not sure why it was hardcoded at
selected = false
before...)Links
Screenshot (Optional if screenshot test is present or unrelated to UI)