Rewrite all UI tests following fail-fast TEST_RULES patterns
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>
This commit is contained in:
@@ -2,80 +2,44 @@
|
||||
// ShareNoDataTests.swift
|
||||
// Tests iOS
|
||||
//
|
||||
// TC-119: Share with no mood data — verifies graceful behavior.
|
||||
// TC-119: Share with no mood data -- verifies graceful behavior.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
|
||||
final class ShareNoDataTests: BaseUITestCase {
|
||||
final class ShareNoDataYearTests: BaseUITestCase {
|
||||
override var seedFixture: String? { "empty" }
|
||||
override var bypassSubscription: Bool { true }
|
||||
|
||||
/// TC-119: With no mood data, Year view share button is absent or sharing handles empty state.
|
||||
func testShare_NoData_GracefulBehavior() {
|
||||
/// TC-119a: With no mood data, Year view share button is absent.
|
||||
func testShare_NoData_YearShareAbsent() {
|
||||
let tabBar = TabBarScreen(app: app)
|
||||
tabBar.tapYear()
|
||||
|
||||
// Wait for year view to load
|
||||
_ = app.waitForExistence(timeout: 3)
|
||||
// With no data, the share button should not appear
|
||||
let shareButton = app.element(UITestID.Year.shareButton)
|
||||
let shareExists = shareButton.waitForExistence(timeout: defaultTimeout)
|
||||
|
||||
XCTAssertFalse(shareExists, "Year share button should be absent when there is no mood data")
|
||||
|
||||
captureScreenshot(name: "share_no_data_year")
|
||||
|
||||
// With no mood data, there should be no year card share button
|
||||
let shareButton = app.element(UITestID.Year.shareButton)
|
||||
let shareExists = shareButton.waitForExistence(timeout: 3)
|
||||
|
||||
if shareExists {
|
||||
// If the share button exists despite no data, tap it and verify
|
||||
// the sharing picker handles empty state gracefully
|
||||
shareButton.tapWhenReady()
|
||||
|
||||
_ = app.waitForExistence(timeout: 2)
|
||||
|
||||
captureScreenshot(name: "share_no_data_picker")
|
||||
|
||||
// Look for "No designs available" text or a valid picker
|
||||
let noDesigns = app.staticTexts["No designs available"].firstMatch
|
||||
let exitButton = app.buttons["Exit"].firstMatch
|
||||
let pickerPresent = noDesigns.waitForExistence(timeout: 3) ||
|
||||
exitButton.waitForExistence(timeout: 3)
|
||||
|
||||
// Either the picker shows empty state or renders normally
|
||||
// Both are acceptable — the key is no crash
|
||||
if exitButton.exists {
|
||||
exitButton.tap()
|
||||
}
|
||||
}
|
||||
|
||||
// Navigate to Month view and check share button there too
|
||||
tabBar.tapMonth()
|
||||
_ = app.waitForExistence(timeout: 3)
|
||||
|
||||
captureScreenshot(name: "share_no_data_month")
|
||||
|
||||
let monthShareButton = app.element(UITestID.Month.shareButton)
|
||||
let monthShareExists = monthShareButton.waitForExistence(timeout: 3)
|
||||
|
||||
// With empty data, month share button should be absent
|
||||
// or if present, should handle gracefully (no crash)
|
||||
if monthShareExists {
|
||||
monthShareButton.tapWhenReady()
|
||||
_ = app.waitForExistence(timeout: 2)
|
||||
captureScreenshot(name: "share_no_data_month_picker")
|
||||
|
||||
let exitButton = app.buttons["Exit"].firstMatch
|
||||
if exitButton.waitForExistence(timeout: 3) {
|
||||
exitButton.tap()
|
||||
}
|
||||
}
|
||||
|
||||
// Final verification: app is still responsive
|
||||
tabBar.tapDay()
|
||||
let emptyState = app.element(UITestID.Day.emptyStateNoData)
|
||||
let moodHeader = app.element(UITestID.Day.moodHeader)
|
||||
XCTAssertTrue(
|
||||
emptyState.waitForExistence(timeout: 5) || moodHeader.waitForExistence(timeout: 2),
|
||||
"App should remain functional after share-with-no-data flow"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
final class ShareNoDataMonthTests: BaseUITestCase {
|
||||
override var seedFixture: String? { "empty" }
|
||||
override var bypassSubscription: Bool { true }
|
||||
|
||||
/// TC-119b: With no mood data, Month view share button is absent.
|
||||
func testShare_NoData_MonthShareAbsent() {
|
||||
let tabBar = TabBarScreen(app: app)
|
||||
tabBar.tapMonth()
|
||||
|
||||
let monthShareButton = app.element(UITestID.Month.shareButton)
|
||||
let shareExists = monthShareButton.waitForExistence(timeout: defaultTimeout)
|
||||
|
||||
XCTAssertFalse(shareExists, "Month share button should be absent when there is no mood data")
|
||||
|
||||
captureScreenshot(name: "share_no_data_month")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user