diff --git a/packages/app/src/features/dialogs/claim-rewards/ClaimRewardsDialog.PageObject.ts b/packages/app/src/features/dialogs/claim-rewards/ClaimRewardsDialog.PageObject.ts index ca66a4daf..e7ba2d752 100644 --- a/packages/app/src/features/dialogs/claim-rewards/ClaimRewardsDialog.PageObject.ts +++ b/packages/app/src/features/dialogs/claim-rewards/ClaimRewardsDialog.PageObject.ts @@ -1,41 +1,39 @@ -// import { Locator, Page, expect } from '@playwright/test' +import { TestContext } from '@/test/e2e/setup' +import { testIds } from '@/ui/utils/testIds' +import { Locator, expect } from '@playwright/test' +import { DialogPageObject } from '../common/Dialog.PageObject' -// import { testIds } from '@/ui/utils/testIds' +export class ClaimRewardsDialogPageObject extends DialogPageObject { + constructor(testContext: TestContext) { + super({ testContext, header: /Claim rewards/ }) + } -// import { DialogPageObject } from '../common/Dialog.PageObject' + // #region assertions + async expectRewards(rows: Reward[], locator?: Locator): Promise { + if (!locator) { + locator = this.region + } -// export class ClaimRewardsDialogPageObject extends DialogPageObject { -// constructor(page: Page) { -// super(page, /.*/) -// this.region = this.locateDialogByHeader('Claim rewards') -// } + for (const [index, row] of rows.entries()) { + const rowLocator = this.page.getByTestId(testIds.dialog.claimRewards.transactionOverview.row(index)).first() + await expect(rowLocator.getByTestId(testIds.dialog.claimRewards.transactionOverview.amount)).toHaveText( + `${row.amount} ${row.tokenSymbol}`, + ) + await expect(rowLocator.getByTestId(testIds.dialog.claimRewards.transactionOverview.amountUSD)).toHaveText( + row.amountUSD, + ) + } + } -// // #region assertions -// async expectRewards(rows: Reward[], locator?: Locator): Promise { -// if (!locator) { -// locator = this.region -// } + async expectClaimRewardsSuccessPage(rows: Reward[]): Promise { + await expect(this.page.getByRole('heading', { name: 'Congrats, all done!' })).toBeVisible() + await this.expectRewards(rows, this.page.getByTestId(testIds.dialog.success)) + } + // #endregion assertions +} -// for (const [index, row] of rows.entries()) { -// const rowLocator = this.page.getByTestId(testIds.dialog.claimRewards.transactionOverview.row(index)).first() -// await expect(rowLocator.getByTestId(testIds.dialog.claimRewards.transactionOverview.amount)).toHaveText( -// `${row.amount} ${row.tokenSymbol}`, -// ) -// await expect(rowLocator.getByTestId(testIds.dialog.claimRewards.transactionOverview.amountUSD)).toHaveText( -// row.amountUSD, -// ) -// } -// } - -// async expectClaimRewardsSuccessPage(rows: Reward[]): Promise { -// await expect(this.page.getByRole('heading', { name: 'Congrats, all done!' })).toBeVisible() -// await this.expectRewards(rows, this.page.getByTestId(testIds.dialog.success)) -// } -// // #endregion assertions -// } - -// interface Reward { -// tokenSymbol: string -// amount: string -// amountUSD: string -// } +interface Reward { + tokenSymbol: string + amount: string + amountUSD: string +} diff --git a/packages/app/src/features/dialogs/claim-rewards/ClaimRewardsDialog.test-e2e.ts b/packages/app/src/features/dialogs/claim-rewards/ClaimRewardsDialog.test-e2e.ts index 7d1de43c6..c807d0c0e 100644 --- a/packages/app/src/features/dialogs/claim-rewards/ClaimRewardsDialog.test-e2e.ts +++ b/packages/app/src/features/dialogs/claim-rewards/ClaimRewardsDialog.test-e2e.ts @@ -1,75 +1,72 @@ -// import { test } from '@playwright/test' -// import { mainnet } from 'viem/chains' +import { TopbarPageObject } from '@/features/topbar/Topbar.PageObject' +import { MyPortfolioPageObject } from '@/pages/MyPortfolio.PageObject' +import { DEFAULT_BLOCK_NUMBER } from '@/test/e2e/constants' +import { TestContext, setup } from '@/test/e2e/setup' +import { test } from '@playwright/test' +import { mainnet } from 'viem/chains' +import { ClaimRewardsDialogPageObject } from './ClaimRewardsDialog.PageObject' -// import { ActionsPageObject } from '@/features/actions/ActionsContainer.PageObject' -// import { TopbarPageObject } from '@/features/topbar/Topbar.PageObject' -// import { MyPortfolioPageObject } from '@/pages/MyPortfolio.PageObject' -// import { setupFork } from '@/test/e2e/forking/setupFork' -// import { setup } from '@/test/e2e/setup' -// import { ClaimRewardsDialogPageObject } from './ClaimRewardsDialog.PageObject' +test.describe('Claim rewards dialog', () => { + let navbar: TopbarPageObject + let claimRewardsDialog: ClaimRewardsDialogPageObject + let testContext: TestContext<'connected-address'> -// test.describe('Claim rewards dialog', () => { -// const fork = setupFork({ -// blockNumber: 20189272n, // block number where the reward program is finished -// chainId: mainnet.id, -// }) -// let navbar: TopbarPageObject -// let claimRewardsDialog: ClaimRewardsDialogPageObject -// let actionsContainer: ActionsPageObject + test.beforeEach(async ({ page }) => { + testContext = await setup(page, { + blockchain: { + blockNumber: DEFAULT_BLOCK_NUMBER, + chainId: mainnet.id, + }, + initialPage: 'easyBorrow', + account: { + type: 'connected-address', + address: '0xf8de75c7b95edb6f1e639751318f117663021cf0', + }, + }) -// test.beforeEach(async ({ page }) => { -// await setup(page, fork, { -// initialPage: 'easyBorrow', -// account: { -// type: 'connected-address', -// address: '0xf8de75c7b95edb6f1e639751318f117663021cf0', -// }, -// }) + navbar = new TopbarPageObject(testContext) + await navbar.openClaimRewardsDialog() -// navbar = new TopbarPageObject(page) -// await navbar.openClaimRewardsDialog() + claimRewardsDialog = new ClaimRewardsDialogPageObject(testContext) + }) -// claimRewardsDialog = new ClaimRewardsDialogPageObject(page) -// actionsContainer = new ActionsPageObject(claimRewardsDialog.locatePanelByHeader('Actions')) -// }) + test('displays correct transaction overview', async () => { + await claimRewardsDialog.expectRewards([ + { + tokenSymbol: 'wstETH', + amount: '6.3697', + amountUSD: '$29,717.60', + }, + ]) + }) -// test('displays correct transaction overview', async () => { -// await claimRewardsDialog.expectRewards([ -// { -// tokenSymbol: 'wstETH', -// amount: '6.3697', -// amountUSD: '$25,583.20', -// }, -// ]) -// }) + test('has correct action plan', async () => { + await claimRewardsDialog.actionsContainer.expectActions([ + { + type: 'claimMarketRewards', + asset: 'wstETH', + }, + ]) + }) -// test('has correct action plan', async () => { -// await actionsContainer.expectActions([ -// { -// type: 'claimMarketRewards', -// asset: 'wstETH', -// }, -// ]) -// }) + test('executes transaction', async () => { + await claimRewardsDialog.actionsContainer.acceptAllActionsAction(1) -// test('executes transaction', async ({ page }) => { -// await actionsContainer.acceptAllActionsAction(1) + await claimRewardsDialog.expectClaimRewardsSuccessPage([ + { + tokenSymbol: 'wstETH', + amount: '6.3697', + amountUSD: '$29,717.60', + }, + ]) -// await claimRewardsDialog.expectClaimRewardsSuccessPage([ -// { -// tokenSymbol: 'wstETH', -// amount: '6.3697', -// amountUSD: '$25,583.20', -// }, -// ]) + const myPortfolioPage = new MyPortfolioPageObject(testContext) + await myPortfolioPage.goToMyPortfolioAction() -// const myPortfolioPage = new MyPortfolioPageObject(page) -// await myPortfolioPage.goToMyPortfolioAction() + await myPortfolioPage.expectBalancesInDepositTable({ + wstETH: 6.3697, + }) -// await myPortfolioPage.expectBalancesInDepositTable({ -// wstETH: 6.3697, -// }) - -// await navbar.expectRewardsBadgeNotVisible() -// }) -// }) + await navbar.expectRewardsBadgeNotVisible() + }) +})