Skip to content

Commit a93b641

Browse files
committed
Update time limit for today tab
1 parent 35b4586 commit a93b641

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

WooCommerce/Classes/Bookings/BookingList/BookingListContainerViewModel.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@ enum BookingListTab: Int, CaseIterable {
4848

4949
func startDateBefore(currentDate: Date) -> Date? {
5050
switch self {
51-
case .today: currentDate.endOfDay(timezone: Self.utcTimeZone)
51+
case .today: currentDate.endOfDay(timezone: Self.utcTimeZone).addingTimeInterval(1)
5252
case .upcoming, .all: nil
5353
}
5454
}
5555

5656
func startDateAfter(currentDate: Date) -> Date? {
5757
switch self {
58-
case .today: currentDate.startOfDay(timezone: Self.utcTimeZone)
58+
case .today: currentDate.startOfDay(timezone: Self.utcTimeZone).addingTimeInterval(-1)
5959
case .upcoming: currentDate.endOfDay(timezone: Self.utcTimeZone)
6060
case .all: nil
6161
}

WooCommerce/Classes/Bookings/BookingList/BookingListView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ private extension BookingListView {
5757
VStack(alignment: .leading) {
5858
Text(booking.startDate.toString(dateStyle: .short,
5959
timeStyle: .short,
60-
timeZone: TimeZone(identifier: "UTC")!))
60+
timeZone: BookingListTab.utcTimeZone))
6161
.font(.body)
6262
.fontWeight(.medium)
6363
.frame(maxWidth: .infinity, alignment: .leading)

WooCommerce/WooCommerceTests/ViewRelated/Bookings/BookingListViewModelTests.swift

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,8 @@ struct BookingListViewModelTests {
337337
viewModel.loadBookings()
338338

339339
// Then
340-
#expect(capturedStartDateAfter == "2021-01-01T00:00:00Z", "Today tab should filter after start of day")
341-
#expect(capturedStartDateBefore == "2021-01-01T23:59:59Z", "Today tab should filter before end of day")
340+
#expect(capturedStartDateAfter == "2020-12-31T23:59:59Z", "Today tab should filter after start of day")
341+
#expect(capturedStartDateBefore == "2021-01-02T00:00:00Z", "Today tab should filter before end of day")
342342
}
343343

344344
@Test func upcoming_tab_passes_correct_date_filters_to_booking_action() {
@@ -471,16 +471,16 @@ struct BookingListViewModelTests {
471471
// Given
472472
let testDate = Date(timeIntervalSince1970: 1609459200) // 2021-01-01 00:00:00 UTC
473473
let todayStart = testDate.startOfDay(timezone: BookingListTab.utcTimeZone)
474-
let todayEnd = testDate.endOfDay(timezone: BookingListTab.utcTimeZone)
474+
let nextDayStart = testDate.endOfDay(timezone: BookingListTab.utcTimeZone).addingTimeInterval(1)
475475

476476
// Create bookings with different start dates
477-
let withinTodayBooking = createBooking(id: 1, startDate: todayStart.addingTimeInterval(3600)) // 1 hour after start
478-
let beforeTodayBooking = createBooking(id: 2, startDate: todayStart.addingTimeInterval(-3600)) // 1 hour before start
479-
let afterTodayBooking = createBooking(id: 3, startDate: todayEnd.addingTimeInterval(3600)) // 1 hour after end
480-
let atStartOfDayBooking = createBooking(id: 4, startDate: todayStart) // Exactly at start
481-
let atEndOfDayBooking = createBooking(id: 5, startDate: todayEnd) // Exactly at end
477+
let atStartOfDayBooking = createBooking(id: 1, startDate: todayStart) // Exactly at start
478+
let withinTodayBooking = createBooking(id: 2, startDate: todayStart.addingTimeInterval(3600)) // 1 hour after start
479+
let beforeTodayBooking = createBooking(id: 3, startDate: todayStart.addingTimeInterval(-3600)) // 1 hour before start
480+
let afterTodayBooking = createBooking(id: 4, startDate: nextDayStart.addingTimeInterval(3600)) // 1 hour after end
481+
let startOfNextDayBooking = createBooking(id: 5, startDate: nextDayStart) // First second of next day
482482

483-
insertBookings([withinTodayBooking, beforeTodayBooking, afterTodayBooking, atStartOfDayBooking, atEndOfDayBooking])
483+
insertBookings([withinTodayBooking, beforeTodayBooking, afterTodayBooking, atStartOfDayBooking, startOfNextDayBooking])
484484

485485
let viewModel = BookingListViewModel(siteID: sampleSiteID,
486486
type: .today,
@@ -489,8 +489,8 @@ struct BookingListViewModelTests {
489489
currentDate: testDate)
490490

491491
// When/Then - should only show bookings within today (startDate > start AND startDate < end)
492-
#expect(viewModel.bookings.count == 1, "Today tab should only show bookings within today")
493-
#expect(viewModel.bookings.first?.bookingID == withinTodayBooking.bookingID, "Should contain only the booking within today")
492+
#expect(viewModel.bookings.count == 2)
493+
#expect(viewModel.bookings.first?.bookingID == withinTodayBooking.bookingID)
494494
}
495495

496496
@Test func upcoming_tab_results_controller_filters_local_storage_correctly() {

0 commit comments

Comments
 (0)