Skip to content

Commit

Permalink
Finish savings deposit E2E tests rewrite
Browse files Browse the repository at this point in the history
  • Loading branch information
yivlad committed Dec 21, 2024
1 parent 440a6a7 commit d51c8cf
Show file tree
Hide file tree
Showing 3 changed files with 195 additions and 195 deletions.
Original file line number Diff line number Diff line change
@@ -1,76 +1,79 @@
// import { ActionsPageObject } from '@/features/actions/ActionsContainer.PageObject'
// import { SavingsPageObject } from '@/pages/Savings.PageObject'
// import { setupFork } from '@/test/e2e/forking/setupFork'
// import { setup } from '@/test/e2e/setup'
// import { test } from '@playwright/test'
// import { base } from 'viem/chains'
// import { SavingsDialogPageObject } from '../../../common/e2e/SavingsDialog.PageObject'
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('Deposit USDC', () => {
// const fork = setupFork({ chainId: base.id, blockNumber: 22143788n, useTenderlyVnet: true })
test.describe('Deposit USDC', () => {
let savingsPage: SavingsPageObject
let depositDialog: SavingsDialogPageObject

// let savingsPage: SavingsPageObject
// let depositDialog: SavingsDialogPageObject
test.beforeEach(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,
USDC: 10_000,
},
},
})

// test.beforeEach(async ({ page }) => {
// await setup(page, fork, {
// initialPage: 'savings',
// account: {
// type: 'connected-random',
// assetBalances: {
// ETH: 1,
// USDC: 10_000,
// },
// },
// })
savingsPage = new SavingsPageObject(testContext)
await savingsPage.clickDepositButtonAction('USDC')

// savingsPage = new SavingsPageObject(page)
// await savingsPage.clickDepositButtonAction('USDC')
depositDialog = new SavingsDialogPageObject({ testContext, type: 'deposit' })
await depositDialog.fillAmountAction(10_000)
})

// depositDialog = new SavingsDialogPageObject({ page, type: 'deposit' })
// await depositDialog.fillAmountAction(10_000)
// })
test('has correct action plan', async () => {
await depositDialog.actionsContainer.expectActions([
{ type: 'approve', asset: 'USDC' },
{ type: 'depositToSavings', asset: 'USDC', savingsAsset: 'sUSDS' },
])
})

// test('has correct action plan', async () => {
// await depositDialog.actionsContainer.expectActions([
// { type: 'approve', asset: 'USDC' },
// { type: 'depositToSavings', asset: 'USDC', savingsAsset: 'sUSDS' },
// ])
// })
test('displays transaction overview', async () => {
await depositDialog.expectNativeRouteTransactionOverview({
apy: {
value: '8.50%',
description: 'Earn ~850.00 USDS/year',
},
routeItems: [
{
tokenAmount: '10,000.00 USDC',
tokenUsdValue: '$10,000.00',
},
{
tokenAmount: '10,000.00 USDS',
tokenUsdValue: '$10,000.00',
},
{
tokenAmount: '9,872.98 sUSDS',
tokenUsdValue: '$10,000.00',
},
],
outcome: '9,872.98 sUSDS',
outcomeUsd: '$10,000.00',
})
})

// test('displays transaction overview', async () => {
// await depositDialog.expectNativeRouteTransactionOverview({
// apy: {
// value: '6.50%',
// description: 'Earn ~650.00 USDS/year',
// },
// routeItems: [
// {
// tokenAmount: '10,000.00 USDC',
// tokenUsdValue: '$10,000.00',
// },
// {
// tokenAmount: '10,000.00 USDS',
// tokenUsdValue: '$10,000.00',
// },
// {
// tokenAmount: '9,911.77 sUSDS',
// tokenUsdValue: '$10,000.00',
// },
// ],
// outcome: '9,911.77 sUSDS',
// outcomeUsd: '$10,000.00',
// })
// })
test('executes deposit', async () => {
await depositDialog.actionsContainer.acceptAllActionsAction(2)

// test('executes deposit', async () => {
// const actionsContainer = new ActionsPageObject(depositDialog.locatePanelByHeader('Actions'))
// await actionsContainer.acceptAllActionsAction(2)
await depositDialog.expectSuccessPage()
await depositDialog.clickBackToSavingsButton()

// await depositDialog.expectSuccessPage()
// await depositDialog.clickBackToSavingsButton()

// await savingsPage.expectSavingsUsdsBalance({ susdsBalance: '9,911.77 sUSDS', estimatedUsdsValue: '10,000' })
// await savingsPage.expectStablecoinsInWalletAssetBalance('USDC', '-')
// })
// })
await savingsPage.expectSavingsUsdsBalance({
susdsBalance: '9,872.98 sUSDS',
estimatedUsdsValue: '9,999.999999', // USDC has 6 decimals, so the value is rounded down. This is consistent with the data in the smart contract
})
await savingsPage.expectStablecoinsInWalletAssetBalance('USDC', '-')
})
})
Original file line number Diff line number Diff line change
@@ -1,73 +1,74 @@
// import { ActionsPageObject } from '@/features/actions/ActionsContainer.PageObject'
// import { SavingsPageObject } from '@/pages/Savings.PageObject'
// import { setupFork } from '@/test/e2e/forking/setupFork'
// import { setup } from '@/test/e2e/setup'
// import { test } from '@playwright/test'
// import { base } from 'viem/chains'
// import { SavingsDialogPageObject } from '../../../common/e2e/SavingsDialog.PageObject'
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('Deposit USDS', () => {
// const fork = setupFork({ chainId: base.id, blockNumber: 22143788n, useTenderlyVnet: true })
// let savingsPage: SavingsPageObject
// let depositDialog: SavingsDialogPageObject
test.describe('Deposit USDS', () => {
let savingsPage: SavingsPageObject
let depositDialog: SavingsDialogPageObject

// test.beforeEach(async ({ page }) => {
// await setup(page, fork, {
// initialPage: 'savings',
// account: {
// type: 'connected-random',
// assetBalances: {
// ETH: 1,
// USDS: 10_000,
// },
// },
// })
test.beforeEach(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,
USDS: 10_000,
},
},
})

// savingsPage = new SavingsPageObject(page)
// await savingsPage.clickDepositButtonAction('USDS')
savingsPage = new SavingsPageObject(testContext)
await savingsPage.clickDepositButtonAction('USDS')

// depositDialog = new SavingsDialogPageObject({ page, type: 'deposit' })
// await depositDialog.fillAmountAction(10_000)
// })
depositDialog = new SavingsDialogPageObject({ testContext, type: 'deposit' })
await depositDialog.fillAmountAction(10_000)
})

// test('has correct action plan', async () => {
// await depositDialog.actionsContainer.expectActions([
// { type: 'approve', asset: 'USDS' },
// { type: 'depositToSavings', asset: 'USDS', savingsAsset: 'sUSDS' },
// ])
// })
test('has correct action plan', async () => {
await depositDialog.actionsContainer.expectActions([
{ type: 'approve', asset: 'USDS' },
{ type: 'depositToSavings', asset: 'USDS', savingsAsset: 'sUSDS' },
])
})

// test('displays transaction overview', async () => {
// await depositDialog.expectNativeRouteTransactionOverview({
// apy: {
// value: '6.50%',
// description: 'Earn ~650.00 USDS/year',
// },
// routeItems: [
// {
// tokenAmount: '10,000.00 USDS',
// tokenUsdValue: '$10,000.00',
// },
// {
// tokenAmount: '9,911.77 sUSDS',
// tokenUsdValue: '$10,000.00',
// },
// ],
// outcome: '9,911.77 sUSDS',
// outcomeUsd: '$10,000.00',
// })
test('displays transaction overview', async () => {
await depositDialog.expectNativeRouteTransactionOverview({
apy: {
value: '8.50%',
description: 'Earn ~850.00 USDS/year',
},
routeItems: [
{
tokenAmount: '10,000.00 USDS',
tokenUsdValue: '$10,000.00',
},
{
tokenAmount: '9,872.98 sUSDS',
tokenUsdValue: '$10,000.00',
},
],
outcome: '9,872.98 sUSDS',
outcomeUsd: '$10,000.00',
})

// await depositDialog.expectUpgradeSwitchToBeHidden()
// })
await depositDialog.expectUpgradeSwitchToBeHidden()
})

// test('executes deposit', async () => {
// const actionsContainer = new ActionsPageObject(depositDialog.locatePanelByHeader('Actions'))
// await actionsContainer.acceptAllActionsAction(2, fork)
test('executes deposit', async () => {
await depositDialog.actionsContainer.acceptAllActionsAction(2)

// await depositDialog.expectSuccessPage()
// await depositDialog.clickBackToSavingsButton()
await depositDialog.expectSuccessPage()
await depositDialog.clickBackToSavingsButton()

// await savingsPage.expectSavingsUsdsBalance({ susdsBalance: '9,911.77 sUSDS', estimatedUsdsValue: '10,000' })
// await savingsPage.expectStablecoinsInWalletAssetBalance('USDS', '-')
// })
// })
await savingsPage.expectSavingsUsdsBalance({ susdsBalance: '9,872.98 sUSDS', estimatedUsdsValue: '10,000' })
await savingsPage.expectStablecoinsInWalletAssetBalance('USDS', '-')
})
})
Loading

0 comments on commit d51c8cf

Please sign in to comment.