@ledgerhq/live-common 34.48.0-nightly.0 → 34.48.0-nightly.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts +2 -2
- package/lib/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/alpaca/network/network-alpaca.js +1 -1
- package/lib/bridge/generic-alpaca/alpaca/network/network-alpaca.js.map +1 -1
- package/lib/bridge/generic-alpaca/signOperation.js +1 -1
- package/lib/bridge/generic-alpaca/signOperation.js.map +1 -1
- package/lib/e2e/index.d.ts +1 -0
- package/lib/e2e/index.d.ts.map +1 -1
- package/lib/env.react.d.ts +1 -1
- package/lib/env.react.d.ts.map +1 -1
- package/lib/modularDrawer/hooks/__test__/useModularDrawerConfiguration.test.d.ts +2 -0
- package/lib/modularDrawer/hooks/__test__/useModularDrawerConfiguration.test.d.ts.map +1 -0
- package/lib/modularDrawer/hooks/__test__/useModularDrawerConfiguration.test.js +206 -0
- package/lib/modularDrawer/hooks/__test__/useModularDrawerConfiguration.test.js.map +1 -0
- package/lib/modularDrawer/hooks/useModularDrawerConfiguration.d.ts +13 -0
- package/lib/modularDrawer/hooks/useModularDrawerConfiguration.d.ts.map +1 -0
- package/lib/modularDrawer/hooks/useModularDrawerConfiguration.js +29 -0
- package/lib/modularDrawer/hooks/useModularDrawerConfiguration.js.map +1 -0
- package/lib-es/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts +2 -2
- package/lib-es/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/alpaca/network/network-alpaca.js +1 -1
- package/lib-es/bridge/generic-alpaca/alpaca/network/network-alpaca.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/signOperation.js +1 -1
- package/lib-es/bridge/generic-alpaca/signOperation.js.map +1 -1
- package/lib-es/e2e/index.d.ts +1 -0
- package/lib-es/e2e/index.d.ts.map +1 -1
- package/lib-es/env.react.d.ts +1 -1
- package/lib-es/env.react.d.ts.map +1 -1
- package/lib-es/modularDrawer/hooks/__test__/useModularDrawerConfiguration.test.d.ts +2 -0
- package/lib-es/modularDrawer/hooks/__test__/useModularDrawerConfiguration.test.d.ts.map +1 -0
- package/lib-es/modularDrawer/hooks/__test__/useModularDrawerConfiguration.test.js +204 -0
- package/lib-es/modularDrawer/hooks/__test__/useModularDrawerConfiguration.test.js.map +1 -0
- package/lib-es/modularDrawer/hooks/useModularDrawerConfiguration.d.ts +13 -0
- package/lib-es/modularDrawer/hooks/useModularDrawerConfiguration.d.ts.map +1 -0
- package/lib-es/modularDrawer/hooks/useModularDrawerConfiguration.js +25 -0
- package/lib-es/modularDrawer/hooks/useModularDrawerConfiguration.js.map +1 -0
- package/package.json +45 -45
- package/src/bridge/generic-alpaca/alpaca/network/network-alpaca.ts +4 -3
- package/src/bridge/generic-alpaca/signOperation.ts +1 -1
- package/src/modularDrawer/hooks/__test__/useModularDrawerConfiguration.test.ts +251 -0
- package/src/modularDrawer/hooks/useModularDrawerConfiguration.ts +33 -0
@@ -0,0 +1,251 @@
|
|
1
|
+
/**
|
2
|
+
* @jest-environment jsdom
|
3
|
+
*/
|
4
|
+
import { renderHook } from "@testing-library/react";
|
5
|
+
import { useFeature } from "../../../featureFlags";
|
6
|
+
import { EnhancedModularDrawerConfiguration } from "../../../wallet-api/ModularDrawer/types";
|
7
|
+
import { useModularDrawerConfiguration } from "../useModularDrawerConfiguration";
|
8
|
+
|
9
|
+
jest.mock("../../../featureFlags", () => ({ useFeature: jest.fn() }));
|
10
|
+
|
11
|
+
const mockUseFeature = jest.mocked(useFeature);
|
12
|
+
|
13
|
+
describe("useModularDrawerConfiguration", () => {
|
14
|
+
beforeEach(() => {
|
15
|
+
jest.clearAllMocks();
|
16
|
+
});
|
17
|
+
|
18
|
+
describe("when modularization is disabled", () => {
|
19
|
+
beforeEach(() => {
|
20
|
+
mockUseFeature.mockReturnValue({
|
21
|
+
enabled: true,
|
22
|
+
params: {
|
23
|
+
enableModularization: false,
|
24
|
+
},
|
25
|
+
});
|
26
|
+
});
|
27
|
+
|
28
|
+
it("should return disabled configurations when no drawer configuration is provided", () => {
|
29
|
+
const { result } = renderHook(() => useModularDrawerConfiguration("lldModularDrawer"));
|
30
|
+
|
31
|
+
expect(result.current.assetsConfiguration).toEqual({
|
32
|
+
rightElement: "undefined",
|
33
|
+
leftElement: "undefined",
|
34
|
+
filter: "undefined",
|
35
|
+
});
|
36
|
+
expect(result.current.networkConfiguration).toEqual({
|
37
|
+
rightElement: "undefined",
|
38
|
+
leftElement: "undefined",
|
39
|
+
});
|
40
|
+
});
|
41
|
+
|
42
|
+
it("should return disabled configurations even when drawer configuration is provided", () => {
|
43
|
+
const drawerConfiguration: EnhancedModularDrawerConfiguration = {
|
44
|
+
assets: {
|
45
|
+
rightElement: "balance",
|
46
|
+
leftElement: "apy",
|
47
|
+
filter: "topNetworks",
|
48
|
+
},
|
49
|
+
networks: {
|
50
|
+
rightElement: "balance",
|
51
|
+
leftElement: "numberOfAccounts",
|
52
|
+
},
|
53
|
+
};
|
54
|
+
|
55
|
+
const { result } = renderHook(() =>
|
56
|
+
useModularDrawerConfiguration("lldModularDrawer", drawerConfiguration),
|
57
|
+
);
|
58
|
+
|
59
|
+
expect(result.current.assetsConfiguration).toEqual({
|
60
|
+
rightElement: "undefined",
|
61
|
+
leftElement: "undefined",
|
62
|
+
filter: "undefined",
|
63
|
+
});
|
64
|
+
expect(result.current.networkConfiguration).toEqual({
|
65
|
+
rightElement: "undefined",
|
66
|
+
leftElement: "undefined",
|
67
|
+
});
|
68
|
+
});
|
69
|
+
});
|
70
|
+
|
71
|
+
describe("when modularization is enabled", () => {
|
72
|
+
beforeEach(() => {
|
73
|
+
mockUseFeature.mockReturnValue({
|
74
|
+
enabled: true,
|
75
|
+
params: {
|
76
|
+
enableModularization: true,
|
77
|
+
},
|
78
|
+
});
|
79
|
+
});
|
80
|
+
|
81
|
+
it("should return undefined configurations when no drawer configuration is provided", () => {
|
82
|
+
const { result } = renderHook(() => useModularDrawerConfiguration("lldModularDrawer"));
|
83
|
+
|
84
|
+
expect(result.current.assetsConfiguration).toBeUndefined();
|
85
|
+
expect(result.current.networkConfiguration).toBeUndefined();
|
86
|
+
});
|
87
|
+
|
88
|
+
it("should return the provided drawer configuration when modularization is enabled", () => {
|
89
|
+
const drawerConfiguration: EnhancedModularDrawerConfiguration = {
|
90
|
+
assets: {
|
91
|
+
rightElement: "balance",
|
92
|
+
leftElement: "apy",
|
93
|
+
filter: "topNetworks",
|
94
|
+
},
|
95
|
+
networks: {
|
96
|
+
rightElement: "balance",
|
97
|
+
leftElement: "numberOfAccounts",
|
98
|
+
},
|
99
|
+
};
|
100
|
+
|
101
|
+
const { result } = renderHook(() =>
|
102
|
+
useModularDrawerConfiguration("lldModularDrawer", drawerConfiguration),
|
103
|
+
);
|
104
|
+
|
105
|
+
expect(result.current.assetsConfiguration).toEqual(drawerConfiguration.assets);
|
106
|
+
expect(result.current.networkConfiguration).toEqual(drawerConfiguration.networks);
|
107
|
+
});
|
108
|
+
|
109
|
+
it("should handle partial drawer configuration", () => {
|
110
|
+
const drawerConfiguration: EnhancedModularDrawerConfiguration = {
|
111
|
+
assets: {
|
112
|
+
rightElement: "balance",
|
113
|
+
leftElement: "marketTrend",
|
114
|
+
filter: "topNetworks",
|
115
|
+
},
|
116
|
+
};
|
117
|
+
|
118
|
+
const { result } = renderHook(() =>
|
119
|
+
useModularDrawerConfiguration("lldModularDrawer", drawerConfiguration),
|
120
|
+
);
|
121
|
+
|
122
|
+
expect(result.current.assetsConfiguration).toEqual(drawerConfiguration.assets);
|
123
|
+
expect(result.current.networkConfiguration).toBeUndefined();
|
124
|
+
});
|
125
|
+
|
126
|
+
it("should handle configuration with undefined values", () => {
|
127
|
+
const drawerConfiguration: EnhancedModularDrawerConfiguration = {
|
128
|
+
assets: undefined,
|
129
|
+
networks: {
|
130
|
+
rightElement: "balance",
|
131
|
+
leftElement: "numberOfAccountsAndApy",
|
132
|
+
},
|
133
|
+
};
|
134
|
+
|
135
|
+
const { result } = renderHook(() =>
|
136
|
+
useModularDrawerConfiguration("lldModularDrawer", drawerConfiguration),
|
137
|
+
);
|
138
|
+
|
139
|
+
expect(result.current.assetsConfiguration).toBeUndefined();
|
140
|
+
expect(result.current.networkConfiguration).toEqual(drawerConfiguration.networks);
|
141
|
+
});
|
142
|
+
});
|
143
|
+
|
144
|
+
describe("when feature flag is not available", () => {
|
145
|
+
beforeEach(() => {
|
146
|
+
mockUseFeature.mockReturnValue(null);
|
147
|
+
});
|
148
|
+
|
149
|
+
it("should default to disabled configuration when feature flag returns null", () => {
|
150
|
+
const drawerConfiguration: EnhancedModularDrawerConfiguration = {
|
151
|
+
assets: {
|
152
|
+
rightElement: "balance",
|
153
|
+
leftElement: "apy",
|
154
|
+
filter: "topNetworks",
|
155
|
+
},
|
156
|
+
networks: {
|
157
|
+
rightElement: "balance",
|
158
|
+
leftElement: "numberOfAccounts",
|
159
|
+
},
|
160
|
+
};
|
161
|
+
|
162
|
+
const { result } = renderHook(() =>
|
163
|
+
useModularDrawerConfiguration("lldModularDrawer", drawerConfiguration),
|
164
|
+
);
|
165
|
+
|
166
|
+
expect(result.current.assetsConfiguration).toEqual({
|
167
|
+
rightElement: "undefined",
|
168
|
+
leftElement: "undefined",
|
169
|
+
filter: "undefined",
|
170
|
+
});
|
171
|
+
expect(result.current.networkConfiguration).toEqual({
|
172
|
+
rightElement: "undefined",
|
173
|
+
leftElement: "undefined",
|
174
|
+
});
|
175
|
+
});
|
176
|
+
});
|
177
|
+
|
178
|
+
describe("when feature flag params are not available", () => {
|
179
|
+
beforeEach(() => {
|
180
|
+
mockUseFeature.mockReturnValue({
|
181
|
+
enabled: true,
|
182
|
+
params: undefined,
|
183
|
+
});
|
184
|
+
});
|
185
|
+
|
186
|
+
it("should default to disabled configuration when params are undefined", () => {
|
187
|
+
const drawerConfiguration: EnhancedModularDrawerConfiguration = {
|
188
|
+
assets: {
|
189
|
+
rightElement: "balance",
|
190
|
+
leftElement: "apy",
|
191
|
+
filter: "topNetworks",
|
192
|
+
},
|
193
|
+
networks: {
|
194
|
+
rightElement: "balance",
|
195
|
+
leftElement: "numberOfAccounts",
|
196
|
+
},
|
197
|
+
};
|
198
|
+
|
199
|
+
const { result } = renderHook(() =>
|
200
|
+
useModularDrawerConfiguration("lldModularDrawer", drawerConfiguration),
|
201
|
+
);
|
202
|
+
|
203
|
+
expect(result.current.assetsConfiguration).toEqual({
|
204
|
+
rightElement: "undefined",
|
205
|
+
leftElement: "undefined",
|
206
|
+
filter: "undefined",
|
207
|
+
});
|
208
|
+
expect(result.current.networkConfiguration).toEqual({
|
209
|
+
rightElement: "undefined",
|
210
|
+
leftElement: "undefined",
|
211
|
+
});
|
212
|
+
});
|
213
|
+
});
|
214
|
+
|
215
|
+
describe("when enableModularization param is not available", () => {
|
216
|
+
beforeEach(() => {
|
217
|
+
mockUseFeature.mockReturnValue({
|
218
|
+
enabled: true,
|
219
|
+
params: {},
|
220
|
+
});
|
221
|
+
});
|
222
|
+
|
223
|
+
it("should default to disabled configuration when enableModularization is not in params", () => {
|
224
|
+
const drawerConfiguration: EnhancedModularDrawerConfiguration = {
|
225
|
+
assets: {
|
226
|
+
rightElement: "balance",
|
227
|
+
leftElement: "apy",
|
228
|
+
filter: "topNetworks",
|
229
|
+
},
|
230
|
+
networks: {
|
231
|
+
rightElement: "balance",
|
232
|
+
leftElement: "numberOfAccounts",
|
233
|
+
},
|
234
|
+
};
|
235
|
+
|
236
|
+
const { result } = renderHook(() =>
|
237
|
+
useModularDrawerConfiguration("lldModularDrawer", drawerConfiguration),
|
238
|
+
);
|
239
|
+
|
240
|
+
expect(result.current.assetsConfiguration).toEqual({
|
241
|
+
rightElement: "undefined",
|
242
|
+
leftElement: "undefined",
|
243
|
+
filter: "undefined",
|
244
|
+
});
|
245
|
+
expect(result.current.networkConfiguration).toEqual({
|
246
|
+
rightElement: "undefined",
|
247
|
+
leftElement: "undefined",
|
248
|
+
});
|
249
|
+
});
|
250
|
+
});
|
251
|
+
});
|
@@ -0,0 +1,33 @@
|
|
1
|
+
import { useFeature } from "../../featureFlags";
|
2
|
+
import { EnhancedModularDrawerConfiguration } from "../../wallet-api/ModularDrawer/types";
|
3
|
+
|
4
|
+
const assetConfigurationDisabled: EnhancedModularDrawerConfiguration["assets"] = {
|
5
|
+
rightElement: "undefined",
|
6
|
+
leftElement: "undefined",
|
7
|
+
filter: "undefined",
|
8
|
+
};
|
9
|
+
|
10
|
+
const networkConfigurationDisabled: EnhancedModularDrawerConfiguration["networks"] = {
|
11
|
+
rightElement: "undefined",
|
12
|
+
leftElement: "undefined",
|
13
|
+
};
|
14
|
+
|
15
|
+
export const useModularDrawerConfiguration = (
|
16
|
+
featureFlagKey: "lldModularDrawer" | "llmModularDrawer",
|
17
|
+
drawerConfiguration?: EnhancedModularDrawerConfiguration,
|
18
|
+
) => {
|
19
|
+
const featureModularDrawer = useFeature(featureFlagKey);
|
20
|
+
|
21
|
+
const modularizationEnabled = featureModularDrawer?.params?.enableModularization ?? false;
|
22
|
+
const assetsConfiguration = modularizationEnabled
|
23
|
+
? drawerConfiguration?.assets
|
24
|
+
: assetConfigurationDisabled;
|
25
|
+
const networkConfiguration = modularizationEnabled
|
26
|
+
? drawerConfiguration?.networks
|
27
|
+
: networkConfigurationDisabled;
|
28
|
+
|
29
|
+
return {
|
30
|
+
assetsConfiguration,
|
31
|
+
networkConfiguration,
|
32
|
+
};
|
33
|
+
};
|