Best Value: one price age instead of a source breakdown

Dated pricing had crowded More info and the station rows, and most of the
extra copy described a distinction the data cannot make: every station
carries a single station-wide timestamp, so "grade-specific vs
station-wide" never varied in practice.

- More info shows one row, "Price updated 28h ago" (or "Not provided"),
  replacing the separate station-report and fuel-update-time rows and the
  blanket "price freshness is not confirmed" label.
- Rows and the detail sheet stay quiet when a saving is shown; only an
  ineligible comparison explains itself. Provisional savings already read
  as estimates from the capsule, so the fuel-named warning lines are gone.
- Freshness/eligibility logic is unchanged: it still gates the baseline and
  still supports grade-specific timestamps for when the relay emits them.
- Tests updated; localisation keys for the removed copy dropped.
This commit is contained in:
FuelBoard Contributor
2026-10-15 22:00:48 +01:00
parent 5c0458dbf6
commit 5f3051aed7
4 changed files with 44 additions and 64 deletions
@@ -70,37 +70,45 @@ final class FuelPriceFreshnessTests: XCTestCase {
XCTAssertTrue(assessment.displayLabel.contains("station-wide"))
}
func testRecentStationReportExplainsSelectedFuelTimeIsMissing() {
func testMoreInfoReportsOneStationPriceAge() {
let updated = now.addingTimeInterval(-28 * 60 * 60).timeIntervalSince1970
let assessment = FuelPriceFreshness.assessment(for: station(priceUpdated: updated), fuel: .e10, now: now)
XCTAssertEqual(assessment.stationReportAgeLabel, "28h ago")
XCTAssertEqual(assessment.selectedFuelUpdateLabel, "Not provided")
XCTAssertEqual(assessment.updateAgeLabel, "28h ago")
XCTAssertEqual(assessment.source, .stationWide)
XCTAssertEqual(assessment.status, .fresh)
XCTAssertEqual(FuelPriceFreshness.comparisonWarning(
station: station(priceUpdated: updated), fuel: .e10,
baseline: station(priceUpdated: updated), now: now),
"Estimated saving · Unleaded price not individually dated")
}
func testOlderFuelSpecificTimestampDoesNotClaimUndatedPrice() {
func testOlderFuelSpecificTimestampStillReportsItsOwnAgeOnce() {
let updated = now.addingTimeInterval(-10 * 86_400).timeIntervalSince1970
let priced = station(priceUpdatedByFuel: [.diesel: updated])
let assessment = FuelPriceFreshness.assessment(for: priced, fuel: .diesel, now: now)
XCTAssertNil(assessment.stationReportAgeLabel)
XCTAssertEqual(assessment.selectedFuelUpdateLabel, "10d ago")
XCTAssertEqual(FuelPriceFreshness.comparisonWarning(
station: priced, fuel: .diesel, baseline: priced, now: now),
"Estimated saving · Diesel price over 7 days old")
XCTAssertEqual(assessment.updateAgeLabel, "10d ago")
XCTAssertEqual(assessment.source, .gradeSpecific)
}
func testProvisionalWarningNamesBaselineWhenCandidateHasFuelSpecificTimestamp() {
func testMissingUpdateTimeReadsNotProvided() {
let assessment = FuelPriceFreshness.assessment(for: station(), fuel: .e10, now: now)
XCTAssertEqual(assessment.updateAgeLabel, "Not provided")
}
func testProvisionalSavingAddsNoSecondWarningLine() {
let recent = now.addingTimeInterval(-28 * 60 * 60).timeIntervalSince1970
let candidate = station(priceUpdatedByFuel: [.e10: recent])
let baseline = station(priceUpdated: recent)
let stationWide = station(priceUpdated: recent)
let gradeSpecific = station(priceUpdatedByFuel: [.e10: recent])
XCTAssertEqual(FuelPriceFreshness.comparisonConfidence(
station: gradeSpecific, fuel: .e10, baseline: stationWide, now: now), .provisional)
XCTAssertNil(FuelPriceFreshness.comparisonWarning(
station: stationWide, fuel: .e10, baseline: stationWide, now: now))
XCTAssertNil(FuelPriceFreshness.comparisonWarning(
station: gradeSpecific, fuel: .e10, baseline: stationWide, now: now))
}
func testIneligibleComparisonStillExplainsItself() {
let old = now.addingTimeInterval(-FuelPriceFreshness.staleAge - 1).timeIntervalSince1970
let stale = station(priceUpdatedByFuel: [.diesel: old])
XCTAssertEqual(FuelPriceFreshness.comparisonWarning(
station: candidate, fuel: .e10, baseline: baseline, now: now),
"Estimated saving · closest eligible station's Unleaded price not individually dated")
station: stale, fuel: .diesel, baseline: stale, now: now),
"Price age unavailable or too old — not a Best Value recommendation.")
}
func testStationWideTimestampAtWarningBoundaryChangesRecommendationEligibility() {