Skip to content

Commit

Permalink
update ui test
Browse files Browse the repository at this point in the history
  • Loading branch information
hiroaki404 committed Sep 10, 2024
1 parent c59ec98 commit 7734bbb
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,9 @@ class TimetableScreenTest(private val testCase: DescribedBehavior<TimetableScree
dateTime = LocalDateTime(
year = 2024,
monthNumber = 9,
dayOfMonth = 12,
hour = 16,
minute = 45,
dayOfMonth = 11,
hour = 10,
minute = 0,
),
shouldShowTimeLine = false,
),
Expand All @@ -196,51 +196,21 @@ class TimetableScreenTest(private val testCase: DescribedBehavior<TimetableScree
year = 2024,
monthNumber = 9,
dayOfMonth = 12,
hour = 23,
minute = 0,
hour = 10,
minute = 30,
),
shouldShowTimeLine = true,
),
).forEach { case ->
val formattedDateTime =
case.dateTime.format(LocalDateTime.Format { byUnicodePattern("yyyy-MM-dd HH-mm") })
describe("when the current datetime is $formattedDateTime") {
doIt {
setupTimetableServer(ServerStatus.Operational)
setupTimetableScreenContent(case.dateTime)
}

val formattedTime =
case.dateTime.time.format(LocalTime.Format { byUnicodePattern("HH-mm") })
val description = "show an timetable item of the current time at $formattedTime"
itShould(description) {
captureScreenWithChecks {
checkTimetableListDisplayed()
}
}
}
}
listOf(
TimeLineTestSpec(
dateTime = LocalDateTime(
year = 2024,
monthNumber = 9,
dayOfMonth = 11,
hour = 10,
dayOfMonth = 12,
hour = 23,
minute = 0,
),
shouldShowTimeLine = false,
),
TimeLineTestSpec(
dateTime = LocalDateTime(
year = 2024,
monthNumber = 9,
dayOfMonth = 12,
hour = 10,
minute = 30,
),
shouldShowTimeLine = true,
),
TimeLineTestSpec(
dateTime = LocalDateTime(
year = 2024,
Expand All @@ -258,19 +228,28 @@ class TimetableScreenTest(private val testCase: DescribedBehavior<TimetableScree
doIt {
setupTimetableServer(ServerStatus.Operational)
setupTimetableScreenContent(case.dateTime)
clickTimetableUiTypeChangeButton()
}

val formattedTime =
case.dateTime.time.format(LocalTime.Format { byUnicodePattern("HH-mm") })
val description = if (case.shouldShowTimeLine) {
"show an indicator of the current time at $formattedTime"
} else {
"not show an indicator of the current time"
}
itShould(description) {
val timetableListDescription = "show an timetable item of the current time at $formattedTime"
itShould(timetableListDescription) {
captureScreenWithChecks {
checkTimetableGridDisplayed()
checkTimetableListDisplayed()
}
}
describe("switch to grid timetable") {
doIt {
clickTimetableUiTypeChangeButton()
}
val timetableGridDescription = if (case.shouldShowTimeLine) {
"show an indicator of the current time at $formattedTime"
} else {
"not show an indicator of the current time"
}
itShould(timetableGridDescription) {
captureScreenWithChecks {
checkTimetableGridDisplayed()
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ internal fun TimetableList(
val progressingSessionIndex = uiState.timetableItemMap.keys
.insertDummyEndOfTheDayItem() // Insert dummy at a position after last session to allow scrolling
.windowed(2, 1, true)
.indexOfFirst { clock.now().toLocalTime() in it.first().startTime..it.last().startTime }
.indexOfFirst { clock.now().toLocalTime() in it.first().startTime..<it.last().startTime }

progressingSessionIndex.takeIf { it != -1 }?.let {
scrollState.scrollToItem(it)
Expand Down

0 comments on commit 7734bbb

Please sign in to comment.