From 4df64349359782eb074bc2134b11352a82254a9a Mon Sep 17 00:00:00 2001 From: oskarvu Date: Thu, 19 Dec 2024 13:33:31 +0700 Subject: [PATCH 1/6] Update dai farm unstake --- .../unstake/UnstakeDialog.PageObject.ts | 293 +++++++++--------- .../e2e/mainnet/UnstakeDAI.test-e2e.ts | 174 ++++++----- 2 files changed, 235 insertions(+), 232 deletions(-) diff --git a/packages/app/src/features/farm-details/dialogs/unstake/UnstakeDialog.PageObject.ts b/packages/app/src/features/farm-details/dialogs/unstake/UnstakeDialog.PageObject.ts index 3c701638f..c792a330b 100644 --- a/packages/app/src/features/farm-details/dialogs/unstake/UnstakeDialog.PageObject.ts +++ b/packages/app/src/features/farm-details/dialogs/unstake/UnstakeDialog.PageObject.ts @@ -1,146 +1,147 @@ -// import { DialogPageObject } from '@/features/dialogs/common/Dialog.PageObject' -// import { testIds } from '@/ui/utils/testIds' -// import { Page, expect } from '@playwright/test' - -// export class UnstakeDialogPageObject extends DialogPageObject { -// constructor(page: Page) { -// super(page, /Withdraw/) -// } - -// // #region actions -// async clickBackToFarmAction(): Promise { -// await this.page.getByRole('button', { name: 'Back to Farm' }).click() -// await this.region.waitFor({ -// state: 'detached', -// }) -// } - -// async clickExitFarmSwitchAction(): Promise { -// await this.page.getByTestId(testIds.farmDetails.unstakeDialog.exitFarmSwitchPanel.switch).click() -// } -// // - -// // #region assertions -// async expectExitFarmSwitchToBeHidden(): Promise { -// await expect(this.page.getByTestId(testIds.farmDetails.unstakeDialog.exitFarmSwitchPanel.switch)).toBeHidden() -// } - -// async expectExitFarmSwitchToBeVisible(): Promise { -// await expect(this.page.getByTestId(testIds.farmDetails.unstakeDialog.exitFarmSwitchPanel.switch)).toBeVisible() -// } - -// async expectExitFarmSwitchNotChecked(): Promise { -// await expect(this.page.getByTestId(testIds.farmDetails.unstakeDialog.exitFarmSwitchPanel.switch)).not.toBeChecked() -// } - -// async expectExitFarmSwitchReward({ min, max, token, usdValue }: Reward): Promise { -// const regexp = /~([\d,\.]+) (\w+) \(~\$([\d,\.]+)\)/ -// const rewardRowText = await this.page -// .getByTestId(testIds.farmDetails.unstakeDialog.exitFarmSwitchPanel.reward) -// .textContent() - -// const match = rewardRowText?.match(regexp) -// expect(match).toBeDefined() - -// const [rewardAmount, rewardToken, rewardUsdValue] = match!.slice(1) -// const rewardNumber = Number(rewardAmount?.replace(/,/g, '')) -// expect(rewardNumber).toBeGreaterThanOrEqual(min) -// expect(rewardNumber).toBeLessThanOrEqual(max) -// expect(rewardToken).toBe(token) -// expect(rewardUsdValue).toContain(usdValue) -// } - -// async expectRoutesOverview(route: Route): Promise { -// const routeItemTestIds = testIds.dialog.transactionOverview.routeItem -// const txOverviewTestIds = testIds.farmDetails.unstakeDialog.transactionOverview - -// for (let i = 0; i < route.swaps.length; i++) { -// // i + 1 because the first item in route is farm itself -// await expect(this.page.getByTestId(routeItemTestIds.tokenWithAmount(i + 1))).toContainText( -// route.swaps[i]!.tokenAmount, -// ) -// await expect(this.page.getByTestId(routeItemTestIds.tokenUsdValue(i + 1))).toContainText( -// route.swaps[i]!.tokenUsdValue, -// ) -// } - -// await expect(this.page.getByTestId(txOverviewTestIds.route.farm.farmName)).toContainText(route.farm.upperText) -// await expect(this.page.getByTestId(txOverviewTestIds.route.farm.stakingToken)).toContainText(route.farm.lowerText) -// } - -// async expectTransactionOverview({ route, outcome }: TransactionOverview): Promise { -// await this.expectRoutesOverview(route) -// await expect(this.page.getByTestId(testIds.farmDetails.unstakeDialog.transactionOverview.outcome)).toContainText( -// outcome, -// ) -// } - -// async expectExitTransactionOverview({ route, reward, outcome }: ExitTransactionOverview): Promise { -// await this.expectRoutesOverview(route) - -// await expect(this.page.getByTestId(testIds.farmDetails.unstakeDialog.transactionOverview.outcome)).toContainText( -// outcome.amount, -// ) -// await expect(this.page.getByTestId(testIds.farmDetails.unstakeDialog.transactionOverview.outcome)).toContainText( -// outcome.token, -// ) -// await expect(this.page.getByTestId(testIds.farmDetails.unstakeDialog.transactionOverview.outcomeUsd)).toContainText( -// outcome.usdValue, -// ) - -// const rewardAmount = await this.page -// .getByTestId(testIds.farmDetails.unstakeDialog.transactionOverview.rewardOutcome) -// .textContent() -// const rewardNumber = Number(rewardAmount?.replace(/[^0-9.]/g, '')) - -// expect(rewardNumber).toBeGreaterThanOrEqual(reward.min) -// expect(rewardNumber).toBeLessThanOrEqual(reward.max) -// await expect( -// this.page.getByTestId(testIds.farmDetails.unstakeDialog.transactionOverview.rewardOutcome), -// ).toContainText(reward.token) -// await expect( -// this.page.getByTestId(testIds.farmDetails.unstakeDialog.transactionOverview.rewardOutcomeUsd), -// ).toContainText(reward.usdValue) -// } - -// async expectSuccessPage(): Promise { -// // for now we only check if the success message is visible -// await expect(this.page.getByText('Congrats, all done!')).toBeVisible() -// } -// // #endregion -// } - -// export interface Reward { -// min: number -// max: number -// token: string -// usdValue: string -// } - -// export interface Outome { -// amount: string -// token: string -// usdValue: string -// } - -// export interface Route { -// swaps: { -// tokenAmount: string -// tokenUsdValue: string -// }[] -// farm: { -// upperText: string -// lowerText: string -// } -// } - -// export interface TransactionOverview { -// route: Route -// outcome: string -// } - -// export interface ExitTransactionOverview { -// route: Route -// reward: Reward -// outcome: Outome -// } +import { DialogPageObject } from '@/features/dialogs/common/Dialog.PageObject' +import { TestContext } from '@/test/e2e/setup' +import { testIds } from '@/ui/utils/testIds' +import { expect } from '@playwright/test' + +export class UnstakeDialogPageObject extends DialogPageObject { + constructor(testContext: TestContext) { + super({ testContext, header: /Withdraw/ }) + } + + // #region actions + async clickBackToFarmAction(): Promise { + await this.page.getByRole('button', { name: 'Back to Farm' }).click() + await this.region.waitFor({ + state: 'detached', + }) + } + + async clickExitFarmSwitchAction(): Promise { + await this.page.getByTestId(testIds.farmDetails.unstakeDialog.exitFarmSwitchPanel.switch).click() + } + // + + // #region assertions + async expectExitFarmSwitchToBeHidden(): Promise { + await expect(this.page.getByTestId(testIds.farmDetails.unstakeDialog.exitFarmSwitchPanel.switch)).toBeHidden() + } + + async expectExitFarmSwitchToBeVisible(): Promise { + await expect(this.page.getByTestId(testIds.farmDetails.unstakeDialog.exitFarmSwitchPanel.switch)).toBeVisible() + } + + async expectExitFarmSwitchNotChecked(): Promise { + await expect(this.page.getByTestId(testIds.farmDetails.unstakeDialog.exitFarmSwitchPanel.switch)).not.toBeChecked() + } + + async expectExitFarmSwitchReward({ min, max, token, usdValue }: Reward): Promise { + const regexp = /~([\d,\.]+) (\w+) \(~\$([\d,\.]+)\)/ + const rewardRowText = await this.page + .getByTestId(testIds.farmDetails.unstakeDialog.exitFarmSwitchPanel.reward) + .textContent() + + const match = rewardRowText?.match(regexp) + expect(match).toBeDefined() + + const [rewardAmount, rewardToken, rewardUsdValue] = match!.slice(1) + const rewardNumber = Number(rewardAmount?.replace(/,/g, '')) + expect(rewardNumber).toBeGreaterThanOrEqual(min) + expect(rewardNumber).toBeLessThanOrEqual(max) + expect(rewardToken).toBe(token) + expect(rewardUsdValue).toContain(usdValue) + } + + async expectRoutesOverview(route: Route): Promise { + const routeItemTestIds = testIds.dialog.transactionOverview.routeItem + const txOverviewTestIds = testIds.farmDetails.unstakeDialog.transactionOverview + + for (let i = 0; i < route.swaps.length; i++) { + // i + 1 because the first item in route is farm itself + await expect(this.page.getByTestId(routeItemTestIds.tokenWithAmount(i + 1))).toContainText( + route.swaps[i]!.tokenAmount, + ) + await expect(this.page.getByTestId(routeItemTestIds.tokenUsdValue(i + 1))).toContainText( + route.swaps[i]!.tokenUsdValue, + ) + } + + await expect(this.page.getByTestId(txOverviewTestIds.route.farm.farmName)).toContainText(route.farm.upperText) + await expect(this.page.getByTestId(txOverviewTestIds.route.farm.stakingToken)).toContainText(route.farm.lowerText) + } + + async expectTransactionOverview({ route, outcome }: TransactionOverview): Promise { + await this.expectRoutesOverview(route) + await expect(this.page.getByTestId(testIds.farmDetails.unstakeDialog.transactionOverview.outcome)).toContainText( + outcome, + ) + } + + async expectExitTransactionOverview({ route, reward, outcome }: ExitTransactionOverview): Promise { + await this.expectRoutesOverview(route) + + await expect(this.page.getByTestId(testIds.farmDetails.unstakeDialog.transactionOverview.outcome)).toContainText( + outcome.amount, + ) + await expect(this.page.getByTestId(testIds.farmDetails.unstakeDialog.transactionOverview.outcome)).toContainText( + outcome.token, + ) + await expect(this.page.getByTestId(testIds.farmDetails.unstakeDialog.transactionOverview.outcomeUsd)).toContainText( + outcome.usdValue, + ) + + const rewardAmount = await this.page + .getByTestId(testIds.farmDetails.unstakeDialog.transactionOverview.rewardOutcome) + .textContent() + const rewardNumber = Number(rewardAmount?.replace(/[^0-9.]/g, '')) + + expect(rewardNumber).toBeGreaterThanOrEqual(reward.min) + expect(rewardNumber).toBeLessThanOrEqual(reward.max) + await expect( + this.page.getByTestId(testIds.farmDetails.unstakeDialog.transactionOverview.rewardOutcome), + ).toContainText(reward.token) + await expect( + this.page.getByTestId(testIds.farmDetails.unstakeDialog.transactionOverview.rewardOutcomeUsd), + ).toContainText(reward.usdValue) + } + + async expectSuccessPage(): Promise { + // for now we only check if the success message is visible + await expect(this.page.getByText('Congrats, all done!')).toBeVisible() + } + // #endregion +} + +export interface Reward { + min: number + max: number + token: string + usdValue: string +} + +export interface Outome { + amount: string + token: string + usdValue: string +} + +export interface Route { + swaps: { + tokenAmount: string + tokenUsdValue: string + }[] + farm: { + upperText: string + lowerText: string + } +} + +export interface TransactionOverview { + route: Route + outcome: string +} + +export interface ExitTransactionOverview { + route: Route + reward: Reward + outcome: Outome +} diff --git a/packages/app/src/features/farm-details/dialogs/unstake/e2e/mainnet/UnstakeDAI.test-e2e.ts b/packages/app/src/features/farm-details/dialogs/unstake/e2e/mainnet/UnstakeDAI.test-e2e.ts index 3973db2a1..a61cd7d21 100644 --- a/packages/app/src/features/farm-details/dialogs/unstake/e2e/mainnet/UnstakeDAI.test-e2e.ts +++ b/packages/app/src/features/farm-details/dialogs/unstake/e2e/mainnet/UnstakeDAI.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 DAI 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 DAI 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, -// DAI: 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, + DAI: 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.progressSimulation(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('DAI') -// await unstakeDialog.fillAmountAction(5_000) -// }) + await unstakeDialog.selectAssetAction('DAI') + 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: 'downgrade', fromToken: 'USDS', toToken: 'DAI' }, -// ]) -// }) + test('has correct action plan', async () => { + await unstakeDialog.actionsContainer.expectActions([ + { type: 'unstake', stakingToken: 'USDS', rewardToken: 'SKY', exit: false }, + { type: 'approve', asset: 'USDS' }, + { type: 'downgrade', fromToken: 'USDS', toToken: 'DAI' }, + ]) + }) -// test('displays transaction overview', async () => { -// await unstakeDialog.expectTransactionOverview({ -// route: { -// swaps: [ -// { -// tokenAmount: '5,000.00 USDS', -// tokenUsdValue: '$5,000.00', -// }, -// { -// tokenAmount: '5,000.00 DAI', -// tokenUsdValue: '$5,000.00', -// }, -// ], -// farm: { -// upperText: 'SKY Farm', -// lowerText: 'Deposited', -// }, -// }, -// outcome: '5,000.00 DAI', -// }) -// }) + test('displays transaction overview', async () => { + await unstakeDialog.expectTransactionOverview({ + route: { + swaps: [ + { + tokenAmount: '5,000.00 USDS', + tokenUsdValue: '$5,000.00', + }, + { + tokenAmount: '5,000.00 DAI', + tokenUsdValue: '$5,000.00', + }, + ], + farm: { + upperText: 'SKY Farm', + lowerText: 'Deposited', + }, + }, + outcome: '5,000.00 DAI', + }) + }) -// 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('DAI', '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('DAI', '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' }) + }) +}) From e272ce067474b8b238634000a782fcd5b3803e84 Mon Sep 17 00:00:00 2001 From: oskarvu Date: Thu, 19 Dec 2024 14:53:34 +0700 Subject: [PATCH 2/6] Set progressed timestamp in browser --- .../claim/e2e/mainnet/ClaimSKY.test-e2e.ts | 3 +- .../unstake/UnstakeDialog.PageObject.ts | 11 +- .../e2e/mainnet/UnstakeDAI.test-e2e.ts | 1 - .../e2e/mainnet/UnstakeUSDS.test-e2e.ts | 380 +++++++++--------- .../e2e/mainnet/WithdrawMaxUSDC.test-e2e.ts | 321 ++++++++------- packages/app/src/test/e2e/setup.ts | 2 +- 6 files changed, 357 insertions(+), 361 deletions(-) diff --git a/packages/app/src/features/farm-details/dialogs/claim/e2e/mainnet/ClaimSKY.test-e2e.ts b/packages/app/src/features/farm-details/dialogs/claim/e2e/mainnet/ClaimSKY.test-e2e.ts index fdd9f0de6..1f6dd826b 100644 --- a/packages/app/src/features/farm-details/dialogs/claim/e2e/mainnet/ClaimSKY.test-e2e.ts +++ b/packages/app/src/features/farm-details/dialogs/claim/e2e/mainnet/ClaimSKY.test-e2e.ts @@ -44,7 +44,6 @@ test.describe('Claim SKY rewards', () => { await stakeDialog.actionsContainer.acceptAllActionsAction(2) await stakeDialog.clickBackToFarmAction() await testContext.testnetController.progressSimulationAndMine(24 * 60 * 60) // 24 hours - await page.reload() await farmDetailsPage.clickInfoPanelClaimButtonAction() claimDialog = new ClaimDialogPageObject(testContext) @@ -72,7 +71,7 @@ test.describe('Claim SKY rewards', () => { await farmDetailsPage.expectTokenToDepositBalance('USDS', '-') await farmDetailsPage.expectReward({ - reward: '0.001', + reward: '0.005', rewardUsd: '<$0.01', }) await farmDetailsPage.expectTokenBalance({ diff --git a/packages/app/src/features/farm-details/dialogs/unstake/UnstakeDialog.PageObject.ts b/packages/app/src/features/farm-details/dialogs/unstake/UnstakeDialog.PageObject.ts index c792a330b..cc6cf29f3 100644 --- a/packages/app/src/features/farm-details/dialogs/unstake/UnstakeDialog.PageObject.ts +++ b/packages/app/src/features/farm-details/dialogs/unstake/UnstakeDialog.PageObject.ts @@ -34,7 +34,7 @@ export class UnstakeDialogPageObject extends DialogPageObject { await expect(this.page.getByTestId(testIds.farmDetails.unstakeDialog.exitFarmSwitchPanel.switch)).not.toBeChecked() } - async expectExitFarmSwitchReward({ min, max, token, usdValue }: Reward): Promise { + async expectExitFarmSwitchReward({ amount, token, usdValue }: Reward): Promise { const regexp = /~([\d,\.]+) (\w+) \(~\$([\d,\.]+)\)/ const rewardRowText = await this.page .getByTestId(testIds.farmDetails.unstakeDialog.exitFarmSwitchPanel.reward) @@ -45,8 +45,7 @@ export class UnstakeDialogPageObject extends DialogPageObject { const [rewardAmount, rewardToken, rewardUsdValue] = match!.slice(1) const rewardNumber = Number(rewardAmount?.replace(/,/g, '')) - expect(rewardNumber).toBeGreaterThanOrEqual(min) - expect(rewardNumber).toBeLessThanOrEqual(max) + expect(rewardNumber).toBe(amount) expect(rewardToken).toBe(token) expect(rewardUsdValue).toContain(usdValue) } @@ -93,9 +92,8 @@ export class UnstakeDialogPageObject extends DialogPageObject { .getByTestId(testIds.farmDetails.unstakeDialog.transactionOverview.rewardOutcome) .textContent() const rewardNumber = Number(rewardAmount?.replace(/[^0-9.]/g, '')) + expect(rewardNumber).toBe(reward.amount) - expect(rewardNumber).toBeGreaterThanOrEqual(reward.min) - expect(rewardNumber).toBeLessThanOrEqual(reward.max) await expect( this.page.getByTestId(testIds.farmDetails.unstakeDialog.transactionOverview.rewardOutcome), ).toContainText(reward.token) @@ -112,8 +110,7 @@ export class UnstakeDialogPageObject extends DialogPageObject { } export interface Reward { - min: number - max: number + amount: number token: string usdValue: string } diff --git a/packages/app/src/features/farm-details/dialogs/unstake/e2e/mainnet/UnstakeDAI.test-e2e.ts b/packages/app/src/features/farm-details/dialogs/unstake/e2e/mainnet/UnstakeDAI.test-e2e.ts index a61cd7d21..184dea7b0 100644 --- a/packages/app/src/features/farm-details/dialogs/unstake/e2e/mainnet/UnstakeDAI.test-e2e.ts +++ b/packages/app/src/features/farm-details/dialogs/unstake/e2e/mainnet/UnstakeDAI.test-e2e.ts @@ -45,7 +45,6 @@ test.describe('Unstake DAI from SKY farm', () => { await stakeDialog.clickBackToFarmAction() await testContext.testnetController.progressSimulation(24 * 60 * 60) // 24 hours - await page.reload() await farmDetailsPage.clickInfoPanelUnstakeButtonAction() unstakeDialog = new UnstakeDialogPageObject(testContext) diff --git a/packages/app/src/features/farm-details/dialogs/unstake/e2e/mainnet/UnstakeUSDS.test-e2e.ts b/packages/app/src/features/farm-details/dialogs/unstake/e2e/mainnet/UnstakeUSDS.test-e2e.ts index 8dcd2e47f..55ea9e88d 100644 --- a/packages/app/src/features/farm-details/dialogs/unstake/e2e/mainnet/UnstakeUSDS.test-e2e.ts +++ b/packages/app/src/features/farm-details/dialogs/unstake/e2e/mainnet/UnstakeUSDS.test-e2e.ts @@ -1,188 +1,192 @@ -// 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 { privateKeyToAddress } from 'viem/accounts' -// import { mainnet } from 'viem/chains' -// import { StakeDialogPageObject } from '../../../stake/StakeDialog.PageObject' -// import { UnstakeDialogPageObject } from '../../UnstakeDialog.PageObject' - -// test.describe('Unstake USDS 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.beforeEach(async ({ page }) => { -// await setup(page, fork, { -// initialPage: 'farmDetails', -// initialPageParams: { -// chainId: mainnet.id.toString(), -// address: '0x0650CAF159C5A49f711e8169D4336ECB9b950275', -// }, -// account: { -// type: 'connected-random', -// assetBalances: { -// ETH: 1, -// DAI: 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) - -// await stakeDialog.selectAssetAction('DAI') -// await stakeDialog.fillAmountAction(10_000) -// await stakeDialog.actionsContainer.acceptAllActionsAction(4) - -// await stakeDialog.clickBackToFarmAction() - -// await fork.progressSimulation(page, 24 * 60 * 60) // 24 hours -// await page.reload() - -// await farmDetailsPage.clickInfoPanelUnstakeButtonAction() -// unstakeDialog = new UnstakeDialogPageObject(page) - -// await unstakeDialog.selectAssetAction('USDS') -// await unstakeDialog.fillAmountAction(5_000) -// }) - -// test('has exit farm switch hidden', async () => { -// await unstakeDialog.expectExitFarmSwitchToBeHidden() -// }) - -// test('has correct action plan', async () => { -// await unstakeDialog.actionsContainer.expectActions([ -// { type: 'unstake', stakingToken: 'USDS', rewardToken: 'SKY', exit: false }, -// ]) -// }) - -// test('displays transaction overview', async () => { -// await unstakeDialog.expectTransactionOverview({ -// route: { -// swaps: [ -// { -// tokenAmount: '5,000.00 USDS', -// tokenUsdValue: '$5,000.00', -// }, -// ], -// farm: { -// upperText: 'SKY Farm', -// lowerText: 'Deposited', -// }, -// }, -// outcome: '5,000.00 USDS', -// }) -// }) - -// test('executes transaction', async () => { -// await unstakeDialog.actionsContainer.acceptAllActionsAction(1) - -// await unstakeDialog.expectSuccessPage() -// await unstakeDialog.clickBackToFarmAction() - -// await farmDetailsPage.expectTokenToDepositBalance('USDS', '15,000.00') -// await farmDetailsPage.expectTokenToDepositBalance('DAI', '-') -// await farmDetailsPage.expectReward({ -// reward: '3,539', -// rewardUsd: '$213', -// }) -// await farmDetailsPage.expectStaked({ amount: '5,000.00', asset: 'USDS' }) -// }) -// }) - -// test.describe('Unstake USDS from CLE farm', () => { -// const testUserPKey = '0xa9f2d3eda4403df2fe54b97291d65d69824e0e2b3134c33b7145cf9b912966d5' -// const testUserAddress = privateKeyToAddress('0xa9f2d3eda4403df2fe54b97291d65d69824e0e2b3134c33b7145cf9b912966d5') -// const harSuffix = testUserAddress.slice(0, 10) - -// const fork = setupFork({ blockNumber: DEFAULT_BLOCK_NUMBER, chainId: mainnet.id, useTenderlyVnet: true }) -// let farmDetailsPage: FarmDetailsPageObject -// let unstakeDialog: UnstakeDialogPageObject - -// test.beforeEach(async ({ page }) => { -// await setup(page, fork, { -// initialPage: 'farmDetails', -// initialPageParams: { -// chainId: mainnet.id.toString(), -// address: '0x10ab606B067C9C461d8893c47C7512472E19e2Ce', -// }, -// account: { -// type: 'connected-pkey', -// privateKey: testUserPKey, -// assetBalances: { -// ETH: 1, -// USDS: 10_000, -// }, -// }, -// }) -// await overrideInfoSkyRouteWithHAR({ page, key: `2-cle-farm-0-balance-${harSuffix}` }) - -// farmDetailsPage = new FarmDetailsPageObject(page) -// await farmDetailsPage.clickInfoPanelStakeButtonAction() -// const stakeDialog = new StakeDialogPageObject(page) -// await stakeDialog.fillAmountAction(10_000) -// await stakeDialog.actionsContainer.acceptAllActionsAction(2) -// await stakeDialog.clickBackToFarmAction() - -// await overrideInfoSkyRouteWithHAR({ page, key: `3-cle-farm-10000-balance-${harSuffix}` }) -// await farmDetailsPage.clickInfoPanelUnstakeButtonAction() -// unstakeDialog = new UnstakeDialogPageObject(page) - -// await unstakeDialog.selectAssetAction('USDS') -// await unstakeDialog.fillAmountAction(5_000) -// }) - -// test('has correct action plan', async () => { -// await unstakeDialog.actionsContainer.expectActions([ -// { type: 'unstake', stakingToken: 'USDS', rewardToken: 'CLE', exit: false }, -// ]) -// }) - -// test('displays transaction overview', async () => { -// await unstakeDialog.expectTransactionOverview({ -// route: { -// swaps: [ -// { -// tokenAmount: '5,000.00 USDS', -// tokenUsdValue: '$5,000.00', -// }, -// ], -// farm: { -// upperText: 'CLE Farm', -// lowerText: 'Deposited', -// }, -// }, -// outcome: '5,000.00 USDS', -// }) -// }) - -// test('executes transaction', async ({ page }) => { -// await unstakeDialog.actionsContainer.acceptAllActionsAction(1) - -// await unstakeDialog.expectSuccessPage() -// await unstakeDialog.clickBackToFarmAction() - -// await farmDetailsPage.expectTokenToDepositBalance('USDS', '5,000.00') -// await farmDetailsPage.expectReward({ -// reward: '257.6', -// }) -// await farmDetailsPage.expectStaked({ amount: '5,000.00', asset: 'USDS' }) -// await farmDetailsPage.expectPointsSyncWarning() - -// await overrideInfoSkyRouteWithHAR({ page, key: `4-cle-farm-5000-balance-${harSuffix}` }) - -// await farmDetailsPage.expectReward({ -// reward: '257.6', -// }) -// await farmDetailsPage.expectPointsSyncWarningToBeHidden() -// await farmDetailsPage.expectInfoPanelClaimButtonToBeHidden() -// await farmDetailsPage.expectStaked({ amount: '5,000.00', asset: 'USDS' }) -// }) -// }) +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 { privateKeyToAddress } from 'viem/accounts' +import { mainnet } from 'viem/chains' +import { StakeDialogPageObject } from '../../../stake/StakeDialog.PageObject' +import { UnstakeDialogPageObject } from '../../UnstakeDialog.PageObject' + +test.describe('Unstake USDS from SKY farm', () => { + let farmDetailsPage: FarmDetailsPageObject + let unstakeDialog: UnstakeDialogPageObject + let stakeDialog: StakeDialogPageObject + + 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, + DAI: 10_000, + USDS: 10_000, + }, + }, + }) + await overrideInfoSkyRouteWithHAR({ page, key: '1-sky-farm-with-8_51-apy' }) + + farmDetailsPage = new FarmDetailsPageObject(testContext) + await farmDetailsPage.clickInfoPanelStakeButtonAction() + stakeDialog = new StakeDialogPageObject(testContext) + + await stakeDialog.selectAssetAction('DAI') + await stakeDialog.fillAmountAction(10_000) + await stakeDialog.actionsContainer.acceptAllActionsAction(4) + + await stakeDialog.clickBackToFarmAction() + + await testContext.testnetController.progressSimulation(24 * 60 * 60) // 24 hours + + await farmDetailsPage.clickInfoPanelUnstakeButtonAction() + unstakeDialog = new UnstakeDialogPageObject(testContext) + + await unstakeDialog.selectAssetAction('USDS') + await unstakeDialog.fillAmountAction(5_000) + }) + + test('has exit farm switch hidden', async () => { + await unstakeDialog.expectExitFarmSwitchToBeHidden() + }) + + test('has correct action plan', async () => { + await unstakeDialog.actionsContainer.expectActions([ + { type: 'unstake', stakingToken: 'USDS', rewardToken: 'SKY', exit: false }, + ]) + }) + + test('displays transaction overview', async () => { + await unstakeDialog.expectTransactionOverview({ + route: { + swaps: [ + { + tokenAmount: '5,000.00 USDS', + tokenUsdValue: '$5,000.00', + }, + ], + farm: { + upperText: 'SKY Farm', + lowerText: 'Deposited', + }, + }, + outcome: '5,000.00 USDS', + }) + }) + + test('executes transaction', async () => { + await unstakeDialog.actionsContainer.acceptAllActionsAction(1) + + await unstakeDialog.expectSuccessPage() + await unstakeDialog.clickBackToFarmAction() + + await farmDetailsPage.expectTokenToDepositBalance('USDS', '15,000.00') + await farmDetailsPage.expectTokenToDepositBalance('DAI', '-') + await farmDetailsPage.expectReward({ + reward: '49.438', + rewardUsd: '$2.98', + }) + await farmDetailsPage.expectStaked({ amount: '5,000.00', asset: 'USDS' }) + }) +}) + +test.describe('Unstake USDS from CLE farm', () => { + const testUserPKey = '0xa9f2d3eda4403df2fe54b97291d65d69824e0e2b3134c33b7145cf9b912966d5' + const testUserAddress = privateKeyToAddress('0xa9f2d3eda4403df2fe54b97291d65d69824e0e2b3134c33b7145cf9b912966d5') + const harSuffix = testUserAddress.slice(0, 10) + + let farmDetailsPage: FarmDetailsPageObject + let unstakeDialog: UnstakeDialogPageObject + + 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: '0x10ab606B067C9C461d8893c47C7512472E19e2Ce', + }, + account: { + type: 'connected-pkey', + privateKey: testUserPKey, + assetBalances: { + ETH: 1, + USDS: 10_000, + }, + }, + }) + await overrideInfoSkyRouteWithHAR({ page, key: `2-cle-farm-0-balance-${harSuffix}` }) + + farmDetailsPage = new FarmDetailsPageObject(testContext) + await farmDetailsPage.clickInfoPanelStakeButtonAction() + const stakeDialog = new StakeDialogPageObject(testContext) + await stakeDialog.fillAmountAction(10_000) + await stakeDialog.actionsContainer.acceptAllActionsAction(2) + await stakeDialog.clickBackToFarmAction() + + await overrideInfoSkyRouteWithHAR({ page, key: `3-cle-farm-10000-balance-${harSuffix}` }) + await farmDetailsPage.clickInfoPanelUnstakeButtonAction() + unstakeDialog = new UnstakeDialogPageObject(testContext) + + await unstakeDialog.selectAssetAction('USDS') + await unstakeDialog.fillAmountAction(5_000) + }) + + test('has correct action plan', async () => { + await unstakeDialog.actionsContainer.expectActions([ + { type: 'unstake', stakingToken: 'USDS', rewardToken: 'CLE', exit: false }, + ]) + }) + + test('displays transaction overview', async () => { + await unstakeDialog.expectTransactionOverview({ + route: { + swaps: [ + { + tokenAmount: '5,000.00 USDS', + tokenUsdValue: '$5,000.00', + }, + ], + farm: { + upperText: 'CLE Farm', + lowerText: 'Deposited', + }, + }, + outcome: '5,000.00 USDS', + }) + }) + + test('executes transaction', async ({ page }) => { + await unstakeDialog.actionsContainer.acceptAllActionsAction(1) + + await unstakeDialog.expectSuccessPage() + await unstakeDialog.clickBackToFarmAction() + + await farmDetailsPage.expectTokenToDepositBalance('USDS', '5,000.00') + await farmDetailsPage.expectReward({ + reward: '257.5', + }) + await farmDetailsPage.expectStaked({ amount: '5,000.00', asset: 'USDS' }) + await farmDetailsPage.expectPointsSyncWarning() + + await overrideInfoSkyRouteWithHAR({ page, key: `4-cle-farm-5000-balance-${harSuffix}` }) + + await farmDetailsPage.expectReward({ + reward: '257.5', + }) + await farmDetailsPage.expectPointsSyncWarningToBeHidden() + await farmDetailsPage.expectInfoPanelClaimButtonToBeHidden() + await farmDetailsPage.expectStaked({ amount: '5,000.00', asset: 'USDS' }) + }) +}) diff --git a/packages/app/src/features/farm-details/dialogs/unstake/e2e/mainnet/WithdrawMaxUSDC.test-e2e.ts b/packages/app/src/features/farm-details/dialogs/unstake/e2e/mainnet/WithdrawMaxUSDC.test-e2e.ts index 9a5b2bde7..de4b7b592 100644 --- a/packages/app/src/features/farm-details/dialogs/unstake/e2e/mainnet/WithdrawMaxUSDC.test-e2e.ts +++ b/packages/app/src/features/farm-details/dialogs/unstake/e2e/mainnet/WithdrawMaxUSDC.test-e2e.ts @@ -1,162 +1,159 @@ -// 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 { Address } from 'viem' -// import { mainnet } from 'viem/chains' -// import { StakeDialogPageObject } from '../../../stake/StakeDialog.PageObject' -// import { UnstakeDialogPageObject } from '../../UnstakeDialog.PageObject' - -// test.describe('Withdraw max 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 -// let account: Address - -// test.beforeEach(async ({ page }) => { -// ;({ account } = await setup(page, fork, { -// initialPage: 'farmDetails', -// initialPageParams: { -// chainId: mainnet.id.toString(), -// address: '0x0650CAF159C5A49f711e8169D4336ECB9b950275', -// }, -// account: { -// type: 'connected-random', -// assetBalances: { -// ETH: 1, -// USDS: 10_000, -// DAI: 10_000, -// USDC: 10_000, -// }, -// }, -// })) - -// await overrideInfoSkyRouteWithHAR({ page, key: '1-sky-farm-with-8_51-apy' }) - -// farmDetailsPage = new FarmDetailsPageObject(page) -// await farmDetailsPage.clickInfoPanelStakeButtonAction() -// stakeDialog = new StakeDialogPageObject(page) - -// await stakeDialog.selectAssetAction('USDS') -// await stakeDialog.fillAmountAction(10_000) -// await stakeDialog.actionsContainer.acceptAllActionsAction(2) - -// await stakeDialog.clickBackToFarmAction() - -// await fork.progressSimulation(page, 24 * 60 * 60) // 24 hours -// await page.reload() - -// await farmDetailsPage.clickInfoPanelUnstakeButtonAction() -// unstakeDialog = new UnstakeDialogPageObject(page) - -// await unstakeDialog.selectAssetAction('USDC') -// await unstakeDialog.clickMaxAmountAction() -// }) - -// 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 when exiting', async () => { -// await unstakeDialog.clickExitFarmSwitchAction() -// await unstakeDialog.actionsContainer.expectActions([ -// { type: 'unstake', stakingToken: 'USDS', rewardToken: 'SKY', exit: true }, -// { type: 'approve', asset: 'USDS' }, -// { type: 'psmConvert', inToken: 'USDS', outToken: 'USDC' }, -// ]) -// }) - -// test('displays transaction overview', async () => { -// await unstakeDialog.expectTransactionOverview({ -// route: { -// swaps: [ -// { -// tokenAmount: '10,000.00 USDS', -// tokenUsdValue: '$10,000.00', -// }, -// { -// tokenAmount: '10,000.00 USDC', -// tokenUsdValue: '$10,000.00', -// }, -// ], -// farm: { -// upperText: 'SKY Farm', -// lowerText: 'Deposited', -// }, -// }, -// outcome: '10,000.00 USDC', -// }) -// }) - -// test('displays transaction overview when exiting', async () => { -// await unstakeDialog.clickExitFarmSwitchAction() -// await unstakeDialog.expectExitTransactionOverview({ -// route: { -// swaps: [ -// { -// tokenAmount: '10,000.00 USDS', -// tokenUsdValue: '$10,000.00', -// }, -// { -// tokenAmount: '10,000.00 USDC', -// tokenUsdValue: '$10,000.00', -// }, -// ], -// farm: { -// upperText: 'SKY Farm', -// lowerText: 'Deposited', -// }, -// }, -// outcome: { -// amount: '10,000.00', -// token: 'USDC', -// usdValue: '10,000.00', -// }, -// reward: { -// min: 3538, -// max: 3541, -// usdValue: '213', -// token: 'SKY', -// }, -// }) -// }) - -// test('executes transaction', async () => { -// await unstakeDialog.actionsContainer.acceptAllActionsAction(3) - -// await unstakeDialog.expectSuccessPage() -// await unstakeDialog.clickBackToFarmAction() - -// await farmDetailsPage.expectTokenToDepositBalance('USDC', '20,000.00') -// await farmDetailsPage.expectReward({ -// reward: '3,539', -// rewardUsd: '$213', -// }) -// }) - -// test('executes exit transaction', async () => { -// await unstakeDialog.clickExitFarmSwitchAction() -// await unstakeDialog.actionsContainer.acceptAllActionsAction(3) - -// await unstakeDialog.expectSuccessPage() -// await unstakeDialog.clickBackToFarmAction() - -// await farmDetailsPage.expectTokenToDepositBalance('USDC', '20,000.00') -// await farmDetailsPage.expectInfoPanelToBeVisible() - -// await farmDetailsPage.expectTokenBalance({ -// address: account, -// fork, -// symbol: 'SKY', -// minBalance: 3_525, -// maxBalance: 3_545, -// }) -// }) -// }) +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 { NormalizedUnitNumber } from '@marsfoundation/common-universal' +import { test } from '@playwright/test' +import { Address } from 'viem' +import { mainnet } from 'viem/chains' +import { StakeDialogPageObject } from '../../../stake/StakeDialog.PageObject' +import { UnstakeDialogPageObject } from '../../UnstakeDialog.PageObject' + +test.describe('Withdraw max USDC from SKY farm', () => { + let farmDetailsPage: FarmDetailsPageObject + let unstakeDialog: UnstakeDialogPageObject + let stakeDialog: StakeDialogPageObject + let account: Address + + 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, + USDS: 10_000, + DAI: 10_000, + USDC: 10_000, + }, + }, + }) + + await overrideInfoSkyRouteWithHAR({ page, key: '1-sky-farm-with-8_51-apy' }) + + farmDetailsPage = new FarmDetailsPageObject(testContext) + await farmDetailsPage.clickInfoPanelStakeButtonAction() + stakeDialog = new StakeDialogPageObject(testContext) + account = testContext.account + + await stakeDialog.selectAssetAction('USDS') + await stakeDialog.fillAmountAction(10_000) + await stakeDialog.actionsContainer.acceptAllActionsAction(2) + + await stakeDialog.clickBackToFarmAction() + + await testContext.testnetController.progressSimulation(24 * 60 * 60) // 24 hours + + await farmDetailsPage.clickInfoPanelUnstakeButtonAction() + unstakeDialog = new UnstakeDialogPageObject(testContext) + + await unstakeDialog.selectAssetAction('USDC') + await unstakeDialog.clickMaxAmountAction() + }) + + 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 when exiting', async () => { + await unstakeDialog.clickExitFarmSwitchAction() + await unstakeDialog.actionsContainer.expectActions([ + { type: 'unstake', stakingToken: 'USDS', rewardToken: 'SKY', exit: true }, + { type: 'approve', asset: 'USDS' }, + { type: 'psmConvert', inToken: 'USDS', outToken: 'USDC' }, + ]) + }) + + test('displays transaction overview', async () => { + await unstakeDialog.expectTransactionOverview({ + route: { + swaps: [ + { + tokenAmount: '10,000.00 USDS', + tokenUsdValue: '$10,000.00', + }, + { + tokenAmount: '10,000.00 USDC', + tokenUsdValue: '$10,000.00', + }, + ], + farm: { + upperText: 'SKY Farm', + lowerText: 'Deposited', + }, + }, + outcome: '10,000.00 USDC', + }) + }) + + test('displays transaction overview when exiting', async () => { + await unstakeDialog.clickExitFarmSwitchAction() + await unstakeDialog.expectExitTransactionOverview({ + route: { + swaps: [ + { + tokenAmount: '10,000.00 USDS', + tokenUsdValue: '$10,000.00', + }, + { + tokenAmount: '10,000.00 USDC', + tokenUsdValue: '$10,000.00', + }, + ], + farm: { + upperText: 'SKY Farm', + lowerText: 'Deposited', + }, + }, + outcome: { + amount: '10,000.00', + token: 'USDC', + usdValue: '10,000.00', + }, + reward: { + amount: 49.44, + usdValue: '2.98', + token: 'SKY', + }, + }) + }) + + test('executes transaction', async () => { + await unstakeDialog.actionsContainer.acceptAllActionsAction(3) + + await unstakeDialog.expectSuccessPage() + await unstakeDialog.clickBackToFarmAction() + + await farmDetailsPage.expectTokenToDepositBalance('USDC', '20,000.00') + await farmDetailsPage.expectReward({ + reward: '49.435971', + rewardUsd: '$2.98', + }) + }) + + test('executes exit transaction', async () => { + await unstakeDialog.clickExitFarmSwitchAction() + await unstakeDialog.actionsContainer.acceptAllActionsAction(3) + + await unstakeDialog.expectSuccessPage() + await unstakeDialog.clickBackToFarmAction() + + await farmDetailsPage.expectTokenToDepositBalance('USDC', '20,000.00') + await farmDetailsPage.expectInfoPanelToBeVisible() + + await farmDetailsPage.expectTokenBalance({ + symbol: 'SKY', + balance: NormalizedUnitNumber('49.43597061732295'), + address: account, + }) + }) +}) diff --git a/packages/app/src/test/e2e/setup.ts b/packages/app/src/test/e2e/setup.ts index 00c83a157..514196e6e 100644 --- a/packages/app/src/test/e2e/setup.ts +++ b/packages/app/src/test/e2e/setup.ts @@ -87,7 +87,7 @@ export async function setup( const progressedTimestamp = currentTimestamp + BigInt(seconds) await testnetClient.setNextBlockTimestamp(progressedTimestamp) - await injectUpdatedDate(page, new Date(Number(currentTimestamp) * 1000)) + await injectUpdatedDate(page, new Date(Number(progressedTimestamp) * 1000)) } async function progressSimulationAndMine(seconds: number): Promise { From a856d278ec37234bbe7aead34ab997487986e8cd Mon Sep 17 00:00:00 2001 From: oskarvu Date: Thu, 19 Dec 2024 16:24:40 +0700 Subject: [PATCH 3/6] Use progress and mine and reload --- .../dialogs/claim/e2e/mainnet/ClaimSKY.test-e2e.ts | 3 ++- .../dialogs/unstake/e2e/mainnet/UnstakeDAI.test-e2e.ts | 3 ++- .../dialogs/unstake/e2e/mainnet/UnstakeUSDS.test-e2e.ts | 7 ++++--- .../unstake/e2e/mainnet/WithdrawMaxUSDC.test-e2e.ts | 7 ++++--- packages/app/src/test/e2e/setup.ts | 2 +- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/packages/app/src/features/farm-details/dialogs/claim/e2e/mainnet/ClaimSKY.test-e2e.ts b/packages/app/src/features/farm-details/dialogs/claim/e2e/mainnet/ClaimSKY.test-e2e.ts index 1f6dd826b..fdd9f0de6 100644 --- a/packages/app/src/features/farm-details/dialogs/claim/e2e/mainnet/ClaimSKY.test-e2e.ts +++ b/packages/app/src/features/farm-details/dialogs/claim/e2e/mainnet/ClaimSKY.test-e2e.ts @@ -44,6 +44,7 @@ test.describe('Claim SKY rewards', () => { await stakeDialog.actionsContainer.acceptAllActionsAction(2) await stakeDialog.clickBackToFarmAction() await testContext.testnetController.progressSimulationAndMine(24 * 60 * 60) // 24 hours + await page.reload() await farmDetailsPage.clickInfoPanelClaimButtonAction() claimDialog = new ClaimDialogPageObject(testContext) @@ -71,7 +72,7 @@ test.describe('Claim SKY rewards', () => { await farmDetailsPage.expectTokenToDepositBalance('USDS', '-') await farmDetailsPage.expectReward({ - reward: '0.005', + reward: '0.001', rewardUsd: '<$0.01', }) await farmDetailsPage.expectTokenBalance({ diff --git a/packages/app/src/features/farm-details/dialogs/unstake/e2e/mainnet/UnstakeDAI.test-e2e.ts b/packages/app/src/features/farm-details/dialogs/unstake/e2e/mainnet/UnstakeDAI.test-e2e.ts index 184dea7b0..30ab8565c 100644 --- a/packages/app/src/features/farm-details/dialogs/unstake/e2e/mainnet/UnstakeDAI.test-e2e.ts +++ b/packages/app/src/features/farm-details/dialogs/unstake/e2e/mainnet/UnstakeDAI.test-e2e.ts @@ -44,7 +44,8 @@ test.describe('Unstake DAI from SKY farm', () => { await stakeDialog.clickBackToFarmAction() - await testContext.testnetController.progressSimulation(24 * 60 * 60) // 24 hours + await testContext.testnetController.progressSimulationAndMine(24 * 60 * 60) // 24 hours + await page.reload() await farmDetailsPage.clickInfoPanelUnstakeButtonAction() unstakeDialog = new UnstakeDialogPageObject(testContext) diff --git a/packages/app/src/features/farm-details/dialogs/unstake/e2e/mainnet/UnstakeUSDS.test-e2e.ts b/packages/app/src/features/farm-details/dialogs/unstake/e2e/mainnet/UnstakeUSDS.test-e2e.ts index 55ea9e88d..36f198961 100644 --- a/packages/app/src/features/farm-details/dialogs/unstake/e2e/mainnet/UnstakeUSDS.test-e2e.ts +++ b/packages/app/src/features/farm-details/dialogs/unstake/e2e/mainnet/UnstakeUSDS.test-e2e.ts @@ -45,7 +45,8 @@ test.describe('Unstake USDS from SKY farm', () => { await stakeDialog.clickBackToFarmAction() - await testContext.testnetController.progressSimulation(24 * 60 * 60) // 24 hours + await testContext.testnetController.progressSimulationAndMine(24 * 60 * 60) // 24 hours + await page.reload() await farmDetailsPage.clickInfoPanelUnstakeButtonAction() unstakeDialog = new UnstakeDialogPageObject(testContext) @@ -175,7 +176,7 @@ test.describe('Unstake USDS from CLE farm', () => { await farmDetailsPage.expectTokenToDepositBalance('USDS', '5,000.00') await farmDetailsPage.expectReward({ - reward: '257.5', + reward: '257.6', }) await farmDetailsPage.expectStaked({ amount: '5,000.00', asset: 'USDS' }) await farmDetailsPage.expectPointsSyncWarning() @@ -183,7 +184,7 @@ test.describe('Unstake USDS from CLE farm', () => { await overrideInfoSkyRouteWithHAR({ page, key: `4-cle-farm-5000-balance-${harSuffix}` }) await farmDetailsPage.expectReward({ - reward: '257.5', + reward: '257.6', }) await farmDetailsPage.expectPointsSyncWarningToBeHidden() await farmDetailsPage.expectInfoPanelClaimButtonToBeHidden() diff --git a/packages/app/src/features/farm-details/dialogs/unstake/e2e/mainnet/WithdrawMaxUSDC.test-e2e.ts b/packages/app/src/features/farm-details/dialogs/unstake/e2e/mainnet/WithdrawMaxUSDC.test-e2e.ts index de4b7b592..a6454870b 100644 --- a/packages/app/src/features/farm-details/dialogs/unstake/e2e/mainnet/WithdrawMaxUSDC.test-e2e.ts +++ b/packages/app/src/features/farm-details/dialogs/unstake/e2e/mainnet/WithdrawMaxUSDC.test-e2e.ts @@ -47,7 +47,8 @@ test.describe('Withdraw max USDC from SKY farm', () => { await stakeDialog.clickBackToFarmAction() - await testContext.testnetController.progressSimulation(24 * 60 * 60) // 24 hours + await testContext.testnetController.progressSimulationAndMine(24 * 60 * 60) // 24 hours + await page.reload() await farmDetailsPage.clickInfoPanelUnstakeButtonAction() unstakeDialog = new UnstakeDialogPageObject(testContext) @@ -135,7 +136,7 @@ test.describe('Withdraw max USDC from SKY farm', () => { await farmDetailsPage.expectTokenToDepositBalance('USDC', '20,000.00') await farmDetailsPage.expectReward({ - reward: '49.435971', + reward: '49.436543', rewardUsd: '$2.98', }) }) @@ -152,7 +153,7 @@ test.describe('Withdraw max USDC from SKY farm', () => { await farmDetailsPage.expectTokenBalance({ symbol: 'SKY', - balance: NormalizedUnitNumber('49.43597061732295'), + balance: NormalizedUnitNumber('49.4365427929088'), address: account, }) }) diff --git a/packages/app/src/test/e2e/setup.ts b/packages/app/src/test/e2e/setup.ts index 514196e6e..00c83a157 100644 --- a/packages/app/src/test/e2e/setup.ts +++ b/packages/app/src/test/e2e/setup.ts @@ -87,7 +87,7 @@ export async function setup( const progressedTimestamp = currentTimestamp + BigInt(seconds) await testnetClient.setNextBlockTimestamp(progressedTimestamp) - await injectUpdatedDate(page, new Date(Number(progressedTimestamp) * 1000)) + await injectUpdatedDate(page, new Date(Number(currentTimestamp) * 1000)) } async function progressSimulationAndMine(seconds: number): Promise { From 669e721dcf0112f94c27fda76ba1940cdeac533f Mon Sep 17 00:00:00 2001 From: oskarvu Date: Thu, 19 Dec 2024 16:43:44 +0700 Subject: [PATCH 4/6] Add withdraw max dai tests --- .../e2e/mainnet/WithdrawMaxDai.test-e2e.ts | 322 +++++++++--------- 1 file changed, 160 insertions(+), 162 deletions(-) diff --git a/packages/app/src/features/farm-details/dialogs/unstake/e2e/mainnet/WithdrawMaxDai.test-e2e.ts b/packages/app/src/features/farm-details/dialogs/unstake/e2e/mainnet/WithdrawMaxDai.test-e2e.ts index aec8adb76..6824c9f1d 100644 --- a/packages/app/src/features/farm-details/dialogs/unstake/e2e/mainnet/WithdrawMaxDai.test-e2e.ts +++ b/packages/app/src/features/farm-details/dialogs/unstake/e2e/mainnet/WithdrawMaxDai.test-e2e.ts @@ -1,162 +1,160 @@ -// 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 { Address } from 'viem' -// import { mainnet } from 'viem/chains' -// import { StakeDialogPageObject } from '../../../stake/StakeDialog.PageObject' -// import { UnstakeDialogPageObject } from '../../UnstakeDialog.PageObject' - -// test.describe('Withdraw max DAI from SKY farm', () => { -// const fork = setupFork({ blockNumber: DEFAULT_BLOCK_NUMBER, chainId: mainnet.id, useTenderlyVnet: true }) -// let farmDetailsPage: FarmDetailsPageObject -// let unstakeDialog: UnstakeDialogPageObject -// let stakeDialog: StakeDialogPageObject -// let account: Address - -// test.beforeEach(async ({ page }) => { -// ;({ account } = await setup(page, fork, { -// initialPage: 'farmDetails', -// initialPageParams: { -// chainId: mainnet.id.toString(), -// address: '0x0650CAF159C5A49f711e8169D4336ECB9b950275', -// }, -// account: { -// type: 'connected-random', -// assetBalances: { -// ETH: 1, -// USDS: 10_000, -// DAI: 10_000, -// USDC: 10_000, -// }, -// }, -// })) - -// await overrideInfoSkyRouteWithHAR({ page, key: '1-sky-farm-with-8_51-apy' }) - -// farmDetailsPage = new FarmDetailsPageObject(page) -// await farmDetailsPage.clickInfoPanelStakeButtonAction() -// stakeDialog = new StakeDialogPageObject(page) - -// await stakeDialog.selectAssetAction('USDS') -// await stakeDialog.fillAmountAction(10_000) -// await stakeDialog.actionsContainer.acceptAllActionsAction(2) - -// await stakeDialog.clickBackToFarmAction() - -// await fork.progressSimulation(page, 24 * 60 * 60) // 24 hours -// await page.reload() - -// await farmDetailsPage.clickInfoPanelUnstakeButtonAction() -// unstakeDialog = new UnstakeDialogPageObject(page) - -// await unstakeDialog.selectAssetAction('DAI') -// await unstakeDialog.clickMaxAmountAction() -// }) - -// test('has correct action plan', async () => { -// await unstakeDialog.actionsContainer.expectActions([ -// { type: 'unstake', stakingToken: 'USDS', rewardToken: 'SKY', exit: false }, -// { type: 'approve', asset: 'USDS' }, -// { type: 'downgrade', fromToken: 'USDS', toToken: 'DAI' }, -// ]) -// }) - -// test('has correct action plan when exiting', async () => { -// await unstakeDialog.clickExitFarmSwitchAction() -// await unstakeDialog.actionsContainer.expectActions([ -// { type: 'unstake', stakingToken: 'USDS', rewardToken: 'SKY', exit: true }, -// { type: 'approve', asset: 'USDS' }, -// { type: 'downgrade', fromToken: 'USDS', toToken: 'DAI' }, -// ]) -// }) - -// test('displays transaction overview', async () => { -// await unstakeDialog.expectTransactionOverview({ -// route: { -// swaps: [ -// { -// tokenAmount: '10,000.00 USDS', -// tokenUsdValue: '$10,000.00', -// }, -// { -// tokenAmount: '10,000.00 DAI', -// tokenUsdValue: '$10,000.00', -// }, -// ], -// farm: { -// upperText: 'SKY Farm', -// lowerText: 'Deposited', -// }, -// }, -// outcome: '10,000.00 DAI', -// }) -// }) - -// test('displays transaction overview when exiting', async () => { -// await unstakeDialog.clickExitFarmSwitchAction() -// await unstakeDialog.expectExitTransactionOverview({ -// route: { -// swaps: [ -// { -// tokenAmount: '10,000.00 USDS', -// tokenUsdValue: '$10,000.00', -// }, -// { -// tokenAmount: '10,000.00 DAI', -// tokenUsdValue: '$10,000.00', -// }, -// ], -// farm: { -// upperText: 'SKY Farm', -// lowerText: 'Deposited', -// }, -// }, -// outcome: { -// amount: '10,000.00', -// token: 'DAI', -// usdValue: '10,000.00', -// }, -// reward: { -// min: 3538, -// max: 3541, -// usdValue: '213', -// token: 'SKY', -// }, -// }) -// }) - -// test('executes transaction', async () => { -// await unstakeDialog.actionsContainer.acceptAllActionsAction(3) - -// await unstakeDialog.expectSuccessPage() -// await unstakeDialog.clickBackToFarmAction() - -// await farmDetailsPage.expectTokenToDepositBalance('DAI', '20,000.00') -// await farmDetailsPage.expectReward({ -// reward: '3,539', -// rewardUsd: '$213', -// }) -// }) - -// test('executes exit transaction', async () => { -// await unstakeDialog.clickExitFarmSwitchAction() -// await unstakeDialog.actionsContainer.acceptAllActionsAction(3) - -// await unstakeDialog.expectSuccessPage() -// await unstakeDialog.clickBackToFarmAction() - -// await farmDetailsPage.expectTokenToDepositBalance('DAI', '20,000.00') -// await farmDetailsPage.expectInfoPanelToBeVisible() - -// await farmDetailsPage.expectTokenBalance({ -// address: account, -// fork, -// symbol: 'SKY', -// minBalance: 3_525, -// maxBalance: 3_545, -// }) -// }) -// }) +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 { NormalizedUnitNumber } from '@marsfoundation/common-universal' +import { test } from '@playwright/test' +import { Address } from 'viem' +import { mainnet } from 'viem/chains' +import { StakeDialogPageObject } from '../../../stake/StakeDialog.PageObject' +import { UnstakeDialogPageObject } from '../../UnstakeDialog.PageObject' + +test.describe('Withdraw max DAI from SKY farm', () => { + let farmDetailsPage: FarmDetailsPageObject + let unstakeDialog: UnstakeDialogPageObject + let stakeDialog: StakeDialogPageObject + let account: Address + + 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, + USDS: 10_000, + DAI: 10_000, + USDC: 10_000, + }, + }, + }) + + await overrideInfoSkyRouteWithHAR({ page, key: '1-sky-farm-with-8_51-apy' }) + + farmDetailsPage = new FarmDetailsPageObject(testContext) + await farmDetailsPage.clickInfoPanelStakeButtonAction() + stakeDialog = new StakeDialogPageObject(testContext) + account = testContext.account + + await stakeDialog.selectAssetAction('USDS') + await stakeDialog.fillAmountAction(10_000) + await stakeDialog.actionsContainer.acceptAllActionsAction(2) + + await stakeDialog.clickBackToFarmAction() + + await testContext.testnetController.progressSimulationAndMine(24 * 60 * 60) // 24 hours + await page.reload() + + await farmDetailsPage.clickInfoPanelUnstakeButtonAction() + unstakeDialog = new UnstakeDialogPageObject(testContext) + + await unstakeDialog.selectAssetAction('DAI') + await unstakeDialog.clickMaxAmountAction() + }) + + test('has correct action plan', async () => { + await unstakeDialog.actionsContainer.expectActions([ + { type: 'unstake', stakingToken: 'USDS', rewardToken: 'SKY', exit: false }, + { type: 'approve', asset: 'USDS' }, + { type: 'downgrade', fromToken: 'USDS', toToken: 'DAI' }, + ]) + }) + + test('has correct action plan when exiting', async () => { + await unstakeDialog.clickExitFarmSwitchAction() + await unstakeDialog.actionsContainer.expectActions([ + { type: 'unstake', stakingToken: 'USDS', rewardToken: 'SKY', exit: true }, + { type: 'approve', asset: 'USDS' }, + { type: 'downgrade', fromToken: 'USDS', toToken: 'DAI' }, + ]) + }) + + test('displays transaction overview', async () => { + await unstakeDialog.expectTransactionOverview({ + route: { + swaps: [ + { + tokenAmount: '10,000.00 USDS', + tokenUsdValue: '$10,000.00', + }, + { + tokenAmount: '10,000.00 DAI', + tokenUsdValue: '$10,000.00', + }, + ], + farm: { + upperText: 'SKY Farm', + lowerText: 'Deposited', + }, + }, + outcome: '10,000.00 DAI', + }) + }) + + test('displays transaction overview when exiting', async () => { + await unstakeDialog.clickExitFarmSwitchAction() + await unstakeDialog.expectExitTransactionOverview({ + route: { + swaps: [ + { + tokenAmount: '10,000.00 USDS', + tokenUsdValue: '$10,000.00', + }, + { + tokenAmount: '10,000.00 DAI', + tokenUsdValue: '$10,000.00', + }, + ], + farm: { + upperText: 'SKY Farm', + lowerText: 'Deposited', + }, + }, + outcome: { + amount: '10,000.00', + token: 'DAI', + usdValue: '10,000.00', + }, + reward: { + amount: 49.44, + usdValue: '$2.98', + token: 'SKY', + }, + }) + }) + + test('executes transaction', async () => { + await unstakeDialog.actionsContainer.acceptAllActionsAction(3) + + await unstakeDialog.expectSuccessPage() + await unstakeDialog.clickBackToFarmAction() + + await farmDetailsPage.expectTokenToDepositBalance('DAI', '20,000.00') + await farmDetailsPage.expectReward({ + reward: '49.436543', + rewardUsd: '$2.98', + }) + }) + + test('executes exit transaction', async () => { + await unstakeDialog.clickExitFarmSwitchAction() + await unstakeDialog.actionsContainer.acceptAllActionsAction(3) + + await unstakeDialog.expectSuccessPage() + await unstakeDialog.clickBackToFarmAction() + + await farmDetailsPage.expectTokenToDepositBalance('DAI', '20,000.00') + await farmDetailsPage.expectInfoPanelToBeVisible() + + await farmDetailsPage.expectTokenBalance({ + address: account, + symbol: 'SKY', + balance: NormalizedUnitNumber('49.4365427929088'), + }) + }) +}) From 1b4222cb0f21193484e17c00d85a5b83ed6a7019 Mon Sep 17 00:00:00 2001 From: oskarvu Date: Thu, 19 Dec 2024 16:53:18 +0700 Subject: [PATCH 5/6] Add withdraw max usds tests --- .../claim/e2e/mainnet/ClaimSKY.test-e2e.ts | 2 +- .../e2e/mainnet/UnstakeDAI.test-e2e.ts | 2 +- .../e2e/mainnet/UnstakeUSDS.test-e2e.ts | 2 +- .../e2e/mainnet/WithdrawMaxDai.test-e2e.ts | 4 +- .../e2e/mainnet/WithdrawMaxUSDC.test-e2e.ts | 2 +- .../e2e/mainnet/WithdrawMaxUSDS.test-e2e.ts | 437 +++++++++--------- 6 files changed, 226 insertions(+), 223 deletions(-) diff --git a/packages/app/src/features/farm-details/dialogs/claim/e2e/mainnet/ClaimSKY.test-e2e.ts b/packages/app/src/features/farm-details/dialogs/claim/e2e/mainnet/ClaimSKY.test-e2e.ts index fdd9f0de6..bc8e65910 100644 --- a/packages/app/src/features/farm-details/dialogs/claim/e2e/mainnet/ClaimSKY.test-e2e.ts +++ b/packages/app/src/features/farm-details/dialogs/claim/e2e/mainnet/ClaimSKY.test-e2e.ts @@ -59,7 +59,7 @@ test.describe('Claim SKY rewards', () => { await claimDialog.expectTransactionOverview({ reward: { amount: '49.44', - amountUSD: '$2.98', + amountUSD: '2.98', }, }) }) diff --git a/packages/app/src/features/farm-details/dialogs/unstake/e2e/mainnet/UnstakeDAI.test-e2e.ts b/packages/app/src/features/farm-details/dialogs/unstake/e2e/mainnet/UnstakeDAI.test-e2e.ts index 30ab8565c..cca32d77e 100644 --- a/packages/app/src/features/farm-details/dialogs/unstake/e2e/mainnet/UnstakeDAI.test-e2e.ts +++ b/packages/app/src/features/farm-details/dialogs/unstake/e2e/mainnet/UnstakeDAI.test-e2e.ts @@ -94,7 +94,7 @@ test.describe('Unstake DAI from SKY farm', () => { await farmDetailsPage.expectTokenToDepositBalance('USDS', '-') await farmDetailsPage.expectReward({ reward: '49.441', - rewardUsd: '$2.98', + 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/UnstakeUSDS.test-e2e.ts b/packages/app/src/features/farm-details/dialogs/unstake/e2e/mainnet/UnstakeUSDS.test-e2e.ts index 36f198961..f8c831a76 100644 --- a/packages/app/src/features/farm-details/dialogs/unstake/e2e/mainnet/UnstakeUSDS.test-e2e.ts +++ b/packages/app/src/features/farm-details/dialogs/unstake/e2e/mainnet/UnstakeUSDS.test-e2e.ts @@ -93,7 +93,7 @@ test.describe('Unstake USDS from SKY farm', () => { await farmDetailsPage.expectTokenToDepositBalance('DAI', '-') await farmDetailsPage.expectReward({ reward: '49.438', - rewardUsd: '$2.98', + 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/WithdrawMaxDai.test-e2e.ts b/packages/app/src/features/farm-details/dialogs/unstake/e2e/mainnet/WithdrawMaxDai.test-e2e.ts index 6824c9f1d..d47cc7769 100644 --- a/packages/app/src/features/farm-details/dialogs/unstake/e2e/mainnet/WithdrawMaxDai.test-e2e.ts +++ b/packages/app/src/features/farm-details/dialogs/unstake/e2e/mainnet/WithdrawMaxDai.test-e2e.ts @@ -122,7 +122,7 @@ test.describe('Withdraw max DAI from SKY farm', () => { }, reward: { amount: 49.44, - usdValue: '$2.98', + usdValue: '2.98', token: 'SKY', }, }) @@ -137,7 +137,7 @@ test.describe('Withdraw max DAI from SKY farm', () => { await farmDetailsPage.expectTokenToDepositBalance('DAI', '20,000.00') await farmDetailsPage.expectReward({ reward: '49.436543', - rewardUsd: '$2.98', + rewardUsd: '2.98', }) }) diff --git a/packages/app/src/features/farm-details/dialogs/unstake/e2e/mainnet/WithdrawMaxUSDC.test-e2e.ts b/packages/app/src/features/farm-details/dialogs/unstake/e2e/mainnet/WithdrawMaxUSDC.test-e2e.ts index a6454870b..4fcc6fb87 100644 --- a/packages/app/src/features/farm-details/dialogs/unstake/e2e/mainnet/WithdrawMaxUSDC.test-e2e.ts +++ b/packages/app/src/features/farm-details/dialogs/unstake/e2e/mainnet/WithdrawMaxUSDC.test-e2e.ts @@ -137,7 +137,7 @@ test.describe('Withdraw max USDC from SKY farm', () => { await farmDetailsPage.expectTokenToDepositBalance('USDC', '20,000.00') await farmDetailsPage.expectReward({ reward: '49.436543', - rewardUsd: '$2.98', + rewardUsd: '2.98', }) }) 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 b91a183bb..e351fb21b 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 @@ -1,217 +1,220 @@ -// 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 { Address } from 'viem' -// import { privateKeyToAddress } from 'viem/accounts' -// import { mainnet } from 'viem/chains' -// import { StakeDialogPageObject } from '../../../stake/StakeDialog.PageObject' -// import { UnstakeDialogPageObject } from '../../UnstakeDialog.PageObject' - -// test.describe('Withdraw max USDS from SKY farm', () => { -// const fork = setupFork({ blockNumber: DEFAULT_BLOCK_NUMBER, chainId: mainnet.id, useTenderlyVnet: true }) -// let farmDetailsPage: FarmDetailsPageObject -// let unstakeDialog: UnstakeDialogPageObject -// let stakeDialog: StakeDialogPageObject -// let account: Address - -// test.beforeEach(async ({ page }) => { -// ;({ account } = await setup(page, fork, { -// initialPage: 'farmDetails', -// initialPageParams: { -// chainId: mainnet.id.toString(), -// address: '0x0650CAF159C5A49f711e8169D4336ECB9b950275', -// }, -// account: { -// type: 'connected-random', -// assetBalances: { -// ETH: 1, -// USDS: 10_000, -// DAI: 10_000, -// USDC: 10_000, -// }, -// }, -// })) - -// await overrideInfoSkyRouteWithHAR({ page, key: '1-sky-farm-with-8_51-apy' }) - -// farmDetailsPage = new FarmDetailsPageObject(page) -// await farmDetailsPage.clickInfoPanelStakeButtonAction() -// stakeDialog = new StakeDialogPageObject(page) - -// await stakeDialog.selectAssetAction('USDS') -// await stakeDialog.fillAmountAction(10_000) -// await stakeDialog.actionsContainer.acceptAllActionsAction(2) - -// await stakeDialog.clickBackToFarmAction() - -// await fork.progressSimulation(page, 24 * 60 * 60) // 24 hours -// await page.reload() - -// await farmDetailsPage.clickInfoPanelUnstakeButtonAction() -// unstakeDialog = new UnstakeDialogPageObject(page) - -// await unstakeDialog.selectAssetAction('USDS') -// await unstakeDialog.clickMaxAmountAction() -// }) - -// test('has reward displayed on exit farm switch', async () => { -// await unstakeDialog.expectExitFarmSwitchToBeVisible() -// await unstakeDialog.expectExitFarmSwitchNotChecked() -// await unstakeDialog.expectExitFarmSwitchReward({ -// min: 3538, -// max: 3541, -// token: 'SKY', -// usdValue: '213', -// }) -// }) - -// test('has correct action plan', async () => { -// await unstakeDialog.actionsContainer.expectActions([ -// { type: 'unstake', stakingToken: 'USDS', rewardToken: 'SKY', exit: false }, -// ]) -// }) - -// test('has correct action plan when exiting', async () => { -// await unstakeDialog.clickExitFarmSwitchAction() -// await unstakeDialog.actionsContainer.expectActions([ -// { type: 'unstake', stakingToken: 'USDS', rewardToken: 'SKY', exit: true }, -// ]) -// }) - -// test('displays transaction overview', async () => { -// await unstakeDialog.expectTransactionOverview({ -// route: { -// swaps: [ -// { -// tokenAmount: '10,000.00 USDS', -// tokenUsdValue: '$10,000.00', -// }, -// ], -// farm: { -// upperText: 'SKY Farm', -// lowerText: 'Deposited', -// }, -// }, -// outcome: '10,000.00 USDS', -// }) -// }) - -// test('displays transaction overview when exiting', async () => { -// await unstakeDialog.clickExitFarmSwitchAction() -// await unstakeDialog.expectExitTransactionOverview({ -// route: { -// swaps: [ -// { -// tokenAmount: '10,000.00 USDS', -// tokenUsdValue: '$10,000.00', -// }, -// ], -// farm: { -// upperText: 'SKY Farm', -// lowerText: 'Deposited', -// }, -// }, -// outcome: { -// amount: '10,000.00', -// token: 'USDS', -// usdValue: '10,000.00', -// }, -// reward: { -// min: 3538, -// max: 3541, -// usdValue: '213', -// token: 'SKY', -// }, -// }) -// }) - -// test('executes transaction', async () => { -// await unstakeDialog.actionsContainer.acceptAllActionsAction(1) - -// await unstakeDialog.expectSuccessPage() -// await unstakeDialog.clickBackToFarmAction() - -// await farmDetailsPage.expectTokenToDepositBalance('USDS', '10,000.00') -// await farmDetailsPage.expectReward({ -// reward: '3,539', -// rewardUsd: '$213', -// }) -// }) - -// test('executes exit transaction', async () => { -// await unstakeDialog.clickExitFarmSwitchAction() -// await unstakeDialog.actionsContainer.acceptAllActionsAction(1) - -// await unstakeDialog.expectSuccessPage() -// await unstakeDialog.clickBackToFarmAction() - -// await farmDetailsPage.expectTokenToDepositBalance('USDS', '10,000.00') -// await farmDetailsPage.expectInfoPanelToBeVisible() - -// await farmDetailsPage.expectTokenBalance({ -// address: account, -// fork, -// symbol: 'SKY', -// minBalance: 3_525, -// maxBalance: 3_545, -// }) -// }) -// }) - -// test.describe('Withdraw max USDS from CLE farm', () => { -// const testUserPKey = '0xa9f2d3eda4403df2fe54b97291d65d69824e0e2b3134c33b7145cf9b912966d5' -// const testUserAddress = privateKeyToAddress('0xa9f2d3eda4403df2fe54b97291d65d69824e0e2b3134c33b7145cf9b912966d5') -// const harSuffix = testUserAddress.slice(0, 10) - -// const fork = setupFork({ blockNumber: DEFAULT_BLOCK_NUMBER, chainId: mainnet.id, useTenderlyVnet: true }) -// let farmDetailsPage: FarmDetailsPageObject -// let unstakeDialog: UnstakeDialogPageObject - -// test.beforeEach(async ({ page }) => { -// await setup(page, fork, { -// initialPage: 'farmDetails', -// initialPageParams: { -// chainId: mainnet.id.toString(), -// address: '0x10ab606B067C9C461d8893c47C7512472E19e2Ce', -// }, -// account: { -// type: 'connected-pkey', -// privateKey: testUserPKey, -// assetBalances: { -// ETH: 1, -// USDS: 10_000, -// }, -// }, -// }) -// await overrideInfoSkyRouteWithHAR({ page, key: `2-cle-farm-0-balance-${harSuffix}` }) - -// farmDetailsPage = new FarmDetailsPageObject(page) -// await farmDetailsPage.clickInfoPanelStakeButtonAction() -// const stakeDialog = new StakeDialogPageObject(page) -// await stakeDialog.fillAmountAction(10_000) -// await stakeDialog.actionsContainer.acceptAllActionsAction(2) -// await stakeDialog.clickBackToFarmAction() -// await overrideInfoSkyRouteWithHAR({ page, key: `3-cle-farm-10000-balance-${harSuffix}` }) - -// await farmDetailsPage.clickInfoPanelUnstakeButtonAction() -// unstakeDialog = new UnstakeDialogPageObject(page) - -// await unstakeDialog.selectAssetAction('USDS') -// await unstakeDialog.clickMaxAmountAction() -// }) - -// test('keeps the exit switch hidden', async () => { -// await unstakeDialog.actionsContainer.expectEnabledActionAtIndex(0) -// await unstakeDialog.expectExitFarmSwitchToBeHidden() -// }) - -// test('has correct action plan', async () => { -// await unstakeDialog.actionsContainer.expectEnabledActionAtIndex(0) -// await unstakeDialog.actionsContainer.expectActions([ -// { type: 'unstake', stakingToken: 'USDS', rewardToken: 'CLE', exit: false }, -// ]) -// }) -// }) +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 { NormalizedUnitNumber } from '@marsfoundation/common-universal' +import { test } from '@playwright/test' +import { Address } from 'viem' +import { privateKeyToAddress } from 'viem/accounts' +import { mainnet } from 'viem/chains' +import { StakeDialogPageObject } from '../../../stake/StakeDialog.PageObject' +import { UnstakeDialogPageObject } from '../../UnstakeDialog.PageObject' + +test.describe('Withdraw max USDS from SKY farm', () => { + let farmDetailsPage: FarmDetailsPageObject + let unstakeDialog: UnstakeDialogPageObject + let stakeDialog: StakeDialogPageObject + let account: Address + + 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, + USDS: 10_000, + DAI: 10_000, + USDC: 10_000, + }, + }, + }) + + await overrideInfoSkyRouteWithHAR({ page, key: '1-sky-farm-with-8_51-apy' }) + + farmDetailsPage = new FarmDetailsPageObject(testContext) + await farmDetailsPage.clickInfoPanelStakeButtonAction() + stakeDialog = new StakeDialogPageObject(testContext) + account = testContext.account + + await stakeDialog.selectAssetAction('USDS') + await stakeDialog.fillAmountAction(10_000) + await stakeDialog.actionsContainer.acceptAllActionsAction(2) + + await stakeDialog.clickBackToFarmAction() + + await testContext.testnetController.progressSimulationAndMine(24 * 60 * 60) // 24 hours + await page.reload() + + await farmDetailsPage.clickInfoPanelUnstakeButtonAction() + unstakeDialog = new UnstakeDialogPageObject(testContext) + + await unstakeDialog.selectAssetAction('USDS') + await unstakeDialog.clickMaxAmountAction() + }) + + test('has reward displayed on exit farm switch', async () => { + await unstakeDialog.expectExitFarmSwitchToBeVisible() + await unstakeDialog.expectExitFarmSwitchNotChecked() + await unstakeDialog.expectExitFarmSwitchReward({ + amount: 49.44, + token: 'SKY', + usdValue: '213', + }) + }) + + test('has correct action plan', async () => { + await unstakeDialog.actionsContainer.expectActions([ + { type: 'unstake', stakingToken: 'USDS', rewardToken: 'SKY', exit: false }, + ]) + }) + + test('has correct action plan when exiting', async () => { + await unstakeDialog.clickExitFarmSwitchAction() + await unstakeDialog.actionsContainer.expectActions([ + { type: 'unstake', stakingToken: 'USDS', rewardToken: 'SKY', exit: true }, + ]) + }) + + test('displays transaction overview', async () => { + await unstakeDialog.expectTransactionOverview({ + route: { + swaps: [ + { + tokenAmount: '10,000.00 USDS', + tokenUsdValue: '$10,000.00', + }, + ], + farm: { + upperText: 'SKY Farm', + lowerText: 'Deposited', + }, + }, + outcome: '10,000.00 USDS', + }) + }) + + test('displays transaction overview when exiting', async () => { + await unstakeDialog.clickExitFarmSwitchAction() + await unstakeDialog.expectExitTransactionOverview({ + route: { + swaps: [ + { + tokenAmount: '10,000.00 USDS', + tokenUsdValue: '$10,000.00', + }, + ], + farm: { + upperText: 'SKY Farm', + lowerText: 'Deposited', + }, + }, + outcome: { + amount: '10,000.00', + token: 'USDS', + usdValue: '10,000.00', + }, + reward: { + amount: 49.44, + usdValue: '2.98', + token: 'SKY', + }, + }) + }) + + test('executes transaction', async () => { + await unstakeDialog.actionsContainer.acceptAllActionsAction(1) + + await unstakeDialog.expectSuccessPage() + await unstakeDialog.clickBackToFarmAction() + + await farmDetailsPage.expectTokenToDepositBalance('USDS', '10,000.00') + await farmDetailsPage.expectReward({ + reward: '49.436543', + rewardUsd: '$2.98', + }) + }) + + test('executes exit transaction', async () => { + await unstakeDialog.clickExitFarmSwitchAction() + await unstakeDialog.actionsContainer.acceptAllActionsAction(1) + + await unstakeDialog.expectSuccessPage() + await unstakeDialog.clickBackToFarmAction() + + await farmDetailsPage.expectTokenToDepositBalance('USDS', '10,000.00') + await farmDetailsPage.expectInfoPanelToBeVisible() + + await farmDetailsPage.expectTokenBalance({ + address: account, + symbol: 'SKY', + balance: NormalizedUnitNumber('49.4365427929088'), + }) + }) +}) + +test.describe('Withdraw max USDS from CLE farm', () => { + const testUserPKey = '0xa9f2d3eda4403df2fe54b97291d65d69824e0e2b3134c33b7145cf9b912966d5' + const testUserAddress = privateKeyToAddress('0xa9f2d3eda4403df2fe54b97291d65d69824e0e2b3134c33b7145cf9b912966d5') + const harSuffix = testUserAddress.slice(0, 10) + + let farmDetailsPage: FarmDetailsPageObject + let unstakeDialog: UnstakeDialogPageObject + + 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: '0x10ab606B067C9C461d8893c47C7512472E19e2Ce', + }, + account: { + type: 'connected-pkey', + privateKey: testUserPKey, + assetBalances: { + ETH: 1, + USDS: 10_000, + }, + }, + }) + await overrideInfoSkyRouteWithHAR({ page, key: `2-cle-farm-0-balance-${harSuffix}` }) + + farmDetailsPage = new FarmDetailsPageObject(testContext) + await farmDetailsPage.clickInfoPanelStakeButtonAction() + const stakeDialog = new StakeDialogPageObject(testContext) + await stakeDialog.fillAmountAction(10_000) + await stakeDialog.actionsContainer.acceptAllActionsAction(2) + await stakeDialog.clickBackToFarmAction() + await overrideInfoSkyRouteWithHAR({ page, key: `3-cle-farm-10000-balance-${harSuffix}` }) + + await farmDetailsPage.clickInfoPanelUnstakeButtonAction() + unstakeDialog = new UnstakeDialogPageObject(testContext) + + await unstakeDialog.selectAssetAction('USDS') + await unstakeDialog.clickMaxAmountAction() + }) + + test('keeps the exit switch hidden', async () => { + await unstakeDialog.actionsContainer.expectEnabledActionAtIndex(0) + await unstakeDialog.expectExitFarmSwitchToBeHidden() + }) + + test('has correct action plan', async () => { + await unstakeDialog.actionsContainer.expectEnabledActionAtIndex(0) + await unstakeDialog.actionsContainer.expectActions([ + { type: 'unstake', stakingToken: 'USDS', rewardToken: 'CLE', exit: false }, + ]) + }) +}) From 2ba6a80534becff07c2c7e0a4b2b769ea004fab0 Mon Sep 17 00:00:00 2001 From: oskarvu Date: Thu, 19 Dec 2024 17:00:25 +0700 Subject: [PATCH 6/6] 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', }) })