test(analytics): add transitional E2E fixture dual-support shim#43467
Conversation
Accept legacy and canonical analytics field names in E2E fixtures, constants, and onboarding flow helpers until all domain PRs merge. Co-authored-by: Cursor <cursoragent@cursor.com>
✨ Files requiring CODEOWNER review ✨🧪 @MetaMask/qa (2 files, +66 -40)
|
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
Builds ready [53a8b4f] [reused from 86afca4]
⚡ Performance Benchmarks (Total: 🟢 14 pass · 🟡 8 warn · 🔴 3 fail)
Bundle size diffs
|
Co-authored-by: Cursor <cursoragent@cursor.com>
Builds ready [1f05308] [reused from 86afca4]
⚡ Performance Benchmarks (Total: 🟢 14 pass · 🟡 8 warn · 🔴 3 fail)
Bundle size diffs
|
There was a problem hiding this comment.
Pull request overview
Adds a transitional dual-support shim in E2E helpers/fixtures so tests can use either legacy MetaMetrics fields (metaMetricsId, participateInMetaMetrics, MOCK_META_METRICS_ID) or canonical analytics fields (analyticsId, optedIn, MOCK_ANALYTICS_ID) without failing TypeScript lint during the migration window.
Changes:
- Introduces
MOCK_ANALYTICS_IDand keepsMOCK_META_METRICS_IDas a deprecated alias. - Extends
FixtureBuilderV2.withMetaMetricsControllerto accept both legacy and canonical patches and apply canonical fields toAnalyticsControllerstate. - Adds
OnboardingMetricsFlowOptions+resolveOptedInto unify opt-in behavior and threadsoptedInthrough onboarding-related flows (including vault corruption flow).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| test/e2e/constants.ts | Adds canonical MOCK_ANALYTICS_ID and keeps deprecated MOCK_META_METRICS_ID alias for backwards compatibility. |
| test/e2e/fixtures/fixture-builder-v2.ts | Updates withMetaMetricsController to map legacy/canonical inputs into AnalyticsController (analyticsId, optedIn) while still patching MetaMetricsController. |
| test/e2e/page-objects/flows/onboarding.flow.ts | Adds shared metrics options type + resolution helper; updates flows to accept optedIn and wait for either analyticsId or legacy metaMetricsId. |
| test/e2e/page-objects/flows/vault-corruption.flow.ts | Reuses the shared onboarding metrics options type and forwards optedIn into onboarding. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Description
Part 2 of the Analytics Phase B split (supersedes monolithic #43406).
After foundation (#43430) merged, child analytics PRs failed
yarn lint:tscbecause migrated E2E tests used canonical fields (analyticsId,optedIn,MOCK_ANALYTICS_ID) while unmigrated tests still used legacy fields (metaMetricsId,participateInMetaMetrics,MOCK_META_METRICS_ID).This PR adds transitional dual-support in E2E fixtures and flow helpers so domain PRs (#43431–#43441) can merge in parallel. Cleanup (#43442) removes this shim last.
Changes:
test/e2e/constants.ts—MOCK_ANALYTICS_IDplus deprecatedMOCK_META_METRICS_IDaliastest/e2e/fixtures/fixture-builder-v2.ts—withMetaMetricsControlleraccepts legacy and canonical patch fieldstest/e2e/page-objects/flows/onboarding.flow.ts—OnboardingMetricsFlowOptionswithresolveOptedIn()test/e2e/page-objects/flows/vault-corruption.flow.ts— accepts canonical onboarding metrics optionsChangelog
CHANGELOG entry: null
Related issues
Fixes: https://github.com/MetaMask/MetaMask-planning/issues/7331 (partial)
Manual testing steps
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Low Risk
Test-only helpers and constants; no production wallet or analytics runtime behavior changes.
Overview
Adds a transitional dual-support layer in E2E so analytics migration PRs can land in parallel without
yarn lint:tscfailures from mixed legacy and canonical naming.Constants: Introduces
MOCK_ANALYTICS_IDand keepsMOCK_META_METRICS_IDas a deprecated alias to the same value.Fixtures:
withMetaMetricsControllernow accepts both legacy (metaMetricsId,participateInMetaMetrics) and canonical (analyticsId,optedIn) patches, resolves them with canonical taking precedence for IDs, and writesAnalyticsControllerstate (analyticsId,optedIn) while still merging realMetaMetricsControllerfields.Onboarding flows: New
OnboardingMetricsFlowOptionsandresolveOptedIn()unify opt-in behavior; flows acceptoptedInalongside deprecatedparticipateInMetaMetrics. Post-metrics wait accepts eitheranalyticsIdormetaMetricsIdin app state.Vault corruption:
onboardThenExecuteScript/onboardThenTriggerCorruptionFlowuse the shared metrics options type and forwardoptedIn.Intended to be removed by a follow-up cleanup PR once all E2E tests use canonical fields.
Reviewed by Cursor Bugbot for commit 1f05308. Bugbot is set up for automated code reviews on this repo. Configure here.