-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Add FXIOS-10881 [Sent from Firefox] Add ability to override a user's preference for a nimbus feature in unit tests #23790
Add FXIOS-10881 [Sent from Firefox] Add ability to override a user's preference for a nimbus feature in unit tests #23790
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some comments to explain what I am doing here...
if AppConstants.isRunningUnitTest, | ||
UserDefaults.standard.valueExists(forKey: PrefsKeys.NimbusUserEnabledFeatureTestsOverride) { | ||
return UserDefaults.standard.bool(forKey: PrefsKeys.NimbusUserEnabledFeatureTestsOverride) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I basically just hijacked some existing code and moved it down into the isUserEnabled()
method instead of isNimbusEnabled()
, so it only overrides the user's preference.
I had to move this code because isNimbusEnabled()
also gets called in getNimbusOrDebugSetting()
, which was overriding both the nimbus flag and the user preference flag in our unit tests... We don't need to override the nimbus flag though because we have better ways of doing that (e.g. #23725 (comment)).
// Only used to force nimbus features to true with tests | ||
public static let NimbusFeatureTestsOverride = "NimbusFeatureTestsOverride" | ||
// Only used in unit tests to override the user's setting for nimbus features | ||
public static let NimbusUserEnabledFeatureTestsOverride = "NimbusUserEnabledFeatureTestsOverride" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed because previously using the NimbusUserEnabledFeatureTestsOverride
always overrode the value to true
. I wanted the value to override either true
or false
so we can test with both the user preference enabled or disabled.
This pull request has conflicts when rebasing. Could you fix it @ih-codes? 🙏 |
…ride flag to ensure it only overrides the user's preference setting in tests. Make behaviour more explicit and add documentation. Update handling for tests using the old code.
…respects the user's Sent from Firefox preference when checking whether WhatsApp share treatment should be appended.
439d51e
to
e455fae
Compare
Client.app: Coverage: 32.07
Generated by 🚫 Danger Swift against e455fae |
📜 Tickets
Jira ticket
Github issue
💡 Description
This PR does two main things:
📝 Checklist
You have to check all boxes before merging
@Mergifyio backport release/v120
)