Files
Reflect/Tests iOS/PaywallGateTests.swift
Trey t 277e277750 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>
2026-02-17 09:37:54 -06:00

89 lines
3.0 KiB
Swift

//
// PaywallGateTests.swift
// Tests iOS
//
// Paywall gate tests: verify paywall overlays appear on premium views
// when trial is expired and subscription is not bypassed.
// TC-032, TC-039, TC-048
//
import XCTest
final class PaywallGateTests: BaseUITestCase {
override var seedFixture: String? { "empty" }
override var bypassSubscription: Bool { false }
override var expireTrial: Bool { true }
/// TC-032: Paywall overlay appears on Month view when trial expired.
func testMonthView_PaywallOverlay_WhenTrialExpired() {
let tabBar = TabBarScreen(app: app)
tabBar.tapMonth()
// Verify the paywall overlay is present
let overlay = app.descendants(matching: .any)
.matching(identifier: "paywall_month_overlay")
.firstMatch
XCTAssertTrue(
overlay.waitForExistence(timeout: 5),
"Month paywall overlay should appear when trial is expired"
)
// Verify the paywall CTA text is visible
let ctaText = app.staticTexts["Explore Your Mood History"]
XCTAssertTrue(
ctaText.waitForExistence(timeout: 3),
"Month paywall CTA text should be visible"
)
captureScreenshot(name: "month_paywall_overlay")
}
/// TC-039: Paywall overlay appears on Year view when trial expired.
func testYearView_PaywallOverlay_WhenTrialExpired() {
let tabBar = TabBarScreen(app: app)
tabBar.tapYear()
// Verify the paywall overlay is present
let overlay = app.descendants(matching: .any)
.matching(identifier: "paywall_year_overlay")
.firstMatch
XCTAssertTrue(
overlay.waitForExistence(timeout: 5),
"Year paywall overlay should appear when trial is expired"
)
// Verify the paywall CTA text is visible
let ctaText = app.staticTexts["See Your Year at a Glance"]
XCTAssertTrue(
ctaText.waitForExistence(timeout: 3),
"Year paywall CTA text should be visible"
)
captureScreenshot(name: "year_paywall_overlay")
}
/// TC-048: Paywall overlay appears on Insights view when trial expired.
func testInsightsView_PaywallOverlay_WhenTrialExpired() {
let tabBar = TabBarScreen(app: app)
tabBar.tapInsights()
// Verify the paywall overlay is present
let overlay = app.descendants(matching: .any)
.matching(identifier: "paywall_insights_overlay")
.firstMatch
XCTAssertTrue(
overlay.waitForExistence(timeout: 5),
"Insights paywall overlay should appear when trial is expired"
)
// Verify the paywall CTA text is visible
let ctaText = app.staticTexts["Unlock AI-Powered Insights"]
XCTAssertTrue(
ctaText.waitForExistence(timeout: 3),
"Insights paywall CTA text should be visible"
)
captureScreenshot(name: "insights_paywall_overlay")
}
}