MetaMask / MetaMask/metamask-extension

[State Sync Redesign 3.12] Update Storybook state mocks

Open
#40,049 0 comments 0 reactions 0 assignees View on GitHub
INVALID-ISSUE-TEMPLATE team-extension-platform
Dominant language
TypeScript
Stars
13.2k
Forks
5.6k
Avg merge
2d 5h
Merged PRs (30d)
451

Description

`.storybook/preview.js` creates a global Redux store from `.storybook/test-data.js` which uses the full flat `metamask: { ... }` shape. 60+ individual story files also mock or mutate `state.metamask` directly.

## Steps

1. Update `.storybook/test-data.js` to provide state via `ControllerStateManager` (or extend the flat-to-keyed auto-mapping from `renderWithControllerState` to Storybook)
2. Update `.storybook/preview.js` `metamaskDecorator` to wrap stories with the `ControllerStateManager` provider alongside Redux
3. Audit 60+ story files that reference `state.metamask` — update per-story mock shapes
4. **Optimization:** If the auto-mapping shim from Issue 3.2 (`renderWithControllerState`) works for test utilities, adapt it for Storybook to defer individual story rewrites

## Files

- `.storybook/test-data.js`
- `.storybook/preview.js`
- `ui/**/*.stories.*`

## Risk

Low — Storybook is a development tool, not production code. Broken stories don't block releases.

## Dependencies

Issue 3.2 (test utility with auto-mapping), can proceed in parallel with component migration (Issue 3.7)

## Context

Part of [State Sync Redesign — Epic 3: UI-controller subscriptions].

Contributor guide

Open the contributing guide

Research direction

Start with .storybook/test-data.js and .storybook/preview.js, then read Issue 3.2 for the proposed auto-mapping approach. Audit the state.metamask references under ui/**/*.stories.* and verify that Storybook stories use the ControllerStateManager provider and updated mock shapes without breaking story rendering.

Written by the indexing model from the issue text.

Assessment

Tech stack
redux, storybook, typescript
Domain
frontend, tooling
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.