Skip to content

Commit

Permalink
Add e2e tests for native max DAI withdrawal
Browse files Browse the repository at this point in the history
  • Loading branch information
Oskar committed Jun 12, 2024
1 parent a786335 commit 1b01de1
Showing 1 changed file with 69 additions and 0 deletions.
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')
})
})

0 comments on commit 1b01de1

Please sign in to comment.