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

UI Preview Mode: mock CustomerInfo #4786

Merged
merged 6 commits into from
Feb 14, 2025
Merged

Conversation

ajpallares
Copy link
Member

@ajpallares ajpallares commented Feb 13, 2025

Checklist

  • If applicable, unit tests

Motivation

In UI Preview mode, the SDK should not make the requests to obtain the CustomerInfo.

Description

When in UI Preview mode, the SDK:

  • Avoids caching CustomerInfo
  • Always returns mocked CustomerInfo (if requested either from the cache or from the backend)

@ajpallares ajpallares marked this pull request as ready for review February 14, 2025 11:32
@ajpallares ajpallares requested review from aboedo and a team February 14, 2025 11:32
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.

Makes sense! :shipit:

@@ -189,6 +189,10 @@ class CustomerInfoManager {
}

func cachedCustomerInfo(appUserID: String) -> CustomerInfo? {
guard !self.systemInfo.dangerousSettings.uiPreviewMode else {
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 guess if we don't cache it, this would always be null and this might not be needed... But I guess I'm ok keeping it just in case.

Copy link
Member Author

Choose a reason for hiding this comment

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

What you say makes total sense. The main reason why I also put this there is to always receive a nonnil CustomerInfo object, even when using CacheFetchPolicy.fromCacheOnly. Like: in UI Preview mode, you consistently get the mocked CustomerInfo every time and in any case (e.g. for any CacheFetchPolicy).

@ajpallares ajpallares enabled auto-merge (squash) February 14, 2025 15:18
@ajpallares ajpallares merged commit 7683d52 into main Feb 14, 2025
8 of 10 checks passed
@ajpallares ajpallares deleted the uiPreviewMode/mockCustomerInfo branch February 14, 2025 15:35
This was referenced Feb 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants