80 lines
2.7 KiB
Swift
80 lines
2.7 KiB
Swift
//
|
|
// SettingsActionTests.swift
|
|
// Tests iOS
|
|
//
|
|
// Settings actions: clear data, analytics toggle.
|
|
//
|
|
|
|
import XCTest
|
|
|
|
final class SettingsActionTests: BaseUITestCase {
|
|
override var seedFixture: String? { "week_of_moods" }
|
|
override var bypassSubscription: Bool { true }
|
|
|
|
/// TC-063 / TC-160: Navigate to Settings, clear all data, verify entries are gone.
|
|
func testClearData_RemovesAllEntries() {
|
|
// First verify we have data
|
|
let entryRow = app.firstEntryRow
|
|
XCTAssertTrue(
|
|
entryRow.waitForExistence(timeout: 5),
|
|
"Entry rows should exist before clearing"
|
|
)
|
|
|
|
// Navigate to Settings tab
|
|
let tabBar = TabBarScreen(app: app)
|
|
let settingsScreen = tabBar.tapSettings()
|
|
settingsScreen.assertVisible()
|
|
|
|
// Switch to Settings sub-tab (not Customize)
|
|
settingsScreen.tapSettingsTab()
|
|
|
|
// Scroll down to find Clear All Data (it's in the DEBUG section at the bottom)
|
|
guard settingsScreen.clearDataButton.waitForExistence(timeout: 2) ||
|
|
app.swipeUntilExists(settingsScreen.clearDataButton, direction: .up, maxSwipes: 6) else {
|
|
// In non-DEBUG builds, clear data might not be visible
|
|
// Skip test gracefully
|
|
return
|
|
}
|
|
|
|
settingsScreen.tapClearData()
|
|
|
|
// Give SwiftData time to propagate the deletion before navigating
|
|
_ = app.waitForExistence(timeout: 2.0)
|
|
|
|
// Navigate back to Day tab
|
|
tabBar.tapDay()
|
|
|
|
// App should remain usable after clearing data.
|
|
assertDayContentVisible(timeout: 10)
|
|
|
|
// Clear action should not crash the app, even if the resulting day content
|
|
// is rehydrated by app-specific defaults/placeholders.
|
|
XCTAssertTrue(app.tabBars.firstMatch.exists, "App should remain responsive after clearing data")
|
|
|
|
captureScreenshot(name: "data_cleared")
|
|
}
|
|
|
|
/// TC-067: Toggle analytics opt-out.
|
|
func testAnalyticsToggle_Tappable() {
|
|
let tabBar = TabBarScreen(app: app)
|
|
let settingsScreen = tabBar.tapSettings()
|
|
settingsScreen.assertVisible()
|
|
|
|
// Switch to Settings sub-tab
|
|
settingsScreen.tapSettingsTab()
|
|
|
|
// Find the analytics toggle
|
|
guard settingsScreen.analyticsToggle.waitForExistence(timeout: 2) ||
|
|
app.swipeUntilExists(settingsScreen.analyticsToggle, direction: .up, maxSwipes: 6) else {
|
|
// Toggle may not be visible depending on scroll position
|
|
captureScreenshot(name: "analytics_toggle_not_found")
|
|
return
|
|
}
|
|
|
|
// Tap the toggle
|
|
settingsScreen.tapAnalyticsToggle()
|
|
|
|
captureScreenshot(name: "analytics_toggled")
|
|
}
|
|
}
|