Rewrote 60+ test files to follow honeydue-style test guidelines:
- defaultTimeout=2s, navigationTimeout=5s — fail fast, no long waits
- No coordinate taps (except onboarding paged TabView swipes)
- No sleep(), no retry loops
- No guard...else { return } silent passes — XCTFail everywhere
- All elements by accessibility ID via UITestID constants
- Screen objects for all navigation/actions/assertions
- One logical assertion per test method
Added missing accessibility identifiers to app views:
- MonthView.swift: added AccessibilityID.MonthView.grid to ScrollView
- YearView.swift: added AccessibilityID.YearView.heatmap to ScrollView
Framework rewrites:
- BaseUITestCase: added session ID, localeArguments, extraLaunchArguments
- WaitHelpers: waitForExistenceOrFail, waitUntilHittableOrFail,
waitForNonExistence, scrollIntoView, forceTap
- All 7 screen objects rewritten with fail-fast semantics
- TEST_RULES.md added with non-negotiable rules
Known remaining issues:
- OnboardingTests: paged TabView swipes unreliable on iOS 26 simulator
- SettingsLegalLinksTests: EULA/Privacy buttons too deep in DEBUG scroll
- Customization horizontal picker scrolling needs further tuning
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
58 lines
2.1 KiB
Swift
58 lines
2.1 KiB
Swift
//
|
|
// Tests_iOS.swift
|
|
// Tests iOS
|
|
//
|
|
// Unit tests for date utility logic.
|
|
//
|
|
|
|
import XCTest
|
|
|
|
// Local copy -- UI test target cannot @testable import Reflect
|
|
private extension Date {
|
|
static func dates(from fromDate: Date, toDate: Date, includingToDate: Bool = false) -> [Date] {
|
|
var dates: [Date] = []
|
|
var date = Calendar.current.date(bySettingHour: 0, minute: 0, second: 0, of: fromDate)!
|
|
let toDate = Calendar.current.date(bySettingHour: 0, minute: 0, second: 0, of: toDate)!
|
|
|
|
if includingToDate {
|
|
while date <= toDate {
|
|
dates.append(date)
|
|
guard let newDate = Calendar.current.date(byAdding: .day, value: 1, to: date) else { break }
|
|
date = newDate
|
|
}
|
|
} else {
|
|
while date < toDate {
|
|
dates.append(date)
|
|
guard let newDate = Calendar.current.date(byAdding: .day, value: 1, to: date) else { break }
|
|
date = newDate
|
|
}
|
|
}
|
|
|
|
return dates
|
|
}
|
|
}
|
|
|
|
final class Tests_iOS: XCTestCase {
|
|
|
|
func testDatesBetween() {
|
|
let today = Calendar.current.date(bySettingHour: 0, minute: 0, second: 0, of: Date())!
|
|
let yesterday = Calendar.current.date(byAdding: .day, value: -1, to: today)!
|
|
let tenDaysAgo = Calendar.current.date(byAdding: .day, value: -10, to: today)!
|
|
|
|
let dates = Date.dates(from: tenDaysAgo, toDate: today)
|
|
|
|
XCTAssertEqual(dates.last, yesterday, "Last date should be yesterday (exclusive end)")
|
|
XCTAssertEqual(dates.first, tenDaysAgo, "First date should be ten days ago")
|
|
}
|
|
|
|
func testDatesIncluding() {
|
|
let today = Calendar.current.date(bySettingHour: 0, minute: 0, second: 0, of: Date())!
|
|
let tenDaysAgo = Calendar.current.date(byAdding: .day, value: -10, to: today)!
|
|
|
|
let dates = Date.dates(from: tenDaysAgo, toDate: today, includingToDate: true)
|
|
|
|
XCTAssertEqual(dates.last, today, "Last date should be today (inclusive end)")
|
|
XCTAssertEqual(dates.first, tenDaysAgo, "First date should be ten days ago")
|
|
}
|
|
}
|