-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Expand file tree
/
Copy pathswap-action-regression.spec.ts
More file actions
76 lines (70 loc) · 2.75 KB
/
Copy pathswap-action-regression.spec.ts
File metadata and controls
76 lines (70 loc) · 2.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import { withFixtures } from '../../framework/fixtures/FixtureHelper';
import { LocalNode, LocalNodeType } from '../../framework/types';
import FixtureBuilder from '../../framework/fixtures/FixtureBuilder';
import TabBarComponent from '../../page-objects/wallet/TabBarComponent';
import WalletView from '../../page-objects/wallet/WalletView';
import { RegressionTrade } from '../../tags';
import {
submitSwapUnifiedUI,
checkSwapActivity,
} from '../../helpers/swap/swap-unified-ui';
import { loginToApp } from '../../flows/wallet.flow';
import { prepareSwapsTestEnvironment } from '../../helpers/swap/prepareSwapsTestEnvironment';
import { AnvilPort } from '../../framework/fixtures/FixtureUtils';
import { testSpecificMock } from '../../helpers/swap/swap-mocks';
import { setupSmartTransactionsMocks } from '../../helpers/swap/smart-transactions-mocks';
import { AnvilManager, DEFAULT_ANVIL_PORT } from '../../seeder/anvil-manager';
describe(RegressionTrade('Swap ETH <-> WETH from Actions'), (): void => {
beforeEach(async (): Promise<void> => {
jest.setTimeout(180000);
});
it('swaps ETH->WETH and WETH->ETH', async (): Promise<void> => {
await withFixtures(
{
fixture: ({ localNodes }: { localNodes?: LocalNode[] }) => {
const node = localNodes?.[0] as unknown as AnvilManager;
const rpcPort =
node instanceof AnvilManager
? (node.getPort() ?? AnvilPort())
: undefined;
return new FixtureBuilder()
.withNetworkController({
chainId: '0x1',
rpcUrl: `http://localhost:${rpcPort ?? AnvilPort()}`,
type: 'custom',
nickname: 'Localhost',
ticker: 'ETH',
})
.build();
},
localNodeOptions: [
{
type: LocalNodeType.anvil,
options: {
chainId: 1,
loadState: './tests/regression/swap/withTokensWeth.json',
},
},
],
testSpecificMock: async (mockServer) => {
await testSpecificMock(mockServer);
await setupSmartTransactionsMocks(mockServer, DEFAULT_ANVIL_PORT);
},
restartDevice: true,
},
async () => {
await loginToApp();
await prepareSwapsTestEnvironment();
await WalletView.tapWalletSwapButton();
// Submit first swap: ETH -> WETH
await submitSwapUnifiedUI('1', 'ETH', 'WETH', '0x1');
await checkSwapActivity('ETH', 'WETH');
await TabBarComponent.tapWallet();
await WalletView.tapWalletSwapButton();
// Submit second swap: WETH -> ETH
await submitSwapUnifiedUI('1', 'WETH', 'ETH', '0x1');
await checkSwapActivity('WETH', 'ETH');
},
);
});
});