diff --git a/packages/app/src/features/dialogs/repay/RepayDialog.test-e2e.ts b/packages/app/src/features/dialogs/repay/RepayDialog.test-e2e.ts index 84ccaec5e..a77a3c983 100644 --- a/packages/app/src/features/dialogs/repay/RepayDialog.test-e2e.ts +++ b/packages/app/src/features/dialogs/repay/RepayDialog.test-e2e.ts @@ -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 }) => { diff --git a/packages/app/src/features/dialogs/savings/withdraw/SavingsWithdrawDialog.test-e2e.ts b/packages/app/src/features/dialogs/savings/withdraw/SavingsWithdrawDialog.test-e2e.ts deleted file mode 100644 index fe04f75b2..000000000 --- a/packages/app/src/features/dialogs/savings/withdraw/SavingsWithdrawDialog.test-e2e.ts +++ /dev/null @@ -1,195 +0,0 @@ -// import { ActionsPageObject } from '@/features/actions/ActionsContainer.PageObject' -// import { SavingsPageObject } from '@/pages/Savings.PageObject' -// import { DEFAULT_BLOCK_NUMBER, GNOSIS_DEFAULT_BLOCK_NUMBER, DEFAULT_BLOCK_NUMBER } from '@/test/e2e/constants' -// import { setupFork } from '@/test/e2e/forking/setupFork' -// import { setup } from '@/test/e2e/setup' -// import { test } from '@playwright/test' -// import { base, gnosis, mainnet } from 'viem/chains' -// import { SavingsDialogPageObject } from '../common/e2e/SavingsDialog.PageObject' - -// test.describe('Savings withdraw dialog', () => { -// test.describe('Mainnet', () => { -// const fork = setupFork({ -// blockNumber: DEFAULT_BLOCK_NUMBER, -// chainId: mainnet.id, -// useTenderlyVnet: true, -// }) - -// test('can switch between tokens', async ({ page }) => { -// await setup(page, fork, { -// initialPage: 'savings', -// account: { -// type: 'connected-random', -// assetBalances: { -// ETH: 1, -// sDAI: 1000, -// }, -// }, -// }) - -// const savingsPage = new SavingsPageObject(page) - -// await savingsPage.clickWithdrawSDaiButtonAction() - -// const withdrawalDialog = new SavingsDialogPageObject({ page, type: 'withdraw' }) -// const actionsContainer = new ActionsPageObject(withdrawalDialog.locatePanelByHeader('Actions')) - -// await withdrawalDialog.fillAmountAction(1000) -// await actionsContainer.expectEnabledActionAtIndex(0) -// await actionsContainer.expectActions([ -// { type: 'withdrawFromSavings', asset: 'DAI', savingsAsset: 'sDAI', mode: 'withdraw' }, -// ]) - -// await withdrawalDialog.selectAssetAction('USDC') -// await withdrawalDialog.fillAmountAction(1000) -// await actionsContainer.expectEnabledActionAtIndex(0) -// await actionsContainer.expectActions([ -// { type: 'approve', asset: 'sDAI' }, -// { type: 'withdrawFromSavings', asset: 'USDC', savingsAsset: 'sDAI', mode: 'withdraw' }, -// ]) - -// await withdrawalDialog.selectAssetAction('DAI') -// await withdrawalDialog.fillAmountAction(1000) -// await actionsContainer.expectEnabledActionAtIndex(0) -// await actionsContainer.expectActions([ -// { type: 'withdrawFromSavings', asset: 'DAI', savingsAsset: 'sDAI', mode: 'withdraw' }, -// ]) -// }) -// }) - -// test.describe('Base', () => { -// const fork = setupFork({ chainId: base.id, blockNumber: 22143788n, useTenderlyVnet: true }) - -// test('can switch between tokens', async ({ page }) => { -// await setup(page, fork, { -// initialPage: 'savings', -// account: { -// type: 'connected-random', -// assetBalances: { -// ETH: 1, -// sUSDS: 1000, -// }, -// }, -// }) - -// const savingsPage = new SavingsPageObject(page) - -// await savingsPage.clickWithdrawSUsdsButtonAction() - -// const withdrawalDialog = new SavingsDialogPageObject({ page, type: 'withdraw' }) -// const actionsContainer = new ActionsPageObject(withdrawalDialog.locatePanelByHeader('Actions')) - -// await withdrawalDialog.fillAmountAction(1000) -// await actionsContainer.expectEnabledActionAtIndex(0) -// await actionsContainer.expectActions([ -// { type: 'approve', asset: 'sUSDS' }, -// { type: 'withdrawFromSavings', asset: 'USDS', savingsAsset: 'sUSDS', mode: 'withdraw' }, -// ]) - -// await withdrawalDialog.selectAssetAction('USDC') -// await withdrawalDialog.fillAmountAction(1000) -// await actionsContainer.expectEnabledActionAtIndex(0) -// await actionsContainer.expectActions([ -// { type: 'approve', asset: 'sUSDS' }, -// { type: 'withdrawFromSavings', asset: 'USDC', savingsAsset: 'sUSDS', mode: 'withdraw' }, -// ]) - -// await withdrawalDialog.selectAssetAction('USDS') -// await withdrawalDialog.fillAmountAction(1000) -// await actionsContainer.expectEnabledActionAtIndex(0) -// await actionsContainer.expectActions([ -// { type: 'approve', asset: 'sUSDS' }, -// { type: 'withdrawFromSavings', asset: 'USDS', savingsAsset: 'sUSDS', mode: 'withdraw' }, -// ]) -// }) -// }) -// }) - -// test.describe('Savings withdraw dialog send mode', () => { -// test.describe('Mainnet', () => { -// const fork = setupFork({ blockNumber: DEFAULT_BLOCK_NUMBER, chainId: mainnet.id, useTenderlyVnet: true }) -// let savingsPage: SavingsPageObject -// let sendDialog: SavingsDialogPageObject - -// test.beforeEach(async ({ page }) => { -// await setup(page, fork, { -// initialPage: 'savings', -// account: { -// type: 'connected-random', -// assetBalances: { -// ETH: 1, -// sDAI: 10_000, -// }, -// }, -// }) - -// savingsPage = new SavingsPageObject(page) -// await savingsPage.clickSendSDaiButtonAction() - -// sendDialog = new SavingsDialogPageObject({ page, type: 'send' }) -// }) - -// test('can select only supported assets', async () => { -// await sendDialog.openAssetSelectorAction() -// await sendDialog.expectAssetSelectorOptions(['DAI', 'USDC']) -// }) -// }) - -// test.describe('Gnosis', () => { -// const fork = setupFork({ blockNumber: GNOSIS_DEFAULT_BLOCK_NUMBER, chainId: gnosis.id, useTenderlyVnet: true }) -// let savingsPage: SavingsPageObject -// let sendDialog: SavingsDialogPageObject - -// test.beforeEach(async ({ page }) => { -// await setup(page, fork, { -// initialPage: 'savings', -// account: { -// type: 'connected-random', -// assetBalances: { -// XDAI: 100, -// sDAI: 10_000, -// }, -// }, -// }) - -// savingsPage = new SavingsPageObject(page) -// await savingsPage.clickSendSDaiButtonAction() - -// sendDialog = new SavingsDialogPageObject({ page, type: 'send' }) -// }) - -// test('can select only supported assets', async () => { -// await sendDialog.openAssetSelectorAction() -// await sendDialog.expectAssetSelectorOptions(['XDAI']) -// }) -// }) - -// test.describe('Base', () => { -// const fork = setupFork({ chainId: base.id, blockNumber: 22143788n, useTenderlyVnet: true }) -// let savingsPage: SavingsPageObject -// let sendDialog: SavingsDialogPageObject - -// test.beforeEach(async ({ page }) => { -// await setup(page, fork, { -// initialPage: 'savings', -// account: { -// type: 'connected-random', -// assetBalances: { -// USDS: 100, -// sUSDS: 10_000, -// }, -// }, -// }) - -// savingsPage = new SavingsPageObject(page) -// await savingsPage.clickSendSUsdsButtonAction() - -// sendDialog = new SavingsDialogPageObject({ page, type: 'send' }) -// }) - -// test('can select only supported assets', async () => { -// await sendDialog.openAssetSelectorAction() -// await sendDialog.expectAssetSelectorOptions(['USDC', 'USDS']) -// }) -// }) -// }) diff --git a/packages/app/src/features/dialogs/savings/withdraw/e2e/base/General.test-e2e.ts b/packages/app/src/features/dialogs/savings/withdraw/e2e/base/General.test-e2e.ts new file mode 100644 index 000000000..fb0c0587d --- /dev/null +++ b/packages/app/src/features/dialogs/savings/withdraw/e2e/base/General.test-e2e.ts @@ -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']) + }) +}) diff --git a/packages/app/src/features/dialogs/savings/withdraw/e2e/base/SendUSDC.test-e2e.ts b/packages/app/src/features/dialogs/savings/withdraw/e2e/base/SendUSDC.test-e2e.ts index d4f72a627..04d7220f9 100644 --- a/packages/app/src/features/dialogs/savings/withdraw/e2e/base/SendUSDC.test-e2e.ts +++ b/packages/app/src/features/dialogs/savings/withdraw/e2e/base/SendUSDC.test-e2e.ts @@ -1,92 +1,91 @@ -// import { SavingsPageObject } from '@/pages/Savings.PageObject' -// import { TOKENS_ON_FORK } from '@/test/e2e/constants' -// import { setupFork } from '@/test/e2e/forking/setupFork' -// import { setup } from '@/test/e2e/setup' -// import { randomAddress } from '@/test/utils/addressUtils' -// 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, TOKENS_ON_FORK } from '@/test/e2e/constants' +import { setup } from '@/test/e2e/setup' +import { randomAddress } from '@/test/utils/addressUtils' +import { test } from '@playwright/test' +import { base } from 'viem/chains' +import { SavingsDialogPageObject } from '../../../common/e2e/SavingsDialog.PageObject' -// test.describe('Send USDC', () => { -// const fork = setupFork({ chainId: base.id, blockNumber: 22143788n, useTenderlyVnet: true }) +test.describe('Send USDC', () => { + let savingsPage: SavingsPageObject + let sendDialog: SavingsDialogPageObject -// let savingsPage: SavingsPageObject -// let sendDialog: SavingsDialogPageObject + const receiver = randomAddress('bob') + const amount = 7000 + const usdc = TOKENS_ON_FORK[base.id].USDC -// const receiver = randomAddress('bob') -// const amount = 7000 -// const usdc = TOKENS_ON_FORK[base.id].USDC + 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, + sUSDS: 10_000, + }, + }, + }) -// test.beforeEach(async ({ page }) => { -// await setup(page, fork, { -// initialPage: 'savings', -// account: { -// type: 'connected-random', -// assetBalances: { -// ETH: 1, -// sUSDS: 10_000, -// }, -// }, -// }) + savingsPage = new SavingsPageObject(testContext) -// savingsPage = new SavingsPageObject(page) + await savingsPage.clickSendSUsdsButtonAction() + sendDialog = new SavingsDialogPageObject({ testContext, type: 'send' }) -// await savingsPage.clickSendSUsdsButtonAction() -// sendDialog = new SavingsDialogPageObject({ page, type: 'send' }) + await sendDialog.selectAssetAction('USDC') + await sendDialog.fillAmountAction(amount) + await sendDialog.fillReceiverAction(receiver) + }) -// await sendDialog.selectAssetAction('USDC') -// await sendDialog.fillAmountAction(amount) -// await sendDialog.fillReceiverAction(receiver) -// }) + test('has correct action plan', async () => { + await sendDialog.actionsContainer.expectActions([ + { type: 'approve', asset: 'sUSDS' }, + { type: 'withdrawFromSavings', asset: 'USDC', savingsAsset: 'sUSDS', mode: 'send' }, + ]) + }) -// test('has correct action plan', async () => { -// await sendDialog.actionsContainer.expectActions([ -// { type: 'approve', asset: 'sUSDS' }, -// { type: 'withdrawFromSavings', asset: 'USDC', savingsAsset: 'sUSDS', mode: 'send' }, -// ]) -// }) + test('displays transaction overview', async () => { + await sendDialog.expectNativeRouteTransactionOverview({ + routeItems: [ + { + tokenAmount: '6,911.09 sUSDS', + tokenUsdValue: '$7,000.00', + }, + { + tokenAmount: '7,000.00 USDS', + tokenUsdValue: '$7,000.00', + }, + { + tokenAmount: '7,000.00 USDC', + tokenUsdValue: '$7,000.00', + }, + ], + outcome: '7,000.00 USDC', + outcomeUsd: '$7,000.00', + }) + }) -// test('displays transaction overview', async () => { -// await sendDialog.expectNativeRouteTransactionOverview({ -// routeItems: [ -// { -// tokenAmount: '6,938.24 sUSDS', -// tokenUsdValue: '$7,000.00', -// }, -// { -// tokenAmount: '7,000.00 USDS', -// tokenUsdValue: '$7,000.00', -// }, -// { -// tokenAmount: '7,000.00 USDC', -// tokenUsdValue: '$7,000.00', -// }, -// ], -// outcome: '7,000.00 USDC', -// outcomeUsd: '$7,000.00', -// }) -// }) + test('executes send', async () => { + await sendDialog.expectReceiverTokenBalance({ + receiver, + token: usdc, + expectedBalance: 0, + }) -// test('executes send', async () => { -// await sendDialog.expectReceiverTokenBalance({ -// forkUrl: fork.forkUrl, -// receiver, -// token: usdc, -// expectedBalance: 0, -// }) + await sendDialog.actionsContainer.acceptAllActionsAction(2) + await sendDialog.expectSuccessPage() -// await sendDialog.actionsContainer.acceptAllActionsAction(2, fork) -// await sendDialog.expectSuccessPage() + await sendDialog.expectReceiverTokenBalance({ + receiver, + token: usdc, + expectedBalance: amount, + }) -// await sendDialog.expectReceiverTokenBalance({ -// forkUrl: fork.forkUrl, -// receiver, -// token: usdc, -// expectedBalance: amount, -// }) - -// await sendDialog.clickBackToSavingsButton() -// await savingsPage.expectSavingsUsdsBalance({ susdsBalance: '3,061.76 sUSDS', estimatedUsdsValue: '3,089' }) -// await savingsPage.expectStablecoinsInWalletAssetBalance('USDC', '-') -// }) -// }) + await sendDialog.clickBackToSavingsButton() + await savingsPage.expectSavingsUsdsBalance({ susdsBalance: '3,088.91 sUSDS', estimatedUsdsValue: '3,128.6548910' }) + await savingsPage.expectStablecoinsInWalletAssetBalance('USDC', '-') + }) +}) diff --git a/packages/app/src/features/dialogs/savings/withdraw/e2e/base/SendUSDS.test-e2e.ts b/packages/app/src/features/dialogs/savings/withdraw/e2e/base/SendUSDS.test-e2e.ts index f19ec24bf..95ab0d43c 100644 --- a/packages/app/src/features/dialogs/savings/withdraw/e2e/base/SendUSDS.test-e2e.ts +++ b/packages/app/src/features/dialogs/savings/withdraw/e2e/base/SendUSDS.test-e2e.ts @@ -1,84 +1,84 @@ -// import { SavingsPageObject } from '@/pages/Savings.PageObject' -// import { TOKENS_ON_FORK } from '@/test/e2e/constants' -// import { setupFork } from '@/test/e2e/forking/setupFork' -// import { setup } from '@/test/e2e/setup' -// import { randomAddress } from '@/test/utils/addressUtils' -// 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, TOKENS_ON_FORK } from '@/test/e2e/constants' +import { setup } from '@/test/e2e/setup' +import { randomAddress } from '@/test/utils/addressUtils' +import { test } from '@playwright/test' +import { base } from 'viem/chains' +import { SavingsDialogPageObject } from '../../../common/e2e/SavingsDialog.PageObject' -// test.describe('Send USDS', () => { -// const fork = setupFork({ chainId: base.id, blockNumber: 22143788n, useTenderlyVnet: true }) -// let savingsPage: SavingsPageObject -// let sendDialog: SavingsDialogPageObject -// const receiver = randomAddress('bob') -// const amount = 7000 -// const usds = TOKENS_ON_FORK[base.id].USDS +test.describe('Send USDS', () => { + let savingsPage: SavingsPageObject + let sendDialog: SavingsDialogPageObject + const receiver = randomAddress('bob') + const amount = 7000 + const usds = TOKENS_ON_FORK[base.id].USDS -// test.beforeEach(async ({ page }) => { -// await setup(page, fork, { -// initialPage: 'savings', -// account: { -// type: 'connected-random', -// assetBalances: { -// ETH: 1, -// sUSDS: 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, + sUSDS: 10_000, + }, + }, + }) -// savingsPage = new SavingsPageObject(page) + savingsPage = new SavingsPageObject(testContext) -// await savingsPage.clickSendSUsdsButtonAction() -// sendDialog = new SavingsDialogPageObject({ page, type: 'send' }) -// await sendDialog.fillAmountAction(amount) -// await sendDialog.fillReceiverAction(receiver) -// }) + await savingsPage.clickSendSUsdsButtonAction() + sendDialog = new SavingsDialogPageObject({ testContext, type: 'send' }) + await sendDialog.fillAmountAction(amount) + await sendDialog.fillReceiverAction(receiver) + }) -// test('has correct action plan', async () => { -// await sendDialog.actionsContainer.expectActions([ -// { type: 'approve', asset: 'sUSDS' }, -// { type: 'withdrawFromSavings', asset: 'USDS', savingsAsset: 'sUSDS', mode: 'send' }, -// ]) -// }) + test('has correct action plan', async () => { + await sendDialog.actionsContainer.expectActions([ + { type: 'approve', asset: 'sUSDS' }, + { type: 'withdrawFromSavings', asset: 'USDS', savingsAsset: 'sUSDS', mode: 'send' }, + ]) + }) -// test('displays transaction overview', async () => { -// await sendDialog.expectNativeRouteTransactionOverview({ -// routeItems: [ -// { -// tokenAmount: '6,938.24 sUSDS', -// tokenUsdValue: '$7,000.00', -// }, -// { -// tokenAmount: '7,000.00 USDS', -// tokenUsdValue: '$7,000.00', -// }, -// ], -// outcome: '7,000.00 USDS', -// outcomeUsd: '$7,000.00', -// }) -// }) + test('displays transaction overview', async () => { + await sendDialog.expectNativeRouteTransactionOverview({ + routeItems: [ + { + tokenAmount: '6,911.09 sUSDS', + tokenUsdValue: '$7,000.00', + }, + { + tokenAmount: '7,000.00 USDS', + tokenUsdValue: '$7,000.00', + }, + ], + outcome: '7,000.00 USDS', + outcomeUsd: '$7,000.00', + }) + }) -// test('executes send', async () => { -// await sendDialog.expectReceiverTokenBalance({ -// forkUrl: fork.forkUrl, -// receiver, -// token: usds, -// expectedBalance: 0, -// }) + test('executes send', async () => { + await sendDialog.expectReceiverTokenBalance({ + receiver, + token: usds, + expectedBalance: 0, + }) -// await sendDialog.actionsContainer.acceptAllActionsAction(2, fork) -// await sendDialog.expectSuccessPage() + await sendDialog.actionsContainer.acceptAllActionsAction(2) + await sendDialog.expectSuccessPage() -// await sendDialog.expectReceiverTokenBalance({ -// forkUrl: fork.forkUrl, -// receiver, -// token: usds, -// expectedBalance: amount, -// }) + await sendDialog.expectReceiverTokenBalance({ + receiver, + token: usds, + expectedBalance: amount, + }) -// await sendDialog.clickBackToSavingsButton() -// await savingsPage.expectSavingsUsdsBalance({ susdsBalance: '3,061.76 sUSDS', estimatedUsdsValue: '3,089' }) -// await savingsPage.expectStablecoinsInWalletAssetBalance('USDS', '-') -// }) -// }) + await sendDialog.clickBackToSavingsButton() + await savingsPage.expectSavingsUsdsBalance({ susdsBalance: '3,088.91 sUSDS', estimatedUsdsValue: '3,128.6548917' }) + await savingsPage.expectStablecoinsInWalletAssetBalance('USDS', '-') + }) +}) diff --git a/packages/app/src/features/dialogs/savings/withdraw/e2e/base/WithdrawMaxUSDC.test-e2e.ts b/packages/app/src/features/dialogs/savings/withdraw/e2e/base/WithdrawMaxUSDC.test-e2e.ts index 2f3a16501..fc32b9368 100644 --- a/packages/app/src/features/dialogs/savings/withdraw/e2e/base/WithdrawMaxUSDC.test-e2e.ts +++ b/packages/app/src/features/dialogs/savings/withdraw/e2e/base/WithdrawMaxUSDC.test-e2e.ts @@ -1,70 +1,71 @@ -// 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('Withdraw Max USDC', () => { -// const fork = setupFork({ chainId: base.id, blockNumber: 22143788n, useTenderlyVnet: true }) -// let savingsPage: SavingsPageObject -// let withdrawDialog: SavingsDialogPageObject +test.describe('Withdraw Max USDC', () => { + let savingsPage: SavingsPageObject + let withdrawDialog: SavingsDialogPageObject -// test.beforeEach(async ({ page }) => { -// await setup(page, fork, { -// initialPage: 'savings', -// account: { -// type: 'connected-random', -// assetBalances: { -// ETH: 1, -// sUSDS: 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, + sUSDS: 10_000, + }, + }, + }) -// savingsPage = new SavingsPageObject(page) + savingsPage = new SavingsPageObject(testContext) -// await savingsPage.clickWithdrawSUsdsButtonAction() -// withdrawDialog = new SavingsDialogPageObject({ page, type: 'withdraw' }) -// await withdrawDialog.selectAssetAction('USDC') -// await withdrawDialog.clickMaxAmountAction() -// }) + await savingsPage.clickWithdrawSUsdsButtonAction() + withdrawDialog = new SavingsDialogPageObject({ testContext, type: 'withdraw' }) + await withdrawDialog.selectAssetAction('USDC') + await withdrawDialog.clickMaxAmountAction() + }) -// test('has correct action plan', async () => { -// await withdrawDialog.actionsContainer.expectActions([ -// { type: 'approve', asset: 'sUSDS' }, -// { type: 'withdrawFromSavings', asset: 'USDC', savingsAsset: 'sUSDS', mode: 'withdraw' }, -// ]) -// }) + test('has correct action plan', async () => { + await withdrawDialog.actionsContainer.expectActions([ + { type: 'approve', asset: 'sUSDS' }, + { type: 'withdrawFromSavings', asset: 'USDC', savingsAsset: 'sUSDS', mode: 'withdraw' }, + ]) + }) -// test('displays transaction overview', async () => { -// await withdrawDialog.expectNativeRouteTransactionOverview({ -// routeItems: [ -// { -// tokenAmount: '10,000.00 sUSDS', -// tokenUsdValue: '$10,089.01', -// }, -// { -// tokenAmount: '10,089.01 USDS', -// tokenUsdValue: '$10,089.01', -// }, -// ], -// outcome: '10,089.01 USDC', -// outcomeUsd: '$10,089.01', -// }) + test('displays transaction overview', async () => { + await withdrawDialog.expectNativeRouteTransactionOverview({ + routeItems: [ + { + tokenAmount: '10,000.00 sUSDS', + tokenUsdValue: '$10,128.65', + }, + { + tokenAmount: '10,128.65 USDS', + tokenUsdValue: '$10,128.65', + }, + ], + outcome: '10,128.65 USDC', + outcomeUsd: '$10,128.65', + }) -// await withdrawDialog.expectUpgradeSwitchToBeHidden() -// }) + await withdrawDialog.expectUpgradeSwitchToBeHidden() + }) -// test('executes withdraw', async () => { -// const actionsContainer = new ActionsPageObject(withdrawDialog.locatePanelByHeader('Actions')) -// await actionsContainer.acceptAllActionsAction(2, fork) + test('executes withdraw', async () => { + await withdrawDialog.actionsContainer.acceptAllActionsAction(2) -// await withdrawDialog.expectSuccessPage() -// await withdrawDialog.clickBackToSavingsButton() + await withdrawDialog.expectSuccessPage() + await withdrawDialog.clickBackToSavingsButton() -// await savingsPage.expectOpportunityStablecoinsAmount('~$10,089.01') -// await savingsPage.expectStablecoinsInWalletAssetBalance('USDC', '10,089.01') -// }) -// }) + await savingsPage.expectOpportunityStablecoinsAmount('~$10,128.65') + await savingsPage.expectStablecoinsInWalletAssetBalance('USDC', '10,128.65') + }) +}) diff --git a/packages/app/src/features/dialogs/savings/withdraw/e2e/base/WithdrawMaxUSDS.test-e2e.ts b/packages/app/src/features/dialogs/savings/withdraw/e2e/base/WithdrawMaxUSDS.test-e2e.ts index 9128574f7..09d6075db 100644 --- a/packages/app/src/features/dialogs/savings/withdraw/e2e/base/WithdrawMaxUSDS.test-e2e.ts +++ b/packages/app/src/features/dialogs/savings/withdraw/e2e/base/WithdrawMaxUSDS.test-e2e.ts @@ -1,69 +1,70 @@ -// 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('Withdraw Max USDS', () => { -// const fork = setupFork({ chainId: base.id, blockNumber: 22143788n, useTenderlyVnet: true }) -// let savingsPage: SavingsPageObject -// let withdrawDialog: SavingsDialogPageObject +test.describe('Withdraw Max USDS', () => { + let savingsPage: SavingsPageObject + let withdrawDialog: SavingsDialogPageObject -// test.beforeEach(async ({ page }) => { -// await setup(page, fork, { -// initialPage: 'savings', -// account: { -// type: 'connected-random', -// assetBalances: { -// ETH: 1, -// sUSDS: 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, + sUSDS: 10_000, + }, + }, + }) -// savingsPage = new SavingsPageObject(page) + savingsPage = new SavingsPageObject(testContext) -// await savingsPage.clickWithdrawSUsdsButtonAction() -// withdrawDialog = new SavingsDialogPageObject({ page, type: 'withdraw' }) -// await withdrawDialog.clickMaxAmountAction() -// }) + await savingsPage.clickWithdrawSUsdsButtonAction() + withdrawDialog = new SavingsDialogPageObject({ testContext, type: 'withdraw' }) + await withdrawDialog.clickMaxAmountAction() + }) -// test('has correct action plan', async () => { -// await withdrawDialog.actionsContainer.expectActions([ -// { type: 'approve', asset: 'sUSDS' }, -// { type: 'withdrawFromSavings', asset: 'USDS', savingsAsset: 'sUSDS', mode: 'withdraw' }, -// ]) -// }) + test('has correct action plan', async () => { + await withdrawDialog.actionsContainer.expectActions([ + { type: 'approve', asset: 'sUSDS' }, + { type: 'withdrawFromSavings', asset: 'USDS', savingsAsset: 'sUSDS', mode: 'withdraw' }, + ]) + }) -// test('displays transaction overview', async () => { -// await withdrawDialog.expectNativeRouteTransactionOverview({ -// routeItems: [ -// { -// tokenAmount: '10,000.00 sUSDS', -// tokenUsdValue: '$10,089.01', -// }, -// { -// tokenAmount: '10,089.01 USDS', -// tokenUsdValue: '$10,089.01', -// }, -// ], -// outcome: '10,089.01 USDS', -// outcomeUsd: '$10,089.01', -// }) + test('displays transaction overview', async () => { + await withdrawDialog.expectNativeRouteTransactionOverview({ + routeItems: [ + { + tokenAmount: '10,000.00 sUSDS', + tokenUsdValue: '$10,128.65', + }, + { + tokenAmount: '10,128.65 USDS', + tokenUsdValue: '$10,128.65', + }, + ], + outcome: '10,128.65 USDS', + outcomeUsd: '$10,128.65', + }) -// await withdrawDialog.expectUpgradeSwitchToBeHidden() -// }) + await withdrawDialog.expectUpgradeSwitchToBeHidden() + }) -// test('executes withdraw', async () => { -// const actionsContainer = new ActionsPageObject(withdrawDialog.locatePanelByHeader('Actions')) -// await actionsContainer.acceptAllActionsAction(2, fork) + test('executes withdraw', async () => { + await withdrawDialog.actionsContainer.acceptAllActionsAction(2) -// await withdrawDialog.expectSuccessPage() -// await withdrawDialog.clickBackToSavingsButton() + await withdrawDialog.expectSuccessPage() + await withdrawDialog.clickBackToSavingsButton() -// await savingsPage.expectOpportunityStablecoinsAmount('~$10,089.01') -// await savingsPage.expectStablecoinsInWalletAssetBalance('USDS', '10,089.01') -// }) -// }) + await savingsPage.expectOpportunityStablecoinsAmount('~$10,128.65') + await savingsPage.expectStablecoinsInWalletAssetBalance('USDS', '10,128.65') + }) +}) diff --git a/packages/app/src/features/dialogs/savings/withdraw/e2e/base/WithdrawUSDC.test-e2e.ts b/packages/app/src/features/dialogs/savings/withdraw/e2e/base/WithdrawUSDC.test-e2e.ts index 702a0eb28..43c2ae911 100644 --- a/packages/app/src/features/dialogs/savings/withdraw/e2e/base/WithdrawUSDC.test-e2e.ts +++ b/packages/app/src/features/dialogs/savings/withdraw/e2e/base/WithdrawUSDC.test-e2e.ts @@ -1,74 +1,75 @@ -// 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('Withdraw USDC', () => { -// const fork = setupFork({ chainId: base.id, blockNumber: 22143788n, useTenderlyVnet: true }) -// let savingsPage: SavingsPageObject -// let withdrawDialog: SavingsDialogPageObject +test.describe('Withdraw USDC', () => { + let savingsPage: SavingsPageObject + let withdrawDialog: SavingsDialogPageObject -// test.beforeEach(async ({ page }) => { -// await setup(page, fork, { -// initialPage: 'savings', -// account: { -// type: 'connected-random', -// assetBalances: { -// ETH: 1, -// sUSDS: 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, + sUSDS: 10_000, + }, + }, + }) -// savingsPage = new SavingsPageObject(page) + savingsPage = new SavingsPageObject(testContext) -// await savingsPage.clickWithdrawSUsdsButtonAction() -// withdrawDialog = new SavingsDialogPageObject({ page, type: 'withdraw' }) -// await withdrawDialog.selectAssetAction('USDC') -// await withdrawDialog.fillAmountAction(1000) -// }) + await savingsPage.clickWithdrawSUsdsButtonAction() + withdrawDialog = new SavingsDialogPageObject({ testContext, type: 'withdraw' }) + await withdrawDialog.selectAssetAction('USDC') + await withdrawDialog.fillAmountAction(1000) + }) -// test('has correct action plan', async () => { -// await withdrawDialog.actionsContainer.expectActions([ -// { type: 'approve', asset: 'sUSDS' }, -// { type: 'withdrawFromSavings', asset: 'USDC', savingsAsset: 'sUSDS', mode: 'withdraw' }, -// ]) -// }) + test('has correct action plan', async () => { + await withdrawDialog.actionsContainer.expectActions([ + { type: 'approve', asset: 'sUSDS' }, + { type: 'withdrawFromSavings', asset: 'USDC', savingsAsset: 'sUSDS', mode: 'withdraw' }, + ]) + }) -// test('displays transaction overview', async () => { -// await withdrawDialog.expectNativeRouteTransactionOverview({ -// routeItems: [ -// { -// tokenAmount: '991.18 sUSDS', -// tokenUsdValue: '$1,000.00', -// }, -// { -// tokenAmount: '1,000.00 USDS', -// tokenUsdValue: '$1,000.00', -// }, -// { -// tokenAmount: '1,000.00 USDC', -// tokenUsdValue: '$1,000.00', -// }, -// ], -// outcome: '1,000.00 USDC', -// outcomeUsd: '$1,000.00', -// }) + test('displays transaction overview', async () => { + await withdrawDialog.expectNativeRouteTransactionOverview({ + routeItems: [ + { + tokenAmount: '987.30 sUSDS', + tokenUsdValue: '$1,000.00', + }, + { + tokenAmount: '1,000.00 USDS', + tokenUsdValue: '$1,000.00', + }, + { + tokenAmount: '1,000.00 USDC', + tokenUsdValue: '$1,000.00', + }, + ], + outcome: '1,000.00 USDC', + outcomeUsd: '$1,000.00', + }) -// await withdrawDialog.expectUpgradeSwitchToBeHidden() -// }) + await withdrawDialog.expectUpgradeSwitchToBeHidden() + }) -// test('executes withdraw', async () => { -// const actionsContainer = new ActionsPageObject(withdrawDialog.locatePanelByHeader('Actions')) -// await actionsContainer.acceptAllActionsAction(2, fork) + test('executes withdraw', async () => { + await withdrawDialog.actionsContainer.acceptAllActionsAction(2) -// await withdrawDialog.expectSuccessPage() -// await withdrawDialog.clickBackToSavingsButton() + await withdrawDialog.expectSuccessPage() + await withdrawDialog.clickBackToSavingsButton() -// await savingsPage.expectSavingsUsdsBalance({ susdsBalance: '9,008.82 sUSDS', estimatedUsdsValue: '9,089' }) -// await savingsPage.expectStablecoinsInWalletAssetBalance('USDC', '1,000') -// }) -// }) + await savingsPage.expectSavingsUsdsBalance({ susdsBalance: '9,012.70 sUSDS', estimatedUsdsValue: '9,128.654891' }) + await savingsPage.expectStablecoinsInWalletAssetBalance('USDC', '1,000') + }) +}) diff --git a/packages/app/src/features/dialogs/savings/withdraw/e2e/base/WithdrawUSDS.test-e2e.ts b/packages/app/src/features/dialogs/savings/withdraw/e2e/base/WithdrawUSDS.test-e2e.ts index 06c3348a3..7e8c47ab1 100644 --- a/packages/app/src/features/dialogs/savings/withdraw/e2e/base/WithdrawUSDS.test-e2e.ts +++ b/packages/app/src/features/dialogs/savings/withdraw/e2e/base/WithdrawUSDS.test-e2e.ts @@ -1,69 +1,70 @@ -// 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('Withdraw USDS', () => { -// const fork = setupFork({ chainId: base.id, blockNumber: 22143788n, useTenderlyVnet: true }) -// let savingsPage: SavingsPageObject -// let withdrawDialog: SavingsDialogPageObject +test.describe('Withdraw USDS', () => { + let savingsPage: SavingsPageObject + let withdrawDialog: SavingsDialogPageObject -// test.beforeEach(async ({ page }) => { -// await setup(page, fork, { -// initialPage: 'savings', -// account: { -// type: 'connected-random', -// assetBalances: { -// ETH: 1, -// sUSDS: 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, + sUSDS: 10_000, + }, + }, + }) -// savingsPage = new SavingsPageObject(page) + savingsPage = new SavingsPageObject(testContext) -// await savingsPage.clickWithdrawSUsdsButtonAction() -// withdrawDialog = new SavingsDialogPageObject({ page, type: 'withdraw' }) -// await withdrawDialog.fillAmountAction(1000) -// }) + await savingsPage.clickWithdrawSUsdsButtonAction() + withdrawDialog = new SavingsDialogPageObject({ testContext, type: 'withdraw' }) + await withdrawDialog.fillAmountAction(1000) + }) -// test('has correct action plan', async () => { -// await withdrawDialog.actionsContainer.expectActions([ -// { type: 'approve', asset: 'sUSDS' }, -// { type: 'withdrawFromSavings', asset: 'USDS', savingsAsset: 'sUSDS', mode: 'withdraw' }, -// ]) -// }) + test('has correct action plan', async () => { + await withdrawDialog.actionsContainer.expectActions([ + { type: 'approve', asset: 'sUSDS' }, + { type: 'withdrawFromSavings', asset: 'USDS', savingsAsset: 'sUSDS', mode: 'withdraw' }, + ]) + }) -// test('displays transaction overview', async () => { -// await withdrawDialog.expectNativeRouteTransactionOverview({ -// routeItems: [ -// { -// tokenAmount: '991.18 sUSDS', -// tokenUsdValue: '$1,000.00', -// }, -// { -// tokenAmount: '1,000.00 USDS', -// tokenUsdValue: '$1,000.00', -// }, -// ], -// outcome: '1,000.00 USDS', -// outcomeUsd: '$1,000.00', -// }) + test('displays transaction overview', async () => { + await withdrawDialog.expectNativeRouteTransactionOverview({ + routeItems: [ + { + tokenAmount: '987.30 sUSDS', + tokenUsdValue: '$1,000.00', + }, + { + tokenAmount: '1,000.00 USDS', + tokenUsdValue: '$1,000.00', + }, + ], + outcome: '1,000.00 USDS', + outcomeUsd: '$1,000.00', + }) -// await withdrawDialog.expectUpgradeSwitchToBeHidden() -// }) + await withdrawDialog.expectUpgradeSwitchToBeHidden() + }) -// test('executes withdraw', async () => { -// const actionsContainer = new ActionsPageObject(withdrawDialog.locatePanelByHeader('Actions')) -// await actionsContainer.acceptAllActionsAction(2, fork) + test('executes withdraw', async () => { + await withdrawDialog.actionsContainer.acceptAllActionsAction(2) -// await withdrawDialog.expectSuccessPage() -// await withdrawDialog.clickBackToSavingsButton() + await withdrawDialog.expectSuccessPage() + await withdrawDialog.clickBackToSavingsButton() -// await savingsPage.expectSavingsUsdsBalance({ susdsBalance: '9,008.82 sUSDS', estimatedUsdsValue: '9,089' }) -// await savingsPage.expectStablecoinsInWalletAssetBalance('USDS', '1,000') -// }) -// }) + await savingsPage.expectSavingsUsdsBalance({ susdsBalance: '9,012.70 sUSDS', estimatedUsdsValue: '9,128.654892' }) + await savingsPage.expectStablecoinsInWalletAssetBalance('USDS', '1,000') + }) +}) diff --git a/packages/app/src/features/dialogs/savings/withdraw/e2e/gnosis/General.test-e2e.ts b/packages/app/src/features/dialogs/savings/withdraw/e2e/gnosis/General.test-e2e.ts new file mode 100644 index 000000000..97c9249e0 --- /dev/null +++ b/packages/app/src/features/dialogs/savings/withdraw/e2e/gnosis/General.test-e2e.ts @@ -0,0 +1,33 @@ +import { SavingsPageObject } from '@/pages/Savings.PageObject' +import { GNOSIS_DEFAULT_BLOCK_NUMBER } from '@/test/e2e/constants' +import { setup } from '@/test/e2e/setup' +import { test } from '@playwright/test' +import { gnosis } from 'viem/chains' +import { SavingsDialogPageObject } from '../../../common/e2e/SavingsDialog.PageObject' + +test.describe('With send mode', () => { + test('can select only supported assets', async ({ page }) => { + const testContext = await setup(page, { + blockchain: { + chainId: gnosis.id, + blockNumber: GNOSIS_DEFAULT_BLOCK_NUMBER, + }, + initialPage: 'savings', + account: { + type: 'connected-random', + assetBalances: { + XDAI: 100, + sDAI: 10_000, + }, + }, + }) + + const savingsPage = new SavingsPageObject(testContext) + await savingsPage.clickSendSDaiButtonAction() + + const sendDialog = new SavingsDialogPageObject({ testContext, type: 'send' }) + + await sendDialog.openAssetSelectorAction() + await sendDialog.expectAssetSelectorOptions(['XDAI']) + }) +}) diff --git a/packages/app/src/features/dialogs/savings/withdraw/e2e/gnosis/SendXDAI.test-e2e.ts b/packages/app/src/features/dialogs/savings/withdraw/e2e/gnosis/SendXDAI.test-e2e.ts index a9bbb8987..4a353bb42 100644 --- a/packages/app/src/features/dialogs/savings/withdraw/e2e/gnosis/SendXDAI.test-e2e.ts +++ b/packages/app/src/features/dialogs/savings/withdraw/e2e/gnosis/SendXDAI.test-e2e.ts @@ -1,81 +1,81 @@ -// import { SavingsPageObject } from '@/pages/Savings.PageObject' -// import { GNOSIS_DEFAULT_BLOCK_NUMBER } from '@/test/e2e/constants' -// import { setupFork } from '@/test/e2e/forking/setupFork' -// import { setup } from '@/test/e2e/setup' -// import { randomAddress } from '@/test/utils/addressUtils' -// import { test } from '@playwright/test' -// import { gnosis } from 'viem/chains' -// import { SavingsDialogPageObject } from '../../../common/e2e/SavingsDialog.PageObject' +import { SavingsPageObject } from '@/pages/Savings.PageObject' +import { GNOSIS_DEFAULT_BLOCK_NUMBER } from '@/test/e2e/constants' +import { setup } from '@/test/e2e/setup' +import { randomAddress } from '@/test/utils/addressUtils' +import { test } from '@playwright/test' +import { gnosis } from 'viem/chains' +import { SavingsDialogPageObject } from '../../../common/e2e/SavingsDialog.PageObject' -// test.describe('Send XDAI on Gnosis', () => { -// const fork = setupFork({ blockNumber: GNOSIS_DEFAULT_BLOCK_NUMBER, chainId: gnosis.id, useTenderlyVnet: true }) -// let savingsPage: SavingsPageObject -// let sendDialog: SavingsDialogPageObject -// const receiver = randomAddress('bob') -// const amount = 7000 +test.describe('Send XDAI on Gnosis', () => { + let savingsPage: SavingsPageObject + let sendDialog: SavingsDialogPageObject + const receiver = randomAddress('bob') + const amount = 7000 -// test.beforeEach(async ({ page }) => { -// await setup(page, fork, { -// initialPage: 'savings', -// account: { -// type: 'connected-random', -// assetBalances: { -// XDAI: 100, -// sDAI: 10_000, -// }, -// }, -// }) + test.beforeEach(async ({ page }) => { + const testContext = await setup(page, { + blockchain: { + chainId: gnosis.id, + blockNumber: GNOSIS_DEFAULT_BLOCK_NUMBER, + }, + initialPage: 'savings', + account: { + type: 'connected-random', + assetBalances: { + XDAI: 100, + sDAI: 10_000, + }, + }, + }) -// savingsPage = new SavingsPageObject(page) -// await savingsPage.clickSendSDaiButtonAction() + savingsPage = new SavingsPageObject(testContext) + await savingsPage.clickSendSDaiButtonAction() -// sendDialog = new SavingsDialogPageObject({ page, type: 'send' }) -// await sendDialog.fillAmountAction(amount) -// await sendDialog.fillReceiverAction(receiver) -// }) + sendDialog = new SavingsDialogPageObject({ testContext, type: 'send' }) + await sendDialog.fillAmountAction(amount) + await sendDialog.fillReceiverAction(receiver) + }) -// test('uses native sDai withdraw and send', async () => { -// await sendDialog.actionsContainer.expectActions([ -// { type: 'approve', asset: 'sDAI' }, -// { type: 'withdrawFromSavings', asset: 'XDAI', savingsAsset: 'sDAI', mode: 'send' }, -// ]) -// }) + test('uses native sDai withdraw and send', async () => { + await sendDialog.actionsContainer.expectActions([ + { type: 'approve', asset: 'sDAI' }, + { type: 'withdrawFromSavings', asset: 'XDAI', savingsAsset: 'sDAI', mode: 'send' }, + ]) + }) -// test('displays transaction overview', async () => { -// await sendDialog.expectNativeRouteTransactionOverview({ -// routeItems: [ -// { -// tokenAmount: '6,434.95 sDAI', -// tokenUsdValue: '$7,000.00', -// }, -// { -// tokenAmount: '7,000.00 XDAI', -// tokenUsdValue: '$7,000.00', -// }, -// ], -// outcome: '7,000.00 XDAI', -// outcomeUsd: '$7,000.00', -// }) -// }) + test('displays transaction overview', async () => { + await sendDialog.expectNativeRouteTransactionOverview({ + routeItems: [ + { + tokenAmount: '6,434.95 sDAI', + tokenUsdValue: '$7,000.00', + }, + { + tokenAmount: '7,000.00 XDAI', + tokenUsdValue: '$7,000.00', + }, + ], + outcome: '7,000.00 XDAI', + outcomeUsd: '$7,000.00', + }) + }) -// test('executes send', async () => { -// await sendDialog.expectReceiverBalance({ -// forkUrl: fork.forkUrl, -// receiver, -// expectedBalance: 0, -// }) + test('executes send', async () => { + await sendDialog.expectReceiverBalance({ + receiver, + expectedBalance: 0, + }) -// await sendDialog.actionsContainer.acceptAllActionsAction(2, fork) -// await sendDialog.expectSuccessPage() + await sendDialog.actionsContainer.acceptAllActionsAction(2) + await sendDialog.expectSuccessPage() -// await sendDialog.expectReceiverBalance({ -// forkUrl: fork.forkUrl, -// receiver, -// expectedBalance: amount, -// }) + await sendDialog.expectReceiverBalance({ + receiver, + expectedBalance: amount, + }) -// await sendDialog.clickBackToSavingsButton() -// await savingsPage.expectSavingsDaiBalance({ sdaiBalance: '3,565.05 sDAI', estimatedDaiValue: '3,878.094168' }) -// await savingsPage.expectStablecoinsInWalletAssetBalance('XDAI', '100') -// }) -// }) + await sendDialog.clickBackToSavingsButton() + await savingsPage.expectSavingsDaiBalance({ sdaiBalance: '3,565.05 sDAI', estimatedDaiValue: '3,878.094168' }) + await savingsPage.expectStablecoinsInWalletAssetBalance('XDAI', '100') + }) +}) diff --git a/packages/app/src/features/dialogs/savings/withdraw/e2e/gnosis/WithdrawMaxXDAI.test-e2e.ts b/packages/app/src/features/dialogs/savings/withdraw/e2e/gnosis/WithdrawMaxXDAI.test-e2e.ts index 77f590f44..4a1988ffe 100644 --- a/packages/app/src/features/dialogs/savings/withdraw/e2e/gnosis/WithdrawMaxXDAI.test-e2e.ts +++ b/packages/app/src/features/dialogs/savings/withdraw/e2e/gnosis/WithdrawMaxXDAI.test-e2e.ts @@ -1,72 +1,68 @@ -// import { ActionsPageObject } from '@/features/actions/ActionsContainer.PageObject' -// import { SavingsPageObject } from '@/pages/Savings.PageObject' -// import { GNOSIS_DEFAULT_BLOCK_NUMBER } from '@/test/e2e/constants' -// import { setupFork } from '@/test/e2e/forking/setupFork' -// import { setup } from '@/test/e2e/setup' -// import { test } from '@playwright/test' -// import { gnosis } from 'viem/chains' -// import { SavingsDialogPageObject } from '../../../common/e2e/SavingsDialog.PageObject' +import { SavingsPageObject } from '@/pages/Savings.PageObject' +import { GNOSIS_DEFAULT_BLOCK_NUMBER } from '@/test/e2e/constants' +import { setup } from '@/test/e2e/setup' +import { test } from '@playwright/test' +import { gnosis } from 'viem/chains' +import { SavingsDialogPageObject } from '../../../common/e2e/SavingsDialog.PageObject' -// test.describe('Withdraw max XDAI on Gnosis', () => { -// const fork = setupFork({ -// blockNumber: GNOSIS_DEFAULT_BLOCK_NUMBER, -// chainId: gnosis.id, -// useTenderlyVnet: true, -// }) -// let savingsPage: SavingsPageObject -// let withdrawalDialog: SavingsDialogPageObject +test.describe('Withdraw max XDAI on Gnosis', () => { + let savingsPage: SavingsPageObject + let withdrawalDialog: SavingsDialogPageObject -// test.beforeEach(async ({ page }) => { -// await setup(page, fork, { -// initialPage: 'savings', -// account: { -// type: 'connected-random', -// assetBalances: { -// XDAI: 100, -// sDAI: 10_000, -// }, -// }, -// }) + test.beforeEach(async ({ page }) => { + const testContext = await setup(page, { + blockchain: { + chainId: gnosis.id, + blockNumber: GNOSIS_DEFAULT_BLOCK_NUMBER, + }, + initialPage: 'savings', + account: { + type: 'connected-random', + assetBalances: { + XDAI: 100, + sDAI: 10_000, + }, + }, + }) -// savingsPage = new SavingsPageObject(page) -// await savingsPage.clickWithdrawSDaiButtonAction() + savingsPage = new SavingsPageObject(testContext) + await savingsPage.clickWithdrawSDaiButtonAction() -// withdrawalDialog = new SavingsDialogPageObject({ page, type: 'withdraw' }) -// await withdrawalDialog.clickMaxAmountAction() -// }) + withdrawalDialog = new SavingsDialogPageObject({ testContext, type: 'withdraw' }) + await withdrawalDialog.clickMaxAmountAction() + }) -// test('uses native sDai withdrawal', async () => { -// await withdrawalDialog.actionsContainer.expectActions([ -// { type: 'approve', asset: 'sDAI' }, -// { type: 'withdrawFromSavings', asset: 'XDAI', savingsAsset: 'sDAI', mode: 'withdraw' }, -// ]) -// }) + test('uses native sDai withdrawal', async () => { + await withdrawalDialog.actionsContainer.expectActions([ + { type: 'approve', asset: 'sDAI' }, + { type: 'withdrawFromSavings', asset: 'XDAI', savingsAsset: 'sDAI', mode: 'withdraw' }, + ]) + }) -// test('displays transaction overview', async () => { -// await withdrawalDialog.expectNativeRouteTransactionOverview({ -// routeItems: [ -// { -// tokenAmount: '10,000.00 sDAI', -// tokenUsdValue: '$10,878.09', -// }, -// { -// tokenAmount: '10,878.09 XDAI', -// tokenUsdValue: '$10,878.09', -// }, -// ], -// outcome: '10,878.09 XDAI', -// outcomeUsd: '$10,878.09', -// }) -// }) + test('displays transaction overview', async () => { + await withdrawalDialog.expectNativeRouteTransactionOverview({ + routeItems: [ + { + tokenAmount: '10,000.00 sDAI', + tokenUsdValue: '$10,878.09', + }, + { + tokenAmount: '10,878.09 XDAI', + tokenUsdValue: '$10,878.09', + }, + ], + outcome: '10,878.09 XDAI', + outcomeUsd: '$10,878.09', + }) + }) -// test('executes max withdrawal', async () => { -// const actionsContainer = new ActionsPageObject(withdrawalDialog.locatePanelByHeader('Actions')) -// await actionsContainer.acceptAllActionsAction(2, fork) + test('executes max withdrawal', async () => { + await withdrawalDialog.actionsContainer.acceptAllActionsAction(2) -// await withdrawalDialog.expectSuccessPage() -// await withdrawalDialog.clickBackToSavingsButton() + await withdrawalDialog.expectSuccessPage() + await withdrawalDialog.clickBackToSavingsButton() -// await savingsPage.expectOpportunityStablecoinsAmount('~$10,978.09') -// await savingsPage.expectStablecoinsInWalletAssetBalance('XDAI', '10,978.09') -// }) -// }) + await savingsPage.expectOpportunityStablecoinsAmount('~$10,978.09') + await savingsPage.expectStablecoinsInWalletAssetBalance('XDAI', '10,978.09') + }) +}) diff --git a/packages/app/src/features/dialogs/savings/withdraw/e2e/gnosis/WithdrawXDAI.test-e2e.ts b/packages/app/src/features/dialogs/savings/withdraw/e2e/gnosis/WithdrawXDAI.test-e2e.ts index 45583c809..a2ec24281 100644 --- a/packages/app/src/features/dialogs/savings/withdraw/e2e/gnosis/WithdrawXDAI.test-e2e.ts +++ b/packages/app/src/features/dialogs/savings/withdraw/e2e/gnosis/WithdrawXDAI.test-e2e.ts @@ -1,72 +1,68 @@ -// import { ActionsPageObject } from '@/features/actions/ActionsContainer.PageObject' -// import { SavingsPageObject } from '@/pages/Savings.PageObject' -// import { GNOSIS_DEFAULT_BLOCK_NUMBER } from '@/test/e2e/constants' -// import { setupFork } from '@/test/e2e/forking/setupFork' -// import { setup } from '@/test/e2e/setup' -// import { test } from '@playwright/test' -// import { gnosis } from 'viem/chains' -// import { SavingsDialogPageObject } from '../../../common/e2e/SavingsDialog.PageObject' +import { SavingsPageObject } from '@/pages/Savings.PageObject' +import { GNOSIS_DEFAULT_BLOCK_NUMBER } from '@/test/e2e/constants' +import { setup } from '@/test/e2e/setup' +import { test } from '@playwright/test' +import { gnosis } from 'viem/chains' +import { SavingsDialogPageObject } from '../../../common/e2e/SavingsDialog.PageObject' -// test.describe('Withdraw XDAI on Gnosis', () => { -// const fork = setupFork({ -// blockNumber: GNOSIS_DEFAULT_BLOCK_NUMBER, -// chainId: gnosis.id, -// useTenderlyVnet: true, -// }) -// let savingsPage: SavingsPageObject -// let withdrawalDialog: SavingsDialogPageObject +test.describe('Withdraw XDAI on Gnosis', () => { + let savingsPage: SavingsPageObject + let withdrawalDialog: SavingsDialogPageObject -// test.beforeEach(async ({ page }) => { -// await setup(page, fork, { -// initialPage: 'savings', -// account: { -// type: 'connected-random', -// assetBalances: { -// XDAI: 100, -// sDAI: 10_000, -// }, -// }, -// }) + test.beforeEach(async ({ page }) => { + const testContext = await setup(page, { + blockchain: { + chainId: gnosis.id, + blockNumber: GNOSIS_DEFAULT_BLOCK_NUMBER, + }, + initialPage: 'savings', + account: { + type: 'connected-random', + assetBalances: { + XDAI: 100, + sDAI: 10_000, + }, + }, + }) -// savingsPage = new SavingsPageObject(page) -// await savingsPage.clickWithdrawSDaiButtonAction() + savingsPage = new SavingsPageObject(testContext) + await savingsPage.clickWithdrawSDaiButtonAction() -// withdrawalDialog = new SavingsDialogPageObject({ page, type: 'withdraw' }) -// await withdrawalDialog.fillAmountAction(7000) -// }) + withdrawalDialog = new SavingsDialogPageObject({ testContext, type: 'withdraw' }) + await withdrawalDialog.fillAmountAction(7000) + }) -// test('uses native sDai withdrawal', async () => { -// await withdrawalDialog.actionsContainer.expectActions([ -// { type: 'approve', asset: 'sDAI' }, -// { type: 'withdrawFromSavings', asset: 'XDAI', savingsAsset: 'sDAI', mode: 'withdraw' }, -// ]) -// }) + test('uses native sDai withdrawal', async () => { + await withdrawalDialog.actionsContainer.expectActions([ + { type: 'approve', asset: 'sDAI' }, + { type: 'withdrawFromSavings', asset: 'XDAI', savingsAsset: 'sDAI', mode: 'withdraw' }, + ]) + }) -// test('displays transaction overview', async () => { -// await withdrawalDialog.expectNativeRouteTransactionOverview({ -// routeItems: [ -// { -// tokenAmount: '6,434.95 sDAI', -// tokenUsdValue: '$7,000.00', -// }, -// { -// tokenAmount: '7,000.00 XDAI', -// tokenUsdValue: '$7,000.00', -// }, -// ], -// outcome: '7,000.00 XDAI', -// outcomeUsd: '$7,000.00', -// }) -// }) + test('displays transaction overview', async () => { + await withdrawalDialog.expectNativeRouteTransactionOverview({ + routeItems: [ + { + tokenAmount: '6,434.95 sDAI', + tokenUsdValue: '$7,000.00', + }, + { + tokenAmount: '7,000.00 XDAI', + tokenUsdValue: '$7,000.00', + }, + ], + outcome: '7,000.00 XDAI', + outcomeUsd: '$7,000.00', + }) + }) -// test('executes withdrawal', async () => { -// const actionsContainer = new ActionsPageObject(withdrawalDialog.locatePanelByHeader('Actions')) -// await actionsContainer.acceptAllActionsAction(2, fork) + test('executes withdrawal', async () => { + await withdrawalDialog.actionsContainer.acceptAllActionsAction(2) -// await withdrawalDialog.expectSuccessPage() -// await withdrawalDialog.clickBackToSavingsButton() + await withdrawalDialog.expectSuccessPage() + await withdrawalDialog.clickBackToSavingsButton() -// await savingsPage.expectSavingsDaiBalance({ sdaiBalance: '3,565.05 sDAI', estimatedDaiValue: '3,878.09' }) -// await savingsPage.expectStablecoinsInWalletAssetBalance('XDAI', '7,100.00') -// }) -// }) + await savingsPage.expectSavingsDaiBalance({ sdaiBalance: '3,565.05 sDAI', estimatedDaiValue: '3,878.09' }) + await savingsPage.expectStablecoinsInWalletAssetBalance('XDAI', '7,100.00') + }) +}) diff --git a/packages/app/src/features/dialogs/savings/withdraw/e2e/mainnet/General.test-e2e.ts b/packages/app/src/features/dialogs/savings/withdraw/e2e/mainnet/General.test-e2e.ts new file mode 100644 index 000000000..eb3a0e5dd --- /dev/null +++ b/packages/app/src/features/dialogs/savings/withdraw/e2e/mainnet/General.test-e2e.ts @@ -0,0 +1,79 @@ +import { SavingsPageObject } from '@/pages/Savings.PageObject' +import { DEFAULT_BLOCK_NUMBER } from '@/test/e2e/constants' +import { setup } from '@/test/e2e/setup' +import { test } from '@playwright/test' +import { mainnet } 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: mainnet.id, + blockNumber: DEFAULT_BLOCK_NUMBER, + }, + initialPage: 'savings', + account: { + type: 'connected-random', + assetBalances: { + ETH: 1, + sDAI: 1000, + }, + }, + }) + + const savingsPage = new SavingsPageObject(testContext) + + await savingsPage.clickWithdrawSDaiButtonAction() + + const withdrawalDialog = new SavingsDialogPageObject({ testContext, type: 'withdraw' }) + + await withdrawalDialog.fillAmountAction(1000) + await withdrawalDialog.actionsContainer.expectEnabledActionAtIndex(0) + await withdrawalDialog.actionsContainer.expectActions([ + { type: 'withdrawFromSavings', asset: 'DAI', savingsAsset: 'sDAI', mode: 'withdraw' }, + ]) + + await withdrawalDialog.selectAssetAction('USDC') + await withdrawalDialog.fillAmountAction(1000) + await withdrawalDialog.actionsContainer.expectEnabledActionAtIndex(0) + await withdrawalDialog.actionsContainer.expectActions([ + { type: 'approve', asset: 'sDAI' }, + { type: 'withdrawFromSavings', asset: 'USDC', savingsAsset: 'sDAI', mode: 'withdraw' }, + ]) + + await withdrawalDialog.selectAssetAction('DAI') + await withdrawalDialog.fillAmountAction(1000) + await withdrawalDialog.actionsContainer.expectEnabledActionAtIndex(0) + await withdrawalDialog.actionsContainer.expectActions([ + { type: 'withdrawFromSavings', asset: 'DAI', savingsAsset: 'sDAI', mode: 'withdraw' }, + ]) + }) +}) + +test.describe('With send mode', () => { + test('can select only supported assets', async ({ page }) => { + const testContext = await setup(page, { + blockchain: { + chainId: mainnet.id, + blockNumber: DEFAULT_BLOCK_NUMBER, + }, + initialPage: 'savings', + account: { + type: 'connected-random', + assetBalances: { + ETH: 1, + sDAI: 10_000, + }, + }, + }) + + const savingsPage = new SavingsPageObject(testContext) + await savingsPage.clickSendSDaiButtonAction() + + const sendDialog = new SavingsDialogPageObject({ testContext, type: 'send' }) + + await sendDialog.openAssetSelectorAction() + await sendDialog.expectAssetSelectorOptions(['DAI', 'USDC', 'USDS']) + }) +}) diff --git a/packages/app/src/features/dialogs/savings/withdraw/e2e/mainnet/SendDAI.test-e2e.ts b/packages/app/src/features/dialogs/savings/withdraw/e2e/mainnet/SendDAI.test-e2e.ts index 4ab4fcf46..f4e211b1f 100644 --- a/packages/app/src/features/dialogs/savings/withdraw/e2e/mainnet/SendDAI.test-e2e.ts +++ b/packages/app/src/features/dialogs/savings/withdraw/e2e/mainnet/SendDAI.test-e2e.ts @@ -1,83 +1,84 @@ -// import { SavingsPageObject } from '@/pages/Savings.PageObject' -// import { DEFAULT_BLOCK_NUMBER, TOKENS_ON_FORK } from '@/test/e2e/constants' -// import { setupFork } from '@/test/e2e/forking/setupFork' -// import { setup } from '@/test/e2e/setup' -// import { randomAddress } from '@/test/utils/addressUtils' -// import { test } from '@playwright/test' -// import { mainnet } from 'viem/chains' -// import { SavingsDialogPageObject } from '../../../common/e2e/SavingsDialog.PageObject' +import { SavingsPageObject } from '@/pages/Savings.PageObject' +import { DEFAULT_BLOCK_NUMBER, TOKENS_ON_FORK } from '@/test/e2e/constants' +import { setup } from '@/test/e2e/setup' +import { randomAddress } from '@/test/utils/addressUtils' +import { test } from '@playwright/test' +import { mainnet } from 'viem/chains' +import { SavingsDialogPageObject } from '../../../common/e2e/SavingsDialog.PageObject' -// test.describe('Send DAI on Mainnet', () => { -// const fork = setupFork({ blockNumber: DEFAULT_BLOCK_NUMBER, chainId: mainnet.id, useTenderlyVnet: true }) -// let savingsPage: SavingsPageObject -// let sendDialog: SavingsDialogPageObject -// const receiver = randomAddress('bob') -// const amount = 7000 -// const dai = TOKENS_ON_FORK[mainnet.id].DAI +test.describe('Send DAI on Mainnet', () => { + let savingsPage: SavingsPageObject + let sendDialog: SavingsDialogPageObject + const receiver = randomAddress('bob') + const amount = 7000 + const dai = TOKENS_ON_FORK[mainnet.id].DAI -// test.beforeEach(async ({ page }) => { -// await setup(page, fork, { -// initialPage: 'savings', -// account: { -// type: 'connected-random', -// assetBalances: { -// ETH: 1, -// sDAI: 10_000, -// }, -// }, -// }) + test.beforeEach(async ({ page }) => { + const testContext = await setup(page, { + blockchain: { + chainId: mainnet.id, + blockNumber: DEFAULT_BLOCK_NUMBER, + }, + initialPage: 'savings', + account: { + type: 'connected-random', + assetBalances: { + ETH: 1, + sDAI: 10_000, + }, + }, + }) -// savingsPage = new SavingsPageObject(page) -// await savingsPage.clickSendSDaiButtonAction() + savingsPage = new SavingsPageObject(testContext) + await savingsPage.clickSendSDaiButtonAction() -// sendDialog = new SavingsDialogPageObject({ page, type: 'send' }) -// await sendDialog.fillAmountAction(amount) -// await sendDialog.fillReceiverAction(receiver) -// }) + sendDialog = new SavingsDialogPageObject({ testContext, type: 'send' }) + await sendDialog.fillAmountAction(amount) + await sendDialog.fillReceiverAction(receiver) + }) -// test('uses native sDai withdraw and send', async () => { -// await sendDialog.actionsContainer.expectActions([ -// { type: 'withdrawFromSavings', asset: 'DAI', savingsAsset: 'sDAI', mode: 'send' }, -// ]) -// }) + test('uses native sDai withdraw and send', async () => { + await sendDialog.actionsContainer.expectActions([ + { type: 'withdrawFromSavings', asset: 'DAI', savingsAsset: 'sDAI', mode: 'send' }, + ]) + }) -// test('displays transaction overview', async () => { -// await sendDialog.expectNativeRouteTransactionOverview({ -// routeItems: [ -// { -// tokenAmount: '6,647.10 sDAI', -// tokenUsdValue: '$7,000.00', -// }, -// { -// tokenAmount: '7,000.00 DAI', -// tokenUsdValue: '$7,000.00', -// }, -// ], -// outcome: '7,000.00 DAI', -// outcomeUsd: '$7,000.00', -// }) -// }) + test('displays transaction overview', async () => { + await sendDialog.expectNativeRouteTransactionOverview({ + routeItems: [ + { + tokenAmount: '6,218.91 sDAI', + tokenUsdValue: '$7,000.00', + }, + { + tokenAmount: '7,000.00 DAI', + tokenUsdValue: '$7,000.00', + }, + ], + outcome: '7,000.00 DAI', + outcomeUsd: '$7,000.00', + }) + }) -// test('executes send', async () => { -// await sendDialog.expectReceiverTokenBalance({ -// forkUrl: fork.forkUrl, -// receiver, -// token: dai, -// expectedBalance: 0, -// }) + test('executes send', async () => { + await sendDialog.expectReceiverTokenBalance({ + receiver, + token: dai, + expectedBalance: 0, + }) -// await sendDialog.actionsContainer.acceptAllActionsAction(1, fork) -// await sendDialog.expectSuccessPage() + await sendDialog.actionsContainer.acceptAllActionsAction(1) + await sendDialog.expectSuccessPage() -// await sendDialog.expectReceiverTokenBalance({ -// forkUrl: fork.forkUrl, -// receiver, -// token: dai, -// expectedBalance: amount, -// }) + await sendDialog.expectReceiverTokenBalance({ + receiver, + token: dai, + expectedBalance: amount, + }) -// await sendDialog.clickBackToSavingsButton() -// await savingsPage.expectSavingsDaiBalance({ sdaiBalance: '3,352.90 sDAI', estimatedDaiValue: '3,530.91' }) -// await savingsPage.expectStablecoinsInWalletAssetBalance('DAI', '-') -// }) -// }) + await sendDialog.clickBackToSavingsButton() + + await savingsPage.expectSavingsDaiBalance({ sdaiBalance: '3,781.09 sDAI', estimatedDaiValue: '4,255.9918184' }) + await savingsPage.expectStablecoinsInWalletAssetBalance('DAI', '-') + }) +}) diff --git a/packages/app/src/features/dialogs/savings/withdraw/e2e/mainnet/SendDAIValidation.test-e2e.ts b/packages/app/src/features/dialogs/savings/withdraw/e2e/mainnet/SendDAIValidation.test-e2e.ts index f6f2be2bf..847220463 100644 --- a/packages/app/src/features/dialogs/savings/withdraw/e2e/mainnet/SendDAIValidation.test-e2e.ts +++ b/packages/app/src/features/dialogs/savings/withdraw/e2e/mainnet/SendDAIValidation.test-e2e.ts @@ -1,246 +1,262 @@ -// import { receiverValidationIssueToMessage } from '@/domain/savings/validateReceiver' -// import { SavingsPageObject } from '@/pages/Savings.PageObject' -// import { DEFAULT_BLOCK_NUMBER } from '@/test/e2e/constants' -// import { setupFork } from '@/test/e2e/forking/setupFork' -// import { setup } from '@/test/e2e/setup' -// import { test } from '@playwright/test' -// import { Address, zeroAddress } from 'viem' -// import { mainnet } from 'viem/chains' -// import { SavingsDialogPageObject } from '../../../common/e2e/SavingsDialog.PageObject' -// import { withdrawValidationIssueToMessage } from '../../logic/validation' - -// test.describe('Asset input validation', () => { -// const fork = setupFork({ blockNumber: DEFAULT_BLOCK_NUMBER, chainId: mainnet.id, useTenderlyVnet: true }) -// let savingsPage: SavingsPageObject -// let sendDialog: SavingsDialogPageObject -// const receiver = '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045' - -// test.describe('Input value exceeds sDAI value', () => { -// test.beforeEach(async ({ page }) => { -// await setup(page, fork, { -// initialPage: 'savings', -// account: { -// type: 'connected-random', -// assetBalances: { -// ETH: 1, -// sDAI: 100, -// }, -// }, -// }) - -// savingsPage = new SavingsPageObject(page) -// await savingsPage.clickSendSDaiButtonAction() - -// sendDialog = new SavingsDialogPageObject({ page, type: 'send' }) -// await sendDialog.fillAmountAction(200) -// await sendDialog.fillReceiverAction(receiver) -// }) - -// test('displays validation error', async () => { -// await sendDialog.expectAssetInputError(withdrawValidationIssueToMessage['exceeds-balance']) -// }) - -// test('actions are disabled', async () => { -// await sendDialog.actionsContainer.expectDisabledActions([ -// { type: 'withdrawFromSavings', asset: 'DAI', savingsAsset: 'sDAI', mode: 'send' }, -// ]) -// }) - -// test('displays sensible tx overview', async () => { -// await sendDialog.expectNativeRouteTransactionOverview({ -// routeItems: [ -// { -// tokenAmount: '189.92 sDAI', -// tokenUsdValue: '$200.00', -// }, -// { -// tokenAmount: '200.00 DAI', -// tokenUsdValue: '$200.00', -// }, -// ], -// outcome: '200.00 DAI', -// outcomeUsd: '$200.00', -// }) -// }) -// }) - -// test('displays validation error for dirty input with 0 value', async ({ page }) => { -// await setup(page, fork, { -// initialPage: 'savings', -// account: { -// type: 'connected-random', -// assetBalances: { -// ETH: 1, -// sDAI: 100, -// }, -// }, -// }) - -// savingsPage = new SavingsPageObject(page) -// await savingsPage.clickSendSDaiButtonAction() -// sendDialog = new SavingsDialogPageObject({ page, type: 'send' }) - -// await sendDialog.fillAmountAction(10) -// await sendDialog.fillAmountAction(0) - -// await sendDialog.expectAssetInputError(withdrawValidationIssueToMessage['value-not-positive']) -// }) -// }) - -// test.describe('Receiver input validation', () => { -// const fork = setupFork({ blockNumber: DEFAULT_BLOCK_NUMBER, chainId: mainnet.id, useTenderlyVnet: true }) -// let savingsPage: SavingsPageObject -// let sendDialog: SavingsDialogPageObject -// let selfAddress: Address - -// test.describe('Incorrect receiver address', () => { -// test.beforeEach(async ({ page }) => { -// const { account } = await setup(page, fork, { -// initialPage: 'savings', -// account: { -// type: 'connected-random', -// assetBalances: { -// ETH: 1, -// sDAI: 100, -// }, -// }, -// }) - -// selfAddress = account - -// savingsPage = new SavingsPageObject(page) -// await savingsPage.clickSendSDaiButtonAction() - -// sendDialog = new SavingsDialogPageObject({ page, type: 'send' }) -// await sendDialog.fillAmountAction(50) // valid input amount -// }) - -// test('displays validation error', async () => { -// // invalid address is not valid -// await sendDialog.fillReceiverAction('0x0') -// await sendDialog.expectAddressInputError(receiverValidationIssueToMessage['invalid-address']) -// await sendDialog.fillReceiverAction('not-an-address') -// await sendDialog.expectAddressInputError(receiverValidationIssueToMessage['invalid-address']) -// await sendDialog.fillReceiverAction('0XD8DA6BF26964AF9D7EED9E03E53415D37AA96045') // uppercase -// await sendDialog.expectAddressInputError(receiverValidationIssueToMessage['invalid-address']) - -// // zero address is not valid -// await sendDialog.fillReceiverAction(zeroAddress) -// await sendDialog.expectAddressInputError(receiverValidationIssueToMessage['zero-address']) - -// // reserve address is not valid -// await sendDialog.fillReceiverAction('0x6B175474E89094C44Da98b954EedeAC495271d0F') // dai -// await sendDialog.expectAddressInputError(receiverValidationIssueToMessage['token-address']) - -// // self address is not valid -// await sendDialog.fillReceiverAction(selfAddress) -// await sendDialog.expectAddressInputError(receiverValidationIssueToMessage['self-address']) - -// // empty address is not valid -// await sendDialog.fillReceiverAction('') -// await sendDialog.expectAddressInputError(receiverValidationIssueToMessage['undefined-receiver']) -// }) - -// test('actions are disabled when receiver input is invalid', async () => { -// await sendDialog.fillReceiverAction('not-an-address') -// await sendDialog.actionsContainer.expectDisabledActions([ -// { type: 'withdrawFromSavings', asset: 'DAI', savingsAsset: 'sDAI', mode: 'send' }, -// ]) -// }) - -// test('displays sensible tx overview when amount is provided and receiver is invalid', async () => { -// await sendDialog.fillReceiverAction('not-an-address') -// await sendDialog.expectNativeRouteTransactionOverview({ -// routeItems: [ -// { -// tokenAmount: '47.48 sDAI', -// tokenUsdValue: '$50.00', -// }, -// { -// tokenAmount: '50.00 DAI', -// tokenUsdValue: '$50.00', -// }, -// ], -// outcome: '50.00 DAI', -// outcomeUsd: '$50.00', -// }) -// }) -// }) - -// test('displays warning when receiver is smart contract address', async ({ page }) => { -// await setup(page, fork, { -// initialPage: 'savings', -// account: { -// type: 'connected-random', -// assetBalances: { -// ETH: 1, -// sDAI: 100, -// }, -// }, -// }) - -// savingsPage = new SavingsPageObject(page) -// await savingsPage.clickSendSDaiButtonAction() -// sendDialog = new SavingsDialogPageObject({ page, type: 'send' }) -// await sendDialog.fillAmountAction(50) // valid input amount - -// await sendDialog.fillReceiverAction('0x197E90f9FAD81970bA7976f33CbD77088E5D7cf7') // pot address -// await sendDialog.expectReceiverIsSmartContractWarning() -// }) -// }) - -// test.describe('Form validation', () => { -// const fork = setupFork({ blockNumber: DEFAULT_BLOCK_NUMBER, chainId: mainnet.id, useTenderlyVnet: true }) -// let savingsPage: SavingsPageObject -// let sendDialog: SavingsDialogPageObject - -// test.beforeEach(async ({ page }) => { -// await setup(page, fork, { -// initialPage: 'savings', -// account: { -// type: 'connected-random', -// assetBalances: { -// ETH: 1, -// sDAI: 100, -// }, -// }, -// }) - -// savingsPage = new SavingsPageObject(page) -// await savingsPage.clickSendSDaiButtonAction() - -// sendDialog = new SavingsDialogPageObject({ page, type: 'send' }) -// }) - -// test('actions are disabled when amount is invalid, but receiver is valid', async () => { -// await sendDialog.fillAmountAction(200) -// await sendDialog.fillReceiverAction('0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045') -// await sendDialog.actionsContainer.expectDisabledActions([ -// { type: 'withdrawFromSavings', asset: 'DAI', savingsAsset: 'sDAI', mode: 'send' }, -// ]) -// }) - -// test('actions are disabled when amount is valid, but receiver is invalid', async () => { -// await sendDialog.fillAmountAction(50) -// await sendDialog.fillReceiverAction('not-an-address') -// await sendDialog.actionsContainer.expectDisabledActions([ -// { type: 'withdrawFromSavings', asset: 'DAI', savingsAsset: 'sDAI', mode: 'send' }, -// ]) -// }) - -// test('actions are disabled when both amount and receiver are invalid', async () => { -// await sendDialog.fillAmountAction(200) -// await sendDialog.fillReceiverAction('not-an-address') -// await sendDialog.actionsContainer.expectDisabledActions([ -// { type: 'withdrawFromSavings', asset: 'DAI', savingsAsset: 'sDAI', mode: 'send' }, -// ]) -// }) - -// test('actions are enabled when amount and receiver are valid', async () => { -// await sendDialog.fillAmountAction(50) -// await sendDialog.fillReceiverAction('0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045') -// await sendDialog.actionsContainer.expectActions([ -// { type: 'withdrawFromSavings', asset: 'DAI', savingsAsset: 'sDAI', mode: 'send' }, -// ]) -// }) -// }) +import { receiverValidationIssueToMessage } from '@/domain/savings/validateReceiver' +import { SavingsPageObject } from '@/pages/Savings.PageObject' +import { DEFAULT_BLOCK_NUMBER } from '@/test/e2e/constants' +import { setup } from '@/test/e2e/setup' +import { test } from '@playwright/test' +import { Address, zeroAddress } from 'viem' +import { mainnet } from 'viem/chains' +import { SavingsDialogPageObject } from '../../../common/e2e/SavingsDialog.PageObject' +import { withdrawValidationIssueToMessage } from '../../logic/validation' + +test.describe('Asset input validation', () => { + let savingsPage: SavingsPageObject + let sendDialog: SavingsDialogPageObject + const receiver = '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045' + + test.describe('Input value exceeds sDAI value', () => { + test.beforeEach(async ({ page }) => { + const testContext = await setup(page, { + blockchain: { + chainId: mainnet.id, + blockNumber: DEFAULT_BLOCK_NUMBER, + }, + initialPage: 'savings', + account: { + type: 'connected-random', + assetBalances: { + ETH: 1, + sDAI: 100, + }, + }, + }) + + savingsPage = new SavingsPageObject(testContext) + await savingsPage.clickSendSDaiButtonAction() + + sendDialog = new SavingsDialogPageObject({ testContext, type: 'send' }) + await sendDialog.fillAmountAction(200) + await sendDialog.fillReceiverAction(receiver) + }) + + test('displays validation error', async () => { + await sendDialog.expectAssetInputError(withdrawValidationIssueToMessage['exceeds-balance']) + }) + + test('actions are disabled', async () => { + await sendDialog.actionsContainer.expectDisabledActions([ + { type: 'withdrawFromSavings', asset: 'DAI', savingsAsset: 'sDAI', mode: 'send' }, + ]) + }) + + test('displays sensible tx overview', async () => { + await sendDialog.expectNativeRouteTransactionOverview({ + routeItems: [ + { + tokenAmount: '177.68 sDAI', + tokenUsdValue: '$200.00', + }, + { + tokenAmount: '200.00 DAI', + tokenUsdValue: '$200.00', + }, + ], + outcome: '200.00 DAI', + outcomeUsd: '$200.00', + }) + }) + }) + + test('displays validation error for dirty input with 0 value', async ({ page }) => { + const testContext = await setup(page, { + blockchain: { + chainId: mainnet.id, + blockNumber: DEFAULT_BLOCK_NUMBER, + }, + initialPage: 'savings', + account: { + type: 'connected-random', + assetBalances: { + ETH: 1, + sDAI: 100, + }, + }, + }) + + savingsPage = new SavingsPageObject(testContext) + await savingsPage.clickSendSDaiButtonAction() + sendDialog = new SavingsDialogPageObject({ testContext, type: 'send' }) + + await sendDialog.fillAmountAction(10) + await sendDialog.fillAmountAction(0) + + await sendDialog.expectAssetInputError(withdrawValidationIssueToMessage['value-not-positive']) + }) +}) + +test.describe('Receiver input validation', () => { + let savingsPage: SavingsPageObject + let sendDialog: SavingsDialogPageObject + let selfAddress: Address + + test.describe('Incorrect receiver address', () => { + test.beforeEach(async ({ page }) => { + const testContext = await setup(page, { + blockchain: { + chainId: mainnet.id, + blockNumber: DEFAULT_BLOCK_NUMBER, + }, + initialPage: 'savings', + account: { + type: 'connected-random', + assetBalances: { + ETH: 1, + sDAI: 100, + }, + }, + }) + + selfAddress = testContext.account + + savingsPage = new SavingsPageObject(testContext) + await savingsPage.clickSendSDaiButtonAction() + + sendDialog = new SavingsDialogPageObject({ testContext, type: 'send' }) + await sendDialog.fillAmountAction(50) // valid input amount + }) + + test('displays validation error', async () => { + // invalid address is not valid + await sendDialog.fillReceiverAction('0x0') + await sendDialog.expectAddressInputError(receiverValidationIssueToMessage['invalid-address']) + await sendDialog.fillReceiverAction('not-an-address') + await sendDialog.expectAddressInputError(receiverValidationIssueToMessage['invalid-address']) + await sendDialog.fillReceiverAction('0XD8DA6BF26964AF9D7EED9E03E53415D37AA96045') // uppercase + await sendDialog.expectAddressInputError(receiverValidationIssueToMessage['invalid-address']) + + // zero address is not valid + await sendDialog.fillReceiverAction(zeroAddress) + await sendDialog.expectAddressInputError(receiverValidationIssueToMessage['zero-address']) + + // reserve address is not valid + await sendDialog.fillReceiverAction('0x6B175474E89094C44Da98b954EedeAC495271d0F') // dai + await sendDialog.expectAddressInputError(receiverValidationIssueToMessage['token-address']) + + // self address is not valid + await sendDialog.fillReceiverAction(selfAddress) + await sendDialog.expectAddressInputError(receiverValidationIssueToMessage['self-address']) + + // empty address is not valid + await sendDialog.fillReceiverAction('') + await sendDialog.expectAddressInputError(receiverValidationIssueToMessage['undefined-receiver']) + }) + + test('actions are disabled when receiver input is invalid', async () => { + await sendDialog.fillReceiverAction('not-an-address') + await sendDialog.actionsContainer.expectDisabledActions([ + { type: 'withdrawFromSavings', asset: 'DAI', savingsAsset: 'sDAI', mode: 'send' }, + ]) + }) + + test('displays sensible tx overview when amount is provided and receiver is invalid', async () => { + await sendDialog.fillReceiverAction('not-an-address') + await sendDialog.expectNativeRouteTransactionOverview({ + routeItems: [ + { + tokenAmount: '44.42 sDAI', + tokenUsdValue: '$50.00', + }, + { + tokenAmount: '50.00 DAI', + tokenUsdValue: '$50.00', + }, + ], + outcome: '50.00 DAI', + outcomeUsd: '$50.00', + }) + }) + }) + + test('displays warning when receiver is smart contract address', async ({ page }) => { + const testContext = await setup(page, { + blockchain: { + chainId: mainnet.id, + blockNumber: DEFAULT_BLOCK_NUMBER, + }, + initialPage: 'savings', + account: { + type: 'connected-random', + assetBalances: { + ETH: 1, + sDAI: 100, + }, + }, + }) + + savingsPage = new SavingsPageObject(testContext) + await savingsPage.clickSendSDaiButtonAction() + sendDialog = new SavingsDialogPageObject({ testContext, type: 'send' }) + await sendDialog.fillAmountAction(50) // valid input amount + + await sendDialog.fillReceiverAction('0x197E90f9FAD81970bA7976f33CbD77088E5D7cf7') // pot address + await sendDialog.expectReceiverIsSmartContractWarning() + }) +}) + +test.describe('Form validation', () => { + let savingsPage: SavingsPageObject + let sendDialog: SavingsDialogPageObject + + test.beforeEach(async ({ page }) => { + const testContext = await setup(page, { + blockchain: { + chainId: mainnet.id, + blockNumber: DEFAULT_BLOCK_NUMBER, + }, + initialPage: 'savings', + account: { + type: 'connected-random', + assetBalances: { + ETH: 1, + sDAI: 100, + }, + }, + }) + + savingsPage = new SavingsPageObject(testContext) + await savingsPage.clickSendSDaiButtonAction() + + sendDialog = new SavingsDialogPageObject({ testContext, type: 'send' }) + }) + + test('actions are disabled when amount is invalid, but receiver is valid', async () => { + await sendDialog.fillAmountAction(200) + await sendDialog.fillReceiverAction('0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045') + await sendDialog.actionsContainer.expectDisabledActions([ + { type: 'withdrawFromSavings', asset: 'DAI', savingsAsset: 'sDAI', mode: 'send' }, + ]) + }) + + test('actions are disabled when amount is valid, but receiver is invalid', async () => { + await sendDialog.fillAmountAction(50) + await sendDialog.fillReceiverAction('not-an-address') + await sendDialog.actionsContainer.expectDisabledActions([ + { type: 'withdrawFromSavings', asset: 'DAI', savingsAsset: 'sDAI', mode: 'send' }, + ]) + }) + + test('actions are disabled when both amount and receiver are invalid', async () => { + await sendDialog.fillAmountAction(200) + await sendDialog.fillReceiverAction('not-an-address') + await sendDialog.actionsContainer.expectDisabledActions([ + { type: 'withdrawFromSavings', asset: 'DAI', savingsAsset: 'sDAI', mode: 'send' }, + ]) + }) + + test('actions are enabled when amount and receiver are valid', async () => { + await sendDialog.fillAmountAction(50) + await sendDialog.fillReceiverAction('0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045') + await sendDialog.actionsContainer.expectActions([ + { type: 'withdrawFromSavings', asset: 'DAI', savingsAsset: 'sDAI', mode: 'send' }, + ]) + }) +}) diff --git a/packages/app/src/features/dialogs/savings/withdraw/e2e/mainnet/SendUSDC.test-e2e.ts b/packages/app/src/features/dialogs/savings/withdraw/e2e/mainnet/SendUSDC.test-e2e.ts index fefc60510..c356bba8f 100644 --- a/packages/app/src/features/dialogs/savings/withdraw/e2e/mainnet/SendUSDC.test-e2e.ts +++ b/packages/app/src/features/dialogs/savings/withdraw/e2e/mainnet/SendUSDC.test-e2e.ts @@ -1,176 +1,177 @@ -// import { SavingsPageObject } from '@/pages/Savings.PageObject' -// import { TOKENS_ON_FORK, DEFAULT_BLOCK_NUMBER } from '@/test/e2e/constants' -// import { setupFork } from '@/test/e2e/forking/setupFork' -// import { setup } from '@/test/e2e/setup' -// import { randomAddress } from '@/test/utils/addressUtils' -// import { test } from '@playwright/test' -// import { mainnet } from 'viem/chains' -// import { SavingsDialogPageObject } from '../../../common/e2e/SavingsDialog.PageObject' - -// test.describe('Send USDC (withdrawing from sUSDS)', () => { -// const fork = setupFork({ blockNumber: DEFAULT_BLOCK_NUMBER, chainId: mainnet.id, useTenderlyVnet: true }) -// let savingsPage: SavingsPageObject -// let sendDialog: SavingsDialogPageObject -// const receiver = randomAddress('bob') -// const amount = 7000 -// const usdc = TOKENS_ON_FORK[mainnet.id].USDC - -// test.beforeEach(async ({ page }) => { -// await setup(page, fork, { -// initialPage: 'savings', -// account: { -// type: 'connected-random', -// assetBalances: { -// ETH: 1, -// USDS: 10_000, -// }, -// }, -// }) - -// savingsPage = new SavingsPageObject(page) - -// await savingsPage.clickDepositButtonAction('USDS') -// const depositDialog = new SavingsDialogPageObject({ page, type: 'deposit' }) -// await depositDialog.fillAmountAction(10_000) -// await depositDialog.actionsContainer.acceptAllActionsAction(2, fork) -// await depositDialog.clickBackToSavingsButton() - -// await savingsPage.clickSendSUsdsButtonAction() -// sendDialog = new SavingsDialogPageObject({ page, type: 'send' }) -// await sendDialog.selectAssetAction('USDC') -// await sendDialog.fillAmountAction(amount) -// await sendDialog.fillReceiverAction(receiver) -// }) - -// test('has correct action plan', async () => { -// await sendDialog.actionsContainer.expectActions([ -// { type: 'approve', asset: 'sUSDS' }, -// { type: 'withdrawFromSavings', asset: 'USDC', savingsAsset: 'sUSDS', mode: 'send' }, -// ]) -// }) - -// test('displays transaction overview', async () => { -// await sendDialog.expectNativeRouteTransactionOverview({ -// routeItems: [ -// { -// tokenAmount: '6,999.84 sUSDS', -// tokenUsdValue: '$7,000.00', -// }, -// { -// tokenAmount: '7,000.00 USDS', -// tokenUsdValue: '$7,000.00', -// }, -// { -// tokenAmount: '7,000.00 USDC', -// tokenUsdValue: '$7,000.00', -// }, -// ], -// outcome: '7,000.00 USDC', -// outcomeUsd: '$7,000.00', -// }) -// }) - -// test('executes send', async () => { -// await sendDialog.expectReceiverTokenBalance({ -// forkUrl: fork.forkUrl, -// receiver, -// token: usdc, -// expectedBalance: 0, -// }) - -// await sendDialog.actionsContainer.acceptAllActionsAction(2, fork) -// await sendDialog.expectSuccessPage() - -// await sendDialog.expectReceiverTokenBalance({ -// forkUrl: fork.forkUrl, -// receiver, -// token: usdc, -// expectedBalance: amount, -// }) - -// await sendDialog.clickBackToSavingsButton() -// await savingsPage.expectSavingsUsdsBalance({ susdsBalance: '2,999.93 sUSDS', estimatedUsdsValue: '3,000' }) -// await savingsPage.expectStablecoinsInWalletAssetBalance('USDC', '-') -// }) -// }) - -// test.describe('Send USDC (withdrawing from sDAI)', () => { -// const fork = setupFork({ blockNumber: DEFAULT_BLOCK_NUMBER, chainId: mainnet.id, useTenderlyVnet: true }) -// let savingsPage: SavingsPageObject -// let sendDialog: SavingsDialogPageObject -// const receiver = randomAddress('bob') -// const amount = 7000 -// const usdc = TOKENS_ON_FORK[mainnet.id].USDC - -// test.beforeEach(async ({ page }) => { -// await setup(page, fork, { -// initialPage: 'savings', -// account: { -// type: 'connected-random', -// assetBalances: { -// ETH: 1, -// sDAI: 10_000, -// }, -// }, -// }) - -// savingsPage = new SavingsPageObject(page) - -// await savingsPage.clickSendSDaiButtonAction() -// sendDialog = new SavingsDialogPageObject({ page, type: 'send' }) -// await sendDialog.selectAssetAction('USDC') -// await sendDialog.fillAmountAction(amount) -// await sendDialog.fillReceiverAction(receiver) -// }) - -// test('uses convert sDAI to USDS action', async () => { -// await sendDialog.actionsContainer.expectActions([ -// { type: 'approve', asset: 'sDAI' }, -// { type: 'withdrawFromSavings', asset: 'USDC', savingsAsset: 'sDAI', mode: 'send' }, -// ]) -// }) - -// test('displays transaction overview', async () => { -// await sendDialog.expectNativeRouteTransactionOverview({ -// routeItems: [ -// { -// tokenAmount: '6,314.32 sDAI', -// tokenUsdValue: '$7,000.00', -// }, -// { -// tokenAmount: '7,000.00 DAI', -// tokenUsdValue: '$7,000.00', -// }, -// { -// tokenAmount: '7,000.00 USDC', -// tokenUsdValue: '$7,000.00', -// }, -// ], -// outcome: '7,000.00 USDC', -// outcomeUsd: '$7,000.00', -// }) -// }) - -// test('executes send', async () => { -// await sendDialog.expectReceiverTokenBalance({ -// forkUrl: fork.forkUrl, -// receiver, -// token: usdc, -// expectedBalance: 0, -// }) - -// await sendDialog.actionsContainer.acceptAllActionsAction(2, fork) -// await sendDialog.expectSuccessPage() - -// await sendDialog.expectReceiverTokenBalance({ -// forkUrl: fork.forkUrl, -// receiver, -// token: usdc, -// expectedBalance: amount, -// }) - -// await sendDialog.clickBackToSavingsButton() -// await savingsPage.expectSavingsDaiBalance({ sdaiBalance: '3,685.68 sDAI', estimatedDaiValue: '4,085.90' }) -// await savingsPage.expectStablecoinsInWalletAssetBalance('USDC', '-') -// }) -// }) +import { SavingsPageObject } from '@/pages/Savings.PageObject' +import { DEFAULT_BLOCK_NUMBER, TOKENS_ON_FORK } from '@/test/e2e/constants' +import { setup } from '@/test/e2e/setup' +import { randomAddress } from '@/test/utils/addressUtils' +import { test } from '@playwright/test' +import { mainnet } from 'viem/chains' +import { SavingsDialogPageObject } from '../../../common/e2e/SavingsDialog.PageObject' + +test.describe('Send USDC (withdrawing from sUSDS)', () => { + let savingsPage: SavingsPageObject + let sendDialog: SavingsDialogPageObject + const receiver = randomAddress('bob') + const amount = 7000 + const usdc = TOKENS_ON_FORK[mainnet.id].USDC + + test.beforeEach(async ({ page }) => { + const testContext = await setup(page, { + blockchain: { + chainId: mainnet.id, + blockNumber: DEFAULT_BLOCK_NUMBER, + }, + initialPage: 'savings', + account: { + type: 'connected-random', + assetBalances: { + ETH: 1, + USDS: 10_000, + }, + }, + }) + + savingsPage = new SavingsPageObject(testContext) + + await savingsPage.clickDepositButtonAction('USDS') + const depositDialog = new SavingsDialogPageObject({ testContext, type: 'deposit' }) + await depositDialog.fillAmountAction(10_000) + await depositDialog.actionsContainer.acceptAllActionsAction(2) + await depositDialog.clickBackToSavingsButton() + + await savingsPage.clickSendSUsdsButtonAction() + sendDialog = new SavingsDialogPageObject({ testContext, type: 'send' }) + await sendDialog.selectAssetAction('USDC') + await sendDialog.fillAmountAction(amount) + await sendDialog.fillReceiverAction(receiver) + }) + + test('has correct action plan', async () => { + await sendDialog.actionsContainer.expectActions([ + { type: 'approve', asset: 'sUSDS' }, + { type: 'withdrawFromSavings', asset: 'USDC', savingsAsset: 'sUSDS', mode: 'send' }, + ]) + }) + + test('displays transaction overview', async () => { + await sendDialog.expectNativeRouteTransactionOverview({ + routeItems: [ + { + tokenAmount: '6,881.24 sUSDS', + tokenUsdValue: '$7,000.00', + }, + { + tokenAmount: '7,000.00 USDS', + tokenUsdValue: '$7,000.00', + }, + { + tokenAmount: '7,000.00 USDC', + tokenUsdValue: '$7,000.00', + }, + ], + outcome: '7,000.00 USDC', + outcomeUsd: '$7,000.00', + }) + }) + + test('executes send', async () => { + await sendDialog.expectReceiverTokenBalance({ + receiver, + token: usdc, + expectedBalance: 0, + }) + + await sendDialog.actionsContainer.acceptAllActionsAction(2) + await sendDialog.expectSuccessPage() + + await sendDialog.expectReceiverTokenBalance({ + receiver, + token: usdc, + expectedBalance: amount, + }) + + await sendDialog.clickBackToSavingsButton() + await savingsPage.expectSavingsUsdsBalance({ susdsBalance: '2,949.10 sUSDS', estimatedUsdsValue: '3,000.0003735' }) + await savingsPage.expectStablecoinsInWalletAssetBalance('USDC', '-') + }) +}) + +test.describe('Send USDC (withdrawing from sDAI)', () => { + let savingsPage: SavingsPageObject + let sendDialog: SavingsDialogPageObject + const receiver = randomAddress('bob') + const amount = 7000 + const usdc = TOKENS_ON_FORK[mainnet.id].USDC + + test.beforeEach(async ({ page }) => { + const testContext = await setup(page, { + blockchain: { + chainId: mainnet.id, + blockNumber: DEFAULT_BLOCK_NUMBER, + }, + initialPage: 'savings', + account: { + type: 'connected-random', + assetBalances: { + ETH: 1, + sDAI: 10_000, + }, + }, + }) + + savingsPage = new SavingsPageObject(testContext) + + await savingsPage.clickSendSDaiButtonAction() + sendDialog = new SavingsDialogPageObject({ testContext, type: 'send' }) + await sendDialog.selectAssetAction('USDC') + await sendDialog.fillAmountAction(amount) + await sendDialog.fillReceiverAction(receiver) + }) + + test('uses convert sDAI to USDS action', async () => { + await sendDialog.actionsContainer.expectActions([ + { type: 'approve', asset: 'sDAI' }, + { type: 'withdrawFromSavings', asset: 'USDC', savingsAsset: 'sDAI', mode: 'send' }, + ]) + }) + + test('displays transaction overview', async () => { + await sendDialog.expectNativeRouteTransactionOverview({ + routeItems: [ + { + tokenAmount: '6,218.91 sDAI', + tokenUsdValue: '$7,000.00', + }, + { + tokenAmount: '7,000.00 DAI', + tokenUsdValue: '$7,000.00', + }, + { + tokenAmount: '7,000.00 USDC', + tokenUsdValue: '$7,000.00', + }, + ], + outcome: '7,000.00 USDC', + outcomeUsd: '$7,000.00', + }) + }) + + test('executes send', async () => { + await sendDialog.expectReceiverTokenBalance({ + receiver, + token: usdc, + expectedBalance: 0, + }) + + await sendDialog.actionsContainer.acceptAllActionsAction(2) + await sendDialog.expectSuccessPage() + + await sendDialog.expectReceiverTokenBalance({ + receiver, + token: usdc, + expectedBalance: amount, + }) + + await sendDialog.clickBackToSavingsButton() + await savingsPage.expectSavingsDaiBalance({ sdaiBalance: '3,781.09 sDAI', estimatedDaiValue: '4,255.9920127' }) + await savingsPage.expectStablecoinsInWalletAssetBalance('USDC', '-') + }) +}) diff --git a/packages/app/src/features/dialogs/savings/withdraw/e2e/mainnet/SendUSDS.test-e2e.ts b/packages/app/src/features/dialogs/savings/withdraw/e2e/mainnet/SendUSDS.test-e2e.ts index 23d3d2d85..7b29d1cd4 100644 --- a/packages/app/src/features/dialogs/savings/withdraw/e2e/mainnet/SendUSDS.test-e2e.ts +++ b/packages/app/src/features/dialogs/savings/withdraw/e2e/mainnet/SendUSDS.test-e2e.ts @@ -1,170 +1,171 @@ -// import { SavingsPageObject } from '@/pages/Savings.PageObject' -// import { TOKENS_ON_FORK, DEFAULT_BLOCK_NUMBER } from '@/test/e2e/constants' -// import { setupFork } from '@/test/e2e/forking/setupFork' -// import { setup } from '@/test/e2e/setup' -// import { randomAddress } from '@/test/utils/addressUtils' -// import { test } from '@playwright/test' -// import { mainnet } from 'viem/chains' -// import { SavingsDialogPageObject } from '../../../common/e2e/SavingsDialog.PageObject' - -// test.describe('Send USDS (withdrawing from sUSDS)', () => { -// const fork = setupFork({ blockNumber: DEFAULT_BLOCK_NUMBER, chainId: mainnet.id, useTenderlyVnet: true }) -// let savingsPage: SavingsPageObject -// let sendDialog: SavingsDialogPageObject -// const receiver = randomAddress('bob') -// const amount = 7000 -// const usds = TOKENS_ON_FORK[mainnet.id].USDS - -// test.beforeEach(async ({ page }) => { -// await setup(page, fork, { -// initialPage: 'savings', -// account: { -// type: 'connected-random', -// assetBalances: { -// ETH: 1, -// USDS: 10_000, -// }, -// }, -// }) - -// savingsPage = new SavingsPageObject(page) - -// await savingsPage.clickDepositButtonAction('USDS') -// const depositDialog = new SavingsDialogPageObject({ page, type: 'deposit' }) -// await depositDialog.fillAmountAction(10_000) -// await depositDialog.actionsContainer.acceptAllActionsAction(2, fork) -// await depositDialog.clickBackToSavingsButton() - -// await savingsPage.clickSendSUsdsButtonAction() -// sendDialog = new SavingsDialogPageObject({ page, type: 'send' }) -// await sendDialog.fillAmountAction(amount) -// await sendDialog.fillReceiverAction(receiver) -// }) - -// test('uses native sUSDS withdraw and send', async () => { -// await sendDialog.actionsContainer.expectActions([ -// { type: 'withdrawFromSavings', asset: 'USDS', savingsAsset: 'sUSDS', mode: 'send' }, -// ]) -// }) - -// test('displays transaction overview', async () => { -// await sendDialog.expectNativeRouteTransactionOverview({ -// routeItems: [ -// { -// tokenAmount: '6,999.84 sUSDS', -// tokenUsdValue: '$7,000.00', -// }, -// { -// tokenAmount: '7,000.00 USDS', -// tokenUsdValue: '$7,000.00', -// }, -// ], -// outcome: '7,000.00 USDS', -// outcomeUsd: '$7,000.00', -// }) -// }) - -// test('executes send', async () => { -// await sendDialog.expectReceiverTokenBalance({ -// forkUrl: fork.forkUrl, -// receiver, -// token: usds, -// expectedBalance: 0, -// }) - -// await sendDialog.actionsContainer.acceptAllActionsAction(1, fork) -// await sendDialog.expectSuccessPage() - -// await sendDialog.expectReceiverTokenBalance({ -// forkUrl: fork.forkUrl, -// receiver, -// token: usds, -// expectedBalance: amount, -// }) - -// await sendDialog.clickBackToSavingsButton() -// await savingsPage.expectSavingsUsdsBalance({ susdsBalance: '2,999.93 sUSDS', estimatedUsdsValue: '3,000' }) -// await savingsPage.expectStablecoinsInWalletAssetBalance('USDS', '-') -// }) -// }) - -// test.describe('Send USDS (withdrawing from sDAI)', () => { -// const fork = setupFork({ blockNumber: DEFAULT_BLOCK_NUMBER, chainId: mainnet.id, useTenderlyVnet: true }) -// let savingsPage: SavingsPageObject -// let sendDialog: SavingsDialogPageObject -// const receiver = randomAddress('bob') -// const amount = 7000 -// const usds = TOKENS_ON_FORK[mainnet.id].USDS - -// test.beforeEach(async ({ page }) => { -// await setup(page, fork, { -// initialPage: 'savings', -// account: { -// type: 'connected-random', -// assetBalances: { -// ETH: 1, -// sDAI: 10_000, -// }, -// }, -// }) - -// savingsPage = new SavingsPageObject(page) - -// await savingsPage.clickSendSDaiButtonAction() -// sendDialog = new SavingsDialogPageObject({ page, type: 'send' }) -// await sendDialog.selectAssetAction('USDS') -// await sendDialog.fillAmountAction(amount) -// await sendDialog.fillReceiverAction(receiver) -// }) - -// test('uses migrate sDAI to USDS action', async () => { -// await sendDialog.actionsContainer.expectActions([ -// { type: 'approve', asset: 'sDAI' }, -// { type: 'withdrawFromSavings', asset: 'USDS', savingsAsset: 'sDAI', mode: 'send' }, -// ]) -// }) - -// test('displays transaction overview', async () => { -// await sendDialog.expectNativeRouteTransactionOverview({ -// routeItems: [ -// { -// tokenAmount: '6,314.32 sDAI', -// tokenUsdValue: '$7,000.00', -// }, -// { -// tokenAmount: '7,000.00 DAI', -// tokenUsdValue: '$7,000.00', -// }, -// { -// tokenAmount: '7,000.00 USDS', -// tokenUsdValue: '$7,000.00', -// }, -// ], -// outcome: '7,000.00 USDS', -// outcomeUsd: '$7,000.00', -// }) -// }) - -// test('executes send', async () => { -// await sendDialog.expectReceiverTokenBalance({ -// forkUrl: fork.forkUrl, -// receiver, -// token: usds, -// expectedBalance: 0, -// }) - -// await sendDialog.actionsContainer.acceptAllActionsAction(2, fork) -// await sendDialog.expectSuccessPage() - -// await sendDialog.expectReceiverTokenBalance({ -// forkUrl: fork.forkUrl, -// receiver, -// token: usds, -// expectedBalance: amount, -// }) - -// await sendDialog.clickBackToSavingsButton() -// await savingsPage.expectSavingsDaiBalance({ sdaiBalance: '3,685.68 sDAI', estimatedDaiValue: '4,085.90' }) -// await savingsPage.expectStablecoinsInWalletAssetBalance('USDS', '-') -// }) -// }) +import { SavingsPageObject } from '@/pages/Savings.PageObject' +import { DEFAULT_BLOCK_NUMBER, TOKENS_ON_FORK } from '@/test/e2e/constants' +import { setup } from '@/test/e2e/setup' +import { randomAddress } from '@/test/utils/addressUtils' +import { test } from '@playwright/test' +import { mainnet } from 'viem/chains' +import { SavingsDialogPageObject } from '../../../common/e2e/SavingsDialog.PageObject' + +test.describe('Send USDS (withdrawing from sUSDS)', () => { + let savingsPage: SavingsPageObject + let sendDialog: SavingsDialogPageObject + const receiver = randomAddress('bob') + const amount = 7000 + const usds = TOKENS_ON_FORK[mainnet.id].USDS + + test.beforeEach(async ({ page }) => { + const testContext = await setup(page, { + blockchain: { + chainId: mainnet.id, + blockNumber: DEFAULT_BLOCK_NUMBER, + }, + initialPage: 'savings', + account: { + type: 'connected-random', + assetBalances: { + ETH: 1, + USDS: 10_000, + }, + }, + }) + + savingsPage = new SavingsPageObject(testContext) + + await savingsPage.clickDepositButtonAction('USDS') + const depositDialog = new SavingsDialogPageObject({ testContext, type: 'deposit' }) + await depositDialog.fillAmountAction(10_000) + await depositDialog.actionsContainer.acceptAllActionsAction(2) + await depositDialog.clickBackToSavingsButton() + + await savingsPage.clickSendSUsdsButtonAction() + sendDialog = new SavingsDialogPageObject({ testContext, type: 'send' }) + await sendDialog.fillAmountAction(amount) + await sendDialog.fillReceiverAction(receiver) + }) + + test('uses native sUSDS withdraw and send', async () => { + await sendDialog.actionsContainer.expectActions([ + { type: 'withdrawFromSavings', asset: 'USDS', savingsAsset: 'sUSDS', mode: 'send' }, + ]) + }) + + test('displays transaction overview', async () => { + await sendDialog.expectNativeRouteTransactionOverview({ + routeItems: [ + { + tokenAmount: '6,881.24 sUSDS', + tokenUsdValue: '$7,000.00', + }, + { + tokenAmount: '7,000.00 USDS', + tokenUsdValue: '$7,000.00', + }, + ], + outcome: '7,000.00 USDS', + outcomeUsd: '$7,000.00', + }) + }) + + test('executes send', async () => { + await sendDialog.expectReceiverTokenBalance({ + receiver, + token: usds, + expectedBalance: 0, + }) + + await sendDialog.actionsContainer.acceptAllActionsAction(1) + await sendDialog.expectSuccessPage() + + await sendDialog.expectReceiverTokenBalance({ + receiver, + token: usds, + expectedBalance: amount, + }) + + await sendDialog.clickBackToSavingsButton() + await savingsPage.expectSavingsUsdsBalance({ susdsBalance: '2,949.10 sUSDS', estimatedUsdsValue: '3,000.0001867' }) + await savingsPage.expectStablecoinsInWalletAssetBalance('USDS', '-') + }) +}) + +test.describe('Send USDS (withdrawing from sDAI)', () => { + let savingsPage: SavingsPageObject + let sendDialog: SavingsDialogPageObject + const receiver = randomAddress('bob') + const amount = 7000 + const usds = TOKENS_ON_FORK[mainnet.id].USDS + + test.beforeEach(async ({ page }) => { + const testContext = await setup(page, { + blockchain: { + chainId: mainnet.id, + blockNumber: DEFAULT_BLOCK_NUMBER, + }, + initialPage: 'savings', + account: { + type: 'connected-random', + assetBalances: { + ETH: 1, + sDAI: 10_000, + }, + }, + }) + + savingsPage = new SavingsPageObject(testContext) + + await savingsPage.clickSendSDaiButtonAction() + sendDialog = new SavingsDialogPageObject({ testContext, type: 'send' }) + await sendDialog.selectAssetAction('USDS') + await sendDialog.fillAmountAction(amount) + await sendDialog.fillReceiverAction(receiver) + }) + + test('uses migrate sDAI to USDS action', async () => { + await sendDialog.actionsContainer.expectActions([ + { type: 'approve', asset: 'sDAI' }, + { type: 'withdrawFromSavings', asset: 'USDS', savingsAsset: 'sDAI', mode: 'send' }, + ]) + }) + + test('displays transaction overview', async () => { + await sendDialog.expectNativeRouteTransactionOverview({ + routeItems: [ + { + tokenAmount: '6,218.91 sDAI', + tokenUsdValue: '$7,000.00', + }, + { + tokenAmount: '7,000.00 DAI', + tokenUsdValue: '$7,000.00', + }, + { + tokenAmount: '7,000.00 USDS', + tokenUsdValue: '$7,000.00', + }, + ], + outcome: '7,000.00 USDS', + outcomeUsd: '$7,000.00', + }) + }) + + test('executes send', async () => { + await sendDialog.expectReceiverTokenBalance({ + receiver, + token: usds, + expectedBalance: 0, + }) + + await sendDialog.actionsContainer.acceptAllActionsAction(2) + await sendDialog.expectSuccessPage() + + await sendDialog.expectReceiverTokenBalance({ + receiver, + token: usds, + expectedBalance: amount, + }) + + await sendDialog.clickBackToSavingsButton() + await savingsPage.expectSavingsDaiBalance({ sdaiBalance: '3,781.09 sDAI', estimatedDaiValue: '4,255.9920127' }) + await savingsPage.expectStablecoinsInWalletAssetBalance('USDS', '-') + }) +}) diff --git a/packages/app/src/features/dialogs/savings/withdraw/e2e/mainnet/WithdrawDAI.test-e2e.ts b/packages/app/src/features/dialogs/savings/withdraw/e2e/mainnet/WithdrawDAI.test-e2e.ts index 4a3fb69cd..c48cc1e5b 100644 --- a/packages/app/src/features/dialogs/savings/withdraw/e2e/mainnet/WithdrawDAI.test-e2e.ts +++ b/packages/app/src/features/dialogs/savings/withdraw/e2e/mainnet/WithdrawDAI.test-e2e.ts @@ -1,144 +1,151 @@ -// import { ActionsPageObject } from '@/features/actions/ActionsContainer.PageObject' -// import { SavingsPageObject } from '@/pages/Savings.PageObject' -// import { DEFAULT_BLOCK_NUMBER } from '@/test/e2e/constants' -// import { setupFork } from '@/test/e2e/forking/setupFork' -// import { setup } from '@/test/e2e/setup' -// import { test } from '@playwright/test' -// import { mainnet } from 'viem/chains' -// import { SavingsDialogPageObject } from '../../../common/e2e/SavingsDialog.PageObject' -// import { withdrawValidationIssueToMessage } from '../../logic/validation' - -// test.describe('Withdraw 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-random', -// assetBalances: { -// ETH: 1, -// sDAI: 10_000, -// }, -// }, -// }) - -// savingsPage = new SavingsPageObject(page) -// await savingsPage.clickWithdrawSDaiButtonAction() - -// withdrawalDialog = new SavingsDialogPageObject({ page, type: 'withdraw' }) -// await withdrawalDialog.fillAmountAction(7000) -// }) - -// test('uses native sDai withdrawal', async () => { -// await withdrawalDialog.actionsContainer.expectActions([ -// { type: 'withdrawFromSavings', asset: 'DAI', savingsAsset: 'sDAI', mode: 'withdraw' }, -// ]) -// }) - -// test('displays transaction overview', async () => { -// await withdrawalDialog.expectNativeRouteTransactionOverview({ -// routeItems: [ -// { -// tokenAmount: '6,532.86 sDAI', -// tokenUsdValue: '$7,000.00', -// }, -// { -// tokenAmount: '7,000.00 DAI', -// tokenUsdValue: '$7,000.00', -// }, -// ], -// outcome: '7,000.00 DAI', -// outcomeUsd: '$7,000.00', -// }) -// }) - -// test('executes withdrawal', async () => { -// const actionsContainer = new ActionsPageObject(withdrawalDialog.locatePanelByHeader('Actions')) -// await actionsContainer.acceptAllActionsAction(1) - -// await withdrawalDialog.expectSuccessPage() -// await withdrawalDialog.clickBackToSavingsButton() - -// await savingsPage.expectSavingsDaiBalance({ sdaiBalance: '3,467.14 sDAI', estimatedDaiValue: '3,715.05' }) -// await savingsPage.expectStablecoinsInWalletAssetBalance('DAI', '7,000.00') -// }) -// }) - -// test.describe('Validation', () => { -// const fork = setupFork({ blockNumber: DEFAULT_BLOCK_NUMBER, chainId: mainnet.id }) -// let savingsPage: SavingsPageObject -// let withdrawalDialog: SavingsDialogPageObject - -// test.describe('Input value exceeds sDAI value', () => { -// test.beforeEach(async ({ page }) => { -// await setup(page, fork, { -// initialPage: 'savings', -// account: { -// type: 'connected-random', -// assetBalances: { -// ETH: 1, -// sDAI: 100, -// }, -// }, -// }) - -// savingsPage = new SavingsPageObject(page) -// await savingsPage.clickWithdrawSDaiButtonAction() - -// withdrawalDialog = new SavingsDialogPageObject({ page, type: 'withdraw' }) -// await withdrawalDialog.fillAmountAction(200) -// }) - -// test('displays validation error', async () => { -// await withdrawalDialog.expectAssetInputError(withdrawValidationIssueToMessage['exceeds-balance']) -// }) - -// test('actions are disabled', async () => { -// await withdrawalDialog.actionsContainer.expectDisabledActions([ -// { type: 'withdrawFromSavings', asset: 'DAI', savingsAsset: 'sDAI', mode: 'withdraw' }, -// ]) -// }) - -// test('displays sensible tx overview', async () => { -// await withdrawalDialog.expectNativeRouteTransactionOverview({ -// routeItems: [ -// { -// tokenAmount: '186.65 sDAI', -// tokenUsdValue: '$200.00', -// }, -// { -// tokenAmount: '200.00 DAI', -// tokenUsdValue: '$200.00', -// }, -// ], -// outcome: '200.00 DAI', -// outcomeUsd: '$200.00', -// }) -// }) -// }) - -// test('displays validation error for dirty input with 0 value', async ({ page }) => { -// await setup(page, fork, { -// initialPage: 'savings', -// account: { -// type: 'connected-random', -// assetBalances: { -// ETH: 1, -// sDAI: 100, -// }, -// }, -// }) - -// savingsPage = new SavingsPageObject(page) -// await savingsPage.clickWithdrawSDaiButtonAction() -// withdrawalDialog = new SavingsDialogPageObject({ page, type: 'withdraw' }) - -// await withdrawalDialog.fillAmountAction(10) -// await withdrawalDialog.fillAmountAction(0) - -// await withdrawalDialog.expectAssetInputError(withdrawValidationIssueToMessage['value-not-positive']) -// }) -// }) +import { SavingsPageObject } from '@/pages/Savings.PageObject' +import { DEFAULT_BLOCK_NUMBER } from '@/test/e2e/constants' +import { setup } from '@/test/e2e/setup' +import { test } from '@playwright/test' +import { mainnet } from 'viem/chains' +import { SavingsDialogPageObject } from '../../../common/e2e/SavingsDialog.PageObject' +import { withdrawValidationIssueToMessage } from '../../logic/validation' + +test.describe('Withdraw DAI on Mainnet', () => { + let savingsPage: SavingsPageObject + let withdrawalDialog: SavingsDialogPageObject + + test.beforeEach(async ({ page }) => { + const testContext = await setup(page, { + blockchain: { + chainId: mainnet.id, + blockNumber: DEFAULT_BLOCK_NUMBER, + }, + initialPage: 'savings', + account: { + type: 'connected-random', + assetBalances: { + ETH: 1, + sDAI: 10_000, + }, + }, + }) + + savingsPage = new SavingsPageObject(testContext) + await savingsPage.clickWithdrawSDaiButtonAction() + + withdrawalDialog = new SavingsDialogPageObject({ testContext, type: 'withdraw' }) + await withdrawalDialog.fillAmountAction(7000) + }) + + test('uses native sDai withdrawal', async () => { + await withdrawalDialog.actionsContainer.expectActions([ + { type: 'withdrawFromSavings', asset: 'DAI', savingsAsset: 'sDAI', mode: 'withdraw' }, + ]) + }) + + test('displays transaction overview', async () => { + await withdrawalDialog.expectNativeRouteTransactionOverview({ + routeItems: [ + { + tokenAmount: '6,218.91 sDAI', + tokenUsdValue: '$7,000.00', + }, + { + tokenAmount: '7,000.00 DAI', + tokenUsdValue: '$7,000.00', + }, + ], + outcome: '7,000.00 DAI', + outcomeUsd: '$7,000.00', + }) + }) + + test('executes withdrawal', async () => { + await withdrawalDialog.actionsContainer.acceptAllActionsAction(1) + + await withdrawalDialog.expectSuccessPage() + await withdrawalDialog.clickBackToSavingsButton() + + await savingsPage.expectSavingsDaiBalance({ sdaiBalance: '3,781.09 sDAI', estimatedDaiValue: '4,255.9918184' }) + await savingsPage.expectStablecoinsInWalletAssetBalance('DAI', '7,000.00') + }) +}) + +test.describe('Validation', () => { + let savingsPage: SavingsPageObject + let withdrawalDialog: SavingsDialogPageObject + + test.describe('Input value exceeds sDAI value', () => { + test.beforeEach(async ({ page }) => { + const testContext = await setup(page, { + blockchain: { + chainId: mainnet.id, + blockNumber: DEFAULT_BLOCK_NUMBER, + }, + initialPage: 'savings', + account: { + type: 'connected-random', + assetBalances: { + ETH: 1, + sDAI: 100, + }, + }, + }) + + savingsPage = new SavingsPageObject(testContext) + await savingsPage.clickWithdrawSDaiButtonAction() + + withdrawalDialog = new SavingsDialogPageObject({ testContext, type: 'withdraw' }) + await withdrawalDialog.fillAmountAction(200) + }) + + test('displays validation error', async () => { + await withdrawalDialog.expectAssetInputError(withdrawValidationIssueToMessage['exceeds-balance']) + }) + + test('actions are disabled', async () => { + await withdrawalDialog.actionsContainer.expectDisabledActions([ + { type: 'withdrawFromSavings', asset: 'DAI', savingsAsset: 'sDAI', mode: 'withdraw' }, + ]) + }) + + test('displays sensible tx overview', async () => { + await withdrawalDialog.expectNativeRouteTransactionOverview({ + routeItems: [ + { + tokenAmount: '177.68 sDAI', + tokenUsdValue: '$200.00', + }, + { + tokenAmount: '200.00 DAI', + tokenUsdValue: '$200.00', + }, + ], + outcome: '200.00 DAI', + outcomeUsd: '$200.00', + }) + }) + }) + + test('displays validation error for dirty input with 0 value', async ({ page }) => { + const testContext = await setup(page, { + blockchain: { + chainId: mainnet.id, + blockNumber: DEFAULT_BLOCK_NUMBER, + }, + initialPage: 'savings', + account: { + type: 'connected-random', + assetBalances: { + ETH: 1, + sDAI: 100, + }, + }, + }) + + savingsPage = new SavingsPageObject(testContext) + await savingsPage.clickWithdrawSDaiButtonAction() + withdrawalDialog = new SavingsDialogPageObject({ testContext, type: 'withdraw' }) + + await withdrawalDialog.fillAmountAction(10) + await withdrawalDialog.fillAmountAction(0) + + await withdrawalDialog.expectAssetInputError(withdrawValidationIssueToMessage['value-not-positive']) + }) +}) diff --git a/packages/app/src/features/dialogs/savings/withdraw/e2e/mainnet/WithdrawMaxDAI.test-e2e.ts b/packages/app/src/features/dialogs/savings/withdraw/e2e/mainnet/WithdrawMaxDAI.test-e2e.ts index 754cc9b65..8e888384e 100644 --- a/packages/app/src/features/dialogs/savings/withdraw/e2e/mainnet/WithdrawMaxDAI.test-e2e.ts +++ b/packages/app/src/features/dialogs/savings/withdraw/e2e/mainnet/WithdrawMaxDAI.test-e2e.ts @@ -1,67 +1,67 @@ -// import { ActionsPageObject } from '@/features/actions/ActionsContainer.PageObject' -// import { SavingsPageObject } from '@/pages/Savings.PageObject' -// import { DEFAULT_BLOCK_NUMBER } from '@/test/e2e/constants' -// import { setupFork } from '@/test/e2e/forking/setupFork' -// import { setup } from '@/test/e2e/setup' -// import { test } from '@playwright/test' -// import { mainnet } from 'viem/chains' -// import { SavingsDialogPageObject } from '../../../common/e2e/SavingsDialog.PageObject' +import { SavingsPageObject } from '@/pages/Savings.PageObject' +import { DEFAULT_BLOCK_NUMBER } from '@/test/e2e/constants' +import { setup } from '@/test/e2e/setup' +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.describe('Withdraw max DAI on Mainnet', () => { + let savingsPage: SavingsPageObject + let withdrawalDialog: SavingsDialogPageObject -// test.beforeEach(async ({ page }) => { -// await setup(page, fork, { -// initialPage: 'savings', -// account: { -// type: 'connected-random', -// assetBalances: { -// ETH: 1, -// sDAI: 10_000, -// }, -// }, -// }) + test.beforeEach(async ({ page }) => { + const testContext = await setup(page, { + blockchain: { + chainId: mainnet.id, + blockNumber: DEFAULT_BLOCK_NUMBER, + }, + initialPage: 'savings', + account: { + type: 'connected-random', + assetBalances: { + ETH: 1, + sDAI: 10_000, + }, + }, + }) -// savingsPage = new SavingsPageObject(page) -// await savingsPage.clickWithdrawSDaiButtonAction() + savingsPage = new SavingsPageObject(testContext) + await savingsPage.clickWithdrawSDaiButtonAction() -// withdrawalDialog = new SavingsDialogPageObject({ page, type: 'withdraw' }) -// await withdrawalDialog.clickMaxAmountAction() -// }) + withdrawalDialog = new SavingsDialogPageObject({ testContext, type: 'withdraw' }) + await withdrawalDialog.clickMaxAmountAction() + }) -// test('uses native sDai withdrawal', async () => { -// await withdrawalDialog.actionsContainer.expectActions([ -// { type: 'withdrawFromSavings', asset: 'DAI', savingsAsset: 'sDAI', mode: 'withdraw' }, -// ]) -// }) + test('uses native sDai withdrawal', async () => { + await withdrawalDialog.actionsContainer.expectActions([ + { type: 'withdrawFromSavings', asset: 'DAI', savingsAsset: 'sDAI', mode: 'withdraw' }, + ]) + }) -// test('displays transaction overview', async () => { -// await withdrawalDialog.expectNativeRouteTransactionOverview({ -// routeItems: [ -// { -// tokenAmount: '10,000.00 sDAI', -// tokenUsdValue: '$10,715.05', -// }, -// { -// tokenAmount: '10,715.05 DAI', -// tokenUsdValue: '$10,715.05', -// }, -// ], -// outcome: '10,715.05 DAI', -// outcomeUsd: '$10,715.05', -// }) -// }) + test('displays transaction overview', async () => { + await withdrawalDialog.expectNativeRouteTransactionOverview({ + routeItems: [ + { + tokenAmount: '10,000.00 sDAI', + tokenUsdValue: '$11,255.99', + }, + { + tokenAmount: '11,255.99 DAI', + tokenUsdValue: '$11,255.99', + }, + ], + outcome: '11,255.99 DAI', + outcomeUsd: '$11,255.99', + }) + }) -// test('executes max withdrawal', async () => { -// const actionsContainer = new ActionsPageObject(withdrawalDialog.locatePanelByHeader('Actions')) -// await actionsContainer.acceptAllActionsAction(1) + test('executes max withdrawal', async () => { + await withdrawalDialog.actionsContainer.acceptAllActionsAction(1) -// await withdrawalDialog.expectSuccessPage() -// await withdrawalDialog.clickBackToSavingsButton() + await withdrawalDialog.expectSuccessPage() + await withdrawalDialog.clickBackToSavingsButton() -// await savingsPage.expectOpportunityStablecoinsAmount('~$10,715.05') -// await savingsPage.expectStablecoinsInWalletAssetBalance('DAI', '10,715.05') -// }) -// }) + await savingsPage.expectOpportunityStablecoinsAmount('~$11,255.99') + await savingsPage.expectStablecoinsInWalletAssetBalance('DAI', '11,255.99') + }) +}) diff --git a/packages/app/src/features/dialogs/savings/withdraw/e2e/mainnet/WithdrawMaxUSDC.test-e2e.ts b/packages/app/src/features/dialogs/savings/withdraw/e2e/mainnet/WithdrawMaxUSDC.test-e2e.ts index 765d73a49..29239802b 100644 --- a/packages/app/src/features/dialogs/savings/withdraw/e2e/mainnet/WithdrawMaxUSDC.test-e2e.ts +++ b/packages/app/src/features/dialogs/savings/withdraw/e2e/mainnet/WithdrawMaxUSDC.test-e2e.ts @@ -1,148 +1,150 @@ -// import { ActionsPageObject } from '@/features/actions/ActionsContainer.PageObject' -// import { SavingsPageObject } from '@/pages/Savings.PageObject' -// import { DEFAULT_BLOCK_NUMBER } from '@/test/e2e/constants' -// import { setupFork } from '@/test/e2e/forking/setupFork' -// import { setup } from '@/test/e2e/setup' -// import { test } from '@playwright/test' -// import { mainnet } from 'viem/chains' -// import { SavingsDialogPageObject } from '../../../common/e2e/SavingsDialog.PageObject' - -// test.describe('Withdraw USDC from sUSDS', () => { -// const fork = setupFork({ blockNumber: DEFAULT_BLOCK_NUMBER, chainId: mainnet.id, useTenderlyVnet: true }) -// let savingsPage: SavingsPageObject -// let withdrawDialog: SavingsDialogPageObject - -// test.beforeEach(async ({ page }) => { -// await setup(page, fork, { -// initialPage: 'savings', -// account: { -// type: 'connected-random', -// assetBalances: { -// ETH: 1, -// USDS: 10_000, -// }, -// }, -// }) - -// savingsPage = new SavingsPageObject(page) - -// await savingsPage.clickDepositButtonAction('USDS') -// const depositDialog = new SavingsDialogPageObject({ page, type: 'deposit' }) -// await depositDialog.fillAmountAction(10_000) -// await depositDialog.actionsContainer.acceptAllActionsAction(2, fork) -// await depositDialog.clickBackToSavingsButton() - -// await savingsPage.clickWithdrawSUsdsButtonAction() -// withdrawDialog = new SavingsDialogPageObject({ page, type: 'withdraw' }) -// await withdrawDialog.selectAssetAction('USDC') -// await withdrawDialog.clickMaxAmountAction() -// }) - -// test('has correct action plan', async () => { -// await withdrawDialog.actionsContainer.expectActions([ -// { type: 'approve', asset: 'sUSDS' }, -// { type: 'withdrawFromSavings', asset: 'USDC', savingsAsset: 'sUSDS', mode: 'withdraw' }, -// ]) -// }) - -// test('displays transaction overview', async () => { -// await withdrawDialog.expectNativeRouteTransactionOverview({ -// routeItems: [ -// { -// tokenAmount: '9,999.77 sUSDS', -// tokenUsdValue: '$10,000.00', -// }, -// { -// tokenAmount: '10,000.00 USDS', -// tokenUsdValue: '$10,000.00', -// }, -// { -// tokenAmount: '10,000.00 USDC', -// tokenUsdValue: '$10,000.00', -// }, -// ], -// outcome: '10,000.00 USDC', -// outcomeUsd: '$10,000.00', -// }) - -// await withdrawDialog.expectUpgradeSwitchToBeHidden() -// }) - -// test('executes withdraw', async () => { -// const actionsContainer = new ActionsPageObject(withdrawDialog.locatePanelByHeader('Actions')) -// await actionsContainer.acceptAllActionsAction(2, fork) - -// await withdrawDialog.expectSuccessPage() -// await withdrawDialog.clickBackToSavingsButton() - -// await savingsPage.expectOpportunityStablecoinsAmount('~$10,000.00') -// await savingsPage.expectStablecoinsInWalletAssetBalance('USDC', '10,000') -// }) -// }) - -// test.describe('Withdraw USDC from sDAI', () => { -// const fork = setupFork({ blockNumber: DEFAULT_BLOCK_NUMBER, chainId: mainnet.id, useTenderlyVnet: true }) -// let savingsPage: SavingsPageObject -// let withdrawDialog: SavingsDialogPageObject - -// test.beforeEach(async ({ page }) => { -// await setup(page, fork, { -// initialPage: 'savings', -// account: { -// type: 'connected-random', -// assetBalances: { -// ETH: 1, -// sDAI: 10_000, -// }, -// }, -// }) - -// savingsPage = new SavingsPageObject(page) - -// await savingsPage.clickWithdrawSDaiButtonAction() -// withdrawDialog = new SavingsDialogPageObject({ page, type: 'withdraw' }) -// await withdrawDialog.selectAssetAction('USDC') -// await withdrawDialog.clickMaxAmountAction() -// }) - -// test('has correct action plan', async () => { -// await withdrawDialog.actionsContainer.expectActions([ -// { type: 'approve', asset: 'sDAI' }, -// { type: 'withdrawFromSavings', asset: 'USDC', savingsAsset: 'sDAI', mode: 'withdraw' }, -// ]) -// }) - -// test('displays transaction overview', async () => { -// await withdrawDialog.expectNativeRouteTransactionOverview({ -// routeItems: [ -// { -// tokenAmount: '10,000.00 sDAI', -// tokenUsdValue: '$11,085.91', -// }, -// { -// tokenAmount: '11,085.91 DAI', -// tokenUsdValue: '$11,085.91', -// }, -// { -// tokenAmount: '11,085.91 USDC', -// tokenUsdValue: '$11,085.91', -// }, -// ], -// outcome: '11,085.91 USDC', -// outcomeUsd: '$11,085.91', -// }) - -// await withdrawDialog.expectUpgradeSwitchToBeHidden() -// }) - -// test('executes withdraw', async () => { -// const actionsContainer = new ActionsPageObject(withdrawDialog.locatePanelByHeader('Actions')) -// await actionsContainer.acceptAllActionsAction(2, fork) - -// await withdrawDialog.expectSuccessPage() -// await withdrawDialog.clickBackToSavingsButton() - -// await savingsPage.expectOpportunityStablecoinsAmount('~$11,085.91') -// await savingsPage.expectStablecoinsInWalletAssetBalance('USDC', '11,085.91') -// }) -// }) +import { SavingsPageObject } from '@/pages/Savings.PageObject' +import { DEFAULT_BLOCK_NUMBER } from '@/test/e2e/constants' +import { setup } from '@/test/e2e/setup' +import { test } from '@playwright/test' +import { mainnet } from 'viem/chains' +import { SavingsDialogPageObject } from '../../../common/e2e/SavingsDialog.PageObject' + +test.describe('Withdraw USDC from sUSDS', () => { + let savingsPage: SavingsPageObject + let withdrawDialog: SavingsDialogPageObject + + test.beforeEach(async ({ page }) => { + const testContext = await setup(page, { + blockchain: { + chainId: mainnet.id, + blockNumber: DEFAULT_BLOCK_NUMBER, + }, + initialPage: 'savings', + account: { + type: 'connected-random', + assetBalances: { + ETH: 1, + USDS: 10_000, + }, + }, + }) + + savingsPage = new SavingsPageObject(testContext) + + await savingsPage.clickDepositButtonAction('USDS') + const depositDialog = new SavingsDialogPageObject({ testContext, type: 'deposit' }) + await depositDialog.fillAmountAction(10_000) + await depositDialog.actionsContainer.acceptAllActionsAction(2) + await depositDialog.clickBackToSavingsButton() + + await savingsPage.clickWithdrawSUsdsButtonAction() + withdrawDialog = new SavingsDialogPageObject({ testContext, type: 'withdraw' }) + await withdrawDialog.selectAssetAction('USDC') + await withdrawDialog.clickMaxAmountAction() + }) + + test('has correct action plan', async () => { + await withdrawDialog.actionsContainer.expectActions([ + { type: 'approve', asset: 'sUSDS' }, + { type: 'withdrawFromSavings', asset: 'USDC', savingsAsset: 'sUSDS', mode: 'withdraw' }, + ]) + }) + + test('displays transaction overview', async () => { + await withdrawDialog.expectNativeRouteTransactionOverview({ + routeItems: [ + { + tokenAmount: '9,830.34 sUSDS', + tokenUsdValue: '$10,000.00', + }, + { + tokenAmount: '10,000.00 USDS', + tokenUsdValue: '$10,000.00', + }, + { + tokenAmount: '10,000.00 USDC', + tokenUsdValue: '$10,000.00', + }, + ], + outcome: '10,000.00 USDC', + outcomeUsd: '$10,000.00', + }) + + await withdrawDialog.expectUpgradeSwitchToBeHidden() + }) + + test('executes withdraw', async () => { + await withdrawDialog.actionsContainer.acceptAllActionsAction(2) + + await withdrawDialog.expectSuccessPage() + await withdrawDialog.clickBackToSavingsButton() + + await savingsPage.expectOpportunityStablecoinsAmount('~$10,000.00') + await savingsPage.expectStablecoinsInWalletAssetBalance('USDC', '10,000') + }) +}) + +test.describe('Withdraw USDC from sDAI', () => { + let savingsPage: SavingsPageObject + let withdrawDialog: SavingsDialogPageObject + + test.beforeEach(async ({ page }) => { + const testContext = await setup(page, { + blockchain: { + chainId: mainnet.id, + blockNumber: DEFAULT_BLOCK_NUMBER, + }, + initialPage: 'savings', + account: { + type: 'connected-random', + assetBalances: { + ETH: 1, + sDAI: 10_000, + }, + }, + }) + + savingsPage = new SavingsPageObject(testContext) + + await savingsPage.clickWithdrawSDaiButtonAction() + withdrawDialog = new SavingsDialogPageObject({ testContext, type: 'withdraw' }) + await withdrawDialog.selectAssetAction('USDC') + await withdrawDialog.clickMaxAmountAction() + }) + + test('has correct action plan', async () => { + await withdrawDialog.actionsContainer.expectActions([ + { type: 'approve', asset: 'sDAI' }, + { type: 'withdrawFromSavings', asset: 'USDC', savingsAsset: 'sDAI', mode: 'withdraw' }, + ]) + }) + + test('displays transaction overview', async () => { + await withdrawDialog.expectNativeRouteTransactionOverview({ + routeItems: [ + { + tokenAmount: '10,000.00 sDAI', + tokenUsdValue: '$11,255.99', + }, + { + tokenAmount: '11,255.99 DAI', + tokenUsdValue: '$11,255.99', + }, + { + tokenAmount: '11,255.99 USDC', + tokenUsdValue: '$11,255.99', + }, + ], + outcome: '11,255.99 USDC', + outcomeUsd: '$11,255.99', + }) + + await withdrawDialog.expectUpgradeSwitchToBeHidden() + }) + + test('executes withdraw', async () => { + await withdrawDialog.actionsContainer.acceptAllActionsAction(2) + + await withdrawDialog.expectSuccessPage() + await withdrawDialog.clickBackToSavingsButton() + + await savingsPage.expectOpportunityStablecoinsAmount('~$11,255.99') + await savingsPage.expectStablecoinsInWalletAssetBalance('USDC', '11,255.99') + }) +}) diff --git a/packages/app/src/features/dialogs/savings/withdraw/e2e/mainnet/WithdrawMaxUSDS.test-e2e.ts b/packages/app/src/features/dialogs/savings/withdraw/e2e/mainnet/WithdrawMaxUSDS.test-e2e.ts index 2dcd77bab..82ea1b76a 100644 --- a/packages/app/src/features/dialogs/savings/withdraw/e2e/mainnet/WithdrawMaxUSDS.test-e2e.ts +++ b/packages/app/src/features/dialogs/savings/withdraw/e2e/mainnet/WithdrawMaxUSDS.test-e2e.ts @@ -1,142 +1,144 @@ -// import { ActionsPageObject } from '@/features/actions/ActionsContainer.PageObject' -// import { SavingsPageObject } from '@/pages/Savings.PageObject' -// import { DEFAULT_BLOCK_NUMBER } from '@/test/e2e/constants' -// import { setupFork } from '@/test/e2e/forking/setupFork' -// import { setup } from '@/test/e2e/setup' -// import { test } from '@playwright/test' -// import { mainnet } from 'viem/chains' -// import { SavingsDialogPageObject } from '../../../common/e2e/SavingsDialog.PageObject' - -// test.describe('Withdraw USDS from sUSDS', () => { -// const fork = setupFork({ blockNumber: DEFAULT_BLOCK_NUMBER, chainId: mainnet.id, useTenderlyVnet: true }) -// let savingsPage: SavingsPageObject -// let withdrawDialog: SavingsDialogPageObject - -// test.beforeEach(async ({ page }) => { -// await setup(page, fork, { -// initialPage: 'savings', -// account: { -// type: 'connected-random', -// assetBalances: { -// ETH: 1, -// USDS: 10_000, -// }, -// }, -// }) - -// savingsPage = new SavingsPageObject(page) - -// await savingsPage.clickDepositButtonAction('USDS') -// const depositDialog = new SavingsDialogPageObject({ page, type: 'deposit' }) -// await depositDialog.fillAmountAction(10_000) -// await depositDialog.actionsContainer.acceptAllActionsAction(2, fork) -// await depositDialog.clickBackToSavingsButton() - -// await savingsPage.clickWithdrawSUsdsButtonAction() -// withdrawDialog = new SavingsDialogPageObject({ page, type: 'withdraw' }) -// await withdrawDialog.clickMaxAmountAction() -// }) - -// test('uses native sUSDS withdraw', async () => { -// await withdrawDialog.actionsContainer.expectActions([ -// { type: 'withdrawFromSavings', asset: 'USDS', savingsAsset: 'sUSDS', mode: 'withdraw' }, -// ]) -// }) - -// test('displays transaction overview', async () => { -// await withdrawDialog.expectNativeRouteTransactionOverview({ -// routeItems: [ -// { -// tokenAmount: '9,999.77 sUSDS', -// tokenUsdValue: '$10,000.00', -// }, -// { -// tokenAmount: '10,000.00 USDS', -// tokenUsdValue: '$10,000.00', -// }, -// ], -// outcome: '10,000.00 USDS', -// outcomeUsd: '$10,000.00', -// }) - -// await withdrawDialog.expectUpgradeSwitchToBeHidden() -// }) - -// test('executes withdraw', async () => { -// const actionsContainer = new ActionsPageObject(withdrawDialog.locatePanelByHeader('Actions')) -// await actionsContainer.acceptAllActionsAction(1, fork) - -// await withdrawDialog.expectSuccessPage() -// await withdrawDialog.clickBackToSavingsButton() - -// await savingsPage.expectOpportunityStablecoinsAmount('~$10,000.00') -// await savingsPage.expectStablecoinsInWalletAssetBalance('USDS', '10,000') -// }) -// }) - -// test.describe('Withdraw USDS from sDAI', () => { -// const fork = setupFork({ blockNumber: DEFAULT_BLOCK_NUMBER, chainId: mainnet.id, useTenderlyVnet: true }) -// let savingsPage: SavingsPageObject -// let withdrawDialog: SavingsDialogPageObject - -// test.beforeEach(async ({ page }) => { -// await setup(page, fork, { -// initialPage: 'savings', -// account: { -// type: 'connected-random', -// assetBalances: { -// ETH: 1, -// sDAI: 10_000, -// }, -// }, -// }) - -// savingsPage = new SavingsPageObject(page) - -// await savingsPage.clickWithdrawSDaiButtonAction() -// withdrawDialog = new SavingsDialogPageObject({ page, type: 'withdraw' }) -// await withdrawDialog.selectAssetAction('USDS') -// await withdrawDialog.clickMaxAmountAction() -// }) - -// test('uses migrate sDAI to USDS action', async () => { -// await withdrawDialog.actionsContainer.expectActions([ -// { type: 'approve', asset: 'sDAI' }, -// { type: 'withdrawFromSavings', asset: 'USDS', savingsAsset: 'sDAI', mode: 'withdraw' }, -// ]) -// }) - -// test('displays transaction overview', async () => { -// await withdrawDialog.expectNativeRouteTransactionOverview({ -// routeItems: [ -// { -// tokenAmount: '10,000.00 sDAI', -// tokenUsdValue: '$11,085.91', -// }, -// { -// tokenAmount: '11,085.91 DAI', -// tokenUsdValue: '$11,085.91', -// }, -// { -// tokenAmount: '11,085.91 USDS', -// tokenUsdValue: '$11,085.91', -// }, -// ], -// outcome: '11,085.91 USDS', -// outcomeUsd: '$11,085.91', -// }) - -// await withdrawDialog.expectUpgradeSwitchToBeHidden() -// }) - -// test('executes withdraw', async () => { -// const actionsContainer = new ActionsPageObject(withdrawDialog.locatePanelByHeader('Actions')) -// await actionsContainer.acceptAllActionsAction(2, fork) - -// await withdrawDialog.expectSuccessPage() -// await withdrawDialog.clickBackToSavingsButton() - -// await savingsPage.expectOpportunityStablecoinsAmount('~$11,085.91') -// await savingsPage.expectStablecoinsInWalletAssetBalance('USDS', '11,085.91') -// }) -// }) +import { SavingsPageObject } from '@/pages/Savings.PageObject' +import { DEFAULT_BLOCK_NUMBER } from '@/test/e2e/constants' +import { setup } from '@/test/e2e/setup' +import { test } from '@playwright/test' +import { mainnet } from 'viem/chains' +import { SavingsDialogPageObject } from '../../../common/e2e/SavingsDialog.PageObject' + +test.describe('Withdraw USDS from sUSDS', () => { + let savingsPage: SavingsPageObject + let withdrawDialog: SavingsDialogPageObject + + test.beforeEach(async ({ page }) => { + const testContext = await setup(page, { + blockchain: { + chainId: mainnet.id, + blockNumber: DEFAULT_BLOCK_NUMBER, + }, + initialPage: 'savings', + account: { + type: 'connected-random', + assetBalances: { + ETH: 1, + USDS: 10_000, + }, + }, + }) + + savingsPage = new SavingsPageObject(testContext) + + await savingsPage.clickDepositButtonAction('USDS') + const depositDialog = new SavingsDialogPageObject({ testContext, type: 'deposit' }) + await depositDialog.fillAmountAction(10_000) + await depositDialog.actionsContainer.acceptAllActionsAction(2) + await depositDialog.clickBackToSavingsButton() + + await savingsPage.clickWithdrawSUsdsButtonAction() + withdrawDialog = new SavingsDialogPageObject({ testContext, type: 'withdraw' }) + await withdrawDialog.clickMaxAmountAction() + }) + + test('uses native sUSDS withdraw', async () => { + await withdrawDialog.actionsContainer.expectActions([ + { type: 'withdrawFromSavings', asset: 'USDS', savingsAsset: 'sUSDS', mode: 'withdraw' }, + ]) + }) + + test('displays transaction overview', async () => { + await withdrawDialog.expectNativeRouteTransactionOverview({ + routeItems: [ + { + tokenAmount: '9,830.34 sUSDS', + tokenUsdValue: '$10,000.00', + }, + { + tokenAmount: '10,000.00 USDS', + tokenUsdValue: '$10,000.00', + }, + ], + outcome: '10,000.00 USDS', + outcomeUsd: '$10,000.00', + }) + + await withdrawDialog.expectUpgradeSwitchToBeHidden() + }) + + test('executes withdraw', async () => { + await withdrawDialog.actionsContainer.acceptAllActionsAction(1) + + await withdrawDialog.expectSuccessPage() + await withdrawDialog.clickBackToSavingsButton() + + await savingsPage.expectOpportunityStablecoinsAmount('~$10,000.00') + await savingsPage.expectStablecoinsInWalletAssetBalance('USDS', '10,000') + }) +}) + +test.describe('Withdraw USDS from sDAI', () => { + let savingsPage: SavingsPageObject + let withdrawDialog: SavingsDialogPageObject + + test.beforeEach(async ({ page }) => { + const testContext = await setup(page, { + blockchain: { + chainId: mainnet.id, + blockNumber: DEFAULT_BLOCK_NUMBER, + }, + initialPage: 'savings', + account: { + type: 'connected-random', + assetBalances: { + ETH: 1, + sDAI: 10_000, + }, + }, + }) + + savingsPage = new SavingsPageObject(testContext) + + await savingsPage.clickWithdrawSDaiButtonAction() + withdrawDialog = new SavingsDialogPageObject({ testContext, type: 'withdraw' }) + await withdrawDialog.selectAssetAction('USDS') + await withdrawDialog.clickMaxAmountAction() + }) + + test('uses migrate sDAI to USDS action', async () => { + await withdrawDialog.actionsContainer.expectActions([ + { type: 'approve', asset: 'sDAI' }, + { type: 'withdrawFromSavings', asset: 'USDS', savingsAsset: 'sDAI', mode: 'withdraw' }, + ]) + }) + + test('displays transaction overview', async () => { + await withdrawDialog.expectNativeRouteTransactionOverview({ + routeItems: [ + { + tokenAmount: '10,000.00 sDAI', + tokenUsdValue: '$11,255.99', + }, + { + tokenAmount: '11,255.99 DAI', + tokenUsdValue: '$11,255.99', + }, + { + tokenAmount: '11,255.99 USDS', + tokenUsdValue: '$11,255.99', + }, + ], + outcome: '11,255.99 USDS', + outcomeUsd: '$11,255.99', + }) + + await withdrawDialog.expectUpgradeSwitchToBeHidden() + }) + + test('executes withdraw', async () => { + await withdrawDialog.actionsContainer.acceptAllActionsAction(2) + + await withdrawDialog.expectSuccessPage() + await withdrawDialog.clickBackToSavingsButton() + + await savingsPage.expectOpportunityStablecoinsAmount('~$11,255.99') + await savingsPage.expectStablecoinsInWalletAssetBalance('USDS', '11,255.99') + }) +}) diff --git a/packages/app/src/features/dialogs/savings/withdraw/e2e/mainnet/WithdrawUSDC.test-e2e.ts b/packages/app/src/features/dialogs/savings/withdraw/e2e/mainnet/WithdrawUSDC.test-e2e.ts index f1aad43ef..bf58c3d99 100644 --- a/packages/app/src/features/dialogs/savings/withdraw/e2e/mainnet/WithdrawUSDC.test-e2e.ts +++ b/packages/app/src/features/dialogs/savings/withdraw/e2e/mainnet/WithdrawUSDC.test-e2e.ts @@ -1,148 +1,150 @@ -// import { ActionsPageObject } from '@/features/actions/ActionsContainer.PageObject' -// import { SavingsPageObject } from '@/pages/Savings.PageObject' -// import { DEFAULT_BLOCK_NUMBER } from '@/test/e2e/constants' -// import { setupFork } from '@/test/e2e/forking/setupFork' -// import { setup } from '@/test/e2e/setup' -// import { test } from '@playwright/test' -// import { mainnet } from 'viem/chains' -// import { SavingsDialogPageObject } from '../../../common/e2e/SavingsDialog.PageObject' - -// test.describe('Withdraw USDC from sUSDS', () => { -// const fork = setupFork({ blockNumber: DEFAULT_BLOCK_NUMBER, chainId: mainnet.id, useTenderlyVnet: true }) -// let savingsPage: SavingsPageObject -// let withdrawDialog: SavingsDialogPageObject - -// test.beforeEach(async ({ page }) => { -// await setup(page, fork, { -// initialPage: 'savings', -// account: { -// type: 'connected-random', -// assetBalances: { -// ETH: 1, -// USDC: 10_000, -// }, -// }, -// }) - -// savingsPage = new SavingsPageObject(page) - -// await savingsPage.clickDepositButtonAction('USDC') -// const depositDialog = new SavingsDialogPageObject({ page, type: 'deposit' }) -// await depositDialog.fillAmountAction(10_000) -// await depositDialog.actionsContainer.acceptAllActionsAction(2, fork) -// await depositDialog.clickBackToSavingsButton() - -// await savingsPage.clickWithdrawSUsdsButtonAction() -// withdrawDialog = new SavingsDialogPageObject({ page, type: 'withdraw' }) -// await withdrawDialog.selectAssetAction('USDC') -// await withdrawDialog.fillAmountAction(1000) -// }) - -// test('has correct action plan', async () => { -// await withdrawDialog.actionsContainer.expectActions([ -// { type: 'approve', asset: 'sUSDS' }, -// { type: 'withdrawFromSavings', asset: 'USDC', savingsAsset: 'sUSDS', mode: 'withdraw' }, -// ]) -// }) - -// test('displays transaction overview', async () => { -// await withdrawDialog.expectNativeRouteTransactionOverview({ -// routeItems: [ -// { -// tokenAmount: '999.98 sUSDS', -// tokenUsdValue: '$1,000.00', -// }, -// { -// tokenAmount: '1,000.00 USDS', -// tokenUsdValue: '$1,000.00', -// }, -// { -// tokenAmount: '1,000.00 USDC', -// tokenUsdValue: '$1,000.00', -// }, -// ], -// outcome: '1,000.00 USDC', -// outcomeUsd: '$1,000.00', -// }) - -// await withdrawDialog.expectUpgradeSwitchToBeHidden() -// }) - -// test('executes withdraw', async () => { -// const actionsContainer = new ActionsPageObject(withdrawDialog.locatePanelByHeader('Actions')) -// await actionsContainer.acceptAllActionsAction(2, fork) - -// await withdrawDialog.expectSuccessPage() -// await withdrawDialog.clickBackToSavingsButton() - -// await savingsPage.expectSavingsUsdsBalance({ susdsBalance: '8,999.79 sUSDS', estimatedUsdsValue: '9,000' }) -// await savingsPage.expectStablecoinsInWalletAssetBalance('USDC', '1,000') -// }) -// }) - -// test.describe('Withdraw USDC from sDAI', () => { -// const fork = setupFork({ blockNumber: DEFAULT_BLOCK_NUMBER, chainId: mainnet.id, useTenderlyVnet: true }) -// let savingsPage: SavingsPageObject -// let withdrawDialog: SavingsDialogPageObject - -// test.beforeEach(async ({ page }) => { -// await setup(page, fork, { -// initialPage: 'savings', -// account: { -// type: 'connected-random', -// assetBalances: { -// ETH: 1, -// sDAI: 10_000, -// }, -// }, -// }) - -// savingsPage = new SavingsPageObject(page) - -// await savingsPage.clickWithdrawSDaiButtonAction() -// withdrawDialog = new SavingsDialogPageObject({ page, type: 'withdraw' }) -// await withdrawDialog.selectAssetAction('USDC') -// await withdrawDialog.fillAmountAction(1000) -// }) - -// test('has correct action plan', async () => { -// await withdrawDialog.actionsContainer.expectActions([ -// { type: 'approve', asset: 'sDAI' }, -// { type: 'withdrawFromSavings', asset: 'USDC', savingsAsset: 'sDAI', mode: 'withdraw' }, -// ]) -// }) - -// test('displays transaction overview', async () => { -// await withdrawDialog.expectNativeRouteTransactionOverview({ -// routeItems: [ -// { -// tokenAmount: '902.05 sDAI', -// tokenUsdValue: '$1,000.00', -// }, -// { -// tokenAmount: '1,000.00 DAI', -// tokenUsdValue: '$1,000.00', -// }, -// { -// tokenAmount: '1,000.00 USDC', -// tokenUsdValue: '$1,000.00', -// }, -// ], -// outcome: '1,000.00 USDC', -// outcomeUsd: '$1,000.00', -// }) - -// await withdrawDialog.expectUpgradeSwitchToBeHidden() -// }) - -// test('executes withdraw', async () => { -// const actionsContainer = new ActionsPageObject(withdrawDialog.locatePanelByHeader('Actions')) -// await actionsContainer.acceptAllActionsAction(2, fork) - -// await withdrawDialog.expectSuccessPage() -// await withdrawDialog.clickBackToSavingsButton() - -// await savingsPage.expectSavingsDaiBalance({ sdaiBalance: '9,097.95 sDAI', estimatedDaiValue: '10,085.90' }) -// await savingsPage.expectStablecoinsInWalletAssetBalance('USDC', '1,000') -// }) -// }) +import { SavingsPageObject } from '@/pages/Savings.PageObject' +import { DEFAULT_BLOCK_NUMBER } from '@/test/e2e/constants' +import { setup } from '@/test/e2e/setup' +import { test } from '@playwright/test' +import { mainnet } from 'viem/chains' +import { SavingsDialogPageObject } from '../../../common/e2e/SavingsDialog.PageObject' + +test.describe('Withdraw USDC from sUSDS', () => { + let savingsPage: SavingsPageObject + let withdrawDialog: SavingsDialogPageObject + + test.beforeEach(async ({ page }) => { + const testContext = await setup(page, { + blockchain: { + chainId: mainnet.id, + blockNumber: DEFAULT_BLOCK_NUMBER, + }, + initialPage: 'savings', + account: { + type: 'connected-random', + assetBalances: { + ETH: 1, + USDC: 10_000, + }, + }, + }) + + savingsPage = new SavingsPageObject(testContext) + + await savingsPage.clickDepositButtonAction('USDC') + const depositDialog = new SavingsDialogPageObject({ testContext, type: 'deposit' }) + await depositDialog.fillAmountAction(10_000) + await depositDialog.actionsContainer.acceptAllActionsAction(2) + await depositDialog.clickBackToSavingsButton() + + await savingsPage.clickWithdrawSUsdsButtonAction() + withdrawDialog = new SavingsDialogPageObject({ testContext, type: 'withdraw' }) + await withdrawDialog.selectAssetAction('USDC') + await withdrawDialog.fillAmountAction(1000) + }) + + test('has correct action plan', async () => { + await withdrawDialog.actionsContainer.expectActions([ + { type: 'approve', asset: 'sUSDS' }, + { type: 'withdrawFromSavings', asset: 'USDC', savingsAsset: 'sUSDS', mode: 'withdraw' }, + ]) + }) + + test('displays transaction overview', async () => { + await withdrawDialog.expectNativeRouteTransactionOverview({ + routeItems: [ + { + tokenAmount: '983.03 sUSDS', + tokenUsdValue: '$1,000.00', + }, + { + tokenAmount: '1,000.00 USDS', + tokenUsdValue: '$1,000.00', + }, + { + tokenAmount: '1,000.00 USDC', + tokenUsdValue: '$1,000.00', + }, + ], + outcome: '1,000.00 USDC', + outcomeUsd: '$1,000.00', + }) + + await withdrawDialog.expectUpgradeSwitchToBeHidden() + }) + + test('executes withdraw', async () => { + await withdrawDialog.actionsContainer.acceptAllActionsAction(2) + + await withdrawDialog.expectSuccessPage() + await withdrawDialog.clickBackToSavingsButton() + + await savingsPage.expectSavingsUsdsBalance({ susdsBalance: '8,847.31 sUSDS', estimatedUsdsValue: '9,000.000373' }) + await savingsPage.expectStablecoinsInWalletAssetBalance('USDC', '1,000') + }) +}) + +test.describe('Withdraw USDC from sDAI', () => { + let savingsPage: SavingsPageObject + let withdrawDialog: SavingsDialogPageObject + + test.beforeEach(async ({ page }) => { + const testContext = await setup(page, { + blockchain: { + chainId: mainnet.id, + blockNumber: DEFAULT_BLOCK_NUMBER, + }, + initialPage: 'savings', + account: { + type: 'connected-random', + assetBalances: { + ETH: 1, + sDAI: 10_000, + }, + }, + }) + + savingsPage = new SavingsPageObject(testContext) + + await savingsPage.clickWithdrawSDaiButtonAction() + withdrawDialog = new SavingsDialogPageObject({ testContext, type: 'withdraw' }) + await withdrawDialog.selectAssetAction('USDC') + await withdrawDialog.fillAmountAction(1000) + }) + + test('has correct action plan', async () => { + await withdrawDialog.actionsContainer.expectActions([ + { type: 'approve', asset: 'sDAI' }, + { type: 'withdrawFromSavings', asset: 'USDC', savingsAsset: 'sDAI', mode: 'withdraw' }, + ]) + }) + + test('displays transaction overview', async () => { + await withdrawDialog.expectNativeRouteTransactionOverview({ + routeItems: [ + { + tokenAmount: '888.42 sDAI', + tokenUsdValue: '$1,000.00', + }, + { + tokenAmount: '1,000.00 DAI', + tokenUsdValue: '$1,000.00', + }, + { + tokenAmount: '1,000.00 USDC', + tokenUsdValue: '$1,000.00', + }, + ], + outcome: '1,000.00 USDC', + outcomeUsd: '$1,000.00', + }) + + await withdrawDialog.expectUpgradeSwitchToBeHidden() + }) + + test('executes withdraw', async () => { + await withdrawDialog.actionsContainer.acceptAllActionsAction(2) + + await withdrawDialog.expectSuccessPage() + await withdrawDialog.clickBackToSavingsButton() + + await savingsPage.expectSavingsDaiBalance({ sdaiBalance: '9,111.58 sDAI', estimatedDaiValue: '10,255.992013' }) + await savingsPage.expectStablecoinsInWalletAssetBalance('USDC', '1,000') + }) +}) diff --git a/packages/app/src/features/dialogs/savings/withdraw/e2e/mainnet/WithdrawUSDS.test-e2e.ts b/packages/app/src/features/dialogs/savings/withdraw/e2e/mainnet/WithdrawUSDS.test-e2e.ts index f8fef0553..0382178d0 100644 --- a/packages/app/src/features/dialogs/savings/withdraw/e2e/mainnet/WithdrawUSDS.test-e2e.ts +++ b/packages/app/src/features/dialogs/savings/withdraw/e2e/mainnet/WithdrawUSDS.test-e2e.ts @@ -1,142 +1,144 @@ -// import { ActionsPageObject } from '@/features/actions/ActionsContainer.PageObject' -// import { SavingsPageObject } from '@/pages/Savings.PageObject' -// import { DEFAULT_BLOCK_NUMBER } from '@/test/e2e/constants' -// import { setupFork } from '@/test/e2e/forking/setupFork' -// import { setup } from '@/test/e2e/setup' -// import { test } from '@playwright/test' -// import { mainnet } from 'viem/chains' -// import { SavingsDialogPageObject } from '../../../common/e2e/SavingsDialog.PageObject' - -// test.describe('Withdraw USDS from sUSDS', () => { -// const fork = setupFork({ blockNumber: DEFAULT_BLOCK_NUMBER, chainId: mainnet.id, useTenderlyVnet: true }) -// let savingsPage: SavingsPageObject -// let withdrawDialog: SavingsDialogPageObject - -// test.beforeEach(async ({ page }) => { -// await setup(page, fork, { -// initialPage: 'savings', -// account: { -// type: 'connected-random', -// assetBalances: { -// ETH: 1, -// USDS: 10_000, -// }, -// }, -// }) - -// savingsPage = new SavingsPageObject(page) - -// await savingsPage.clickDepositButtonAction('USDS') -// const depositDialog = new SavingsDialogPageObject({ page, type: 'deposit' }) -// await depositDialog.fillAmountAction(10_000) -// await depositDialog.actionsContainer.acceptAllActionsAction(2, fork) -// await depositDialog.clickBackToSavingsButton() - -// await savingsPage.clickWithdrawSUsdsButtonAction() -// withdrawDialog = new SavingsDialogPageObject({ page, type: 'withdraw' }) -// await withdrawDialog.fillAmountAction(1000) -// }) - -// test('uses native sUSDS withdraw', async () => { -// await withdrawDialog.actionsContainer.expectActions([ -// { type: 'withdrawFromSavings', asset: 'USDS', savingsAsset: 'sUSDS', mode: 'withdraw' }, -// ]) -// }) - -// test('displays transaction overview', async () => { -// await withdrawDialog.expectNativeRouteTransactionOverview({ -// routeItems: [ -// { -// tokenAmount: '999.98 sUSDS', -// tokenUsdValue: '$1,000.00', -// }, -// { -// tokenAmount: '1,000.00 USDS', -// tokenUsdValue: '$1,000.00', -// }, -// ], -// outcome: '1,000.00 USDS', -// outcomeUsd: '$1,000.00', -// }) - -// await withdrawDialog.expectUpgradeSwitchToBeHidden() -// }) - -// test('executes withdraw', async () => { -// const actionsContainer = new ActionsPageObject(withdrawDialog.locatePanelByHeader('Actions')) -// await actionsContainer.acceptAllActionsAction(1, fork) - -// await withdrawDialog.expectSuccessPage() -// await withdrawDialog.clickBackToSavingsButton() - -// await savingsPage.expectSavingsUsdsBalance({ susdsBalance: '8,999.79 sUSDS', estimatedUsdsValue: '9,000' }) -// await savingsPage.expectStablecoinsInWalletAssetBalance('USDS', '1,000') -// }) -// }) - -// test.describe('Withdraw USDS from sDAI', () => { -// const fork = setupFork({ blockNumber: DEFAULT_BLOCK_NUMBER, chainId: mainnet.id, useTenderlyVnet: true }) -// let savingsPage: SavingsPageObject -// let withdrawDialog: SavingsDialogPageObject - -// test.beforeEach(async ({ page }) => { -// await setup(page, fork, { -// initialPage: 'savings', -// account: { -// type: 'connected-random', -// assetBalances: { -// ETH: 1, -// sDAI: 10_000, -// }, -// }, -// }) - -// savingsPage = new SavingsPageObject(page) - -// await savingsPage.clickWithdrawSDaiButtonAction() -// withdrawDialog = new SavingsDialogPageObject({ page, type: 'withdraw' }) -// await withdrawDialog.selectAssetAction('USDS') -// await withdrawDialog.fillAmountAction(1000) -// }) - -// test('uses migrate sDAI to USDS action', async () => { -// await withdrawDialog.actionsContainer.expectActions([ -// { type: 'approve', asset: 'sDAI' }, -// { type: 'withdrawFromSavings', asset: 'USDS', savingsAsset: 'sDAI', mode: 'withdraw' }, -// ]) -// }) - -// test('displays transaction overview', async () => { -// await withdrawDialog.expectNativeRouteTransactionOverview({ -// routeItems: [ -// { -// tokenAmount: '902.05 sDAI', -// tokenUsdValue: '$1,000.00', -// }, -// { -// tokenAmount: '1,000.00 DAI', -// tokenUsdValue: '$1,000.00', -// }, -// { -// tokenAmount: '1,000.00 USDS', -// tokenUsdValue: '$1,000.00', -// }, -// ], -// outcome: '1,000.00 USDS', -// outcomeUsd: '$1,000.00', -// }) - -// await withdrawDialog.expectUpgradeSwitchToBeHidden() -// }) - -// test('executes withdraw', async () => { -// const actionsContainer = new ActionsPageObject(withdrawDialog.locatePanelByHeader('Actions')) -// await actionsContainer.acceptAllActionsAction(2, fork) - -// await withdrawDialog.expectSuccessPage() -// await withdrawDialog.clickBackToSavingsButton() - -// await savingsPage.expectSavingsDaiBalance({ sdaiBalance: '9,097.95 sDAI', estimatedDaiValue: '10,085.90' }) -// await savingsPage.expectStablecoinsInWalletAssetBalance('USDS', '1,000') -// }) -// }) +import { SavingsPageObject } from '@/pages/Savings.PageObject' +import { DEFAULT_BLOCK_NUMBER } from '@/test/e2e/constants' +import { setup } from '@/test/e2e/setup' +import { test } from '@playwright/test' +import { mainnet } from 'viem/chains' +import { SavingsDialogPageObject } from '../../../common/e2e/SavingsDialog.PageObject' + +test.describe('Withdraw USDS from sUSDS', () => { + let savingsPage: SavingsPageObject + let withdrawDialog: SavingsDialogPageObject + + test.beforeEach(async ({ page }) => { + const testContext = await setup(page, { + blockchain: { + chainId: mainnet.id, + blockNumber: DEFAULT_BLOCK_NUMBER, + }, + initialPage: 'savings', + account: { + type: 'connected-random', + assetBalances: { + ETH: 1, + USDS: 10_000, + }, + }, + }) + + savingsPage = new SavingsPageObject(testContext) + + await savingsPage.clickDepositButtonAction('USDS') + const depositDialog = new SavingsDialogPageObject({ testContext, type: 'deposit' }) + await depositDialog.fillAmountAction(10_000) + await depositDialog.actionsContainer.acceptAllActionsAction(2) + await depositDialog.clickBackToSavingsButton() + + await savingsPage.clickWithdrawSUsdsButtonAction() + withdrawDialog = new SavingsDialogPageObject({ testContext, type: 'withdraw' }) + await withdrawDialog.fillAmountAction(1000) + }) + + test('uses native sUSDS withdraw', async () => { + await withdrawDialog.actionsContainer.expectActions([ + { type: 'withdrawFromSavings', asset: 'USDS', savingsAsset: 'sUSDS', mode: 'withdraw' }, + ]) + }) + + test('displays transaction overview', async () => { + await withdrawDialog.expectNativeRouteTransactionOverview({ + routeItems: [ + { + tokenAmount: '983.03 sUSDS', + tokenUsdValue: '$1,000.00', + }, + { + tokenAmount: '1,000.00 USDS', + tokenUsdValue: '$1,000.00', + }, + ], + outcome: '1,000.00 USDS', + outcomeUsd: '$1,000.00', + }) + + await withdrawDialog.expectUpgradeSwitchToBeHidden() + }) + + test('executes withdraw', async () => { + await withdrawDialog.actionsContainer.acceptAllActionsAction(1) + + await withdrawDialog.expectSuccessPage() + await withdrawDialog.clickBackToSavingsButton() + + await savingsPage.expectSavingsUsdsBalance({ susdsBalance: '8,847.31 sUSDS', estimatedUsdsValue: '9,000.000187' }) + await savingsPage.expectStablecoinsInWalletAssetBalance('USDS', '1,000') + }) +}) + +test.describe('Withdraw USDS from sDAI', () => { + let savingsPage: SavingsPageObject + let withdrawDialog: SavingsDialogPageObject + + test.beforeEach(async ({ page }) => { + const testContext = await setup(page, { + blockchain: { + chainId: mainnet.id, + blockNumber: DEFAULT_BLOCK_NUMBER, + }, + initialPage: 'savings', + account: { + type: 'connected-random', + assetBalances: { + ETH: 1, + sDAI: 10_000, + }, + }, + }) + + savingsPage = new SavingsPageObject(testContext) + + await savingsPage.clickWithdrawSDaiButtonAction() + withdrawDialog = new SavingsDialogPageObject({ testContext, type: 'withdraw' }) + await withdrawDialog.selectAssetAction('USDS') + await withdrawDialog.fillAmountAction(1000) + }) + + test('uses migrate sDAI to USDS action', async () => { + await withdrawDialog.actionsContainer.expectActions([ + { type: 'approve', asset: 'sDAI' }, + { type: 'withdrawFromSavings', asset: 'USDS', savingsAsset: 'sDAI', mode: 'withdraw' }, + ]) + }) + + test('displays transaction overview', async () => { + await withdrawDialog.expectNativeRouteTransactionOverview({ + routeItems: [ + { + tokenAmount: '888.42 sDAI', + tokenUsdValue: '$1,000.00', + }, + { + tokenAmount: '1,000.00 DAI', + tokenUsdValue: '$1,000.00', + }, + { + tokenAmount: '1,000.00 USDS', + tokenUsdValue: '$1,000.00', + }, + ], + outcome: '1,000.00 USDS', + outcomeUsd: '$1,000.00', + }) + + await withdrawDialog.expectUpgradeSwitchToBeHidden() + }) + + test('executes withdraw', async () => { + await withdrawDialog.actionsContainer.acceptAllActionsAction(2) + + await withdrawDialog.expectSuccessPage() + await withdrawDialog.clickBackToSavingsButton() + + await savingsPage.expectSavingsDaiBalance({ sdaiBalance: '9,111.58 sDAI', estimatedDaiValue: '10,255.992013' }) + await savingsPage.expectStablecoinsInWalletAssetBalance('USDS', '1,000') + }) +})