Skip to content

Commit e39dd19

Browse files
committed
chore(runway): cherry-pick feat: legacy-ios-feature-flag cp-7.71.0 (#27848)
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** Support webcredential for ios google login Part 2/4 - Add feature flag This pr add feature flag for the ios google login PR list Part 1/ 4 - #27741 Part 2/ 4 - #27848 Part 3/ 4 - #27850 Part 4/ 4 - TBA <!-- Write a short description of the changes included in this pull request, also include relevant motivation and context. Have in mind the following questions: 1. What is the reason for the change? 2. What is the improvement/solution? --> ## **Changelog** <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> CHANGELOG entry: added legacyIosGoogleConfigEnabled feature flag ## **Related issues** Fixes: ## **Manual testing steps** ```gherkin Feature: my feature name Scenario: user [verb for user action] Given [describe expected initial app state] When user [verb for user action] Then [describe expected outcome] ``` ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [ ] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I've included tests if applicable - [ ] I've documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I've applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Low risk: adds a new remote feature flag and selector with env override, without changing authentication flow yet; main risk is misconfiguration since the selector defaults to enabled. > > **Overview** > Adds a new remote feature flag, `legacyIosGoogleConfigEnabled`, including registry metadata and a dedicated selector `selectLegacyIosGoogleConfigEnabled` (defaulting to `true`) that can be force-overridden via `MM_LEGACY_IOS_GOOGLE_CONFIG_ENABLED`. > > Includes unit tests covering default/remote/env override behavior, and updates `babel.config.tests.js` to avoid inlining env vars for the new selector and its tests. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit ca7e813. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 94e6bcb commit e39dd19

5 files changed

Lines changed: 93 additions & 0 deletions

File tree

app/constants/featureFlags.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export enum FeatureFlagNames {
1515
tokenDetailsV2Buttons = 'tokenDetailsV2Buttons',
1616
tokenDetailsV2ButtonLayout = 'tokenDetailsV2ButtonLayout',
1717
complianceEnabled = 'complianceEnabled',
18+
legacyIosGoogleConfigEnabled = 'legacyIosGoogleConfigEnabled',
1819
}
1920

2021
export const DEFAULT_FEATURE_FLAG_VALUES: Partial<
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import {
2+
DEFAULT_LEGACY_IOS_GOOGLE_CONFIG_ENABLED,
3+
selectLegacyIosGoogleConfigEnabled,
4+
} from '.';
5+
import { FeatureFlagNames } from '../../../constants/featureFlags';
6+
7+
describe('Legacy iOS Google Config Feature Flag Selector', () => {
8+
const originalEnv = process.env.MM_LEGACY_IOS_GOOGLE_CONFIG_ENABLED;
9+
10+
beforeEach(() => {
11+
delete process.env.MM_LEGACY_IOS_GOOGLE_CONFIG_ENABLED;
12+
});
13+
14+
afterAll(() => {
15+
if (originalEnv === undefined) {
16+
delete process.env.MM_LEGACY_IOS_GOOGLE_CONFIG_ENABLED;
17+
return;
18+
}
19+
20+
process.env.MM_LEGACY_IOS_GOOGLE_CONFIG_ENABLED = originalEnv;
21+
});
22+
23+
it('returns the default value when the remote flag is missing', () => {
24+
const result = selectLegacyIosGoogleConfigEnabled.resultFunc({});
25+
26+
expect(result).toBe(DEFAULT_LEGACY_IOS_GOOGLE_CONFIG_ENABLED);
27+
});
28+
29+
it('returns the remote flag value when present', () => {
30+
const result = selectLegacyIosGoogleConfigEnabled.resultFunc({
31+
[FeatureFlagNames.legacyIosGoogleConfigEnabled]: false,
32+
});
33+
34+
expect(result).toBe(false);
35+
});
36+
37+
it('allows the local env var to force enable the legacy config', () => {
38+
process.env.MM_LEGACY_IOS_GOOGLE_CONFIG_ENABLED = 'true';
39+
40+
const result = selectLegacyIosGoogleConfigEnabled.resultFunc({
41+
[FeatureFlagNames.legacyIosGoogleConfigEnabled]: false,
42+
});
43+
44+
expect(result).toBe(true);
45+
});
46+
47+
it('allows the local env var to force disable the legacy config', () => {
48+
process.env.MM_LEGACY_IOS_GOOGLE_CONFIG_ENABLED = 'false';
49+
50+
const result = selectLegacyIosGoogleConfigEnabled.resultFunc({
51+
[FeatureFlagNames.legacyIosGoogleConfigEnabled]: true,
52+
});
53+
54+
expect(result).toBe(false);
55+
});
56+
});
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { hasProperty } from '@metamask/utils';
2+
import { createSelector } from 'reselect';
3+
import { FeatureFlagNames } from '../../../constants/featureFlags';
4+
import { getFeatureFlagValue } from '../env';
5+
import { selectRemoteFeatureFlags } from '..';
6+
7+
export const DEFAULT_LEGACY_IOS_GOOGLE_CONFIG_ENABLED = true;
8+
9+
export const selectLegacyIosGoogleConfigEnabled = createSelector(
10+
selectRemoteFeatureFlags,
11+
(remoteFeatureFlags) => {
12+
const remoteValue = hasProperty(
13+
remoteFeatureFlags,
14+
FeatureFlagNames.legacyIosGoogleConfigEnabled,
15+
)
16+
? Boolean(
17+
remoteFeatureFlags[FeatureFlagNames.legacyIosGoogleConfigEnabled],
18+
)
19+
: DEFAULT_LEGACY_IOS_GOOGLE_CONFIG_ENABLED;
20+
return getFeatureFlagValue(
21+
// Use direct env access so Babel can inline this value in app builds.
22+
process.env.MM_LEGACY_IOS_GOOGLE_CONFIG_ENABLED,
23+
remoteValue,
24+
);
25+
},
26+
);

babel.config.tests.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ const newOverrides = [
3737
'app/components/UI/Ramp/hooks/useRampTokens.test.ts',
3838
'app/components/Views/confirmations/hooks/pay/useTransactionPayWithdraw.ts',
3939
'app/components/Views/confirmations/hooks/pay/useTransactionPayWithdraw.test.ts',
40+
'app/selectors/featureFlagController/legacyIosGoogleConfig/index.ts',
41+
'app/selectors/featureFlagController/legacyIosGoogleConfig/index.test.ts',
4042
'app/util/environment.ts',
4143
'app/util/environment.test.ts',
4244
'app/core/Engine/controllers/rewards-controller/utils/rewards-api-url.ts',

tests/feature-flags/feature-flag-registry.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2829,6 +2829,14 @@ export const FEATURE_FLAG_REGISTRY: Record<string, FeatureFlagRegistryEntry> = {
28292829
status: FeatureFlagStatus.Active,
28302830
},
28312831

2832+
legacyIosGoogleConfigEnabled: {
2833+
name: 'legacyIosGoogleConfigEnabled',
2834+
type: FeatureFlagType.Remote,
2835+
inProd: true,
2836+
productionDefault: true,
2837+
status: FeatureFlagStatus.Active,
2838+
},
2839+
28322840
metalCardCheckoutEnabled: {
28332841
name: 'metalCardCheckoutEnabled',
28342842
type: FeatureFlagType.Remote,

0 commit comments

Comments
 (0)