-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add e2e tests for native max DAI withdrawal
- Loading branch information
Oskar
committed
Jun 12, 2024
1 parent
a786335
commit 1b01de1
Showing
1 changed file
with
69 additions
and
0 deletions.
There are no files selected for viewing
69 changes: 69 additions & 0 deletions
69
packages/app/src/features/dialogs/savings/withdraw/e2e/WithdrawMaxDAI.test-e2e.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { ActionsPageObject } from '@/features/actions/ActionsContainer.PageObject' | ||
import { SavingsPageObject } from '@/pages/Savings.PageObject' | ||
import { DEFAULT_BLOCK_NUMBER } from '@/test/e2e/constants' | ||
import { setup } from '@/test/e2e/setup' | ||
import { setupFork } from '@/test/e2e/setupFork' | ||
import { test } from '@playwright/test' | ||
import { mainnet } from 'viem/chains' | ||
import { SavingsDialogPageObject } from '../../common/e2e/SavingsDialog.PageObject' | ||
|
||
test.describe('Withdraw max DAI on Mainnet', () => { | ||
const fork = setupFork({ blockNumber: DEFAULT_BLOCK_NUMBER, chainId: mainnet.id }) | ||
let savingsPage: SavingsPageObject | ||
let withdrawalDialog: SavingsDialogPageObject | ||
|
||
test.beforeEach(async ({ page }) => { | ||
await setup(page, fork, { | ||
initialPage: 'savings', | ||
account: { | ||
type: 'connected', | ||
assetBalances: { | ||
ETH: 1, | ||
sDAI: 10_000, | ||
}, | ||
}, | ||
}) | ||
|
||
savingsPage = new SavingsPageObject(page) | ||
await savingsPage.clickWithdrawButtonAction() | ||
|
||
withdrawalDialog = new SavingsDialogPageObject({ page, type: 'withdraw' }) | ||
await withdrawalDialog.clickMaxAmountAction() | ||
}) | ||
|
||
test('uses native sDai withdrawal', async () => { | ||
await withdrawalDialog.expectToUseNativeSDaiAction({ asset: 'DAI', amount: 10_715.05 }) | ||
}) | ||
|
||
test('displays transaction overview', async () => { | ||
await withdrawalDialog.expectNativeRouteTransactionOverview({ | ||
apy: { | ||
value: '5.00%', | ||
description: 'Earn ~535.75 DAI per year', | ||
}, | ||
routeItems: [ | ||
{ | ||
tokenAmount: '10,000.00 sDAI', | ||
tokenUsdValue: '$10,715.05', | ||
}, | ||
{ | ||
tokenAmount: '10,715.05 DAI', | ||
tokenUsdValue: '$10,715.05', | ||
}, | ||
], | ||
outcome: '10,715.05 DAI worth $10,715.05', | ||
}) | ||
}) | ||
|
||
test('executes max withdrawal', async () => { | ||
const actionsContainer = new ActionsPageObject(withdrawalDialog.locatePanelByHeader('Actions')) | ||
await actionsContainer.acceptAllActionsAction(1) | ||
|
||
await withdrawalDialog.expectSuccessPage() | ||
await withdrawalDialog.clickBackToSavingsButton() | ||
|
||
await savingsPage.expectPotentialProjection('$43.06', '30-day') | ||
await savingsPage.expectPotentialProjection('$535.75', '1-year') | ||
await savingsPage.expectCashInWalletAssetBalance('DAI', '10,715.05') | ||
}) | ||
}) |