Add Unity Edit Mode tests and run them on CI - #1006
Closed
vegaro wants to merge 5 commits into
Closed
Conversation
…ing, and models Splits the growing PurchasesCallTests.cs by responsibility (purchases, single-request callbacks, tracking, wrapper pass-throughs) and adds coverage for discounted/win-back purchases, PurchaseResult parsing, remaining single-request callback flows, custom paywall impression resolution, AdTracker forwarding/serialization, low-risk wrapper pass-throughs, and JSON model parsing for CustomerInfo, SubscriptionOption, and WebPurchaseRedemptionResult. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Design notes for the Unity Edit Mode test expansion are tracked in the Obsidian dev-memory vault instead of the repo. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Member
Author
|
Splitting this into a stack of smaller, independently reviewable PRs:
Closing in favor of that stack. |
This was referenced Jul 24, 2026
vegaro
added a commit
that referenced
this pull request
Jul 28, 2026
Part of the #1006 split, stacked on #1009. 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. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Test-only additions with no runtime SDK changes; low risk aside from documenting current builder default quirks. > > **Overview** > Adds **EditMode NUnit tests** under `IntegrationTests/Assets/Tests/EditMode/` as part of the #1006 split (stacked on #1009). No production SDK changes—only test coverage and Unity `.meta` assets. > > **Harness / configure:** `PurchasesCallTests` wires `Purchases` to `PurchasesWrapperSpy` and asserts `Configure` forwards a fully built `PurchasesConfiguration` to `IPurchasesWrapper.Setup` with all 14 arguments (including dangerous settings JSON). > > **Configuration builder:** `PurchasesConfigurationTests` locks in builder defaults vs explicit `Set*` values and null `DangerousSettings` handling; documents intentional divergences from inspector/docs (StoreKit version, in-app messages, entitlement verification). > > **Models:** `JsonModelTests` covers `VirtualCurrencies`, `SubscriptionOption.Price` (large `amountMicros`), and `StoreProduct` category parsing/fallback. `PresentedOfferingContextTests` covers JSON round-trip and minimal constructor serialization. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 115d745. 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>
vegaro
added a commit
that referenced
this pull request
Jul 29, 2026
Part of the #1006 split, stacked on #1009. Adds `WrapperPassthroughTests.cs`: message display, locale override, cache invalidation, attribute setters, AppsFlyer conversion data, and Amazon purchase sync forwarding. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Test-only change with no production code modifications; low regression risk beyond test maintenance. > > **Overview** > Adds **`WrapperPassthroughTests`** in the IntegrationTests EditMode suite, following the same `Purchases` + **`PurchasesWrapperSpy`** setup used by **`PurchasesCallTests`**. > > New NUnit cases assert that public **`Purchases`** APIs delegate to **`IPurchasesWrapper`** with the expected arguments: JSON serialization for **`SetAttributes`** (strings and nulls) and **`SetAppsFlyerConversionData`** (nested maps/lists), reference/null forwarding for **`ShowInAppMessages`**, string/locale and ID passthrough (**`OverridePreferredUILocale`**, **`SetAdjustID`**), ordered args for **`SyncAmazonPurchase`**, boolean forwarding for **`SetSimulatesAskToBuyInSandbox`**, and no-arg wrapper calls for cache invalidation and **`CollectDeviceIdentifiers`**. Includes Unity **`WrapperPassthroughTests.cs.meta`** asset metadata. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 3b5a14e. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
vegaro
added a commit
that referenced
this pull request
Aug 6, 2026
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Thank you for contributing to Purchases. Before pressing the "Create Pull Request" button, please provide the following:
Adds the first executable Unity Edit Mode test suite and runs it against the exported packages on CircleCI, including
Purchasescall forwarding and native callback contracts through a fake wrapper.This is not tied to an issue.
Seventeen Edit Mode tests pass on Unity
6000.2.6f2; the CircleCI config and Unity metadata checks pass too.