The screens/ gitignore rule was matching Tests iOS/Screens/ on case-insensitive macOS. Anchored to /screens/ (repo root only) so the 7 UI test page object files are no longer ignored. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
77 lines
2.5 KiB
Swift
77 lines
2.5 KiB
Swift
//
|
|
// OnboardingScreen.swift
|
|
// Tests iOS
|
|
//
|
|
// Screen object for the onboarding flow — welcome, time, day, style, and subscription screens.
|
|
//
|
|
|
|
import XCTest
|
|
|
|
struct OnboardingScreen {
|
|
let app: XCUIApplication
|
|
|
|
// MARK: - Screen Elements
|
|
|
|
var welcomeScreen: XCUIElement { app.otherElements["onboarding_welcome"] }
|
|
var dayScreen: XCUIElement { app.otherElements["onboarding_day"] }
|
|
var subscriptionScreen: XCUIElement { app.otherElements["onboarding_subscription"] }
|
|
|
|
var dayTodayButton: XCUIElement { app.buttons.matching(NSPredicate(format: "identifier == %@", "onboarding_day_today")).firstMatch }
|
|
var dayYesterdayButton: XCUIElement { app.buttons.matching(NSPredicate(format: "identifier == %@", "onboarding_day_yesterday")).firstMatch }
|
|
var subscribeButton: XCUIElement { app.buttons.matching(NSPredicate(format: "identifier == %@", "onboarding_subscribe_button")).firstMatch }
|
|
var skipButton: XCUIElement { app.buttons.matching(NSPredicate(format: "identifier == %@", "onboarding_skip_button")).firstMatch }
|
|
|
|
// MARK: - Actions
|
|
|
|
/// Swipe left to advance to the next onboarding page.
|
|
func swipeToNext() {
|
|
app.swipeLeft()
|
|
}
|
|
|
|
/// Complete the full onboarding flow by swiping through all screens and tapping "Maybe Later".
|
|
func completeOnboarding() {
|
|
// Welcome -> swipe
|
|
if welcomeScreen.waitForExistence(timeout: 5) {
|
|
swipeToNext()
|
|
}
|
|
|
|
// Time -> swipe
|
|
// Time screen doesn't have a unique identifier, just swipe
|
|
swipeToNext()
|
|
|
|
// Day -> select Today, then swipe
|
|
if dayTodayButton.waitForExistence(timeout: 3) {
|
|
dayTodayButton.tap()
|
|
}
|
|
swipeToNext()
|
|
|
|
// Style -> swipe
|
|
swipeToNext()
|
|
|
|
// Subscription -> tap "Maybe Later"
|
|
if skipButton.waitForExistence(timeout: 5) {
|
|
skipButton.tap()
|
|
}
|
|
}
|
|
|
|
// MARK: - Assertions
|
|
|
|
func assertVisible(file: StaticString = #file, line: UInt = #line) {
|
|
XCTAssertTrue(
|
|
welcomeScreen.waitForExistence(timeout: 5),
|
|
"Onboarding welcome screen should be visible",
|
|
file: file, line: line
|
|
)
|
|
}
|
|
|
|
func assertDismissed(file: StaticString = #file, line: UInt = #line) {
|
|
// After onboarding, the tab bar should be visible
|
|
let tabBar = app.tabBars.firstMatch
|
|
XCTAssertTrue(
|
|
tabBar.waitForExistence(timeout: 10),
|
|
"Tab bar should be visible after onboarding completes",
|
|
file: file, line: line
|
|
)
|
|
}
|
|
}
|