Skip to content

Add testModeBehavior option to SuperwallOptions#437

Merged
yusuftor merged 6 commits intofeature/test-storefrom
feature/debug-mode-behavior
Feb 18, 2026
Merged

Add testModeBehavior option to SuperwallOptions#437
yusuftor merged 6 commits intofeature/test-storefrom
feature/debug-mode-behavior

Conversation

@jakemor
Copy link
Copy Markdown
Collaborator

@jakemor jakemor commented Feb 17, 2026

Summary

  • Adds TestModeBehavior enum and testModeBehavior property to SuperwallOptions, giving developers explicit control over when test mode activates (.automatic, .whenEnabledForUser, .never, .always)
  • Refactors TestModeManager.evaluateTestMode to respect the new option, extracting checkConfigMatch and checkBundleIdMismatch helpers
  • Forces shouldBypassAppTransactionCheck = true in test environments so StoreKit checks don't block test runners
  • Renames DebugModeBehaviorTestModeBehavior, debugModeBehaviortestModeBehavior, SWKDebugModeBehaviorSWKTestModeBehavior for consistency
  • Renames debugOptiontestModeOption and isUITestEnvironmentisTestEnvironment
  • isTestEnvironment detects all test runners via NSClassFromString("XCTestCase") but bypasses detection when SUPERWALL_UNIT_TESTS launch argument is present, allowing internal unit tests to exercise the .automatic path
  • Adds dark branded header with Superwall logo to TestModePurchaseDrawer and replaces hardcoded colors with semantic UIKit colors for dark mode support
  • Fixes all SwiftLint violations in TestMode files
  • Adds test coverage for all four TestModeBehavior cases

Test plan

  • Verify .automatic (default) behavior matches existing behavior for dashboard-enabled users and bundle ID mismatches
  • Verify .automatic skips test mode activation when running in external test environments (no SUPERWALL_UNIT_TESTS arg)
  • Verify .whenEnabledForUser only activates on dashboard user match, ignoring bundle ID mismatch
  • Verify .never prevents test mode from activating even with matching config
  • Verify .always enables test mode regardless of config
  • Verify shouldBypassAppTransactionCheck is forced true in test environments
  • Verify dark mode appearance of TestModePurchaseDrawer in both light and dark modes
  • Run existing test suite to confirm no regressions

🤖 Generated with Claude Code

Adds a new `debugModeBehavior` property to `SuperwallOptions` that gives
developers explicit control over when test mode activates:

- `.automatic` (default): activates on dashboard match or bundle ID
  mismatch, but never during UI tests
- `.whenEnabledForUser`: only activates on dashboard user match
- `.never`: test mode is never activated
- `.always`: test mode is always activated

Also forces `shouldBypassAppTransactionCheck = true` in UI test
environments so StoreKit checks don't block test runners.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

6 files reviewed, 3 comments

Edit Code Review Agent Settings | Greptile

Comment thread Sources/SuperwallKit/TestMode/TestModeManager.swift Outdated
Comment thread Tests/SuperwallKitTests/TestMode/TestModeManagerTests.swift Outdated
Comment thread Sources/SuperwallKit/Dependencies/DependencyContainer.swift Outdated
yusuftor and others added 4 commits February 18, 2026 14:04
… detection

- Rename DebugModeBehavior -> TestModeBehavior, debugModeBehavior -> testModeBehavior
- Rename SWKDebugModeBehavior -> SWKTestModeBehavior (ObjC)
- Rename debugOption -> testModeOption
- Rename isUITestEnvironment -> isTestEnvironment
- Skip test mode in test environments unless SUPERWALL_UNIT_TESTS launch arg is set
- Update tests to work correctly with the new environment detection

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Use where clause instead of if inside for loop
- Remove superfluous swiftlint disable commands
- Remove extra blank line before closing brace

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@yusuftor yusuftor changed the title Add debugModeBehavior option to SuperwallOptions Add testModeBehavior option to SuperwallOptions Feb 18, 2026
@yusuftor yusuftor merged commit 5075092 into feature/test-store Feb 18, 2026
2 checks passed
@yusuftor yusuftor deleted the feature/debug-mode-behavior branch February 18, 2026 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants