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

Paywalls: new TestData to store fake paywalls #1239

Merged
merged 5 commits into from
Sep 13, 2023

Conversation

NachoSoto
Copy link
Contributor

This allows us to create previews for each template so we can easily iterate on them.

@NachoSoto NachoSoto requested a review from a team September 11, 2023 23:15
@Preview(showBackground = true)
@Composable
fun Template2PaywallPreview() {
InternalPaywallView(offering = TestData.template2Offering)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't actually work, and I have no idea why. Preview fails to load:

java.lang.ClassNotFoundException: com.revenuecat.purchases.Package   at java.lang.ClassLoader.loadClass  at java.lang.ClassLoader.loadClass  at java.lang.Class.getDeclaredMethods0  at java.lang.Class.privateGetDeclaredMethods  at java.lang.Class.getDeclaredMethods  at androidx.compose.ui.tooling.ComposableInvoker.getDeclaredCompatibleMethod   ... (ComposableInvoker.kt:54)   at androidx.compose.ui.tooling.ComposableInvoker.findComposableMethod(ComposableInvoker.kt:74)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I checked out this branch and I'm getting:
image
Which seems to make sense, since we don't have packages with those ids.

I wasn't able to reproduce your issue. Happy to chat today to figure this out!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed the data now so all packages are found. But now I'm running into this from PurchaseButton:

java.lang.IllegalStateException: Error finding activity

@Preview(showBackground = true)
@Composable
fun Template2PaywallPreview() {
InternalPaywallView(offering = TestData.template2Offering)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I checked out this branch and I'm getting:
image
Which seems to make sense, since we don't have packages with those ids.

I wasn't able to reproduce your issue. Happy to chat today to figure this out!

import com.revenuecat.purchases.paywalls.PaywallData
import java.net.URL

class TestData {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, we could make this internal

@tonidero
Copy link
Contributor

Also, looks like you might need to run detekt to autocorrect some issues, you can just do ./gradlew detektAll in the root of the project to auto-correct most issues

}?.value
}

private val Locale.languageWithFallback: String
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a comment mentioning this is to fix testing and previews

@@ -22,7 +24,7 @@ internal interface PaywallViewModel {
val state: StateFlow<PaywallViewState>

fun selectPackage(packageToSelect: Package)
fun purchaseSelectedPackage(activity: Activity)
fun purchaseSelectedPackage(context: Context)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, I worry about this becuase there's no indication to the developers that this should be a context with an Activity

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to fix the previews right? 🤔

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's to fix the previews. Basically, it can't find an activity in the preview context so it fails... Any ideas of how to solve this? I can add a comment to the function so at least we are aware when using this function... And well, this context is usually an activity... I don't think LocalContext.current would return any service context or anything like that afaik.

This allows us to create previews for each template so we can easily iterate on them.
@NachoSoto
Copy link
Contributor Author

@tonidero this should be ready now :)

@codecov
Copy link

codecov bot commented Sep 13, 2023

Codecov Report

❗ No coverage uploaded for pull request base (paywalls@c313806). Click here to learn what that means.
Patch has no changes to coverable lines.

Additional details and impacted files
@@             Coverage Diff             @@
##             paywalls    #1239   +/-   ##
===========================================
  Coverage            ?   85.45%           
===========================================
  Files               ?      187           
  Lines               ?     6351           
  Branches            ?      923           
===========================================
  Hits                ?     5427           
  Misses              ?      567           
  Partials            ?      357           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@tonidero tonidero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job! This will make iterating much faster 💪

val images = PaywallData.Configuration.Images(
header = "9a17e0a7_1689854430..jpeg",
background = "9a17e0a7_1689854342..jpg",
icon = "9a17e0a7_1689854430..jpeg",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it normal these have two dots?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was a bug in how the backend was storing these initially (/cc @joshdholtz 😅)
It's since been fixed, but these test images were uploaded early on.

@NachoSoto NachoSoto merged commit 6c3867c into paywalls Sep 13, 2023
7 checks passed
@NachoSoto NachoSoto deleted the nacho/paywalls-test-data branch September 13, 2023 20:01
tonidero added a commit that referenced this pull request Oct 31, 2023
This allows us to create previews for each template so we can easily
iterate on them.

---------

Co-authored-by: Toni Rico <antonio.rico.diez@revenuecat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants