Files
Reflect/Tests iOS/IconPackTests.swift
Trey t c286294cd3 Fix remaining 12 UI test failures: subscription state, hittability, tab selection
- IAPManager: add resetForTesting() to discard stale cached subscription state
- UITestMode: call resetForTesting() after clearing defaults (fixes 5 banner tests)
- StabilityTests: use NSPredicate wait for isSelected (iOS 26 Liquid Glass)
- SettingsActionTests: use coordinate tap for clear data and analytics toggle
- IconPackTests: add horizontal scroll fallback for off-screen icon packs

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

92 lines
2.8 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)"]
if !button.exists {
// Icon packs may be in a horizontal scroll try swipe left first
app.swipeLeft()
}
if !button.exists {
// If still not found, try scrolling the page down
app.swipeUp()
}
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")
}
}