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

Add tests to verify DroidKaigi2024Day and the initially displayed timetable tab #482

Conversation

mannodermaus
Copy link
Contributor

Issue

Overview (Required)

  • Add unit tests for DroidKaigi2024Day:
    Introduce kotlin-test to allow for multiplatform unit tests of logic that doesn't require any UI components
  • Simplify DroidKaigi2024Day enum and fix end-of-day logic:
    The 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
  • Extend fake clock capabilities & add robot test for the second day, too:
    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)

Screenshot 2024-08-15 at 20 31 55

.height(64.dp),
selected = false,
Copy link
Contributor Author

@mannodermaus mannodermaus Aug 15, 2024

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.

Copy link
Member

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. 😭

@github-actions github-actions bot temporarily deployed to deploygate-distribution August 15, 2024 11:40 Inactive
@mannodermaus mannodermaus marked this pull request as ready for review August 15, 2024 11:51
public val start: Instant,
public val end: Instant,
private val visibleForUsers: Boolean,
private val date: LocalDate,
Copy link
Member

Choose a reason for hiding this comment

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

Elegant solution 🎉

Copy link
Member

@takahirom takahirom left a 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)
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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,
Copy link
Member

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)
Copy link
Member

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.

Copy link
Contributor Author

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

Copy link
Contributor Author

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

Screenshot 2024-08-16 at 9 01 37

Copy link
Member

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...)
@mannodermaus mannodermaus force-pushed the test/timetable-default-tab-based-on-today branch from 577139f to be8b056 Compare August 15, 2024 23:59
@github-actions github-actions bot temporarily deployed to deploygate-distribution August 16, 2024 00:09 Inactive
@takahirom takahirom added the awesome Label for project-applicable insights or remarkable technologies. label Aug 16, 2024
Copy link
Member

@takahirom takahirom left a 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.

@takahirom takahirom merged commit edd88b0 into DroidKaigi:main Aug 16, 2024
9 checks passed
@mannodermaus mannodermaus deleted the test/timetable-default-tab-based-on-today branch August 16, 2024 03:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awesome Label for project-applicable insights or remarkable technologies.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add tests for each conference day
2 participants