Debugview: Add snapshot tests for debug view using Paparazzi#1187
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1187 +/- ##
=======================================
Coverage 85.92% 85.92%
=======================================
Files 181 181
Lines 6217 6217
Branches 900 900
=======================================
Hits 5342 5342
Misses 533 533
Partials 342 342 |
245a982 to
da87a22
Compare
7f8712d to
9813a81
Compare
49814ff to
5926a5c
Compare
| toastMessage, | ||
| Toast.LENGTH_LONG, | ||
| ).show() | ||
| viewModel.toastDisplayed() |
There was a problem hiding this comment.
This was wrong, we should only call this after displaying the toast
| android.useAndroidX=true | ||
| android.enableJetifier=true | ||
| # This is needed for paparazzi to work through jetifier. | ||
| android.jetifier.ignorelist=android-base-common,common |
There was a problem hiding this comment.
We should see if we still need to enable jetifier... For now, this was part of the documentation and didn't find any issues after this.
| factory = InternalDebugRevenueCatScreenViewModelFactory(onPurchaseCompleted, onPurchaseErrored), | ||
| ), | ||
| screenViewModel: DebugRevenueCatViewModel? = null, | ||
| activity: Activity? = null, |
There was a problem hiding this comment.
We need to be able to pass a mock activity now since this is no longer instrumentation tests (doesn't require a device).
| @Test | ||
| fun notConfiguredStateDisplaysCorrectly() { | ||
| snapshotTest { | ||
| InternalDebugRevenueCatScreen( |
There was a problem hiding this comment.
I tried to use the bottom sheet instead of the Screen composable directly, but couldn't get it to work. I changed to this and it worked like a charm, and I think it covers most of what we want.
| onPurchaseErrored: (PurchasesTransactionException) -> Unit, | ||
| isVisible: Boolean = false, | ||
| onDismissCallback: (() -> Unit)? = null, | ||
| viewModel: DebugRevenueCatViewModel? = null, |
There was a problem hiding this comment.
It think this could clarify that passing nil will create a default view model.
There was a problem hiding this comment.
I will add a comment 👍
| @Preview(showBackground = true) | ||
| @Composable | ||
| private fun SettingGroupPreview() { | ||
| val viewModel = object : DebugRevenueCatViewModel { |
| import com.revenuecat.purchases.models.SubscriptionOptions | ||
|
|
||
| @Suppress("MagicNumber") | ||
| internal val testOffering: Offering |
| @Test | ||
| fun notConfiguredStateDisplaysCorrectly() { | ||
| snapshotTest { | ||
| InternalDebugRevenueCatScreen( |
|
|
||
| private fun snapshotTest(composable: @Composable () -> Unit) { | ||
| paparazzi.snapshot { | ||
| Column(modifier = Modifier.heightIn(max = maxHeight)) { |
**This is an automatic release.** ### Bugfixes * Fix NoSuchElementException by using poll when accessing serviceRequests (#1190) via Cesar de la Vega (@vegaro) ### Other Changes * Debug view: rename package (#1191) via Toni Rico (@tonidero) * Debugview: Add snapshot tests for debug view using Paparazzi (#1187) via Toni Rico (@tonidero) * Debug view: Add offerings section and purchasing capabilities (#1186) via Toni Rico (@tonidero) * Debug view: Initial UI + Usage in MagicWeatherCompose (#1075) via Toni Rico (@tonidero) * Remove customEntitlementComputation flavor for non-purchases modules (#1180) via Toni Rico (@tonidero) Co-authored-by: revenuecat-ops <ops@revenuecat.com>
Description
This PR adds some simple snapshot tests for the debug view using Paparazzi. This allows us to not need an emulator, since it uses the android studio engine to generate the snapshots.