@@ -13,7 +13,7 @@ import type { Meta, StoryObj } from "@storybook/react";
13
13
import { expect , fn , userEvent , waitFor , within } from "@storybook/test" ;
14
14
import React from "react" ;
15
15
import { Provider } from "react-redux" ;
16
- import { legacy_createStore as createStore } from "redux " ;
16
+ import { configureStore } from "@reduxjs/toolkit " ;
17
17
import { track } from "~/renderer/analytics/__mocks__/segment" ;
18
18
import { ARB_ACCOUNT , BTC_ACCOUNT , ETH_ACCOUNT } from "../__mocks__/accounts.mock" ;
19
19
import {
@@ -22,11 +22,11 @@ import {
22
22
bitcoinCurrency ,
23
23
ethereumCurrency ,
24
24
} from "../__mocks__/useSelectAssetFlow.mock" ;
25
- import ModularDrawerFlowManager , {
26
- ModularDrawerFlowManagerProps ,
27
- } from "./ModularDrawerFlowManager " ;
25
+ import { assetsDataApi } from "./data/state-manager/api" ;
26
+ import ModularDrawerFlowManager from "./ModularDrawerFlowManager" ;
27
+ import { ModularDrawerFlowManagerProps } from "./types " ;
28
28
29
- const store = createStore ( ( ) => ( {
29
+ const createMockState = ( ) => ( {
30
30
accounts : [ ARB_ACCOUNT , ETH_ACCOUNT , BTC_ACCOUNT ] ,
31
31
wallet : {
32
32
accountNames : new Map ( [
@@ -36,7 +36,7 @@ const store = createStore(() => ({
36
36
] ) ,
37
37
} ,
38
38
currency : {
39
- type : "FiatCurrency" ,
39
+ type : "FiatCurrency" as const ,
40
40
ticker : "USD" ,
41
41
name : "US Dollar" ,
42
42
symbol : "$" ,
@@ -51,7 +51,24 @@ const store = createStore(() => ({
51
51
] ,
52
52
} ,
53
53
application : { debug : { } } ,
54
- } ) ) ;
54
+ } ) ;
55
+
56
+ const initialMockState = createMockState ( ) ;
57
+
58
+ const store = configureStore ( {
59
+ reducer : {
60
+ accounts : ( state = initialMockState . accounts ) => state ,
61
+ wallet : ( state = initialMockState . wallet ) => state ,
62
+ currency : ( state = initialMockState . currency ) => state ,
63
+ application : ( state = initialMockState . application ) => state ,
64
+ assetsDataApi : assetsDataApi . reducer ,
65
+ } ,
66
+ middleware : getDefaultMiddleware =>
67
+ getDefaultMiddleware ( {
68
+ serializableCheck : false ,
69
+ immutableCheck : false ,
70
+ } ) . concat ( assetsDataApi . middleware ) ,
71
+ } ) ;
55
72
56
73
function makeMockedContextValue (
57
74
mockedFeatures : Partial < Record < FeatureId , Feature > > ,
@@ -72,6 +89,7 @@ type ExtraStoryArgs = {
72
89
networksLeftElement ?: ( typeof networksLeftElementOptions ) [ number ] | "default" ;
73
90
networksRightElement ?: ( typeof networksRightElementOptions ) [ number ] | "default" ;
74
91
assetsFilter ?: ( typeof filterOptions ) [ number ] | "default" ;
92
+ lldModularDrawerBackendDataEnabled ?: boolean ;
75
93
} ;
76
94
77
95
type StoryArgs = ModularDrawerFlowManagerProps & ExtraStoryArgs ;
@@ -85,6 +103,7 @@ const meta: Meta<StoryArgs> = {
85
103
onAccountSelected : ( ) => null ,
86
104
source : "sourceTest" ,
87
105
flow : "Modular Asset Flow" ,
106
+ lldModularDrawerBackendDataEnabled : false ,
88
107
} ,
89
108
argTypes : {
90
109
assetsFilter : {
@@ -107,14 +126,20 @@ const meta: Meta<StoryArgs> = {
107
126
options : [ ...networksRightElementOptions , "default" ] ,
108
127
control : { type : "select" } ,
109
128
} ,
129
+ lldModularDrawerBackendDataEnabled : {
130
+ control : { type : "boolean" } ,
131
+ description : "Enable/disable the lldModularDrawerBackendData feature flag" ,
132
+ } ,
110
133
} ,
111
134
decorators : [
112
- Story => {
135
+ ( Story , context ) => {
136
+ const { lldModularDrawerBackendDataEnabled = false } = context . args ;
113
137
return (
114
138
< div style = { { minHeight : "400px" , position : "relative" , margin : "50px" } } >
115
139
< FeatureFlagsProvider
116
140
value = { makeMockedContextValue ( {
117
141
lldModularDrawer : { enabled : true , params : { enableModularization : true } } ,
142
+ lldModularDrawerBackendData : { enabled : lldModularDrawerBackendDataEnabled } ,
118
143
} ) }
119
144
>
120
145
< Provider store = { store } >
@@ -168,13 +193,18 @@ export const CustomDrawerConfig: StoryObj<StoryArgs> = {
168
193
< div style = { { color : "#333" , backgroundColor : "#f9f9f9" , padding : "5px" } } >
169
194
< p style = { { fontSize : "16px" , marginBottom : "8px" } } >
170
195
Use the storybook controls below to alter the{ " " }
171
- < span style = { { fontWeight : 600 } } > drawerConfiguration</ span > parameters:
196
+ < span style = { { fontWeight : 600 } } > drawerConfiguration</ span > parameters and feature
197
+ flags:
172
198
</ p >
173
199
< p style = { { fontSize : "14px" , marginBottom : "16px" , color : "#555" } } >
174
200
"undefined" represents no element shown, "default" represents the
175
201
default element if the parameter is not provided in the drawerConfiguration object.
176
202
</ p >
177
203
< ul style = { { paddingLeft : "20px" , fontSize : "14px" , marginBottom : "16px" } } >
204
+ < li >
205
+ < span style = { { fontWeight : 600 } } > lldModularDrawerBackendDataEnabled:</ span > Toggle
206
+ the lldModularDrawerBackendData feature flag to enable/disable backend data fetching.
207
+ </ li >
178
208
< li >
179
209
< span style = { { fontWeight : 600 } } > assetsFilter:</ span > Element to display at the top
180
210
of the drawer to filter assets.
0 commit comments