diff --git a/Modules/Sources/Networking/Model/Copiable/Models+Copiable.generated.swift b/Modules/Sources/Networking/Model/Copiable/Models+Copiable.generated.swift index e236694ea40..d253c95e65b 100644 --- a/Modules/Sources/Networking/Model/Copiable/Models+Copiable.generated.swift +++ b/Modules/Sources/Networking/Model/Copiable/Models+Copiable.generated.swift @@ -5,6 +5,7 @@ import Codegen import Foundation import WooFoundation import struct Alamofire.JSONEncoding +import struct NetworkingCore.JetpackSite extension Networking.AIProduct { diff --git a/Modules/Tests/YosemiteTests/PointOfSale/POSCouponTests.swift b/Modules/Tests/YosemiteTests/PointOfSale/POSCouponTests.swift index 1d700af32c8..921881202e2 100644 --- a/Modules/Tests/YosemiteTests/PointOfSale/POSCouponTests.swift +++ b/Modules/Tests/YosemiteTests/PointOfSale/POSCouponTests.swift @@ -31,10 +31,34 @@ struct POSCouponTests { @Test func test_isExpired_when_current_date_then_returns_true() { // Given - let now = Date() + let now = fixedDate(daysFromReference: 0) let coupon = POSCoupon(id: UUID(), code: "expired-now", dateExpires: now) // Then #expect(coupon.isExpired == true, "A coupon expiring at the current time should be considered expired") } } + +private extension POSCouponTests { + /// Returns a fixed date with optional day offset + /// - Parameter daysFromReference: Number of days to add/subtract from the reference date (0 = reference date) + /// - Returns: A fixed date + func fixedDate(daysFromReference: Int = 0) -> Date { + var components = DateComponents() + components.year = 2024 + components.month = 6 + components.day = 15 + components.hour = 12 + components.minute = 0 + components.second = 0 + components.timeZone = TimeZone(identifier: "UTC") + + guard let baseDate = Calendar(identifier: .gregorian).date(from: components) else { + // Fallback to the same date (2024-06-15 12:00:00 UTC) if calendar creation fails + return Date(timeIntervalSince1970: 1718452800) + } + guard daysFromReference != 0 else { return baseDate } + + return Calendar.current.date(byAdding: .day, value: daysFromReference, to: baseDate) ?? baseDate + } +}