// // 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") } }