Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PaywallsTester by changing TestData DEBUG checks #4092

Merged
merged 1 commit into from
Jul 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 45 additions & 46 deletions RevenueCatUI/Data/TestData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ enum TestData {
)
}()

#if DEBUG

static let weeklyProduct = TestStoreProduct(
localizedTitle: "Weekly",
price: 1.99,
Expand Down Expand Up @@ -116,40 +114,6 @@ enum TestData {
subscriptionPeriod: nil,
locale: Self.locale
)
static let productWithIntroOffer = TestStoreProduct(
localizedTitle: "PRO monthly",
price: 3.99,
localizedPriceString: "$3.99",
productIdentifier: "com.revenuecat.product_4",
productType: .autoRenewableSubscription,
localizedDescription: "PRO monthly",
subscriptionGroupIdentifier: "group",
subscriptionPeriod: .init(value: 1, unit: .month),
introductoryDiscount: .init(
identifier: "intro",
price: 0,
localizedPriceString: "$0.00",
paymentMode: .freeTrial,
subscriptionPeriod: .init(value: 1, unit: .week),
numberOfPeriods: 1,
type: .introductory
),
discounts: [],
locale: Self.locale
)
static let productWithNoIntroOffer = TestStoreProduct(
localizedTitle: "PRO annual",
price: 34.99,
localizedPriceString: "$34.99",
productIdentifier: "com.revenuecat.product_3",
productType: .autoRenewableSubscription,
localizedDescription: "PRO annual",
subscriptionGroupIdentifier: "group",
subscriptionPeriod: .init(value: 1, unit: .year),
introductoryDiscount: nil,
discounts: [],
locale: Self.locale
)
// @PublicForExternalTesting
static let weeklyPackage = Package(
identifier: PackageType.weekly.identifier,
Expand Down Expand Up @@ -185,6 +149,49 @@ enum TestData {
storeProduct: Self.annualProduct.toStoreProduct(),
offeringIdentifier: Self.offeringIdentifier
)
// @PublicForExternalTesting
static let lifetimePackage = Package(
identifier: PackageType.lifetime.identifier,
packageType: .lifetime,
storeProduct: Self.lifetimeProduct.toStoreProduct(),
offeringIdentifier: Self.offeringIdentifier
)

#if DEBUG
static let productWithIntroOffer = TestStoreProduct(
localizedTitle: "PRO monthly",
price: 3.99,
localizedPriceString: "$3.99",
productIdentifier: "com.revenuecat.product_4",
productType: .autoRenewableSubscription,
localizedDescription: "PRO monthly",
subscriptionGroupIdentifier: "group",
subscriptionPeriod: .init(value: 1, unit: .month),
introductoryDiscount: .init(
identifier: "intro",
price: 0,
localizedPriceString: "$0.00",
paymentMode: .freeTrial,
subscriptionPeriod: .init(value: 1, unit: .week),
numberOfPeriods: 1,
type: .introductory
),
discounts: [],
locale: Self.locale
)
static let productWithNoIntroOffer = TestStoreProduct(
localizedTitle: "PRO annual",
price: 34.99,
localizedPriceString: "$34.99",
productIdentifier: "com.revenuecat.product_3",
productType: .autoRenewableSubscription,
localizedDescription: "PRO annual",
subscriptionGroupIdentifier: "group",
subscriptionPeriod: .init(value: 1, unit: .year),
introductoryDiscount: nil,
discounts: [],
locale: Self.locale
)
static let customPackage = Package(
identifier: "Custom",
packageType: .custom,
Expand All @@ -211,14 +218,6 @@ enum TestData {
storeProduct: productWithNoIntroOffer.toStoreProduct(),
offeringIdentifier: Self.offeringIdentifier
)
// @PublicForExternalTesting
static let lifetimePackage = Package(
identifier: PackageType.lifetime.identifier,
packageType: .lifetime,
storeProduct: Self.lifetimeProduct.toStoreProduct(),
offeringIdentifier: Self.offeringIdentifier
)

static let packages = [
Self.packageWithIntroOffer,
Self.packageWithNoIntroOffer
Expand Down Expand Up @@ -729,6 +728,8 @@ enum TestData {
)
static let paywallAssetBaseURL = URL(string: "https://assets.pawwalls.com")!

#endif

#if os(watchOS)
// `Locale.current` in watchOS produces `en_001` when running tests
static let locale: Locale = .init(identifier: "en_US")
Expand All @@ -754,8 +755,6 @@ enum TestData {
)
}

#endif

}

// MARK: -
Expand Down