Add XCUITest suite with 27 test files covering unmapped P1 test cases

- Add 8 new test files: HeaderMoodLogging (TC-002), DayViewGrouping (TC-019),
  AllDayViewStyles (TC-021), MonthViewInteraction (TC-030), PaywallGate
  (TC-032/039/048), AppTheme (TC-070), IconPack (TC-072),
  PremiumCustomization (TC-075)
- Add accessibility IDs for paywall overlays, icon packs, app theme cards,
  and day view section headers
- Add --expire-trial launch argument to UITestMode for paywall gate testing
- Update QA test plan spreadsheet with XCUITest names for 14 test cases
- Include existing test infrastructure: screen objects, helpers, base class,
  and 19 previously written test files

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Trey t
2026-02-17 09:37:54 -06:00
parent 1f860aafd1
commit 277e277750
47 changed files with 2386 additions and 50 deletions

View File

@@ -0,0 +1,146 @@
//
// AccessibilityIdentifiers.swift
// Feels (iOS)
//
// Centralized accessibility identifiers for XCUITest targeting.
//
import Foundation
enum AccessibilityID {
// MARK: - Tabs
enum Tab {
static let day = "tab_day"
static let month = "tab_month"
static let year = "tab_year"
static let insights = "tab_insights"
static let settings = "tab_settings"
}
// MARK: - Mood Buttons (voting header)
enum MoodButton {
static let great = "mood_button_great"
static let good = "mood_button_good"
static let average = "mood_button_average"
static let bad = "mood_button_bad"
static let horrible = "mood_button_horrible"
static func id(for moodStrValue: String) -> String {
"mood_button_\(moodStrValue.lowercased())"
}
}
// MARK: - Day View
enum DayView {
static let moodHeader = "mood_header"
static let entryList = "entry_list"
static let emptyState = "empty_state"
static let emptyStateNoData = "empty_state_no_data"
static func entryRow(dateString: String) -> String {
"entry_row_\(dateString)"
}
}
// MARK: - Entry Detail
enum EntryDetail {
static let sheet = "entry_detail_sheet"
static let doneButton = "entry_detail_done"
static let deleteButton = "entry_detail_delete"
static let noteButton = "entry_detail_note_button"
static let noteArea = "entry_detail_note_area"
static let moodGrid = "entry_detail_mood_grid"
}
// MARK: - Note Editor
enum NoteEditor {
static let textEditor = "note_editor_text"
static let saveButton = "note_editor_save"
static let cancelButton = "note_editor_cancel"
}
// MARK: - Settings
enum Settings {
static let header = "settings_header"
static let customizeTab = "settings_tab_customize"
static let settingsTab = "settings_tab_settings"
static let upgradeBanner = "upgrade_banner"
static let subscribeButton = "subscribe_button"
static let whyUpgradeButton = "why_upgrade_button"
static let clearDataButton = "settings_clear_data"
static let analyticsToggle = "settings_analytics_toggle"
static let showOnboardingButton = "settings_show_onboarding"
}
// MARK: - Customize
enum Customize {
static let themeSection = "customize_theme_section"
static let browseThemesButton = "browse_themes_button"
static func themeButton(_ name: String) -> String {
"customize_theme_\(name.lowercased())"
}
static func votingLayoutButton(_ name: String) -> String {
"customize_voting_\(name.lowercased())"
}
static func dayViewStyleButton(_ name: String) -> String {
"customize_daystyle_\(name.lowercased())"
}
static func iconPackButton(_ name: String) -> String {
"customize_iconpack_\(name.lowercased())"
}
static func appThemeCard(_ name: String) -> String {
"apptheme_card_\(name.lowercased())"
}
}
// MARK: - Paywall
enum Paywall {
static let monthOverlay = "paywall_month_overlay"
static let yearOverlay = "paywall_year_overlay"
static let insightsOverlay = "paywall_insights_overlay"
}
// MARK: - Day View Section Headers
enum DaySection {
static func header(month: Int, year: Int) -> String {
"day_section_\(month)_\(year)"
}
}
// MARK: - Insights
enum Insights {
static let header = "insights_header"
static let monthSection = "insights_month_section"
static let yearSection = "insights_year_section"
static let allTimeSection = "insights_all_time_section"
}
// MARK: - Month View
enum MonthView {
static let grid = "month_grid"
}
// MARK: - Year View
enum YearView {
static let heatmap = "year_heatmap"
}
// MARK: - Onboarding
enum Onboarding {
static let container = "onboarding_container"
static let welcomeScreen = "onboarding_welcome"
static let timeScreen = "onboarding_time"
static let dayScreen = "onboarding_day"
static let dayToday = "onboarding_day_today"
static let dayYesterday = "onboarding_day_yesterday"
static let styleScreen = "onboarding_style"
static let subscriptionScreen = "onboarding_subscription"
static let subscribeButton = "onboarding_subscribe_button"
static let skipButton = "onboarding_skip_button"
}
// MARK: - Common
enum Common {
static let lockScreen = "lock_screen"
static let onboarding = "onboarding_sheet"
}
}

View File

@@ -24,6 +24,11 @@ struct FeelsApp: App {
@State private var showStorageFallbackAlert = SharedModelContainer.isUsingInMemoryFallback
init() {
// Configure UI test mode before anything else
if UITestMode.isUITesting {
UITestMode.configureIfNeeded()
}
AnalyticsManager.shared.configure()
BGTaskScheduler.shared.cancelAllTaskRequests()

View File

@@ -73,7 +73,8 @@ struct OnboardingDay: View {
example: "e.g. Tue reminder → Rate Tue",
icon: "sun.max.fill",
isSelected: onboardingData.inputDay == .Today,
action: { onboardingData.inputDay = .Today }
action: { onboardingData.inputDay = .Today },
testID: AccessibilityID.Onboarding.dayToday
)
DayOptionCard(
@@ -82,7 +83,8 @@ struct OnboardingDay: View {
example: "e.g. Tue reminder → Rate Mon",
icon: "moon.fill",
isSelected: onboardingData.inputDay == .Previous,
action: { onboardingData.inputDay = .Previous }
action: { onboardingData.inputDay = .Previous },
testID: AccessibilityID.Onboarding.dayYesterday
)
}
.padding(.horizontal, 20)
@@ -103,6 +105,7 @@ struct OnboardingDay: View {
.padding(.bottom, 80)
}
}
.accessibilityIdentifier(AccessibilityID.Onboarding.dayScreen)
}
}
@@ -113,6 +116,7 @@ struct DayOptionCard: View {
let icon: String
let isSelected: Bool
let action: () -> Void
var testID: String? = nil
var body: some View {
Button(action: action) {
@@ -168,6 +172,7 @@ struct DayOptionCard: View {
.accessibilityLabel("\(title), \(subtitle)")
.accessibilityHint(example)
.accessibilityAddTraits(isSelected ? [.isSelected] : [])
.accessibilityIdentifier(testID ?? "")
}
}

View File

@@ -117,6 +117,7 @@ struct OnboardingSubscription: View {
}
.accessibilityLabel(String(localized: "Get Personal Insights"))
.accessibilityHint(String(localized: "Opens subscription options"))
.accessibilityIdentifier(AccessibilityID.Onboarding.subscribeButton)
// Skip button
Button(action: {
@@ -130,12 +131,14 @@ struct OnboardingSubscription: View {
}
.accessibilityLabel(String(localized: "Maybe Later"))
.accessibilityHint(String(localized: "Skip subscription and complete setup"))
.accessibilityIdentifier(AccessibilityID.Onboarding.skipButton)
.padding(.top, 4)
}
.padding(.horizontal, 24)
.padding(.bottom, 50)
}
}
.accessibilityIdentifier(AccessibilityID.Onboarding.subscriptionScreen)
.sheet(isPresented: $showSubscriptionStore, onDismiss: {
// After subscription store closes, complete onboarding
AnalyticsManager.shared.track(.onboardingCompleted(dayId: nil))

View File

@@ -75,6 +75,7 @@ struct OnboardingWelcome: View {
.accessibilityHint(String(localized: "Swipe to the next onboarding step"))
}
}
.accessibilityIdentifier(AccessibilityID.Onboarding.welcomeScreen)
}
}

132
Shared/UITestMode.swift Normal file
View File

@@ -0,0 +1,132 @@
//
// UITestMode.swift
// Feels (iOS)
//
// Handles launch arguments for UI testing mode.
// When --ui-testing is passed, the app uses deterministic settings.
//
import Foundation
#if canImport(UIKit)
import UIKit
#endif
enum UITestMode {
/// Whether the app was launched in UI testing mode
static var isUITesting: Bool {
ProcessInfo.processInfo.arguments.contains("--ui-testing")
}
/// Whether to reset all state before the test run
static var shouldResetState: Bool {
ProcessInfo.processInfo.arguments.contains("--reset-state")
}
/// Whether to disable animations for faster, more deterministic tests
static var disableAnimations: Bool {
ProcessInfo.processInfo.arguments.contains("--disable-animations")
}
/// Whether to bypass the subscription paywall
static var bypassSubscription: Bool {
ProcessInfo.processInfo.arguments.contains("--bypass-subscription")
}
/// Whether to skip onboarding
static var skipOnboarding: Bool {
ProcessInfo.processInfo.arguments.contains("--skip-onboarding")
}
/// Whether to force the trial to be expired (sets firstLaunchDate to 31 days ago)
static var expireTrial: Bool {
ProcessInfo.processInfo.arguments.contains("--expire-trial")
}
/// Seed fixture name if provided (via environment variable)
static var seedFixture: String? {
ProcessInfo.processInfo.environment["UI_TEST_FIXTURE"]
}
/// Apply all UI test mode settings. Called early in app startup.
@MainActor
static func configureIfNeeded() {
guard isUITesting else { return }
#if canImport(UIKit)
if disableAnimations {
UIView.setAnimationsEnabled(false)
}
#endif
if shouldResetState {
resetAppState()
}
if skipOnboarding {
GroupUserDefaults.groupDefaults.set(false, forKey: UserDefaultsStore.Keys.needsOnboarding.rawValue)
}
if bypassSubscription {
#if DEBUG
IAPManager.shared.bypassSubscription = true
#endif
}
if expireTrial {
// Set firstLaunchDate to 31 days ago so the 30-day trial is expired
let expiredDate = Calendar.current.date(byAdding: .day, value: -31, to: Date())!
GroupUserDefaults.groupDefaults.set(expiredDate, forKey: UserDefaultsStore.Keys.firstLaunchDate.rawValue)
GroupUserDefaults.groupDefaults.synchronize()
}
// Seed fixture data if requested
if let fixture = seedFixture {
seedData(fixture: fixture)
}
}
/// Reset all user defaults and persisted state for a clean test run
@MainActor
private static func resetAppState() {
// Clear group user defaults
let defaults = GroupUserDefaults.groupDefaults
if let bundleId = Bundle.main.bundleIdentifier {
defaults.removePersistentDomain(forName: bundleId)
}
// Reset key defaults explicitly
defaults.set(false, forKey: UserDefaultsStore.Keys.needsOnboarding.rawValue)
defaults.set(0, forKey: UserDefaultsStore.Keys.votingLayoutStyle.rawValue) // horizontal
defaults.synchronize()
// Clear standard user defaults
UserDefaults.standard.set(false, forKey: "debug_bypassSubscription")
// Clear all mood data
DataController.shared.clearDB()
}
/// Seed the database with fixture data for deterministic tests
@MainActor
private static func seedData(fixture: String) {
switch fixture {
case "single_mood":
// One entry for today with mood "Great"
DataController.shared.add(mood: .great, forDate: Calendar.current.startOfDay(for: Date()), entryType: .listView)
case "week_of_moods":
// One mood per day for the last 7 days
let moods: [Mood] = [.great, .good, .average, .bad, .horrible, .good, .great]
for (offset, mood) in moods.enumerated() {
let date = Calendar.current.date(byAdding: .day, value: -offset, to: Calendar.current.startOfDay(for: Date()))!
DataController.shared.add(mood: mood, forDate: date, entryType: .listView)
}
case "empty":
// No data already cleared in resetAppState
break
default:
break
}
}
}

View File

@@ -68,6 +68,7 @@ struct AddMoodHeaderView: View {
}
.cornerRadius(Constants.viewsCornerRaidus, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
.fixedSize(horizontal: false, vertical: true)
.accessibilityIdentifier(AccessibilityID.DayView.moodHeader)
}
@ViewBuilder
@@ -121,6 +122,7 @@ struct HorizontalVotingView: View {
}
.buttonStyle(MoodButtonStyle())
.frame(maxWidth: .infinity)
.accessibilityIdentifier(AccessibilityID.MoodButton.id(for: mood.widgetDisplayName))
.accessibilityLabel(mood.strValue)
.accessibilityHint(String(localized: "Select this mood"))
}
@@ -185,6 +187,7 @@ struct CardVotingView: View {
)
}
.buttonStyle(CardButtonStyle())
.accessibilityIdentifier(AccessibilityID.MoodButton.id(for: mood.widgetDisplayName))
.accessibilityLabel(mood.strValue)
.accessibilityHint(String(localized: "Select this mood"))
}
@@ -224,6 +227,7 @@ struct StackedVotingView: View {
)
}
.buttonStyle(CardButtonStyle())
.accessibilityIdentifier(AccessibilityID.MoodButton.id(for: mood.widgetDisplayName))
.accessibilityLabel(mood.strValue)
.accessibilityHint(String(localized: "Select this mood"))
}
@@ -310,6 +314,7 @@ struct AuraVotingView: View {
}
}
.buttonStyle(AuraButtonStyle(color: color))
.accessibilityIdentifier(AccessibilityID.MoodButton.id(for: mood.widgetDisplayName))
.accessibilityLabel(mood.strValue)
.accessibilityHint(String(localized: "Select this mood"))
}
@@ -400,6 +405,7 @@ struct OrbitVotingView: View {
}
.buttonStyle(OrbitButtonStyle(color: color))
.position(x: posX, y: posY)
.accessibilityIdentifier(AccessibilityID.MoodButton.id(for: mood.widgetDisplayName))
.accessibilityLabel(mood.strValue)
.accessibilityHint(String(localized: "Select this mood"))
}
@@ -687,6 +693,7 @@ struct NeonEqualizerBar: View {
}
.buttonStyle(NeonBarButtonStyle(isPressed: $isPressed))
.frame(maxWidth: .infinity)
.accessibilityIdentifier(AccessibilityID.MoodButton.id(for: mood.widgetDisplayName))
.accessibilityLabel(mood.strValue)
.accessibilityHint(String(localized: "Select this mood"))
}

View File

@@ -278,6 +278,7 @@ struct ThemePickerCompact: View {
}
}
.buttonStyle(BorderlessButtonStyle())
.accessibilityIdentifier(AccessibilityID.Customize.themeButton(aTheme.title))
}
Spacer()
}
@@ -331,6 +332,7 @@ struct ImagePackPickerCompact: View {
)
}
.buttonStyle(.plain)
.accessibilityIdentifier(AccessibilityID.Customize.iconPackButton("\(images)"))
}
}
}
@@ -379,6 +381,7 @@ struct VotingLayoutPickerCompact: View {
)
}
.buttonStyle(.plain)
.accessibilityIdentifier(AccessibilityID.Customize.votingLayoutButton(layout.displayName))
}
}
.padding(.horizontal, 4)
@@ -742,6 +745,7 @@ struct DayViewStylePickerCompact: View {
)
}
.buttonStyle(.plain)
.accessibilityIdentifier(AccessibilityID.Customize.dayViewStyleButton(style.displayName))
}
}
.padding(.horizontal, 4)

View File

@@ -214,6 +214,7 @@ struct AppThemeCard: View {
)
}
.buttonStyle(.plain)
.accessibilityIdentifier(AccessibilityID.Customize.appThemeCard(theme.name))
}
}

View File

@@ -159,6 +159,7 @@ extension DayView {
defaultSectionHeader(month: month, year: year)
}
}
.accessibilityIdentifier(AccessibilityID.DaySection.header(month: month, year: year))
}
private func defaultSectionHeader(month: Int, year: Int) -> some View {

View File

@@ -34,10 +34,12 @@ struct EmptyHomeView: View {
.padding()
.fixedSize(horizontal: false, vertical: true)
.foregroundColor(textColor)
.accessibilityIdentifier(AccessibilityID.DayView.emptyStateNoData)
Spacer()
}
}
}
.accessibilityIdentifier(AccessibilityID.DayView.emptyState)
}
.fixedSize(horizontal: false, vertical: true)
.cornerRadius(Constants.viewsCornerRaidus, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])

View File

@@ -93,6 +93,7 @@ struct EntryListView: View {
}
}
.accessibilityElement(children: .combine)
.accessibilityIdentifier(AccessibilityID.DayView.entryRow(dateString: cachedYearMonthDayDigits))
.accessibilityLabel(accessibilityDescription)
.accessibilityHint(isMissing ? String(localized: "Tap to log mood for this day") : String(localized: "Tap to view or edit"))
.accessibilityAddTraits(.isButton)

View File

@@ -28,6 +28,7 @@ struct InsightsView: View {
Text("Insights")
.font(.title.weight(.bold))
.foregroundColor(textColor)
.accessibilityIdentifier(AccessibilityID.Insights.header)
Spacer()
// AI badge
@@ -168,6 +169,7 @@ struct InsightsView: View {
Spacer()
}
.background(theme.currentTheme.bg)
.accessibilityIdentifier(AccessibilityID.Paywall.insightsOverlay)
}
}
.sheet(isPresented: $showSubscriptionStore) {

View File

@@ -28,26 +28,31 @@ struct MainTabView: View {
.tabItem {
Label(String(localized: "content_view_tab_main"), systemImage: "list.dash")
}
.accessibilityIdentifier(AccessibilityID.Tab.day)
monthView
.tabItem {
Label(String(localized: "content_view_tab_month"), systemImage: "calendar")
}
.accessibilityIdentifier(AccessibilityID.Tab.month)
yearView
.tabItem {
Label(String(localized: "content_view_tab_filter"), systemImage: "line.3.horizontal.decrease.circle")
}
.accessibilityIdentifier(AccessibilityID.Tab.year)
insightsView
.tabItem {
Label(String(localized: "content_view_tab_insights"), systemImage: "lightbulb.fill")
}
.accessibilityIdentifier(AccessibilityID.Tab.insights)
SettingsTabView()
.tabItem {
Label("Settings", systemImage: "gear")
}
.accessibilityIdentifier(AccessibilityID.Tab.settings)
}
.accentColor(textColor)
.sheet(isPresented: $needsOnboarding, onDismiss: { }, content: {

View File

@@ -327,6 +327,7 @@ struct MonthView: View {
.frame(maxWidth: .infinity)
.background(theme.currentTheme.bg)
.frame(maxHeight: .infinity, alignment: .bottom)
.accessibilityIdentifier(AccessibilityID.Paywall.monthOverlay)
} else if iapManager.shouldShowTrialWarning && !demoManager.isDemoMode {
VStack {
Spacer()

View File

@@ -45,6 +45,7 @@ struct NoteEditorView: View {
.frame(maxHeight: .infinity)
.scrollContentBackground(.hidden)
.padding(.horizontal, 4)
.accessibilityIdentifier(AccessibilityID.NoteEditor.textEditor)
// Character count
HStack {
@@ -63,6 +64,7 @@ struct NoteEditorView: View {
Button("Cancel") {
dismiss()
}
.accessibilityIdentifier(AccessibilityID.NoteEditor.cancelButton)
}
ToolbarItem(placement: .confirmationAction) {
@@ -71,6 +73,7 @@ struct NoteEditorView: View {
}
.disabled(isSaving || noteText.count > maxCharacters)
.fontWeight(.semibold)
.accessibilityIdentifier(AccessibilityID.NoteEditor.saveButton)
}
ToolbarItemGroup(placement: .keyboard) {
@@ -197,11 +200,13 @@ struct EntryDetailView: View {
.background(Color(.systemGroupedBackground))
.navigationTitle("Entry Details")
.navigationBarTitleDisplayMode(.inline)
.accessibilityIdentifier(AccessibilityID.EntryDetail.sheet)
.toolbar {
ToolbarItem(placement: .confirmationAction) {
Button("Done") {
dismiss()
}
.accessibilityIdentifier(AccessibilityID.EntryDetail.doneButton)
}
}
.sheet(isPresented: $showNoteEditor) {
@@ -345,6 +350,7 @@ struct EntryDetailView: View {
RoundedRectangle(cornerRadius: 16)
.fill(Color(.systemBackground))
)
.accessibilityIdentifier(AccessibilityID.EntryDetail.moodGrid)
}
}
@@ -364,6 +370,7 @@ struct EntryDetailView: View {
.font(.subheadline)
.fontWeight(.medium)
}
.accessibilityIdentifier(AccessibilityID.EntryDetail.noteButton)
}
Button {
@@ -399,6 +406,7 @@ struct EntryDetailView: View {
)
}
.buttonStyle(.plain)
.accessibilityIdentifier(AccessibilityID.EntryDetail.noteArea)
}
}
@@ -495,6 +503,7 @@ struct EntryDetailView: View {
)
}
.padding(.top, 8)
.accessibilityIdentifier(AccessibilityID.EntryDetail.deleteButton)
}
}

View File

@@ -34,6 +34,7 @@ struct SettingsTabView: View {
.frame(maxWidth: .infinity, alignment: .leading)
.padding(.horizontal, 16)
.padding(.top, 8)
.accessibilityIdentifier(AccessibilityID.Settings.header)
// Upgrade Banner (only show if not subscribed)
if !iapManager.isSubscribed && !iapManager.bypassSubscription {
@@ -123,6 +124,7 @@ struct UpgradeBannerView: View {
.stroke(Color.accentColor, lineWidth: 1.5)
)
}
.accessibilityIdentifier(AccessibilityID.Settings.whyUpgradeButton)
// Subscribe button
Button {
@@ -138,6 +140,7 @@ struct UpgradeBannerView: View {
.fill(Color.pink)
)
}
.accessibilityIdentifier(AccessibilityID.Settings.subscribeButton)
}
}
.padding(14)
@@ -145,6 +148,7 @@ struct UpgradeBannerView: View {
RoundedRectangle(cornerRadius: 14)
.fill(colorScheme == .dark ? Color(.systemGray6) : Color(.systemGray6).opacity(0.5))
)
.accessibilityIdentifier(AccessibilityID.Settings.upgradeBanner)
}
}

View File

@@ -827,6 +827,7 @@ struct SettingsContentView: View {
.padding()
}
}
.accessibilityIdentifier(AccessibilityID.Settings.clearDataButton)
.fixedSize(horizontal: false, vertical: true)
.cornerRadius(Constants.viewsCornerRaidus, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
}
@@ -1073,6 +1074,7 @@ struct SettingsContentView: View {
.foregroundColor(textColor)
})
.accessibilityHint(String(localized: "View the app introduction again"))
.accessibilityIdentifier(AccessibilityID.Settings.showOnboardingButton)
.padding()
}
.fixedSize(horizontal: false, vertical: true)
@@ -1168,6 +1170,7 @@ struct SettingsContentView: View {
}
))
.labelsHidden()
.accessibilityIdentifier(AccessibilityID.Settings.analyticsToggle)
.accessibilityLabel("Share Analytics")
.accessibilityHint("Toggle anonymous usage analytics")
}
@@ -1903,6 +1906,7 @@ struct SettingsView: View {
}
))
.labelsHidden()
.accessibilityIdentifier(AccessibilityID.Settings.analyticsToggle)
.accessibilityLabel("Share Analytics")
.accessibilityHint("Toggle anonymous usage analytics")
}

View File

@@ -263,6 +263,7 @@ struct YearView: View {
.frame(maxWidth: .infinity)
.background(theme.currentTheme.bg)
.frame(maxHeight: .infinity, alignment: .bottom)
.accessibilityIdentifier(AccessibilityID.Paywall.yearOverlay)
} else if iapManager.shouldShowTrialWarning && !demoManager.isDemoMode {
VStack {
Spacer()