Files
Reflect/Tests iOS/IconPackTests.swift
Trey t 9157fd2577 Fix remaining 9 UI test failures: subscription state, scroll, timing
- Replace removePersistentDomain with key-by-key removal in resetAppState
  (removePersistentDomain is unreliable on app group UserDefaults suites)
- Add explicit cache clearing in IAPManager.resetForTesting() to prevent
  stale cachedSubscriptionExpiration from restoring .subscribed state
- Use descendants(matching: .any) for upgrade_banner and subscribe_button
  queries (VStack may not match otherElements in SwiftUI)
- Add multiple swipe attempts for icon pack horizontal scroll
- Use coordinate-based drag for onboarding paged TabView advancement
- Add longer wait for Day view refresh after theme change
- Add multiple scroll attempts to find clear data button in Settings

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 19:13:18 -06:00

103 lines
3.3 KiB
Swift

//
// IconPackTests.swift
// Tests iOS
//
// Icon pack tests: select each of the 7 icon packs and verify no crash.
// TC-072
//
import XCTest
final class IconPackTests: BaseUITestCase {
override var seedFixture: String? { "single_mood" }
override var bypassSubscription: Bool { true }
/// All 7 icon pack accessibility identifiers (lowercased enum case names).
private let allIconPacks = [
"fontawesome",
"emoji",
"handemjoi",
"weather",
"garden",
"hearts",
"cosmic"
]
/// TC-072: Select each of 7 icon packs without crashing.
func testIconPacks_AllSelectable() {
let tabBar = TabBarScreen(app: app)
let settingsScreen = tabBar.tapSettings()
settingsScreen.assertVisible()
// Should already be on Customize sub-tab
// Scroll down to find the icon pack section
app.swipeUp()
for pack in allIconPacks {
let button = app.buttons["customize_iconpack_\(pack)"]
// Icon packs are in a horizontal scroll view.
// Try multiple scroll strategies to find the button.
if !button.waitForExistence(timeout: 2) {
// Try swiping left in the horizontal scroll area
app.swipeLeft()
}
if !button.waitForExistence(timeout: 1) {
app.swipeLeft()
}
if !button.waitForExistence(timeout: 1) {
// Try scrolling the page down to reveal the icon pack section
app.swipeUp()
}
if !button.waitForExistence(timeout: 1) {
// Try swiping left again after scrolling down
app.swipeLeft()
}
if button.waitForExistence(timeout: 3) {
button.coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 0.5)).tap()
} else {
XCTFail("Icon pack button '\(pack)' should exist in the customize view")
}
}
captureScreenshot(name: "icon_packs_cycled")
// Navigate to Day tab and verify no crash entry row should still exist
tabBar.tapDay()
let entryRow = app.descendants(matching: .any)
.matching(NSPredicate(format: "identifier BEGINSWITH %@", "entry_row_"))
.firstMatch
XCTAssertTrue(
entryRow.waitForExistence(timeout: 5),
"Entry row should still be visible after cycling icon packs (no crash)"
)
captureScreenshot(name: "day_view_after_icon_pack_change")
}
/// TC-072: Verify each icon pack button exists in the customize view.
func testIconPacks_AllButtonsExist() {
let tabBar = TabBarScreen(app: app)
let settingsScreen = tabBar.tapSettings()
settingsScreen.assertVisible()
// Scroll down to the icon pack section
app.swipeUp()
for pack in allIconPacks {
let button = app.buttons["customize_iconpack_\(pack)"]
if !button.exists {
app.swipeUp()
}
XCTAssertTrue(
button.waitForExistence(timeout: 3),
"Icon pack button '\(pack)' should exist"
)
}
captureScreenshot(name: "icon_packs_all_buttons")
}
}