Add configuration and harness smoke tests - #1014
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
3ded913 to
62ef6c4
Compare
2d7a57e to
fddeb79
Compare
98db931 to
c91fc0a
Compare
fddeb79 to
485bb0e
Compare
c91fc0a to
a45f0a2
Compare
485bb0e to
f4dd9a5
Compare
This one's pure harness/CI plumbing, no test content, so it's a small. Adds the `RevenueCat.Tests.EditMode` assembly, `PurchasesWrapperSpy`, and an internal `SetWrapper` hook (via `InternalsVisibleTo`) so tests can inject the spy into `Purchases`. Wires a `test-edit-mode` CircleCI job that imports the packaged SDK and runs the suite the same way CI already exercises the API tests. Stacked on top, each independent of the others: - #1014 configuration and harness smoke tests - #1010 wrapper pass-through tests - #1011 purchase forwarding & result parsing - #1012 single-request callback flows - #1013 tracking + model tests <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Changes are test/CI infrastructure plus a small internal injection hook on `Purchases`; no production purchase or auth behavior changes for shipped apps. > > **Overview** > Adds **Unity Edit Mode test plumbing** so later PRs can assert `Purchases` behavior against the **exported** `Purchases.unitypackage` / `PurchasesUI.unitypackage`. > > Introduces the Editor-only `RevenueCat.Tests.EditMode` assembly and a **`PurchasesWrapperSpy`** that records every `IPurchasesWrapper` call. **`Purchases.SetWrapper`** (internal, exposed via `InternalsVisibleTo` on the SDK assembly) lets tests inject the spy and keeps **`AdTracker`** wired to the same wrapper; platform `Start()` now goes through `SetWrapper` instead of assigning `_wrapper` directly. > > **CircleCI** broadens the pre-import “hide scripts” step to `Assets/Tests` (`.cs` and `.asmdef`), adds a **`test-edit-mode`** job (`unity/test` editmode after `import-package`), stores JUnit artifacts, and gates the release **hold** on that job. **IntegrationTests README** documents running Edit Mode tests locally via Test Runner. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit a45f0a2. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
Adds baseline tests exercising the harness end to end: Configure forwarding through the wrapper spy, configuration builder defaults, presented-offering-context resolution, and baseline JSON model parsing.
f4dd9a5 to
3af09b8
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 3af09b8. Configure here.
| Assert.That(virtualCurrencies.All["COIN"].Name, Is.EqualTo("Coins")); | ||
| Assert.That(virtualCurrencies.All["COIN"].ServerDescription, Is.EqualTo("Earned in game")); | ||
| Assert.That(virtualCurrencies.All["GEM"].Balance, Is.EqualTo(4)); | ||
| Assert.That(virtualCurrencies.All["GEM"].ServerDescription, Is.Null); |
There was a problem hiding this comment.
Null currency description assertion fails
High Severity
VirtualCurrenciesParsesCurrenciesByCode expects ServerDescription to be C# null for a JSON null, but SimpleJSON's string conversion returns the literal "null" from JSONNull.Value. The assertion fails against current parsing behavior.
Reviewed by Cursor Bugbot for commit 3af09b8. Configure here.
rickvdl
left a comment
There was a problem hiding this comment.
Nice first set of test cases 🫶 Codex and Cursor found a few mismatched with the assertions (that the test should hopefully catch), but overall looks good!
BuildUsesDocumentedDefaults asserted default(...) for StoreKitVersion, ShouldShowInAppMessagesAutomatically and EntitlementVerificationMode, which read as an endorsement of values that diverge from the inspector defaults on Purchases: the builder leaves these at their C# zero values, so the runtime-setup path gets StoreKit 1, in-app messages disabled and verification disabled. Assert the explicit current values and name each divergence, so the test guards today's behavior without claiming it is correct. Renamed to BuildUsesBuilderDefaults to match. Fixing the defaults is a runtime behavior change and is handled separately. Co-Authored-By: Claude <noreply@anthropic.com>
- Assert the serialized UseWorkflows flag alongside AutoSyncPurchases, and build DangerousSettings with differing values so the two keys can't be confused for each other. - Read the spy's only invocation instead of its last, matching what the Has.Count.EqualTo(1) guard already asserts. - Add a SUBSCRIPTION case for productCategory. The UNKNOWN fallback test alone would still pass if Enum.TryParse stopped matching anything. Co-Authored-By: Claude <noreply@anthropic.com>
**This is an automatic release.** ## RevenueCat SDK ### ✨ New Features * feat(paywalls): Add PaywallListener support to presented paywalls (SDK-4397) (#1001) via Toni Rico (@tonidero) ### 📦 Dependency Updates * [AUTOMATIC BUMP] Updates purchases-hybrid-common to 18.27.0 (#1026) via RevenueCat Git Bot (@RCGitBot) * [Android 10.15.1](https://github.com/RevenueCat/purchases-android/releases/tag/10.15.1) * [iOS 5.82.0](https://github.com/RevenueCat/purchases-ios/releases/tag/5.82.0) * [iOS 5.81.3](https://github.com/RevenueCat/purchases-ios/releases/tag/5.81.3) * [AUTOMATIC BUMP] Updates purchases-hybrid-common to 18.26.0 (#1021) via RevenueCat Git Bot (@RCGitBot) * [AUTOMATIC BUMP] Updates purchases-hybrid-common to 18.25.0 (#1015) via RevenueCat Git Bot (@RCGitBot) * [AUTOMATIC BUMP] Updates purchases-hybrid-common to 18.24.0 (#1007) via RevenueCat Git Bot (@RCGitBot) ### 🔄 Other Changes * Test wrapper pass-through calls (#1010) via Cesar de la Vega (@vegaro) * Add configuration and harness smoke tests (#1014) via Cesar de la Vega (@vegaro) * Add IOSPaywallPresentationStyle.FormSheet for iPad paywall presentation (#995) via Facundo Menzella (@facumenzella) * Bump fastlane-plugin-revenuecat_internal from `d392939` to `3421c88` (#1017) via dependabot[bot] (@dependabot[bot]) * Add Unity Edit Mode test harness and CI job (#1009) via Cesar de la Vega (@vegaro) * Use mise lockfile and install-mise-tools in CI (#997) via Álvaro Brey (@AlvaroBrey) * Bump json from 2.15.2.1 to 2.19.9 in /IntegrationTests (#1005) via dependabot[bot] (@dependabot[bot]) * Bump fastlane-plugin-revenuecat_internal from `b52fca5` to `d392939` (#1004) via dependabot[bot] (@dependabot[bot]) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > The diff only updates version strings and changelogs; no new SDK logic here. Underlying feature and dependency changes were merged separately and are documented in CHANGELOG. > > **Overview** > This PR is an **automatic release** that ships **9.6.0** by bumping version metadata everywhere it must stay aligned: `.version`, `RevenueCat/package.json`, `RevenueCatUI/package.json`, `VERSIONS.md`, and the reported plugin version in `PurchasesWrapper.java` and `PurchasesUnityHelper.m`. > > The **changelog** for 9.6.0 documents what landed since 9.5.3—not new code in this diff. Highlights for reviewers: **PaywallListener** on presented paywalls, **purchases-hybrid-common 18.27.0** (Android 10.15.1, iOS 5.82.0), **FormSheet** iPad paywall presentation style, plus CI/test harness work (Edit Mode tests, mise lockfile, wrapper pass-through tests). > > **Risk:** Low for this PR itself—it is versioning and release notes; runtime behavior changes come from the dependency bumps and features already merged on the release branch. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit d8e79d2. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
…1013) Part of the #1006 split. Rebased onto `main`; no longer stacked on anything. Adds `TrackingTests.cs` for custom paywall parameter resolution and ad-tracker forwarding/JSON serialization, and extends `JsonModelTests.cs` with full/minimal `CustomerInfo` and `SubscriptionOption` payloads, the epoch-vs-null date quirk, unrecognized-enum fallbacks, and the `WebPurchaseRedemption`/`WebPurchaseRedemptionResult` variants. ## The JsonModelTests overlap is resolved The earlier note here warned that this and #1014 both create `JsonModelTests.cs`. #1014 landed first, so I checked what `main` already has before rebasing: `main`'s version holds 4 tests (`VirtualCurrenciesParsesCurrenciesByCode`, `SubscriptionPriceSupportsValuesAboveInt32Range`, `StoreProductParsesKnownProductCategory`, `StoreProductFallsBackToUnknownProductCategory`), this branch's version is a strict superset containing those same 4 with byte-identical bodies plus 11 more. Nothing on `main` is unique, so the rebase keeps this version wholesale — no coverage lost, no duplication introduced. The file now has 15 tests. ## Second commit: fixture fidelity `MinimalCustomerInfoJson` omitted every field the mappers always send as an explicit null, plus `entitlements.verification`. Android's `convertToJson` maps Kotlin `null` to `JSONObject.NULL` and the iOS mappers use `NSNull()`, so those keys are on the wire, not absent. The web-redemption error fixture paired `"code":11` with `readableErrorCode: "UNKNOWN_ERROR"` — a value neither platform emits, and inconsistent with the code. Code 11 is `InvalidCredentialsError`, so it now carries the iOS values for that code plus the deprecated `readable_error_code` that ships alongside it. The synthetic `"UNRECOGNIZED"` and `"BOGUS"` values are unchanged and now carry comments: they stand in for enum members added natively before Unity knows the name, which is exactly what those fallback tests exist to pin down. Verified against purchases-hybrid-common 18.29.0, which is what `main` pins. The `redeemWebPurchase` result names and per-variant payload shapes (`customerInfo` on success, `error` on failure, `obfuscatedEmail` on expiry, bare `result` for the other two) already matched and were left alone. ## Verification - [x] Edit Mode tests: 49 passed, 0 failed. Packages rebuilt from this branch and re-imported so the run used this code. 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Test-only changes in IntegrationTests; no runtime SDK or purchase logic modified. > > **Overview** > Adds Edit Mode test coverage for JSON model parsing and analytics forwarding, with **no production code changes**. > > **JsonModelTests** moves inline JSON into a `JsonModelFixtures` folder and adds tests for full/minimal `CustomerInfo` and `SubscriptionOption` payloads, millis `0` vs null dates, unrecognized enum fallbacks, and all `WebPurchaseRedemptionResult` variants (including throw on unknown `result`). > > **TrackingTests** (new) uses `PurchasesWrapperSpy` to verify `TrackCustomPaywallImpression` parameter resolution (`CustomPaywallImpressionParams`, offering context from first package) and that ad tracker events (`TrackAdDisplayed`, revenue, load failures, etc.) forward to the wrapper with correct `ToJsonString` optional-field behavior. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 7c1a88a. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: Claude <noreply@anthropic.com>



Part of the #1006 split, stacked on #1009.
Adds baseline tests exercising the harness end to end:
Configureforwarding through the wrapper spy, configuration builder defaults, presented-offering-context resolution, and baseline JSON model parsing.Note
Low Risk
Test-only additions with no runtime SDK changes; low risk aside from documenting intentional configuration-builder default mismatches.
Overview
Adds EditMode NUnit tests under
IntegrationTests/Assets/Tests/EditMode/as part of the #1006 split (stacked on #1009). No production SDK code changes—only new test coverage and Unity.metafiles.Harness / configure:
PurchasesCallTestswiresPurchasestoPurchasesWrapperSpyand assertsConfigureforwards a fully populatedPurchasesConfigurationtoIPurchasesWrapper.Setupwith all 14 arguments (including dangerous settings JSON).Configuration builder:
PurchasesConfigurationTestsdocuments and locks in builder defaults vs inspector/docs (StoreKit 1, in-app messages off, verification disabled), custom builder values, and nullDangerousSettingsrestoring defaults.Models:
PresentedOfferingContextTestscovers JSON round-trip and minimal constructor serialization.JsonModelTestscovers virtual currencies, subscription price micros aboveint32, store product category parsing, and unknown category fallback.Reviewed by Cursor Bugbot for commit 14a1b01. Bugbot is set up for automated code reviews on this repo. Configure here.