Skip to content

Commit

Permalink
Rewrite savings withdraw E2E tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yivlad committed Dec 21, 2024
1 parent 08c5e32 commit 9cc4211
Show file tree
Hide file tree
Showing 24 changed files with 2,262 additions and 2,240 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,6 @@ test.describe('Repay dialog', () => {
repayDialog = new DialogPageObject({ testContext, header: headerRegExp })

await myPortfolioPage.expectHealthFactor('3.73')

// forcefully set browser time to the timestamp of borrow transaction
// const block = await testContext.testnetController.client.getBlock()
// await injectFixedDate(page, new Date(Number(block.timestamp) * 1000))
// await page.reload()
})

test('can repay if balance is less than debt', async ({ page }) => {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import { SavingsPageObject } from '@/pages/Savings.PageObject'
import { BASE_DEFAULT_BLOCK_NUMBER } from '@/test/e2e/constants'
import { setup } from '@/test/e2e/setup'
import { test } from '@playwright/test'
import { base } from 'viem/chains'
import { SavingsDialogPageObject } from '../../../common/e2e/SavingsDialog.PageObject'

test.describe('Without send mode', () => {
test('can switch between tokens', async ({ page }) => {
const testContext = await setup(page, {
blockchain: {
chainId: base.id,
blockNumber: BASE_DEFAULT_BLOCK_NUMBER,
},
initialPage: 'savings',
account: {
type: 'connected-random',
assetBalances: {
ETH: 1,
sUSDS: 1000,
},
},
})

const savingsPage = new SavingsPageObject(testContext)

await savingsPage.clickWithdrawSUsdsButtonAction()

const withdrawalDialog = new SavingsDialogPageObject({ testContext, type: 'withdraw' })

await withdrawalDialog.fillAmountAction(1000)
await withdrawalDialog.actionsContainer.expectEnabledActionAtIndex(0)
await withdrawalDialog.actionsContainer.expectActions([
{ type: 'approve', asset: 'sUSDS' },
{ type: 'withdrawFromSavings', asset: 'USDS', savingsAsset: 'sUSDS', mode: 'withdraw' },
])

await withdrawalDialog.selectAssetAction('USDC')
await withdrawalDialog.fillAmountAction(1000)
await withdrawalDialog.actionsContainer.expectEnabledActionAtIndex(0)
await withdrawalDialog.actionsContainer.expectActions([
{ type: 'approve', asset: 'sUSDS' },
{ type: 'withdrawFromSavings', asset: 'USDC', savingsAsset: 'sUSDS', mode: 'withdraw' },
])

await withdrawalDialog.selectAssetAction('USDS')
await withdrawalDialog.fillAmountAction(1000)
await withdrawalDialog.actionsContainer.expectEnabledActionAtIndex(0)
await withdrawalDialog.actionsContainer.expectActions([
{ type: 'approve', asset: 'sUSDS' },
{ type: 'withdrawFromSavings', asset: 'USDS', savingsAsset: 'sUSDS', mode: 'withdraw' },
])
})
})

test.describe('With send mode', () => {
test('can select only supported assets', async ({ page }) => {
const testContext = await setup(page, {
blockchain: {
chainId: base.id,
blockNumber: BASE_DEFAULT_BLOCK_NUMBER,
},
initialPage: 'savings',
account: {
type: 'connected-random',
assetBalances: {
USDS: 100,
sUSDS: 10_000,
},
},
})

const savingsPage = new SavingsPageObject(testContext)
await savingsPage.clickSendSUsdsButtonAction()

const sendDialog = new SavingsDialogPageObject({ testContext, type: 'send' })

await sendDialog.openAssetSelectorAction()
await sendDialog.expectAssetSelectorOptions(['USDC', 'USDS'])
})
})
Loading

0 comments on commit 9cc4211

Please sign in to comment.