Skip to content

test(privacy): add integration tests for social-login marketing consent (MMQA-2605) - #48077

Draft
racitores wants to merge 1 commit into
mainfrom
cursor/marketing-consent-integration-tests-eba4
Draft

racitores wants to merge 1 commit into
mainfrom
cursor/marketing-consent-integration-tests-eba4

Conversation

@racitores

@racitores racitores commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Description

Integration test coverage for the social-login marketing consent behaviour fixed by GE-648 (#47808, merged 2026-11-12). QA ticket: MMQA-2605 (item 1, P1, Growth Engagement).

Context / problem: the existing unit tests (ui/pages/settings/privacy-tab/data-collection-item.test.tsx, ui/components/app/metametrics-consent/metametrics-consent-container.test.tsx) mock the OAuth actions and use redux-mock-store, so the UI-level behaviour with a real Redux store and a failing OAuth/marketing write was not covered. Before #47808, the settings item read remote consent on mount (OAuthService:getMarketingConsent, which resolves false on any failure) and dispatched it locally, so a failed/stale server write made the consent toggle snap back and has_marketing_consent diverged.

Solution: adds test/integration/privacy/marketing-consent.test.tsx (7 tests, no production code changes). The tests render the real app through integrationTestRender with the real Redux store seeded from test/integration/data/integration-init-state.json, overridden with social-login state (firstTimeFlowType: socialCreate — the integration env already sets SEEDLESS_ONBOARDING_ENABLED=true, so the real getIsSocialLoginFlow selector is used). The background connection is mocked at the submitRequestToBackground boundary (same pattern as test/integration/notifications&auth/notifications-toggle.test.tsx), with OAuthService:setMarketingConsent resolving (success path) or rejecting (failure path, mirroring the controller rethrowing on POST /api/v1/oauth/marketing_opt_in_status failure).

What is covered

Settings > Privacy > "Data collection for marketing" toggle (navigated through the real account menu → Settings → Privacy tab):

  1. Social-login user opts out while the OAuth write fails: the local decision is applied, the failed write is still attempted with false, the toggle stays off after all pending async work settles (no snap-back), OAuthService:getMarketingConsent is never called, and the AnalyticsPreferenceSelected event carries has_marketing_consent: false / location Settings.
  2. Social-login user opts out while the OAuth write succeeds: same expectations with the write resolving true (success path).
  3. Social-login user opts in while the OAuth write fails: the toggle stays on and the event carries has_marketing_consent: true.
  4. SRP user (firstTimeFlowType: create): the toggle still works locally and no OAuthService:setMarketingConsent/getMarketingConsent call is made.

Home-page marketing consent modal (MetaMetricsConsentContainer, shown to social-login users without a local decision):

  1. Accepting while the OAuth write fails: modal closes, local opt-in is kept (modal does not reappear after async work settles), the write is still attempted with true, and the event carries has_marketing_consent: true / location marketing_consent_modal.
  2. Declining while the OAuth write fails: local opt-out is kept and the event carries has_marketing_consent: false.
  3. SRP user: accepting the modal does not POST to the OAuth backend.

The has_marketing_consent assertions exercise the same state expression (marketingConsentDecisionMade === true ? optedInToMarketing === true : null) that both the UI selectors and the background UserTraitsService use, so the trait stays consistent with the visible toggle. The e2e seedless-onboarding mocks were consulted for the OAuth POST contract (opt_in_status body, Bearer token), but at the integration layer the background is mocked, so no network mocks were needed.

No production code was changed. The tests pass against the current main behaviour from #47808 — no open bug was exposed by them. test/jest/console-baseline-integration.json gains the standard per-file entry for the new test file (incidental warnings only; the intentional error log from the failure path is silenced via loglevel in the test).

How to run: yarn test:integration (or jest --config jest.integration.config.js test/integration/privacy/marketing-consent.test.tsx after the integration assets build).

Changelog

CHANGELOG entry: null

Related issues

Manual testing steps

  1. Run the extension (yarn start) and sign in with Google or Apple (or use yarn start:with-state with social-login state).
  2. Open Settings > Security & privacy, flip the "Data collection for marketing" toggle on and off.
  3. Verify the toggle stays where it is set and does not snap back, even if the OAuth backend request fails (e.g. block */api/v1/oauth/marketing_opt_in_status in DevTools network conditions).
  4. Verify each flip sends one POST (no GET) to /api/v1/oauth/marketing_opt_in_status with the new opt_in_status value.
  5. For a restored social-login wallet without a local decision, verify the home consent modal appears; accepting/declining keeps the choice and also POSTs it.

Pre-merge author checklist

Open in Web Open in Cursor 

…MQA-2605)

Add integration tests under test/integration/privacy that exercise the
marketing consent surfaces with the real Redux store and a mocked
background connection:

- settings toggle keeps the local decision when the OAuth
  setMarketingConsent write fails (no snap-back), still attempts the
  write, never reads OAuthService:getMarketingConsent, and tracks
  AnalyticsPreferenceSelected with has_marketing_consent
- success-path write keeps the toggle off as well
- SRP users never sync marketing consent with the OAuth backend
- home consent modal keeps accept/decline decisions when the OAuth
  write fails and does not POST for SRP users

Also add the console baseline entry for the new test file.

Refs MMQA-2605, GE-648 (fix in #47808).

Co-authored-by: racitores <racitores@users.noreply.github.com>
@metamask-ci

metamask-ci Bot commented Nov 18, 2026

Copy link
Copy Markdown
Contributor
Builds ready [7d308c2]
⚡ Performance Benchmarks (Total: 🟢 9 pass · 🟡 2 warn · 🔴 2 fail)

Baseline (latest main): f693520 | Date: 11/3/2026 | Pipeline: 44347917623 | Baseline logs

Metricschrome-webpackfirefox-webpack
loadNewAccount
[Sentry log · main/release]
🔴 load_new_account(p95) [CI log]🔴 load_new_account(p95) [CI log]

Regressions (🔴 2 failures)

Interaction Benchmarks · Samples: 5 🔴 2
Benchmarkchrome-webpackfirefox-webpack
loadNewAccount
[Sentry log · main/release]
🔴 [CI log]
🔴 load_new_account
🔴 [CI log]
🔴 load_new_account
confirmTx
[Sentry log · main/release]
🟢 [CI log]🟢 [CI log]
bridgeUserActions
[Sentry log · main/release]
🟢 [CI log]🟡 [CI log]
🟡 bridge_search_token

📈 Results compared to the previous 5 runs on main

  • ↑ loadNewAccount/load_new_account: +186%
  • ↑ loadNewAccount/total: +186%
  • ↑ loadNewAccount/inp: +19%
  • ↑ loadNewAccount/lcp: +881%
  • ↑ loadNewAccount/cls: +195%
  • ↑ confirmTx/longTaskCount: +33%
  • ↑ confirmTx/longTaskTotalDuration: +47%
  • ↑ confirmTx/longTaskMaxDuration: +58%
  • ↑ confirmTx/tbt: +59%
  • ↑ confirmTx/lcp: +840%
  • ↓ confirmTx/cls: -20%
  • ↑ bridgeUserActions/bridge_load_page: +59%
  • ↑ bridgeUserActions/bridge_load_asset_picker: +115%
  • ↑ bridgeUserActions/bridge_search_token: +24%
  • ↑ bridgeUserActions/longTaskCount: +36%
  • ↑ bridgeUserActions/longTaskTotalDuration: +63%
  • ↑ bridgeUserActions/longTaskMaxDuration: +43%
  • ↑ bridgeUserActions/tbt: +106%
  • ↑ bridgeUserActions/total: +40%
  • ↑ bridgeUserActions/inp: +47%
  • ↑ bridgeUserActions/lcp: +854%
  • ↓ bridgeUserActions/cls: -89%
  • ↑ loadNewAccount/load_new_account: +180%
  • ↑ loadNewAccount/total: +180%
  • ↑ loadNewAccount/inp: +87%
  • ↓ loadNewAccount/fcp: -71%
  • ↑ loadNewAccount/lcp: +797%
  • ↓ confirmTx/longTaskCount: -100%
  • ↓ confirmTx/longTaskTotalDuration: -100%
  • ↓ confirmTx/longTaskMaxDuration: -100%
  • ↓ confirmTx/tbt: -100%
  • ↑ confirmTx/inp: +35%
  • ↓ confirmTx/fcp: -69%
  • ↑ confirmTx/lcp: +903%
  • ↑ bridgeUserActions/bridge_load_page: +525%
  • ↑ bridgeUserActions/bridge_load_asset_picker: +91%
  • ↑ bridgeUserActions/bridge_search_token: +147%
  • ↓ bridgeUserActions/longTaskCount: -100%
  • ↓ bridgeUserActions/longTaskTotalDuration: -100%
  • ↓ bridgeUserActions/longTaskMaxDuration: -100%
  • ↓ bridgeUserActions/tbt: -100%
  • ↑ bridgeUserActions/total: +172%
  • ↓ bridgeUserActions/inp: -19%
  • ↓ bridgeUserActions/fcp: -71%
  • ↑ bridgeUserActions/lcp: +892%
Startup Benchmarks · Samples: 100
Benchmarkchrome-webpackfirefox-webpack
startupStandardHome
[Sentry log · main/release]
🟢 [CI log]🟢 [CI log]

📈 Results compared to the previous 5 runs on main

  • ↓ startupStandardHome/uiStartup: -18%
  • ↓ startupStandardHome/domInteractive: -18%
  • ↓ startupStandardHome/firstPaint: -48%
  • ↓ startupStandardHome/backgroundConnect: -21%
  • ↓ startupStandardHome/firstReactRender: -47%
  • ↓ startupStandardHome/initialActions: -64%
  • ↑ startupStandardHome/setupStore: +62%
  • ↑ startupStandardHome/longTaskCount: +43%
  • ↑ startupStandardHome/longTaskMaxDuration: +10%
  • ↓ startupStandardHome/inp: -24%
  • ↑ startupStandardHome/lcp: +347%
  • ↓ startupStandardHome/cls: -78%
  • ↑ startupStandardHome/domInteractive: +28%
  • ↑ startupStandardHome/backgroundConnect: +11%
  • ↑ startupStandardHome/firstReactRender: +26%
  • ↓ startupStandardHome/initialActions: -50%
  • ↑ startupStandardHome/fcp: +30%
User Journey Benchmarks · Samples: 5 · mock API
Benchmarkchrome-webpackfirefox-webpack
onboardingImportWallet
[Sentry log · main/release]
🟢 [CI log]🟡 [CI log]
🟡 total
onboardingNewWallet
[Sentry log · main/release]
🟢 [CI log]🟢 [CI log]

📈 Results compared to the previous 5 runs on main

  • ↑ onboardingImportWallet/srpButtonToSrpForm: +13%
  • ↑ onboardingImportWallet/confirmSrpToPwForm: +24%
  • ↑ onboardingImportWallet/pwFormToMetricsScreen: +33%
  • ↑ onboardingImportWallet/metricsToWalletReadyScreen: +13%
  • ↓ onboardingImportWallet/doneButtonToHomeScreen: -93%
  • ↓ onboardingImportWallet/openAccountMenuToAccountListLoaded: -74%
  • ↓ onboardingImportWallet/longTaskCount: -100%
  • ↓ onboardingImportWallet/longTaskTotalDuration: -100%
  • ↓ onboardingImportWallet/longTaskMaxDuration: -100%
  • ↓ onboardingImportWallet/tbt: -100%
  • ↓ onboardingImportWallet/total: -86%
  • ↑ onboardingNewWallet/createPwToRecoveryScreen: +25%
  • ↑ onboardingNewWallet/skipBackupToMetricsScreen: +23%
  • ↑ onboardingNewWallet/agreeButtonToOnboardingSuccess: +12%
  • ↓ onboardingNewWallet/doneButtonToAssetList: -77%
  • ↓ onboardingNewWallet/longTaskCount: -62%
  • ↓ onboardingNewWallet/longTaskTotalDuration: -69%
  • ↓ onboardingNewWallet/longTaskMaxDuration: -26%
  • ↓ onboardingNewWallet/tbt: -84%
  • ↓ onboardingNewWallet/total: -72%
Dapp Page Load Benchmarks · Samples: 100
Benchmarkchrome-webpack
dappPageLoad
[Sentry log · main/release]
🟢 [CI log]

📈 Results compared to the previous 5 runs on main

  • ↓ dappPageLoad/pageLoadTime: -61%
  • ↓ dappPageLoad/domContentLoaded: -20%
  • ↓ dappPageLoad/firstPaint: -47%
  • ↓ dappPageLoad/firstContentfulPaint: -47%
Bundle Size Diffs [🚀 Bundle size reduced!]
Status Bundle Total Diff Change
✅ background 15.03 MiB -138.11 KiB -0.89%
✅ ui 18.96 MiB -238.1 KiB -1.21%
✅ common 0 Bytes 0 Bytes 0.00%
✅ other 4.44 MiB -17.8 KiB -0.39%
✅ content scripts 3.15 MiB -35.38 KiB -1.08%
✅ unzipped 79.09 MiB -428.6 KiB -0.53%
✅ zip 23.84 MiB -90.76 KiB -0.37%

@sonarqubecloud

Copy link
Copy Markdown

This branch was previously deployed

1 inactive deployment
pr-comment — 7d308c22 Deployed Nov 18, 2026 by racitores via Publish prerelease / Publish prerelease #175526
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