|
1 | 1 | import { Box } from '@chakra-ui/react'; |
2 | 2 | import React from 'react'; |
3 | 3 |
|
4 | | -import type { OptimisticL2WithdrawalStatus } from 'types/api/optimisticL2'; |
| 4 | +import type { OpWithdrawal } from 'types/api/transaction'; |
5 | 5 |
|
| 6 | +import * as addressMock from 'mocks/address/address'; |
6 | 7 | import { ENVS_MAP } from 'playwright/fixtures/mockEnvs'; |
7 | 8 | import { test, expect } from 'playwright/lib'; |
8 | 9 |
|
9 | 10 | import TxDetailsWithdrawalStatusOptimistic from './TxDetailsWithdrawalStatusOptimistic'; |
10 | 11 |
|
11 | | -const statuses: Array<OptimisticL2WithdrawalStatus> = [ |
12 | | - 'Waiting for state root', |
13 | | - 'Ready for relay', |
14 | | - 'Relayed', |
15 | | -]; |
| 12 | +const TX_HASH = '0x7d93a59a228e97d084a635181c3053e324237d07566ec12287eae6da2bcf9456'; |
16 | 13 |
|
17 | | -statuses.forEach((status) => { |
18 | | - test(`status="${ status }"`, async({ render, mockEnvs }) => { |
| 14 | +const BASE_DATA: OpWithdrawal = { |
| 15 | + l1_transaction_hash: TX_HASH, |
| 16 | + nonce: 1, |
| 17 | + status: 'Waiting for state root', |
| 18 | + portal_contract_address_hash: null, |
| 19 | + msg_sender_address_hash: null, |
| 20 | + msg_target_address_hash: null, |
| 21 | + msg_data: null, |
| 22 | + msg_gas_limit: null, |
| 23 | + msg_nonce_raw: null, |
| 24 | + msg_value: null, |
| 25 | +}; |
| 26 | + |
| 27 | +test('status=Waiting for state root', async({ render, mockEnvs }) => { |
| 28 | + await mockEnvs(ENVS_MAP.optimisticRollup); |
| 29 | + |
| 30 | + const data: OpWithdrawal = { |
| 31 | + ...BASE_DATA, |
| 32 | + status: 'Waiting for state root', |
| 33 | + }; |
| 34 | + |
| 35 | + const component = await render( |
| 36 | + <Box p={ 2 }> |
| 37 | + <TxDetailsWithdrawalStatusOptimistic |
| 38 | + data={ data } |
| 39 | + txHash={ TX_HASH } |
| 40 | + from={ addressMock.withoutName } |
| 41 | + /> |
| 42 | + </Box>, |
| 43 | + ); |
| 44 | + |
| 45 | + await expect(component).toHaveScreenshot(); |
| 46 | +}); |
| 47 | + |
| 48 | +test.describe('status=Ready for relay', () => { |
| 49 | + test('with claim button', async({ render, mockEnvs }) => { |
19 | 50 | await mockEnvs(ENVS_MAP.optimisticRollup); |
| 51 | + |
| 52 | + const data: OpWithdrawal = { |
| 53 | + ...BASE_DATA, |
| 54 | + status: 'Ready for relay', |
| 55 | + }; |
| 56 | + |
20 | 57 | const component = await render( |
21 | 58 | <Box p={ 2 }> |
22 | | - <TxDetailsWithdrawalStatusOptimistic status={ status } l1TxHash="0x7d93a59a228e97d084a635181c3053e324237d07566ec12287eae6da2bcf9456"/> |
| 59 | + <TxDetailsWithdrawalStatusOptimistic |
| 60 | + data={ data } |
| 61 | + txHash={ TX_HASH } |
| 62 | + from={ addressMock.withoutName } |
| 63 | + /> |
23 | 64 | </Box>, |
24 | 65 | ); |
25 | 66 |
|
26 | 67 | await expect(component).toHaveScreenshot(); |
27 | 68 | }); |
| 69 | + |
| 70 | + test('without claim button', async({ render, mockEnvs }) => { |
| 71 | + await mockEnvs([ |
| 72 | + ...ENVS_MAP.optimisticRollup, |
| 73 | + [ 'NEXT_PUBLIC_ROLLUP_L2_WITHDRAWAL_URL', '' ], |
| 74 | + ]); |
| 75 | + |
| 76 | + const data: OpWithdrawal = { |
| 77 | + ...BASE_DATA, |
| 78 | + status: 'Ready for relay', |
| 79 | + }; |
| 80 | + |
| 81 | + const component = await render( |
| 82 | + <Box p={ 2 }> |
| 83 | + <TxDetailsWithdrawalStatusOptimistic |
| 84 | + data={ data } |
| 85 | + txHash={ TX_HASH } |
| 86 | + from={ addressMock.withoutName } |
| 87 | + /> |
| 88 | + </Box>, |
| 89 | + ); |
| 90 | + |
| 91 | + await expect(component).toHaveScreenshot(); |
| 92 | + }); |
| 93 | +}); |
| 94 | + |
| 95 | +test('status=Relayed', async({ render, mockEnvs }) => { |
| 96 | + await mockEnvs(ENVS_MAP.optimisticRollup); |
| 97 | + |
| 98 | + const data: OpWithdrawal = { |
| 99 | + ...BASE_DATA, |
| 100 | + status: 'Relayed', |
| 101 | + }; |
| 102 | + |
| 103 | + const component = await render( |
| 104 | + <Box p={ 2 }> |
| 105 | + <TxDetailsWithdrawalStatusOptimistic |
| 106 | + data={ data } |
| 107 | + txHash={ TX_HASH } |
| 108 | + from={ addressMock.withoutName } |
| 109 | + /> |
| 110 | + </Box>, |
| 111 | + ); |
| 112 | + |
| 113 | + await expect(component).toHaveScreenshot(); |
28 | 114 | }); |
0 commit comments