From 2ba6a80534becff07c2c7e0a4b2b769ea004fab0 Mon Sep 17 00:00:00 2001 From: oskarvu Date: Thu, 19 Dec 2024 17:00:25 +0700 Subject: [PATCH] Add unstake usdc tests --- .../e2e/mainnet/UnstakeUSDC.test-e2e.ts | 174 +++++++++--------- .../e2e/mainnet/WithdrawMaxUSDS.test-e2e.ts | 4 +- 2 files changed, 90 insertions(+), 88 deletions(-) diff --git a/packages/app/src/features/farm-details/dialogs/unstake/e2e/mainnet/UnstakeUSDC.test-e2e.ts b/packages/app/src/features/farm-details/dialogs/unstake/e2e/mainnet/UnstakeUSDC.test-e2e.ts index eaa8366d9..e5788c604 100644 --- a/packages/app/src/features/farm-details/dialogs/unstake/e2e/mainnet/UnstakeUSDC.test-e2e.ts +++ b/packages/app/src/features/farm-details/dialogs/unstake/e2e/mainnet/UnstakeUSDC.test-e2e.ts @@ -1,99 +1,101 @@ -// import { FarmDetailsPageObject } from '@/features/farm-details/FarmDetails.PageObject' -// import { DEFAULT_BLOCK_NUMBER } from '@/test/e2e/constants' -// import { setupFork } from '@/test/e2e/forking/setupFork' -// import { overrideInfoSkyRouteWithHAR } from '@/test/e2e/info-sky' -// import { setup } from '@/test/e2e/setup' -// import { test } from '@playwright/test' -// import { mainnet } from 'viem/chains' -// import { StakeDialogPageObject } from '../../../stake/StakeDialog.PageObject' -// import { UnstakeDialogPageObject } from '../../UnstakeDialog.PageObject' +import { FarmDetailsPageObject } from '@/features/farm-details/FarmDetails.PageObject' +import { DEFAULT_BLOCK_NUMBER } from '@/test/e2e/constants' +import { overrideInfoSkyRouteWithHAR } from '@/test/e2e/info-sky' +import { setup } from '@/test/e2e/setup' +import { test } from '@playwright/test' +import { mainnet } from 'viem/chains' +import { StakeDialogPageObject } from '../../../stake/StakeDialog.PageObject' +import { UnstakeDialogPageObject } from '../../UnstakeDialog.PageObject' -// test.describe('Unstake USDC from SKY farm', () => { -// const fork = setupFork({ blockNumber: DEFAULT_BLOCK_NUMBER, chainId: mainnet.id, useTenderlyVnet: true }) -// let farmDetailsPage: FarmDetailsPageObject -// let unstakeDialog: UnstakeDialogPageObject -// let stakeDialog: StakeDialogPageObject +test.describe('Unstake USDC from SKY farm', () => { + let farmDetailsPage: FarmDetailsPageObject + let unstakeDialog: UnstakeDialogPageObject + let stakeDialog: StakeDialogPageObject -// test.beforeEach(async ({ page }) => { -// await setup(page, fork, { -// initialPage: 'farmDetails', -// initialPageParams: { -// chainId: mainnet.id.toString(), -// address: '0x0650CAF159C5A49f711e8169D4336ECB9b950275', -// }, -// account: { -// type: 'connected-random', -// assetBalances: { -// ETH: 1, -// USDC: 10_000, -// USDS: 10_000, -// }, -// }, -// }) -// await overrideInfoSkyRouteWithHAR({ page, key: '1-sky-farm-with-8_51-apy' }) + test.beforeEach(async ({ page }) => { + const testContext = await setup(page, { + blockchain: { + blockNumber: DEFAULT_BLOCK_NUMBER, + chainId: mainnet.id, + }, + initialPage: 'farmDetails', + initialPageParams: { + chainId: mainnet.id.toString(), + address: '0x0650CAF159C5A49f711e8169D4336ECB9b950275', + }, + account: { + type: 'connected-random', + assetBalances: { + ETH: 1, + USDC: 10_000, + USDS: 10_000, + }, + }, + }) + await overrideInfoSkyRouteWithHAR({ page, key: '1-sky-farm-with-8_51-apy' }) -// farmDetailsPage = new FarmDetailsPageObject(page) -// await farmDetailsPage.clickInfoPanelStakeButtonAction() -// stakeDialog = new StakeDialogPageObject(page) + farmDetailsPage = new FarmDetailsPageObject(testContext) + await farmDetailsPage.clickInfoPanelStakeButtonAction() + stakeDialog = new StakeDialogPageObject(testContext) -// await stakeDialog.selectAssetAction('USDS') -// await stakeDialog.fillAmountAction(10_000) -// await stakeDialog.actionsContainer.acceptAllActionsAction(2) + await stakeDialog.selectAssetAction('USDS') + await stakeDialog.fillAmountAction(10_000) + await stakeDialog.actionsContainer.acceptAllActionsAction(2) -// await stakeDialog.clickBackToFarmAction() + await stakeDialog.clickBackToFarmAction() -// await fork.progressSimulation(page, 24 * 60 * 60) // 24 hours -// await page.reload() + await testContext.testnetController.progressSimulationAndMine(24 * 60 * 60) // 24 hours + await page.reload() -// await farmDetailsPage.clickInfoPanelUnstakeButtonAction() -// unstakeDialog = new UnstakeDialogPageObject(page) + await farmDetailsPage.clickInfoPanelUnstakeButtonAction() + unstakeDialog = new UnstakeDialogPageObject(testContext) -// await unstakeDialog.selectAssetAction('USDC') -// await unstakeDialog.fillAmountAction(5_000) -// }) + await unstakeDialog.selectAssetAction('USDC') + await unstakeDialog.fillAmountAction(5_000) + }) -// test('has correct action plan', async () => { -// await unstakeDialog.actionsContainer.expectActions([ -// { type: 'unstake', stakingToken: 'USDS', rewardToken: 'SKY', exit: false }, -// { type: 'approve', asset: 'USDS' }, -// { type: 'psmConvert', inToken: 'USDS', outToken: 'USDC' }, -// ]) -// }) + test('has correct action plan', async () => { + await unstakeDialog.actionsContainer.expectActions([ + { type: 'unstake', stakingToken: 'USDS', rewardToken: 'SKY', exit: false }, + { type: 'approve', asset: 'USDS' }, + { type: 'psmConvert', inToken: 'USDS', outToken: 'USDC' }, + ]) + }) -// test('displays transaction overview', async () => { -// await unstakeDialog.expectTransactionOverview({ -// route: { -// swaps: [ -// { -// tokenAmount: '5,000.00 USDS', -// tokenUsdValue: '$5,000.00', -// }, -// { -// tokenAmount: '5,000.00 USDC', -// tokenUsdValue: '$5,000.00', -// }, -// ], -// farm: { -// upperText: 'SKY Farm', -// lowerText: 'Deposited', -// }, -// }, -// outcome: '5,000.00 USDC', -// }) -// }) + test('displays transaction overview', async () => { + await unstakeDialog.expectTransactionOverview({ + route: { + swaps: [ + { + tokenAmount: '5,000.00 USDS', + tokenUsdValue: '$5,000.00', + }, + { + tokenAmount: '5,000.00 USDC', + tokenUsdValue: '$5,000.00', + }, + ], + farm: { + upperText: 'SKY Farm', + lowerText: 'Deposited', + }, + }, + outcome: '5,000.00 USDC', + }) + }) -// test('executes transaction', async () => { -// await unstakeDialog.actionsContainer.acceptAllActionsAction(3) + test('executes transaction', async () => { + await unstakeDialog.actionsContainer.acceptAllActionsAction(3) -// await unstakeDialog.expectSuccessPage() -// await unstakeDialog.clickBackToFarmAction() + await unstakeDialog.expectSuccessPage() + await unstakeDialog.clickBackToFarmAction() -// await farmDetailsPage.expectTokenToDepositBalance('USDC', '15,000.00') -// await farmDetailsPage.expectTokenToDepositBalance('USDS', '-') -// await farmDetailsPage.expectReward({ -// reward: '3,539', -// rewardUsd: '$213', -// }) -// await farmDetailsPage.expectStaked({ amount: '5,000.00', asset: 'USDS' }) -// }) -// }) + await farmDetailsPage.expectTokenToDepositBalance('USDC', '15,000.00') + await farmDetailsPage.expectTokenToDepositBalance('USDS', '-') + await farmDetailsPage.expectReward({ + reward: '49.441', + rewardUsd: '2.98', + }) + await farmDetailsPage.expectStaked({ amount: '5,000.00', asset: 'USDS' }) + }) +}) diff --git a/packages/app/src/features/farm-details/dialogs/unstake/e2e/mainnet/WithdrawMaxUSDS.test-e2e.ts b/packages/app/src/features/farm-details/dialogs/unstake/e2e/mainnet/WithdrawMaxUSDS.test-e2e.ts index e351fb21b..88e08f073 100644 --- a/packages/app/src/features/farm-details/dialogs/unstake/e2e/mainnet/WithdrawMaxUSDS.test-e2e.ts +++ b/packages/app/src/features/farm-details/dialogs/unstake/e2e/mainnet/WithdrawMaxUSDS.test-e2e.ts @@ -67,7 +67,7 @@ test.describe('Withdraw max USDS from SKY farm', () => { await unstakeDialog.expectExitFarmSwitchReward({ amount: 49.44, token: 'SKY', - usdValue: '213', + usdValue: '2.98', }) }) @@ -139,7 +139,7 @@ test.describe('Withdraw max USDS from SKY farm', () => { await farmDetailsPage.expectTokenToDepositBalance('USDS', '10,000.00') await farmDetailsPage.expectReward({ reward: '49.436543', - rewardUsd: '$2.98', + rewardUsd: '2.98', }) })