Repository navigation
Conversation
…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>
Contributor
Builds ready [7d308c2]
⚡ Performance Benchmarks (Total: 🟢 9 pass · 🟡 2 warn · 🔴 2 fail)
Bundle Size Diffs [🚀 Bundle size reduced!]
|
|
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



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 useredux-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 resolvesfalseon any failure) and dispatched it locally, so a failed/stale server write made the consent toggle snap back andhas_marketing_consentdiverged.Solution: adds
test/integration/privacy/marketing-consent.test.tsx(7 tests, no production code changes). The tests render the real app throughintegrationTestRenderwith the real Redux store seeded fromtest/integration/data/integration-init-state.json, overridden with social-login state (firstTimeFlowType: socialCreate— the integration env already setsSEEDLESS_ONBOARDING_ENABLED=true, so the realgetIsSocialLoginFlowselector is used). The background connection is mocked at thesubmitRequestToBackgroundboundary (same pattern astest/integration/notifications&auth/notifications-toggle.test.tsx), withOAuthService:setMarketingConsentresolving (success path) or rejecting (failure path, mirroring the controller rethrowing onPOST /api/v1/oauth/marketing_opt_in_statusfailure).What is covered
Settings > Privacy > "Data collection for marketing" toggle (navigated through the real account menu → Settings → Privacy tab):
false, the toggle stays off after all pending async work settles (no snap-back),OAuthService:getMarketingConsentis never called, and theAnalyticsPreferenceSelectedevent carrieshas_marketing_consent: false/ locationSettings.true(success path).has_marketing_consent: true.firstTimeFlowType: create): the toggle still works locally and noOAuthService:setMarketingConsent/getMarketingConsentcall is made.Home-page marketing consent modal (
MetaMetricsConsentContainer, shown to social-login users without a local decision):true, and the event carrieshas_marketing_consent: true/ locationmarketing_consent_modal.has_marketing_consent: false.The
has_marketing_consentassertions exercise the same state expression (marketingConsentDecisionMade === true ? optedInToMarketing === true : null) that both the UI selectors and the backgroundUserTraitsServiceuse, so the trait stays consistent with the visible toggle. The e2e seedless-onboarding mocks were consulted for the OAuth POST contract (opt_in_statusbody, 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
mainbehaviour from #47808 — no open bug was exposed by them.test/jest/console-baseline-integration.jsongains 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(orjest --config jest.integration.config.js test/integration/privacy/marketing-consent.test.tsxafter the integration assets build).Changelog
CHANGELOG entry: null
Related issues
Manual testing steps
yarn start) and sign in with Google or Apple (or useyarn start:with-statewith social-login state).*/api/v1/oauth/marketing_opt_in_statusin DevTools network conditions)./api/v1/oauth/marketing_opt_in_statuswith the newopt_in_statusvalue.Pre-merge author checklist