From 0ed39707f351e813930bc83fef8b613a559fc8e5 Mon Sep 17 00:00:00 2001 From: Cesar de la Vega Date: Wed, 4 Oct 2023 17:10:42 +0200 Subject: [PATCH 1/9] creates test with json --- ui/revenuecatui/build.gradle | 2 + .../ui/revenuecatui/data/testdata/TestData.kt | 61 +++++++++++ .../revenuecatui/PaywallDataValidationTest.kt | 103 ++++++++++++++++++ ...TemplateNameGeneratesDefaultPaywall.1.json | 52 +++++++++ 4 files changed, 218 insertions(+) create mode 100644 ui/revenuecatui/src/test/kotlin/com/revenuecat/purchases/ui/revenuecatui/PaywallDataValidationTest.kt create mode 100644 ui/revenuecatui/src/test/resources/testUnrecognizedTemplateNameGeneratesDefaultPaywall.1.json diff --git a/ui/revenuecatui/build.gradle b/ui/revenuecatui/build.gradle index a25e12af90..0d26ef8d54 100644 --- a/ui/revenuecatui/build.gradle +++ b/ui/revenuecatui/build.gradle @@ -1,6 +1,7 @@ plugins { alias libs.plugins.android.library alias libs.plugins.kotlin.android + alias libs.plugins.kotlin.serialization } @@ -53,6 +54,7 @@ dependencies { implementation libs.coil.svg debugImplementation libs.compose.ui.tooling debugImplementation libs.androidx.test.compose.manifest + implementation libs.kotlinx.serialization.json testImplementation libs.bundles.test testImplementation libs.coroutines.test diff --git a/ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/data/testdata/TestData.kt b/ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/data/testdata/TestData.kt index 3deb0016c2..80f7d80dc7 100644 --- a/ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/data/testdata/TestData.kt +++ b/ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/data/testdata/TestData.kt @@ -15,6 +15,7 @@ import com.revenuecat.purchases.models.RecurrenceMode import com.revenuecat.purchases.models.StoreProduct import com.revenuecat.purchases.models.SubscriptionOption import com.revenuecat.purchases.models.SubscriptionOptions +import com.revenuecat.purchases.paywalls.PaywallColor import com.revenuecat.purchases.paywalls.PaywallData import com.revenuecat.purchases.ui.revenuecatui.PaywallViewMode import com.revenuecat.purchases.ui.revenuecatui.R @@ -42,8 +43,28 @@ internal object TestData { ) val assetBaseURL = URL("https://assets.pawwalls.com") + + val localization = PaywallData.LocalizedConfiguration( + title = "Call to action for _better_ conversion.", + subtitle = "Lorem ipsum is simply dummy text of the ~printing and~ typesetting industry.", + callToAction = "Subscribe for {{ sub_price_per_month }}/mo", + offerDetails = "{{ total_price_and_per_month }}", + offerDetailsWithIntroOffer = "{{ total_price_and_per_month }} after {{ sub_offer_duration }} trial", + offerName = "{{ sub_period }}", + features = emptyList(), + ) } + val offeringWithNoPaywall = Offering( + identifier = "Template1", + availablePackages = listOf( + Packages.monthly, + ), + metadata = mapOf(), + paywall = null, + serverDescription = "", + ) + val template1Offering = Offering( identifier = "Template1", availablePackages = listOf( @@ -76,6 +97,46 @@ internal object TestData { serverDescription = "", ) + val offeringWithMultiPackagePaywall = Offering( + identifier = "offeringWithMultiPackagePaywall", + serverDescription = "Offering", + metadata = mapOf(), + paywall = PaywallData( + templateName = PaywallTemplate.TEMPLATE_2.id, + config = PaywallData.Configuration( + packages = listOf(PackageType.ANNUAL.identifier!!, PackageType.MONTHLY.identifier!!), + images = Constants.images, + colors = PaywallData.Configuration.ColorInformation( + light = PaywallData.Configuration.Colors( + background = PaywallColor("#FFFFFF"), + text1 = PaywallColor("#111111"), + callToActionBackground = PaywallColor("#EC807C"), + callToActionForeground = PaywallColor("#FFFFFF"), + accent1 = PaywallColor("#BC66FF"), + accent2 = PaywallColor("#111100"), + ), + dark = PaywallData.Configuration.Colors( + background = PaywallColor("#000000"), + text1 = PaywallColor("#EEEEEE"), + callToActionBackground = PaywallColor("#ACD27A"), + callToActionForeground = PaywallColor("#000000"), + accent1 = PaywallColor("#B022BB"), + accent2 = PaywallColor("#EEDDEE"), + ), + ), + blurredBackgroundImage = true, + privacyURL = URL("https://revenuecat.com/tos"), + ), + localization = mapOf("en_US" to Constants.localization), + assetBaseURL = Constants.assetBaseURL, + ), + availablePackages = listOf( + Packages.weekly, + Packages.monthly, + Packages.annual, + ), + ) + object Packages { val weekly = Package( packageType = PackageType.WEEKLY, diff --git a/ui/revenuecatui/src/test/kotlin/com/revenuecat/purchases/ui/revenuecatui/PaywallDataValidationTest.kt b/ui/revenuecatui/src/test/kotlin/com/revenuecat/purchases/ui/revenuecatui/PaywallDataValidationTest.kt new file mode 100644 index 0000000000..e9971daf40 --- /dev/null +++ b/ui/revenuecatui/src/test/kotlin/com/revenuecat/purchases/ui/revenuecatui/PaywallDataValidationTest.kt @@ -0,0 +1,103 @@ +package com.revenuecat.purchases.ui.revenuecatui + +import androidx.compose.material3.ColorScheme +import androidx.compose.ui.graphics.Color +import androidx.test.ext.junit.runners.AndroidJUnit4 +import com.revenuecat.purchases.paywalls.PaywallData +import com.revenuecat.purchases.ui.revenuecatui.data.testdata.TestData +import com.revenuecat.purchases.ui.revenuecatui.errors.PaywallValidationError +import com.revenuecat.purchases.ui.revenuecatui.helpers.validatedPaywall +import io.mockk.every +import io.mockk.mockk +import kotlinx.serialization.decodeFromString +import kotlinx.serialization.json.Json +import org.assertj.core.api.Assertions.assertThat +import org.junit.Before +import org.junit.Test +import org.junit.runner.RunWith +import java.io.File + +@RunWith(AndroidJUnit4::class) +class PaywallDataValidationTest { + + @Before + fun setUp() { + } + + @Test + fun `Validate an offering without paywall`() { + val offering = TestData.offeringWithNoPaywall + val paywallValidationResult = offering.validatedPaywall( + currentColorScheme = mockk(relaxed = true), + ) + assertThat(paywallValidationResult.error).isEqualTo(PaywallValidationError.MissingPaywall) + } + + @Test + fun `Validate a valid paywall`() { + val offering = TestData.template1Offering + val paywallValidationResult = offering.validatedPaywall( + currentColorScheme = mockk(relaxed = true), + ) + assertThat(paywallValidationResult.error).isNull() + } + + @Test + fun `Unrecognized template name generates default paywall`() { + val templateName = "unrecognized_template" + val originalOffering = TestData.offeringWithMultiPackagePaywall + val offering = originalOffering.copy(paywall = originalOffering.paywall!!.copy(templateName = templateName)) + val currentColorScheme = ColorScheme( + primary = Color.White, + onPrimary = Color.White, + primaryContainer = Color.White, + onPrimaryContainer = Color.White, + inversePrimary = Color.Green, + secondary = Color.Black, + onSecondary = Color.Black, + secondaryContainer = Color.Black, + onSecondaryContainer = Color.Black, + tertiary = Color.Cyan, + onTertiary = Color.Black, + tertiaryContainer = Color.Gray, + onTertiaryContainer = Color.White, + background = Color.White, + onBackground = Color.Black, + surface = Color.Gray, + onSurface = Color.Black, + surfaceVariant = Color.DarkGray, + onSurfaceVariant = Color.White, + surfaceTint = Color.LightGray, + inverseSurface = Color.Black, + inverseOnSurface = Color.White, + error = Color.Red, + onError = Color.White, + errorContainer = Color.Red, + onErrorContainer = Color.White, + outline = Color.Transparent, + outlineVariant = Color.LightGray, + scrim = Color.Gray + ) + + val paywallValidationResult = offering.validatedPaywall( + currentColorScheme = currentColorScheme, + ) + + verifyPackages(paywallValidationResult.displayablePaywall, originalOffering.paywall!!) + snapshot(paywallValidationResult.displayablePaywall) + assertThat(paywallValidationResult.error).isEqualTo(PaywallValidationError.InvalidTemplate(templateName)) + } + + private fun verifyPackages(actual: PaywallData, expectation: PaywallData) { + assertThat(actual.config.packages).isEqualTo(expectation.config.packages) + } + + private fun snapshot(displayablePaywall: PaywallData) { + val json = loadJSON("testUnrecognizedTemplateNameGeneratesDefaultPaywall.1.json") + val paywall: PaywallData = Json.decodeFromString(json) + assertThat(displayablePaywall).isEqualTo(paywall) + } + + private fun loadJSON(jsonFileName: String) = File(javaClass.classLoader!!.getResource(jsonFileName).file).readText() + +} \ No newline at end of file diff --git a/ui/revenuecatui/src/test/resources/testUnrecognizedTemplateNameGeneratesDefaultPaywall.1.json b/ui/revenuecatui/src/test/resources/testUnrecognizedTemplateNameGeneratesDefaultPaywall.1.json new file mode 100644 index 0000000000..ad14dc3efd --- /dev/null +++ b/ui/revenuecatui/src/test/resources/testUnrecognizedTemplateNameGeneratesDefaultPaywall.1.json @@ -0,0 +1,52 @@ +{ + "asset_base_url" : "https:", + "config" : { + "blurred_background_image" : true, + "colors" : { + "light" : { + "accent_1" : "#000000", + "accent_2" : "#FFFFFF", + "background" : "#FFFFFF", + "call_to_action_background" : "#000000", + "call_to_action_foreground" : "#FFFFFF", + "text_1" : "#FFFFFF" + }, + "dark" : { + "accent_1" : "#000000", + "accent_2" : "#FFFFFF", + "background" : "#000000", + "call_to_action_background" : "#000000", + "call_to_action_foreground" : "#000000", + "text_1" : "#FFFFFF" + } + }, + "display_restore_purchases" : true, + "images" : { + "background" : "default_background", + "header" : null, + "icon" : "revenuecatui_default_paywall_app_icon" + }, + "packages" : [ + "$rc_annual", + "$rc_monthly" + ], + "privacy_url" : null, + "tos_url" : null + }, + "localized_strings" : { + "en_US" : { + "call_to_action" : "Continue", + "call_to_action_with_intro_offer" : null, + "features" : [ + + ], + "offer_details" : "{{ total_price_and_per_month }}", + "offer_details_with_intro_offer" : "Start your {{ sub_offer_duration }} trial, then {{ total_price_and_per_month }}.", + "offer_name" : null, + "subtitle" : null, + "title" : "{{ app_name }}" + } + }, + "revision" : -1, + "template_name" : "2" +} \ No newline at end of file From 0fa14dacc8527c82f6c54045f47eee435cd4f908 Mon Sep 17 00:00:00 2001 From: Cesar de la Vega Date: Wed, 4 Oct 2023 18:07:48 +0200 Subject: [PATCH 2/9] move ColorScheme to constants --- .../ui/revenuecatui/data/testdata/TestData.kt | 33 +++++++++++++ .../revenuecatui/PaywallDataValidationTest.kt | 49 ++++--------------- 2 files changed, 42 insertions(+), 40 deletions(-) diff --git a/ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/data/testdata/TestData.kt b/ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/data/testdata/TestData.kt index 80f7d80dc7..7131e142d5 100644 --- a/ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/data/testdata/TestData.kt +++ b/ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/data/testdata/TestData.kt @@ -2,6 +2,7 @@ package com.revenuecat.purchases.ui.revenuecatui.data.testdata import android.content.Context import androidx.compose.material3.ColorScheme +import androidx.compose.ui.graphics.Color import androidx.lifecycle.ViewModel import com.revenuecat.purchases.Offering import com.revenuecat.purchases.Package @@ -53,6 +54,38 @@ internal object TestData { offerName = "{{ sub_period }}", features = emptyList(), ) + + val currentColorScheme = ColorScheme( + primary = Color.White, + onPrimary = Color.White, + primaryContainer = Color.White, + onPrimaryContainer = Color.White, + inversePrimary = Color.Green, + secondary = Color.Black, + onSecondary = Color.Black, + secondaryContainer = Color.Black, + onSecondaryContainer = Color.Black, + tertiary = Color.Cyan, + onTertiary = Color.Black, + tertiaryContainer = Color.Gray, + onTertiaryContainer = Color.White, + background = Color.White, + onBackground = Color.Black, + surface = Color.Gray, + onSurface = Color.Black, + surfaceVariant = Color.DarkGray, + onSurfaceVariant = Color.White, + surfaceTint = Color.LightGray, + inverseSurface = Color.Black, + inverseOnSurface = Color.White, + error = Color.Red, + onError = Color.White, + errorContainer = Color.Red, + onErrorContainer = Color.White, + outline = Color.Transparent, + outlineVariant = Color.LightGray, + scrim = Color.Gray, + ) } val offeringWithNoPaywall = Offering( diff --git a/ui/revenuecatui/src/test/kotlin/com/revenuecat/purchases/ui/revenuecatui/PaywallDataValidationTest.kt b/ui/revenuecatui/src/test/kotlin/com/revenuecat/purchases/ui/revenuecatui/PaywallDataValidationTest.kt index e9971daf40..d261390ea9 100644 --- a/ui/revenuecatui/src/test/kotlin/com/revenuecat/purchases/ui/revenuecatui/PaywallDataValidationTest.kt +++ b/ui/revenuecatui/src/test/kotlin/com/revenuecat/purchases/ui/revenuecatui/PaywallDataValidationTest.kt @@ -1,13 +1,10 @@ package com.revenuecat.purchases.ui.revenuecatui -import androidx.compose.material3.ColorScheme -import androidx.compose.ui.graphics.Color import androidx.test.ext.junit.runners.AndroidJUnit4 import com.revenuecat.purchases.paywalls.PaywallData import com.revenuecat.purchases.ui.revenuecatui.data.testdata.TestData import com.revenuecat.purchases.ui.revenuecatui.errors.PaywallValidationError import com.revenuecat.purchases.ui.revenuecatui.helpers.validatedPaywall -import io.mockk.every import io.mockk.mockk import kotlinx.serialization.decodeFromString import kotlinx.serialization.json.Json @@ -28,7 +25,7 @@ class PaywallDataValidationTest { fun `Validate an offering without paywall`() { val offering = TestData.offeringWithNoPaywall val paywallValidationResult = offering.validatedPaywall( - currentColorScheme = mockk(relaxed = true), + currentColorScheme = TestData.Constants.currentColorScheme, ) assertThat(paywallValidationResult.error).isEqualTo(PaywallValidationError.MissingPaywall) } @@ -37,7 +34,7 @@ class PaywallDataValidationTest { fun `Validate a valid paywall`() { val offering = TestData.template1Offering val paywallValidationResult = offering.validatedPaywall( - currentColorScheme = mockk(relaxed = true), + currentColorScheme = TestData.Constants.currentColorScheme, ) assertThat(paywallValidationResult.error).isNull() } @@ -47,44 +44,16 @@ class PaywallDataValidationTest { val templateName = "unrecognized_template" val originalOffering = TestData.offeringWithMultiPackagePaywall val offering = originalOffering.copy(paywall = originalOffering.paywall!!.copy(templateName = templateName)) - val currentColorScheme = ColorScheme( - primary = Color.White, - onPrimary = Color.White, - primaryContainer = Color.White, - onPrimaryContainer = Color.White, - inversePrimary = Color.Green, - secondary = Color.Black, - onSecondary = Color.Black, - secondaryContainer = Color.Black, - onSecondaryContainer = Color.Black, - tertiary = Color.Cyan, - onTertiary = Color.Black, - tertiaryContainer = Color.Gray, - onTertiaryContainer = Color.White, - background = Color.White, - onBackground = Color.Black, - surface = Color.Gray, - onSurface = Color.Black, - surfaceVariant = Color.DarkGray, - onSurfaceVariant = Color.White, - surfaceTint = Color.LightGray, - inverseSurface = Color.Black, - inverseOnSurface = Color.White, - error = Color.Red, - onError = Color.White, - errorContainer = Color.Red, - onErrorContainer = Color.White, - outline = Color.Transparent, - outlineVariant = Color.LightGray, - scrim = Color.Gray - ) val paywallValidationResult = offering.validatedPaywall( - currentColorScheme = currentColorScheme, + currentColorScheme = TestData.Constants.currentColorScheme, ) verifyPackages(paywallValidationResult.displayablePaywall, originalOffering.paywall!!) - snapshot(paywallValidationResult.displayablePaywall) + compareWithJson( + paywallValidationResult.displayablePaywall, + "testUnrecognizedTemplateNameGeneratesDefaultPaywall.1.json" + ) assertThat(paywallValidationResult.error).isEqualTo(PaywallValidationError.InvalidTemplate(templateName)) } @@ -92,8 +61,8 @@ class PaywallDataValidationTest { assertThat(actual.config.packages).isEqualTo(expectation.config.packages) } - private fun snapshot(displayablePaywall: PaywallData) { - val json = loadJSON("testUnrecognizedTemplateNameGeneratesDefaultPaywall.1.json") + private fun compareWithJson(displayablePaywall: PaywallData, jsonFileName: String) { + val json = loadJSON(jsonFileName) val paywall: PaywallData = Json.decodeFromString(json) assertThat(displayablePaywall).isEqualTo(paywall) } From a6507bcedb8c32f4412fb183ab8eff410aa68c15 Mon Sep 17 00:00:00 2001 From: Cesar de la Vega Date: Wed, 4 Oct 2023 18:09:48 +0200 Subject: [PATCH 3/9] creates file OfferingWithMultiPackagePaywall --- .../ui/revenuecatui/data/testdata/TestData.kt | 41 --------------- .../OfferingWithMultiPackagePaywall.kt | 50 +++++++++++++++++++ 2 files changed, 50 insertions(+), 41 deletions(-) create mode 100644 ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/data/testdata/offerings/OfferingWithMultiPackagePaywall.kt diff --git a/ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/data/testdata/TestData.kt b/ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/data/testdata/TestData.kt index 7131e142d5..9dfc4fea01 100644 --- a/ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/data/testdata/TestData.kt +++ b/ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/data/testdata/TestData.kt @@ -16,7 +16,6 @@ import com.revenuecat.purchases.models.RecurrenceMode import com.revenuecat.purchases.models.StoreProduct import com.revenuecat.purchases.models.SubscriptionOption import com.revenuecat.purchases.models.SubscriptionOptions -import com.revenuecat.purchases.paywalls.PaywallColor import com.revenuecat.purchases.paywalls.PaywallData import com.revenuecat.purchases.ui.revenuecatui.PaywallViewMode import com.revenuecat.purchases.ui.revenuecatui.R @@ -130,46 +129,6 @@ internal object TestData { serverDescription = "", ) - val offeringWithMultiPackagePaywall = Offering( - identifier = "offeringWithMultiPackagePaywall", - serverDescription = "Offering", - metadata = mapOf(), - paywall = PaywallData( - templateName = PaywallTemplate.TEMPLATE_2.id, - config = PaywallData.Configuration( - packages = listOf(PackageType.ANNUAL.identifier!!, PackageType.MONTHLY.identifier!!), - images = Constants.images, - colors = PaywallData.Configuration.ColorInformation( - light = PaywallData.Configuration.Colors( - background = PaywallColor("#FFFFFF"), - text1 = PaywallColor("#111111"), - callToActionBackground = PaywallColor("#EC807C"), - callToActionForeground = PaywallColor("#FFFFFF"), - accent1 = PaywallColor("#BC66FF"), - accent2 = PaywallColor("#111100"), - ), - dark = PaywallData.Configuration.Colors( - background = PaywallColor("#000000"), - text1 = PaywallColor("#EEEEEE"), - callToActionBackground = PaywallColor("#ACD27A"), - callToActionForeground = PaywallColor("#000000"), - accent1 = PaywallColor("#B022BB"), - accent2 = PaywallColor("#EEDDEE"), - ), - ), - blurredBackgroundImage = true, - privacyURL = URL("https://revenuecat.com/tos"), - ), - localization = mapOf("en_US" to Constants.localization), - assetBaseURL = Constants.assetBaseURL, - ), - availablePackages = listOf( - Packages.weekly, - Packages.monthly, - Packages.annual, - ), - ) - object Packages { val weekly = Package( packageType = PackageType.WEEKLY, diff --git a/ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/data/testdata/offerings/OfferingWithMultiPackagePaywall.kt b/ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/data/testdata/offerings/OfferingWithMultiPackagePaywall.kt new file mode 100644 index 0000000000..63e11bd0ff --- /dev/null +++ b/ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/data/testdata/offerings/OfferingWithMultiPackagePaywall.kt @@ -0,0 +1,50 @@ +package com.revenuecat.purchases.ui.revenuecatui.data.testdata.offerings + +import com.revenuecat.purchases.Offering +import com.revenuecat.purchases.PackageType +import com.revenuecat.purchases.paywalls.PaywallColor +import com.revenuecat.purchases.paywalls.PaywallData +import com.revenuecat.purchases.ui.revenuecatui.data.processed.PaywallTemplate +import com.revenuecat.purchases.ui.revenuecatui.data.testdata.TestData +import java.net.URL + +internal val TestData.offeringWithMultiPackagePaywall: Offering + get() = Offering( + identifier = "offeringWithMultiPackagePaywall", + serverDescription = "Offering", + metadata = mapOf(), + paywall = PaywallData( + templateName = PaywallTemplate.TEMPLATE_2.id, + config = PaywallData.Configuration( + packages = listOf(PackageType.ANNUAL.identifier!!, PackageType.MONTHLY.identifier!!), + images = TestData.Constants.images, + colors = PaywallData.Configuration.ColorInformation( + light = PaywallData.Configuration.Colors( + background = PaywallColor("#FFFFFF"), + text1 = PaywallColor("#111111"), + callToActionBackground = PaywallColor("#EC807C"), + callToActionForeground = PaywallColor("#FFFFFF"), + accent1 = PaywallColor("#BC66FF"), + accent2 = PaywallColor("#111100"), + ), + dark = PaywallData.Configuration.Colors( + background = PaywallColor("#000000"), + text1 = PaywallColor("#EEEEEE"), + callToActionBackground = PaywallColor("#ACD27A"), + callToActionForeground = PaywallColor("#000000"), + accent1 = PaywallColor("#B022BB"), + accent2 = PaywallColor("#EEDDEE"), + ), + ), + blurredBackgroundImage = true, + privacyURL = URL("https://revenuecat.com/tos"), + ), + localization = mapOf("en_US" to TestData.Constants.localization), + assetBaseURL = TestData.Constants.assetBaseURL, + ), + availablePackages = listOf( + TestData.Packages.weekly, + TestData.Packages.monthly, + TestData.Packages.annual, + ), + ) From a5e05af4dd08cb87a0ad4a86359e54041f172497 Mon Sep 17 00:00:00 2001 From: Cesar de la Vega Date: Wed, 4 Oct 2023 18:21:03 +0200 Subject: [PATCH 4/9] unrecognized variable --- .../revenuecatui/PaywallDataValidationTest.kt | 31 +++++++++++++++++-- ...ltPaywall.1.json => default_template.json} | 0 2 files changed, 29 insertions(+), 2 deletions(-) rename ui/revenuecatui/src/test/resources/{testUnrecognizedTemplateNameGeneratesDefaultPaywall.1.json => default_template.json} (100%) diff --git a/ui/revenuecatui/src/test/kotlin/com/revenuecat/purchases/ui/revenuecatui/PaywallDataValidationTest.kt b/ui/revenuecatui/src/test/kotlin/com/revenuecat/purchases/ui/revenuecatui/PaywallDataValidationTest.kt index d261390ea9..37478b54d9 100644 --- a/ui/revenuecatui/src/test/kotlin/com/revenuecat/purchases/ui/revenuecatui/PaywallDataValidationTest.kt +++ b/ui/revenuecatui/src/test/kotlin/com/revenuecat/purchases/ui/revenuecatui/PaywallDataValidationTest.kt @@ -3,6 +3,7 @@ package com.revenuecat.purchases.ui.revenuecatui import androidx.test.ext.junit.runners.AndroidJUnit4 import com.revenuecat.purchases.paywalls.PaywallData import com.revenuecat.purchases.ui.revenuecatui.data.testdata.TestData +import com.revenuecat.purchases.ui.revenuecatui.data.testdata.offerings.offeringWithMultiPackagePaywall import com.revenuecat.purchases.ui.revenuecatui.errors.PaywallValidationError import com.revenuecat.purchases.ui.revenuecatui.helpers.validatedPaywall import io.mockk.mockk @@ -52,11 +53,38 @@ class PaywallDataValidationTest { verifyPackages(paywallValidationResult.displayablePaywall, originalOffering.paywall!!) compareWithJson( paywallValidationResult.displayablePaywall, - "testUnrecognizedTemplateNameGeneratesDefaultPaywall.1.json" + "default_template.json" ) assertThat(paywallValidationResult.error).isEqualTo(PaywallValidationError.InvalidTemplate(templateName)) } + @Test + fun `Unrecognized variable generates default paywall`() { + val originalOffering = TestData.offeringWithMultiPackagePaywall + + val paywall = originalOffering.paywall!!.let { originalPaywall -> + val (locale, originalLocalizedConfiguration) = originalPaywall.localizedConfiguration + val localizedConfiguration = originalLocalizedConfiguration.copy( + title = "Title with {{ unrecognized_variable }}", + callToAction = "{{ future_variable }}", + ) + originalPaywall.copy(localization = mapOf(locale.toString() to localizedConfiguration)) + } + + val offering = originalOffering.copy(paywall = paywall) + val paywallValidationResult = offering.validatedPaywall( + currentColorScheme = TestData.Constants.currentColorScheme, + ) + verifyPackages(paywallValidationResult.displayablePaywall, originalOffering.paywall!!) + compareWithJson( + paywallValidationResult.displayablePaywall, + "default_template.json" + ) + assertThat(paywallValidationResult.error).isEqualTo( + PaywallValidationError.InvalidVariables(setOf("unrecognized_variable", "future_variable")) + ) + } + private fun verifyPackages(actual: PaywallData, expectation: PaywallData) { assertThat(actual.config.packages).isEqualTo(expectation.config.packages) } @@ -68,5 +96,4 @@ class PaywallDataValidationTest { } private fun loadJSON(jsonFileName: String) = File(javaClass.classLoader!!.getResource(jsonFileName).file).readText() - } \ No newline at end of file diff --git a/ui/revenuecatui/src/test/resources/testUnrecognizedTemplateNameGeneratesDefaultPaywall.1.json b/ui/revenuecatui/src/test/resources/default_template.json similarity index 100% rename from ui/revenuecatui/src/test/resources/testUnrecognizedTemplateNameGeneratesDefaultPaywall.1.json rename to ui/revenuecatui/src/test/resources/default_template.json From 66f1a2294a25f170c6b1cd576779a852c18eb0fe Mon Sep 17 00:00:00 2001 From: Cesar de la Vega Date: Wed, 4 Oct 2023 19:15:10 +0200 Subject: [PATCH 5/9] finish tests --- .../revenuecatui/PaywallDataValidationTest.kt | 71 +++++++++++-------- 1 file changed, 42 insertions(+), 29 deletions(-) diff --git a/ui/revenuecatui/src/test/kotlin/com/revenuecat/purchases/ui/revenuecatui/PaywallDataValidationTest.kt b/ui/revenuecatui/src/test/kotlin/com/revenuecat/purchases/ui/revenuecatui/PaywallDataValidationTest.kt index 37478b54d9..799e47483a 100644 --- a/ui/revenuecatui/src/test/kotlin/com/revenuecat/purchases/ui/revenuecatui/PaywallDataValidationTest.kt +++ b/ui/revenuecatui/src/test/kotlin/com/revenuecat/purchases/ui/revenuecatui/PaywallDataValidationTest.kt @@ -1,16 +1,15 @@ package com.revenuecat.purchases.ui.revenuecatui import androidx.test.ext.junit.runners.AndroidJUnit4 +import com.revenuecat.purchases.Offering import com.revenuecat.purchases.paywalls.PaywallData import com.revenuecat.purchases.ui.revenuecatui.data.testdata.TestData import com.revenuecat.purchases.ui.revenuecatui.data.testdata.offerings.offeringWithMultiPackagePaywall import com.revenuecat.purchases.ui.revenuecatui.errors.PaywallValidationError import com.revenuecat.purchases.ui.revenuecatui.helpers.validatedPaywall -import io.mockk.mockk import kotlinx.serialization.decodeFromString import kotlinx.serialization.json.Json import org.assertj.core.api.Assertions.assertThat -import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import java.io.File @@ -18,25 +17,17 @@ import java.io.File @RunWith(AndroidJUnit4::class) class PaywallDataValidationTest { - @Before - fun setUp() { - } - @Test fun `Validate an offering without paywall`() { val offering = TestData.offeringWithNoPaywall - val paywallValidationResult = offering.validatedPaywall( - currentColorScheme = TestData.Constants.currentColorScheme, - ) + val paywallValidationResult = getPaywallValidationResult(offering) assertThat(paywallValidationResult.error).isEqualTo(PaywallValidationError.MissingPaywall) } @Test fun `Validate a valid paywall`() { val offering = TestData.template1Offering - val paywallValidationResult = offering.validatedPaywall( - currentColorScheme = TestData.Constants.currentColorScheme, - ) + val paywallValidationResult = getPaywallValidationResult(offering) assertThat(paywallValidationResult.error).isNull() } @@ -46,15 +37,10 @@ class PaywallDataValidationTest { val originalOffering = TestData.offeringWithMultiPackagePaywall val offering = originalOffering.copy(paywall = originalOffering.paywall!!.copy(templateName = templateName)) - val paywallValidationResult = offering.validatedPaywall( - currentColorScheme = TestData.Constants.currentColorScheme, - ) + val paywallValidationResult = getPaywallValidationResult(offering) verifyPackages(paywallValidationResult.displayablePaywall, originalOffering.paywall!!) - compareWithJson( - paywallValidationResult.displayablePaywall, - "default_template.json" - ) + compareWithDefaultTemplate(paywallValidationResult.displayablePaywall) assertThat(paywallValidationResult.error).isEqualTo(PaywallValidationError.InvalidTemplate(templateName)) } @@ -72,28 +58,55 @@ class PaywallDataValidationTest { } val offering = originalOffering.copy(paywall = paywall) - val paywallValidationResult = offering.validatedPaywall( - currentColorScheme = TestData.Constants.currentColorScheme, - ) + val paywallValidationResult = getPaywallValidationResult(offering) verifyPackages(paywallValidationResult.displayablePaywall, originalOffering.paywall!!) - compareWithJson( - paywallValidationResult.displayablePaywall, - "default_template.json" - ) + compareWithDefaultTemplate(paywallValidationResult.displayablePaywall) assertThat(paywallValidationResult.error).isEqualTo( PaywallValidationError.InvalidVariables(setOf("unrecognized_variable", "future_variable")) ) } + @Test + fun `Unrecognized variables in features generate default paywall`() { + val originalOffering = TestData.offeringWithMultiPackagePaywall + + val paywall = originalOffering.paywall!!.let { originalPaywall -> + val (locale, originalLocalizedConfiguration) = originalPaywall.localizedConfiguration + val localizedConfiguration = originalLocalizedConfiguration.copy( + features = listOf( + PaywallData.LocalizedConfiguration.Feature( + title = "{{ future_variable }}", + content = "{{ new_variable }}" + ), + PaywallData.LocalizedConfiguration.Feature( + title = "{{ another_one }}" + ) + ) + ) + originalPaywall.copy(localization = mapOf(locale.toString() to localizedConfiguration)) + } + + val offering = originalOffering.copy(paywall = paywall) + val paywallValidationResult = getPaywallValidationResult(offering) + verifyPackages(paywallValidationResult.displayablePaywall, originalOffering.paywall!!) + compareWithDefaultTemplate(paywallValidationResult.displayablePaywall) + assertThat(paywallValidationResult.error).isEqualTo( + PaywallValidationError.InvalidVariables(setOf("future_variable", "new_variable", "another_one")) + ) + } + + private fun getPaywallValidationResult(offering: Offering) = offering.validatedPaywall( + currentColorScheme = TestData.Constants.currentColorScheme, + ) + private fun verifyPackages(actual: PaywallData, expectation: PaywallData) { assertThat(actual.config.packages).isEqualTo(expectation.config.packages) } - private fun compareWithJson(displayablePaywall: PaywallData, jsonFileName: String) { - val json = loadJSON(jsonFileName) + private fun compareWithDefaultTemplate(displayablePaywall: PaywallData) { + val json = File(javaClass.classLoader!!.getResource("default_template.json").file).readText() val paywall: PaywallData = Json.decodeFromString(json) assertThat(displayablePaywall).isEqualTo(paywall) } - private fun loadJSON(jsonFileName: String) = File(javaClass.classLoader!!.getResource(jsonFileName).file).readText() } \ No newline at end of file From b2850fe4a22f5a42ae48184a506c2f3696d34572 Mon Sep 17 00:00:00 2001 From: Cesar de la Vega Date: Wed, 4 Oct 2023 19:22:01 +0200 Subject: [PATCH 6/9] add icons validation --- .../revenuecatui/PaywallDataValidationTest.kt | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/ui/revenuecatui/src/test/kotlin/com/revenuecat/purchases/ui/revenuecatui/PaywallDataValidationTest.kt b/ui/revenuecatui/src/test/kotlin/com/revenuecat/purchases/ui/revenuecatui/PaywallDataValidationTest.kt index 799e47483a..408bcc5fd5 100644 --- a/ui/revenuecatui/src/test/kotlin/com/revenuecat/purchases/ui/revenuecatui/PaywallDataValidationTest.kt +++ b/ui/revenuecatui/src/test/kotlin/com/revenuecat/purchases/ui/revenuecatui/PaywallDataValidationTest.kt @@ -95,6 +95,32 @@ class PaywallDataValidationTest { ) } + @Test + fun `Unrecognized icons generate default paywall`() { + val originalOffering = TestData.offeringWithMultiPackagePaywall + + val paywall = originalOffering.paywall!!.let { originalPaywall -> + val (locale, originalLocalizedConfiguration) = originalPaywall.localizedConfiguration + val localizedConfiguration = originalLocalizedConfiguration.copy( + features = listOf( + PaywallData.LocalizedConfiguration.Feature( + title = "Feature Title", + iconID = "an_unrecognized_icon", + ), + ) + ) + originalPaywall.copy(localization = mapOf(locale.toString() to localizedConfiguration)) + } + + val offering = originalOffering.copy(paywall = paywall) + val paywallValidationResult = getPaywallValidationResult(offering) + verifyPackages(paywallValidationResult.displayablePaywall, originalOffering.paywall!!) + compareWithDefaultTemplate(paywallValidationResult.displayablePaywall) + assertThat(paywallValidationResult.error).isEqualTo( + PaywallValidationError.InvalidIcons(setOf("an_unrecognized_icon")) + ) + } + private fun getPaywallValidationResult(offering: Offering) = offering.validatedPaywall( currentColorScheme = TestData.Constants.currentColorScheme, ) From 68a535b132825e060483eaf94a84f214c3312a1f Mon Sep 17 00:00:00 2001 From: Cesar de la Vega Date: Thu, 5 Oct 2023 12:25:26 +0200 Subject: [PATCH 7/9] some refactoring for better failure reports --- .../OfferingWithMultiPackagePaywall.kt | 50 ------------------- .../testdata/templates/Template2TestData.kt | 3 +- .../revenuecatui/PaywallDataValidationTest.kt | 44 +++++++++++++--- .../TemplateConfigurationFactoryTest.kt | 10 ++-- 4 files changed, 45 insertions(+), 62 deletions(-) delete mode 100644 ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/data/testdata/offerings/OfferingWithMultiPackagePaywall.kt diff --git a/ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/data/testdata/offerings/OfferingWithMultiPackagePaywall.kt b/ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/data/testdata/offerings/OfferingWithMultiPackagePaywall.kt deleted file mode 100644 index 63e11bd0ff..0000000000 --- a/ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/data/testdata/offerings/OfferingWithMultiPackagePaywall.kt +++ /dev/null @@ -1,50 +0,0 @@ -package com.revenuecat.purchases.ui.revenuecatui.data.testdata.offerings - -import com.revenuecat.purchases.Offering -import com.revenuecat.purchases.PackageType -import com.revenuecat.purchases.paywalls.PaywallColor -import com.revenuecat.purchases.paywalls.PaywallData -import com.revenuecat.purchases.ui.revenuecatui.data.processed.PaywallTemplate -import com.revenuecat.purchases.ui.revenuecatui.data.testdata.TestData -import java.net.URL - -internal val TestData.offeringWithMultiPackagePaywall: Offering - get() = Offering( - identifier = "offeringWithMultiPackagePaywall", - serverDescription = "Offering", - metadata = mapOf(), - paywall = PaywallData( - templateName = PaywallTemplate.TEMPLATE_2.id, - config = PaywallData.Configuration( - packages = listOf(PackageType.ANNUAL.identifier!!, PackageType.MONTHLY.identifier!!), - images = TestData.Constants.images, - colors = PaywallData.Configuration.ColorInformation( - light = PaywallData.Configuration.Colors( - background = PaywallColor("#FFFFFF"), - text1 = PaywallColor("#111111"), - callToActionBackground = PaywallColor("#EC807C"), - callToActionForeground = PaywallColor("#FFFFFF"), - accent1 = PaywallColor("#BC66FF"), - accent2 = PaywallColor("#111100"), - ), - dark = PaywallData.Configuration.Colors( - background = PaywallColor("#000000"), - text1 = PaywallColor("#EEEEEE"), - callToActionBackground = PaywallColor("#ACD27A"), - callToActionForeground = PaywallColor("#000000"), - accent1 = PaywallColor("#B022BB"), - accent2 = PaywallColor("#EEDDEE"), - ), - ), - blurredBackgroundImage = true, - privacyURL = URL("https://revenuecat.com/tos"), - ), - localization = mapOf("en_US" to TestData.Constants.localization), - assetBaseURL = TestData.Constants.assetBaseURL, - ), - availablePackages = listOf( - TestData.Packages.weekly, - TestData.Packages.monthly, - TestData.Packages.annual, - ), - ) diff --git a/ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/data/testdata/templates/Template2TestData.kt b/ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/data/testdata/templates/Template2TestData.kt index 4598f1b972..4ca797af12 100644 --- a/ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/data/testdata/templates/Template2TestData.kt +++ b/ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/data/testdata/templates/Template2TestData.kt @@ -12,9 +12,8 @@ internal val TestData.template2: PaywallData templateName = PaywallTemplate.TEMPLATE_2.id, config = PaywallData.Configuration( packages = listOf( - PackageType.WEEKLY.identifier!!, - PackageType.MONTHLY.identifier!!, PackageType.ANNUAL.identifier!!, + PackageType.MONTHLY.identifier!!, ), defaultPackage = PackageType.MONTHLY.identifier!!, images = TestData.Constants.images, diff --git a/ui/revenuecatui/src/test/kotlin/com/revenuecat/purchases/ui/revenuecatui/PaywallDataValidationTest.kt b/ui/revenuecatui/src/test/kotlin/com/revenuecat/purchases/ui/revenuecatui/PaywallDataValidationTest.kt index 408bcc5fd5..c49847b1db 100644 --- a/ui/revenuecatui/src/test/kotlin/com/revenuecat/purchases/ui/revenuecatui/PaywallDataValidationTest.kt +++ b/ui/revenuecatui/src/test/kotlin/com/revenuecat/purchases/ui/revenuecatui/PaywallDataValidationTest.kt @@ -2,6 +2,7 @@ package com.revenuecat.purchases.ui.revenuecatui import androidx.test.ext.junit.runners.AndroidJUnit4 import com.revenuecat.purchases.Offering +import com.revenuecat.purchases.paywalls.PaywallColor import com.revenuecat.purchases.paywalls.PaywallData import com.revenuecat.purchases.ui.revenuecatui.data.testdata.TestData import com.revenuecat.purchases.ui.revenuecatui.data.testdata.offerings.offeringWithMultiPackagePaywall @@ -13,6 +14,7 @@ import org.assertj.core.api.Assertions.assertThat import org.junit.Test import org.junit.runner.RunWith import java.io.File +import java.net.URL @RunWith(AndroidJUnit4::class) class PaywallDataValidationTest { @@ -34,7 +36,7 @@ class PaywallDataValidationTest { @Test fun `Unrecognized template name generates default paywall`() { val templateName = "unrecognized_template" - val originalOffering = TestData.offeringWithMultiPackagePaywall + val originalOffering = TestData.template2Offering val offering = originalOffering.copy(paywall = originalOffering.paywall!!.copy(templateName = templateName)) val paywallValidationResult = getPaywallValidationResult(offering) @@ -46,7 +48,7 @@ class PaywallDataValidationTest { @Test fun `Unrecognized variable generates default paywall`() { - val originalOffering = TestData.offeringWithMultiPackagePaywall + val originalOffering = TestData.template2Offering val paywall = originalOffering.paywall!!.let { originalPaywall -> val (locale, originalLocalizedConfiguration) = originalPaywall.localizedConfiguration @@ -68,7 +70,7 @@ class PaywallDataValidationTest { @Test fun `Unrecognized variables in features generate default paywall`() { - val originalOffering = TestData.offeringWithMultiPackagePaywall + val originalOffering = TestData.template2Offering val paywall = originalOffering.paywall!!.let { originalPaywall -> val (locale, originalLocalizedConfiguration) = originalPaywall.localizedConfiguration @@ -97,7 +99,7 @@ class PaywallDataValidationTest { @Test fun `Unrecognized icons generate default paywall`() { - val originalOffering = TestData.offeringWithMultiPackagePaywall + val originalOffering = TestData.template2Offering val paywall = originalOffering.paywall!!.let { originalPaywall -> val (locale, originalLocalizedConfiguration) = originalPaywall.localizedConfiguration @@ -131,8 +133,38 @@ class PaywallDataValidationTest { private fun compareWithDefaultTemplate(displayablePaywall: PaywallData) { val json = File(javaClass.classLoader!!.getResource("default_template.json").file).readText() - val paywall: PaywallData = Json.decodeFromString(json) - assertThat(displayablePaywall).isEqualTo(paywall) + val defaultPaywall: PaywallData = Json.decodeFromString(json) + + assertThat(displayablePaywall.assetBaseURL).isEqualTo(defaultPaywall.assetBaseURL) + assertThat(displayablePaywall.templateName).isEqualTo(defaultPaywall.templateName) + assertThat(displayablePaywall.revision).isEqualTo(defaultPaywall.revision) + + (displayablePaywall.config to defaultPaywall.config).let { (config, defaultConfig) -> + assertThat(config.blurredBackgroundImage).isEqualTo(defaultConfig.blurredBackgroundImage) + assertColors(config.colors.light, defaultConfig.colors.light) + assertColors(config.colors.dark!!, defaultConfig.colors.dark!!) + assertThat(config.displayRestorePurchases).isEqualTo(defaultConfig.displayRestorePurchases) + assertThat(config.images.background).isEqualTo(defaultConfig.images.background) + assertThat(config.images.header).isEqualTo(defaultConfig.images.header) + assertThat(config.images.icon).isEqualTo(defaultConfig.images.icon) + assertThat(config.packages).containsExactly(*defaultConfig.packages.toTypedArray()) + assertThat(config.defaultPackage).isEqualTo(defaultConfig.defaultPackage) + assertThat(config.termsOfServiceURL).isEqualTo(defaultConfig.termsOfServiceURL) + assertThat(config.privacyURL).isEqualTo(defaultConfig.privacyURL) + } + + assertThat(displayablePaywall.localizedConfiguration).isEqualTo(defaultPaywall.localizedConfiguration) } + private fun assertColors( + actualColors: PaywallData.Configuration.Colors, + defaultColors: PaywallData.Configuration.Colors, + ) { + assertThat(actualColors.accent1).isEqualTo(defaultColors.accent1) + assertThat(actualColors.accent2).isEqualTo(defaultColors.accent2) + assertThat(actualColors.background).isEqualTo(defaultColors.background) + assertThat(actualColors.callToActionBackground).isEqualTo(defaultColors.callToActionBackground) + assertThat(actualColors.callToActionForeground).isEqualTo(defaultColors.callToActionForeground) + assertThat(actualColors.text1).isEqualTo(defaultColors.text1) + } } \ No newline at end of file diff --git a/ui/revenuecatui/src/test/kotlin/com/revenuecat/purchases/ui/revenuecatui/data/processed/TemplateConfigurationFactoryTest.kt b/ui/revenuecatui/src/test/kotlin/com/revenuecat/purchases/ui/revenuecatui/data/processed/TemplateConfigurationFactoryTest.kt index 977a8ed3d6..5c9113b795 100644 --- a/ui/revenuecatui/src/test/kotlin/com/revenuecat/purchases/ui/revenuecatui/data/processed/TemplateConfigurationFactoryTest.kt +++ b/ui/revenuecatui/src/test/kotlin/com/revenuecat/purchases/ui/revenuecatui/data/processed/TemplateConfigurationFactoryTest.kt @@ -60,15 +60,17 @@ internal class TemplateConfigurationFactoryTest { val packageConfiguration = template2Configuration.packages as TemplateConfiguration.PackageConfiguration.Multiple val expectedConfiguration = TemplateConfiguration.PackageConfiguration.Multiple( - first = getPackageInfo(TestData.Packages.weekly), + first = getPackageInfo(TestData.Packages.annual), default = getPackageInfo(TestData.Packages.monthly), all = listOf( - getPackageInfo(TestData.Packages.weekly), + getPackageInfo(TestData.Packages.annual), getPackageInfo(TestData.Packages.monthly), - getPackageInfo(TestData.Packages.annual) ), ) - assertThat(packageConfiguration).isEqualTo(expectedConfiguration) + + assertThat(packageConfiguration.first).isEqualTo(expectedConfiguration.first) + assertThat(packageConfiguration.default).isEqualTo(expectedConfiguration.default) + assertThat(packageConfiguration.all).containsExactly(*expectedConfiguration.all.toTypedArray()) } @Test From 6054ccecc5da867ac911ce3d5396a9baae9220e9 Mon Sep 17 00:00:00 2001 From: Cesar de la Vega Date: Thu, 5 Oct 2023 12:26:05 +0200 Subject: [PATCH 8/9] test implementation --- ui/revenuecatui/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/revenuecatui/build.gradle b/ui/revenuecatui/build.gradle index 0d26ef8d54..07bdaf28fd 100644 --- a/ui/revenuecatui/build.gradle +++ b/ui/revenuecatui/build.gradle @@ -54,8 +54,8 @@ dependencies { implementation libs.coil.svg debugImplementation libs.compose.ui.tooling debugImplementation libs.androidx.test.compose.manifest - implementation libs.kotlinx.serialization.json testImplementation libs.bundles.test testImplementation libs.coroutines.test + testImplementation libs.kotlinx.serialization.json } From 5875da0ddcdb80998d36d56e61fbdb2ec4ad35e0 Mon Sep 17 00:00:00 2001 From: Cesar de la Vega Date: Thu, 5 Oct 2023 13:23:42 +0200 Subject: [PATCH 9/9] fix imports --- .../purchases/ui/revenuecatui/PaywallDataValidationTest.kt | 3 --- 1 file changed, 3 deletions(-) diff --git a/ui/revenuecatui/src/test/kotlin/com/revenuecat/purchases/ui/revenuecatui/PaywallDataValidationTest.kt b/ui/revenuecatui/src/test/kotlin/com/revenuecat/purchases/ui/revenuecatui/PaywallDataValidationTest.kt index c49847b1db..69070f4530 100644 --- a/ui/revenuecatui/src/test/kotlin/com/revenuecat/purchases/ui/revenuecatui/PaywallDataValidationTest.kt +++ b/ui/revenuecatui/src/test/kotlin/com/revenuecat/purchases/ui/revenuecatui/PaywallDataValidationTest.kt @@ -2,10 +2,8 @@ package com.revenuecat.purchases.ui.revenuecatui import androidx.test.ext.junit.runners.AndroidJUnit4 import com.revenuecat.purchases.Offering -import com.revenuecat.purchases.paywalls.PaywallColor import com.revenuecat.purchases.paywalls.PaywallData import com.revenuecat.purchases.ui.revenuecatui.data.testdata.TestData -import com.revenuecat.purchases.ui.revenuecatui.data.testdata.offerings.offeringWithMultiPackagePaywall import com.revenuecat.purchases.ui.revenuecatui.errors.PaywallValidationError import com.revenuecat.purchases.ui.revenuecatui.helpers.validatedPaywall import kotlinx.serialization.decodeFromString @@ -14,7 +12,6 @@ import org.assertj.core.api.Assertions.assertThat import org.junit.Test import org.junit.runner.RunWith import java.io.File -import java.net.URL @RunWith(AndroidJUnit4::class) class PaywallDataValidationTest {