Skip to content

Commit ad792ce

Browse files
committed
Add test for token panel
1 parent ec6fbfe commit ad792ce

2 files changed

Lines changed: 257 additions & 84 deletions

File tree

packages/arb-token-bridge-ui/src/components/TransferPanel/TransferPanel.default-tokens.integration.test.tsx

Lines changed: 204 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,52 @@ import {
1313
} from './TransferPanel.integration.helpers';
1414

1515
const APE_LOGO_URI = '/images/ApeTokenLogo.svg';
16+
const WETH_LOGO_URI =
17+
'https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2/logo.png';
1618

1719
const defaultTokenCases: RouteTokenCase[] = [
20+
{
21+
sourceChain: 'base',
22+
destinationChain: 'apechain',
23+
expectedSourceToken: { symbol: 'APE', logoURI: APE_LOGO_URI },
24+
expectedDestinationToken: { symbol: 'APE', logoURI: APE_LOGO_URI },
25+
},
26+
{
27+
sourceChain: 'base',
28+
destinationChain: 'superposition',
29+
expectedSourceToken: { symbol: 'ETH', logoURI: ETHER_TOKEN_LOGO },
30+
expectedDestinationToken: { symbol: 'ETH', logoURI: ETHER_TOKEN_LOGO },
31+
},
32+
{
33+
sourceChain: 'base',
34+
destinationChain: 'arbitrum-one',
35+
expectedSourceToken: { symbol: 'ETH', logoURI: ETHER_TOKEN_LOGO },
36+
expectedDestinationToken: { symbol: 'ETH', logoURI: ETHER_TOKEN_LOGO },
37+
},
38+
{
39+
sourceChain: 'arbitrum-one',
40+
destinationChain: 'apechain',
41+
expectedSourceToken: { symbol: 'APE', logoURI: APE_LOGO_URI },
42+
expectedDestinationToken: { symbol: 'APE', logoURI: APE_LOGO_URI },
43+
},
44+
{
45+
sourceChain: 'arbitrum-one',
46+
destinationChain: 'superposition',
47+
expectedSourceToken: { symbol: 'ETH', logoURI: ETHER_TOKEN_LOGO },
48+
expectedDestinationToken: { symbol: 'ETH', logoURI: ETHER_TOKEN_LOGO },
49+
},
50+
{
51+
sourceChain: 'apechain',
52+
destinationChain: 'arbitrum-one',
53+
expectedSourceToken: { symbol: 'APE', logoURI: APE_LOGO_URI },
54+
expectedDestinationToken: { symbol: 'APE', logoURI: APE_LOGO_URI },
55+
},
56+
{
57+
sourceChain: 'superposition',
58+
destinationChain: 'arbitrum-one',
59+
expectedSourceToken: { symbol: 'ETH', logoURI: ETHER_TOKEN_LOGO },
60+
expectedDestinationToken: { symbol: 'ETH', logoURI: ETHER_TOKEN_LOGO },
61+
},
1862
{
1963
sourceChain: 'ethereum',
2064
destinationChain: 'apechain',
@@ -51,93 +95,181 @@ const defaultTokenCases: RouteTokenCase[] = [
5195
expectedSourceToken: { symbol: 'ETH', logoURI: ETHER_TOKEN_LOGO },
5296
expectedDestinationToken: {
5397
symbol: 'WETH',
54-
logoURI:
55-
'https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2/logo.png',
98+
logoURI: WETH_LOGO_URI,
5699
},
57100
},
58101
];
59102

60103
type DefaultTokenPanelCase = {
61104
sourceChain: RouteTokenCase['sourceChain'];
62105
destinationChain: RouteTokenCase['destinationChain'];
63-
expectedSourcePanelSymbols: string[];
64-
expectedDestinationPanelSymbols: string[];
65-
expectedSourcePanelToken: TokenExpectation;
66-
expectedDestinationPanelToken: TokenExpectation;
106+
expectedSourcePanelSymbols: TokenExpectation[];
107+
expectedDestinationPanelSymbols: TokenExpectation[];
67108
};
68109

69110
const defaultTokenPanelCases: DefaultTokenPanelCase[] = [
111+
{
112+
sourceChain: 'base',
113+
destinationChain: 'apechain',
114+
expectedSourcePanelSymbols: [
115+
{
116+
symbol: 'APE',
117+
logoURI: APE_LOGO_URI,
118+
},
119+
],
120+
expectedDestinationPanelSymbols: [
121+
{ symbol: 'APE', logoURI: APE_LOGO_URI },
122+
{ symbol: 'USDC.e' },
123+
{ symbol: 'USDT' },
124+
{ symbol: 'WETH' },
125+
],
126+
},
127+
{
128+
sourceChain: 'base',
129+
destinationChain: 'superposition',
130+
expectedSourcePanelSymbols: [{ symbol: 'ETH', logoURI: ETHER_TOKEN_LOGO }],
131+
expectedDestinationPanelSymbols: [
132+
{ symbol: 'ETH', logoURI: ETHER_TOKEN_LOGO },
133+
{ symbol: 'USDC.e' },
134+
{ symbol: 'WETH' },
135+
],
136+
},
137+
{
138+
sourceChain: 'base',
139+
destinationChain: 'arbitrum-one',
140+
expectedSourcePanelSymbols: [{ symbol: 'ETH', logoURI: ETHER_TOKEN_LOGO }],
141+
expectedDestinationPanelSymbols: [
142+
{ symbol: 'ETH', logoURI: ETHER_TOKEN_LOGO },
143+
{ symbol: 'USDC' },
144+
{ symbol: 'USDT' },
145+
{ symbol: 'WETH' },
146+
],
147+
},
148+
{
149+
sourceChain: 'arbitrum-one',
150+
destinationChain: 'apechain',
151+
expectedSourcePanelSymbols: [
152+
{
153+
symbol: 'APE',
154+
logoURI: APE_LOGO_URI,
155+
},
156+
],
157+
expectedDestinationPanelSymbols: [
158+
{ symbol: 'APE', logoURI: APE_LOGO_URI },
159+
{ symbol: 'USDC.e' },
160+
{ symbol: 'USDT' },
161+
{ symbol: 'WETH' },
162+
],
163+
},
164+
{
165+
sourceChain: 'arbitrum-one',
166+
destinationChain: 'superposition',
167+
expectedSourcePanelSymbols: [{ symbol: 'ETH', logoURI: ETHER_TOKEN_LOGO }],
168+
expectedDestinationPanelSymbols: [
169+
{ symbol: 'ETH', logoURI: ETHER_TOKEN_LOGO },
170+
{ symbol: 'USDC.e' },
171+
{ symbol: 'WETH' },
172+
],
173+
},
174+
{
175+
sourceChain: 'apechain',
176+
destinationChain: 'arbitrum-one',
177+
expectedSourcePanelSymbols: [{ symbol: 'APE', logoURI: APE_LOGO_URI }],
178+
expectedDestinationPanelSymbols: [
179+
{
180+
symbol: 'APE',
181+
logoURI: APE_LOGO_URI,
182+
},
183+
{ symbol: 'USDC' },
184+
{ symbol: 'USDT' },
185+
{ symbol: 'WETH' },
186+
{ symbol: 'ETH' },
187+
],
188+
},
189+
{
190+
sourceChain: 'superposition',
191+
destinationChain: 'arbitrum-one',
192+
expectedSourcePanelSymbols: [{ symbol: 'ETH', logoURI: ETHER_TOKEN_LOGO }],
193+
expectedDestinationPanelSymbols: [
194+
{ symbol: 'ETH', logoURI: ETHER_TOKEN_LOGO },
195+
{ symbol: 'USDC' },
196+
{ symbol: 'WETH' },
197+
],
198+
},
70199
{
71200
sourceChain: 'ethereum',
72201
destinationChain: 'apechain',
73-
expectedSourcePanelSymbols: ['APE'],
74-
expectedDestinationPanelSymbols: ['APE', 'USDC.e', 'USDT', 'WETH'],
75-
expectedSourcePanelToken: {
76-
symbol: 'APE',
77-
},
78-
expectedDestinationPanelToken: {
79-
symbol: 'APE',
80-
},
202+
expectedSourcePanelSymbols: [
203+
{
204+
symbol: 'APE',
205+
logoURI: APE_LOGO_URI,
206+
},
207+
],
208+
expectedDestinationPanelSymbols: [
209+
{ symbol: 'APE', logoURI: APE_LOGO_URI },
210+
{ symbol: 'USDC.e' },
211+
{ symbol: 'USDT' },
212+
{ symbol: 'WETH' },
213+
],
81214
},
82215
{
83216
sourceChain: 'apechain',
84217
destinationChain: 'ethereum',
85-
expectedSourcePanelSymbols: ['APE'],
86-
expectedDestinationPanelSymbols: ['APE', 'USDC', 'USDT', 'WETH', 'ETH'],
87-
expectedSourcePanelToken: {
88-
symbol: 'APE',
89-
},
90-
expectedDestinationPanelToken: {
91-
symbol: 'APE',
92-
},
218+
expectedSourcePanelSymbols: [{ symbol: 'APE', logoURI: APE_LOGO_URI }],
219+
expectedDestinationPanelSymbols: [
220+
{
221+
symbol: 'APE',
222+
logoURI: APE_LOGO_URI,
223+
},
224+
{ symbol: 'USDC' },
225+
{ symbol: 'USDT' },
226+
{ symbol: 'WETH' },
227+
{ symbol: 'ETH' },
228+
],
93229
},
94230
{
95231
sourceChain: 'ethereum',
96232
destinationChain: 'superposition',
97-
expectedSourcePanelSymbols: ['ETH'],
98-
expectedDestinationPanelSymbols: ['ETH', 'USDC.e', 'WETH'],
99-
expectedSourcePanelToken: {
100-
symbol: 'ETH',
101-
},
102-
expectedDestinationPanelToken: {
103-
symbol: 'ETH',
104-
},
233+
expectedSourcePanelSymbols: [{ symbol: 'ETH', logoURI: ETHER_TOKEN_LOGO }],
234+
expectedDestinationPanelSymbols: [
235+
{ symbol: 'ETH', logoURI: ETHER_TOKEN_LOGO },
236+
{ symbol: 'USDC.e' },
237+
{ symbol: 'WETH' },
238+
],
105239
},
106240
{
107241
sourceChain: 'superposition',
108242
destinationChain: 'ethereum',
109-
expectedSourcePanelSymbols: ['ETH'],
110-
expectedDestinationPanelSymbols: ['ETH', 'USDC', 'WETH'],
111-
expectedSourcePanelToken: {
112-
symbol: 'ETH',
113-
},
114-
expectedDestinationPanelToken: {
115-
symbol: 'ETH',
116-
},
243+
expectedSourcePanelSymbols: [{ symbol: 'ETH', logoURI: ETHER_TOKEN_LOGO }],
244+
expectedDestinationPanelSymbols: [
245+
{ symbol: 'ETH', logoURI: ETHER_TOKEN_LOGO },
246+
{ symbol: 'USDC' },
247+
{ symbol: 'WETH' },
248+
],
117249
},
118250
{
119251
sourceChain: 'apechain',
120252
destinationChain: 'superposition',
121-
expectedSourcePanelSymbols: ['APE'],
122-
expectedDestinationPanelSymbols: ['ETH', 'USDC.e', 'WETH'],
123-
expectedSourcePanelToken: {
124-
symbol: 'APE',
125-
},
126-
expectedDestinationPanelToken: {
127-
symbol: 'ETH',
128-
},
253+
expectedSourcePanelSymbols: [{ symbol: 'APE', logoURI: APE_LOGO_URI }],
254+
expectedDestinationPanelSymbols: [
255+
{ symbol: 'ETH', logoURI: ETHER_TOKEN_LOGO },
256+
{ symbol: 'USDC.e' },
257+
{ symbol: 'WETH' },
258+
],
129259
},
130260
{
131261
sourceChain: 'superposition',
132262
destinationChain: 'apechain',
133-
expectedSourcePanelSymbols: ['ETH'],
134-
expectedDestinationPanelSymbols: ['APE', 'USDC.e', 'WETH'],
135-
expectedSourcePanelToken: {
136-
symbol: 'ETH',
137-
},
138-
expectedDestinationPanelToken: {
139-
symbol: 'APE',
140-
},
263+
expectedSourcePanelSymbols: [{ symbol: 'ETH', logoURI: ETHER_TOKEN_LOGO }],
264+
expectedDestinationPanelSymbols: [
265+
{
266+
symbol: 'WETH',
267+
logoURI: WETH_LOGO_URI,
268+
},
269+
{ symbol: 'APE' },
270+
{ symbol: 'USDC.e' },
271+
{ symbol: 'WETH' },
272+
],
141273
},
142274
];
143275

@@ -171,24 +303,36 @@ describe.sequential('TransferPanel LiFi Integration - Default Token', () => {
171303
destinationChain,
172304
expectedSourcePanelSymbols,
173305
expectedDestinationPanelSymbols,
174-
expectedSourcePanelToken,
175-
expectedDestinationPanelToken,
176306
}) => {
177307
await renderTransferPanel({
178308
sourceChain,
179309
destinationChain,
180310
destinationAddress: nonConnectedDestinationAddress,
181311
});
312+
const expectedSourcePanelTokenSymbols = expectedSourcePanelSymbols.map(
313+
({ symbol }) => symbol,
314+
);
315+
const expectedDestinationPanelTokenSymbols = expectedDestinationPanelSymbols.map(
316+
({ symbol }) => symbol,
317+
);
318+
const sourcePanelTokenExpectation = expectedSourcePanelSymbols[0];
319+
const destinationPanelTokenExpectation = expectedDestinationPanelSymbols[0];
320+
321+
if (!sourcePanelTokenExpectation || !destinationPanelTokenExpectation) {
322+
throw new Error(
323+
`Missing primary token expectation for "${sourceChain}" -> "${destinationChain}".`,
324+
);
325+
}
182326

183327
await expectTokenPanelContent({
184328
isDestination: false,
185-
symbolsToContain: expectedSourcePanelSymbols,
186-
tokenExpectation: expectedSourcePanelToken,
329+
symbolsToContain: expectedSourcePanelTokenSymbols,
330+
tokenExpectation: sourcePanelTokenExpectation,
187331
});
188332
await expectTokenPanelContent({
189333
isDestination: true,
190-
symbolsToContain: expectedDestinationPanelSymbols,
191-
tokenExpectation: expectedDestinationPanelToken,
334+
symbolsToContain: expectedDestinationPanelTokenSymbols,
335+
tokenExpectation: destinationPanelTokenExpectation,
192336
});
193337
},
194338
);

0 commit comments

Comments
 (0)