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 RevenueCatUI API issues and add API tests #1433

Merged
merged 4 commits into from
Nov 6, 2023

Conversation

tonidero
Copy link
Contributor

@tonidero tonidero commented Nov 3, 2023

Description

This adds API tests for the paywalls module. In the process of writing those API tests I found 2 issues that I wanted to get fixed while the API is experimental:

  • The requiredEntitlementIdentifier parameter in the PaywallActivityLauncher.launchIfNeeded method was after some optional parameters, making it mandatory to use named parameters if you didn't want to pass the other optional parameters.
  • In Java, it wasn't possible to create a PaywallFont since it was using value classes that are not available in Java.

offering: Offering? = null,
fontProvider: ParcelizableFontProvider? = null,
requiredEntitlementIdentifier: String,
Copy link
Contributor Author

@tonidero tonidero Nov 3, 2023

Choose a reason for hiding this comment

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

Honestly I wasn't sure about doing this now since it's a breaking change, but I think it's better now that the API is still experimental. If we don't put this mandatory parameter first, users are forced to use named parameters if they only want to set the requiredEntitlementIdentifier but not the optional parameters.

Lmk if you would prefer me to revert it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, better now than never! I don't think there are that many users yet so let's fix these things while we have time.

@tonidero tonidero changed the title Add revenuecatui api tests Add RevenueCat API tests Nov 3, 2023
@tonidero tonidero changed the title Add RevenueCat API tests Add RevenueCatUI API tests Nov 3, 2023
@tonidero tonidero force-pushed the add-revenuecatui-api-tests branch from 3452e7a to ada223a Compare November 3, 2023 15:07
@@ -17,7 +17,7 @@ android {
}

defaultConfig {
minSdkVersion 21 // Compose requires minSdkVersion 21
minSdkVersion 24 // RevenueCat UI requires 24
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Had to update the api tests in order to test the revenuecatui module. I think it should be fine, since our API shouldn't depend on the sdk version

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm but this helped guarantee that we didn't break this compatibility. Should we create a separate module for revenuecatui API tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm I see your point, but it's difficult to change the minSdkVersion accidentally 🤞, and the main sdk shouldn't compile already if there is any issue that would be caught by the API tester. So I think it's ok to keep it in the same module? cc @vegaro. In case you have other thoughts.

*/
@TypeParceler<FontStyle, FontStyleParceler>()
val fontStyle: FontStyle = FontStyle.Normal,
val fontStyle: Int = FontStyle.Normal.value,
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 is another breaking change in kotlin... Basically I'm doing this since it made it impossible to create instances of these classes in Java, since FontStyle is not available in Java.

@tonidero tonidero changed the title Add RevenueCatUI API tests Fix RevenueCatUI API issues and add API tests Nov 3, 2023
@tonidero tonidero marked this pull request as ready for review November 3, 2023 15:10
@tonidero tonidero requested a review from a team November 3, 2023 15:10
Copy link

codecov bot commented Nov 3, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.13%. Comparing base (afbe457) to head (797c5fa).
Report is 320 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1433   +/-   ##
=======================================
  Coverage   84.13%   84.13%           
=======================================
  Files         197      197           
  Lines        6649     6649           
  Branches      965      965           
=======================================
  Hits         5594     5594           
  Misses        684      684           
  Partials      371      371           

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

Copy link
Contributor

@NachoSoto NachoSoto left a comment

Choose a reason for hiding this comment

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

Awesome thanks for doing this! I figured we'd catch little things like that <3

Just one suggestion, but let me know if that's more trouble than it's worth.

@@ -17,7 +17,7 @@ android {
}

defaultConfig {
minSdkVersion 21 // Compose requires minSdkVersion 21
minSdkVersion 24 // RevenueCat UI requires 24
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm but this helped guarantee that we didn't break this compatibility. Should we create a separate module for revenuecatui API tests?

offering: Offering? = null,
fontProvider: ParcelizableFontProvider? = null,
requiredEntitlementIdentifier: String,
Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, better now than never! I don't think there are that many users yet so let's fix these things while we have time.

@tonidero tonidero merged commit 0f688aa into main Nov 6, 2023
@tonidero tonidero deleted the add-revenuecatui-api-tests branch November 6, 2023 09:13
NachoSoto pushed a commit that referenced this pull request Nov 6, 2023
**This is an automatic release.**

### New Features
* `StoreProduct`: new `pricePerWeek` and `pricePerYear` (#1426) via
NachoSoto (@NachoSoto)
### RevenueCatUI
* Fix RevenueCatUI API issues and add API tests (#1433) via Toni Rico
(@tonidero)
* Paywalls: Add initial snapshot testings for RevenueCatUI library
(#1432) via Toni Rico (@tonidero)
* `Paywalls`: new `{{ sub_price_per_week }}` variable (#1427) via
NachoSoto (@NachoSoto)
* `Paywalls`: new `{{ sub_relative_discount }}` variable (#1425) via
NachoSoto (@NachoSoto)
### Dependency Updates
* Bump fastlane-plugin-revenuecat_internal from `a297205` to `0ddee10`
(#1431) via dependabot[bot] (@dependabot[bot])
### Other Changes
* `Offering`: restore constructor with no `PaywallData` (#1437) via
NachoSoto (@NachoSoto)

Co-authored-by: revenuecat-ops <ops@revenuecat.com>
@vegaro vegaro added pr:other and removed pr:test labels Sep 17, 2024
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.

3 participants