diff --git a/packages/app/src/features/dialogs/convert-stables/ConvertStablesDialog.PageObject.ts b/packages/app/src/features/dialogs/convert-stables/ConvertStablesDialog.PageObject.ts index 24e7bab72..d75088ad3 100644 --- a/packages/app/src/features/dialogs/convert-stables/ConvertStablesDialog.PageObject.ts +++ b/packages/app/src/features/dialogs/convert-stables/ConvertStablesDialog.PageObject.ts @@ -1,123 +1,124 @@ -// import { DialogPageObject, TxOverviewWithRoute } from '@/features/dialogs/common/Dialog.PageObject' -// import { testIds } from '@/ui/utils/testIds' -// import { Locator, Page, expect } from '@playwright/test' - -// export class ConvertStablesDialogPageObject extends DialogPageObject { -// constructor(page: Page) { -// super(page, /Convert Tokens/) -// } - -// // # region locators -// locateAssetInSelector(): Locator { -// return this.region.getByTestId(testIds.component.AssetSelector.trigger).first() -// } - -// locateAssetOutSelector(): Locator { -// return this.region.getByTestId(testIds.component.AssetSelector.trigger).last() -// } - -// locateAssetInInput(): Locator { -// return this.region.getByTestId(testIds.component.AssetInput.input).first() -// } - -// locateAssetOutInput(): Locator { -// return this.region.getByTestId(testIds.component.AssetInput.input).last() -// } - -// locateAssetInMaxButton(): Locator { -// return this.region.getByTestId(testIds.component.AssetInput.maxButton).first() -// } - -// locateAssetOutMaxButton(): Locator { -// return this.region.getByTestId(testIds.component.AssetInput.maxButton).last() -// } -// // #endregion locators - -// // #region actions -// async selectAssetInAction(asset: string): Promise { -// const selector = this.locateAssetInSelector() -// await this.selectOptionByLabelAction(selector, asset) -// } - -// async selectAssetOutAction(asset: string): Promise { -// const selector = this.locateAssetOutSelector() -// await this.selectOptionByLabelAction(selector, asset) -// } - -// async openAssetInSelectorAction(): Promise { -// await this.locateAssetInSelector().click() -// } - -// async openAssetOutSelectorAction(): Promise { -// await this.locateAssetOutSelector().click() -// } - -// async fillAmountInAction(amount: number): Promise { -// await this.locateAssetInInput().fill(amount.toString()) -// } - -// async fillAmountOutAction(amount: number): Promise { -// await this.locateAssetOutInput().fill(amount.toString()) -// } - -// async clickMaxAmountInAction(): Promise { -// await this.locateAssetInMaxButton().click() -// } - -// async clickMaxAmountOutAction(): Promise { -// await this.locateAssetOutMaxButton().click() -// } - -// async clickBackToSavingsButton(): Promise { -// await this.page.getByRole('button', { name: 'Back to Savings' }).click() -// await this.region.waitFor({ -// state: 'detached', -// }) -// } -// // #endregion actions - -// // #region assertions -// async expectSuccessPage(): Promise { -// await expect(this.page.getByText('Congrats, all done!')).toBeVisible() -// } - -// async expectTransactionOverview(transactionOverview: TxOverviewWithRoute): Promise { -// await this.expectTransactionOverviewRoute(transactionOverview.routeItems) -// await this.expectOutcomeText(transactionOverview.outcome) -// if (transactionOverview.outcomeUsd) { -// await this.expectOutcomeUsdText(transactionOverview.outcomeUsd) -// } -// } - -// async expectAssetInSelectorSelectedOption(option: string): Promise { -// await expect(this.locateAssetInSelector()).toHaveText(option) -// } - -// async expectAssetOutSelectorSelectedOption(option: string): Promise { -// await expect(this.locateAssetOutSelector()).toHaveText(option) -// } - -// async expectSelectorOptions(options: string[]): Promise { -// const selectorOptions = await this.page.getByTestId(testIds.component.AssetSelector.option).all() -// expect(selectorOptions).toHaveLength(options.length) - -// for (const [index, option] of selectorOptions.entries()) { -// await expect(option).toContainText(options[index]!) -// } -// } - -// async expectAssetInInputValue(value: string): Promise { -// await expect(this.locateAssetInInput()).toHaveValue(value) -// } - -// async expectAssetOutInputValue(value: string): Promise { -// await expect(this.locateAssetOutInput()).toHaveValue(value) -// } - -// async expectSingleInputError(error: string): Promise { -// const inputError = this.page.getByTestId(testIds.component.AssetInput.error) -// await expect(inputError).toHaveCount(1) -// await expect(inputError).toHaveText(error) -// } -// // #endregion assertions -// } +import { DialogPageObject, TxOverviewWithRoute } from '@/features/dialogs/common/Dialog.PageObject' +import { TestContext } from '@/test/e2e/setup' +import { testIds } from '@/ui/utils/testIds' +import { Locator, expect } from '@playwright/test' + +export class ConvertStablesDialogPageObject extends DialogPageObject { + constructor(testContext: TestContext) { + super({ testContext, header: /Convert Tokens/ }) + } + + // # region locators + locateAssetInSelector(): Locator { + return this.region.getByTestId(testIds.component.AssetSelector.trigger).first() + } + + locateAssetOutSelector(): Locator { + return this.region.getByTestId(testIds.component.AssetSelector.trigger).last() + } + + locateAssetInInput(): Locator { + return this.region.getByTestId(testIds.component.AssetInput.input).first() + } + + locateAssetOutInput(): Locator { + return this.region.getByTestId(testIds.component.AssetInput.input).last() + } + + locateAssetInMaxButton(): Locator { + return this.region.getByTestId(testIds.component.AssetInput.maxButton).first() + } + + locateAssetOutMaxButton(): Locator { + return this.region.getByTestId(testIds.component.AssetInput.maxButton).last() + } + // #endregion locators + + // #region actions + async selectAssetInAction(asset: string): Promise { + const selector = this.locateAssetInSelector() + await this.selectOptionByLabelAction(selector, asset) + } + + async selectAssetOutAction(asset: string): Promise { + const selector = this.locateAssetOutSelector() + await this.selectOptionByLabelAction(selector, asset) + } + + async openAssetInSelectorAction(): Promise { + await this.locateAssetInSelector().click() + } + + async openAssetOutSelectorAction(): Promise { + await this.locateAssetOutSelector().click() + } + + async fillAmountInAction(amount: number): Promise { + await this.locateAssetInInput().fill(amount.toString()) + } + + async fillAmountOutAction(amount: number): Promise { + await this.locateAssetOutInput().fill(amount.toString()) + } + + async clickMaxAmountInAction(): Promise { + await this.locateAssetInMaxButton().click() + } + + async clickMaxAmountOutAction(): Promise { + await this.locateAssetOutMaxButton().click() + } + + async clickBackToSavingsButton(): Promise { + await this.page.getByRole('button', { name: 'Back to Savings' }).click() + await this.region.waitFor({ + state: 'detached', + }) + } + // #endregion actions + + // #region assertions + async expectSuccessPage(): Promise { + await expect(this.page.getByText('Congrats, all done!')).toBeVisible() + } + + async expectTransactionOverview(transactionOverview: TxOverviewWithRoute): Promise { + await this.expectTransactionOverviewRoute(transactionOverview.routeItems) + await this.expectOutcomeText(transactionOverview.outcome) + if (transactionOverview.outcomeUsd) { + await this.expectOutcomeUsdText(transactionOverview.outcomeUsd) + } + } + + async expectAssetInSelectorSelectedOption(option: string): Promise { + await expect(this.locateAssetInSelector()).toHaveText(option) + } + + async expectAssetOutSelectorSelectedOption(option: string): Promise { + await expect(this.locateAssetOutSelector()).toHaveText(option) + } + + async expectSelectorOptions(options: string[]): Promise { + const selectorOptions = await this.page.getByTestId(testIds.component.AssetSelector.option).all() + expect(selectorOptions).toHaveLength(options.length) + + for (const [index, option] of selectorOptions.entries()) { + await expect(option).toContainText(options[index]!) + } + } + + async expectAssetInInputValue(value: string): Promise { + await expect(this.locateAssetInInput()).toHaveValue(value) + } + + async expectAssetOutInputValue(value: string): Promise { + await expect(this.locateAssetOutInput()).toHaveValue(value) + } + + async expectSingleInputError(error: string): Promise { + const inputError = this.page.getByTestId(testIds.component.AssetInput.error) + await expect(inputError).toHaveCount(1) + await expect(inputError).toHaveText(error) + } + // #endregion assertions +} diff --git a/packages/app/src/features/dialogs/convert-stables/ConvertStablesDialog.test-e2e.ts b/packages/app/src/features/dialogs/convert-stables/ConvertStablesDialog.test-e2e.ts index 66920cc48..9a31dd640 100644 --- a/packages/app/src/features/dialogs/convert-stables/ConvertStablesDialog.test-e2e.ts +++ b/packages/app/src/features/dialogs/convert-stables/ConvertStablesDialog.test-e2e.ts @@ -1,75 +1,77 @@ -// import { SavingsPageObject } from '@/pages/Savings.PageObject' -// import { DEFAULT_BLOCK_NUMBER } from '@/test/e2e/constants' -// import { setupFork } from '@/test/e2e/forking/setupFork' -// import { setup } from '@/test/e2e/setup' -// import { test } from '@playwright/test' -// import { mainnet } from 'viem/chains' -// import { ConvertStablesDialogPageObject } from './ConvertStablesDialog.PageObject' +import { SavingsPageObject } from '@/pages/Savings.PageObject' +import { DEFAULT_BLOCK_NUMBER } from '@/test/e2e/constants' +import { setup } from '@/test/e2e/setup' +import { test } from '@playwright/test' +import { mainnet } from 'viem/chains' +import { ConvertStablesDialogPageObject } from './ConvertStablesDialog.PageObject' -// test.describe('Convert Stables Dialog', () => { -// const fork = setupFork({ blockNumber: DEFAULT_BLOCK_NUMBER, chainId: mainnet.id, useTenderlyVnet: true }) -// let savingsPage: SavingsPageObject -// let convertStablesDialog: ConvertStablesDialogPageObject +test.describe('Convert Stables Dialog', () => { + let savingsPage: SavingsPageObject + let convertStablesDialog: ConvertStablesDialogPageObject -// test.beforeEach(async ({ page }) => { -// await setup(page, fork, { -// initialPage: 'savings', -// account: { -// type: 'connected-random', -// assetBalances: { -// ETH: 1, -// DAI: 10_000, -// }, -// }, -// }) + test.beforeEach(async ({ page }) => { + const testContext = await setup(page, { + blockchain: { + blockNumber: DEFAULT_BLOCK_NUMBER, + chainId: mainnet.id, + }, + initialPage: 'savings', + account: { + type: 'connected-random', + assetBalances: { + ETH: 1, + DAI: 10_000, + }, + }, + }) -// savingsPage = new SavingsPageObject(page) -// await savingsPage.clickConvertStablesButtonAction() -// convertStablesDialog = new ConvertStablesDialogPageObject(page) -// }) + savingsPage = new SavingsPageObject(testContext) + await savingsPage.clickConvertStablesButtonAction() + convertStablesDialog = new ConvertStablesDialogPageObject(testContext) + }) -// test('has correct selectors configuration', async ({ page }) => { -// await convertStablesDialog.expectAssetInSelectorSelectedOption('DAI') -// await convertStablesDialog.openAssetInSelectorAction() -// await convertStablesDialog.expectSelectorOptions(['USDC', 'USDS']) -// await page.keyboard.press('Escape') // closing selector + test('has correct selectors configuration', async ({ page }) => { + await convertStablesDialog.expectAssetInSelectorSelectedOption('DAI') + await convertStablesDialog.openAssetInSelectorAction() + await convertStablesDialog.expectSelectorOptions(['USDC', 'USDS']) + await page.keyboard.press('Escape') // closing selector -// await convertStablesDialog.expectAssetOutSelectorSelectedOption('USDC') -// await convertStablesDialog.openAssetOutSelectorAction() -// await convertStablesDialog.expectSelectorOptions(['USDS']) // no DAI option cause already selected in first selector -// }) + await convertStablesDialog.expectAssetOutSelectorSelectedOption('USDC') + await convertStablesDialog.openAssetOutSelectorAction() + await convertStablesDialog.expectSelectorOptions(['USDS']) // no DAI option cause already selected in first selector + }) -// test('first selector can override second selector', async () => { -// await convertStablesDialog.expectAssetInSelectorSelectedOption('DAI') -// await convertStablesDialog.expectAssetOutSelectorSelectedOption('USDC') + test('first selector can override second selector', async () => { + await convertStablesDialog.expectAssetInSelectorSelectedOption('DAI') + await convertStablesDialog.expectAssetOutSelectorSelectedOption('USDC') -// await convertStablesDialog.selectAssetInAction('USDC') // choosing already selected in second selector option + await convertStablesDialog.selectAssetInAction('USDC') // choosing already selected in second selector option -// await convertStablesDialog.expectAssetOutSelectorSelectedOption('DAI') // fist selector can override second -// await convertStablesDialog.openAssetOutSelectorAction() -// await convertStablesDialog.expectSelectorOptions(['USDS']) -// }) + await convertStablesDialog.expectAssetOutSelectorSelectedOption('DAI') // fist selector can override second + await convertStablesDialog.openAssetOutSelectorAction() + await convertStablesDialog.expectSelectorOptions(['USDS']) + }) -// test('changing value of any input updates both inputs', async () => { -// await convertStablesDialog.fillAmountInAction(5000) -// await convertStablesDialog.expectAssetInInputValue('5000') -// await convertStablesDialog.expectAssetOutInputValue('5000') + test('changing value of any input updates both inputs', async () => { + await convertStablesDialog.fillAmountInAction(5000) + await convertStablesDialog.expectAssetInInputValue('5000') + await convertStablesDialog.expectAssetOutInputValue('5000') -// await convertStablesDialog.clickMaxAmountInAction() -// await convertStablesDialog.expectAssetInInputValue('10000') -// await convertStablesDialog.expectAssetOutInputValue('10000') + await convertStablesDialog.clickMaxAmountInAction() + await convertStablesDialog.expectAssetInInputValue('10000') + await convertStablesDialog.expectAssetOutInputValue('10000') -// await convertStablesDialog.fillAmountOutAction(8_000) -// await convertStablesDialog.expectAssetInInputValue('8000') -// await convertStablesDialog.expectAssetOutInputValue('8000') + await convertStablesDialog.fillAmountOutAction(8_000) + await convertStablesDialog.expectAssetInInputValue('8000') + await convertStablesDialog.expectAssetOutInputValue('8000') -// await convertStablesDialog.clickMaxAmountOutAction() -// await convertStablesDialog.expectAssetInInputValue('10000') -// await convertStablesDialog.expectAssetOutInputValue('10000') -// }) + await convertStablesDialog.clickMaxAmountOutAction() + await convertStablesDialog.expectAssetInInputValue('10000') + await convertStablesDialog.expectAssetOutInputValue('10000') + }) -// test('displays validation error only for first input', async () => { -// await convertStablesDialog.fillAmountInAction(20_000) -// await convertStablesDialog.expectSingleInputError('Exceeds your balance') -// }) -// }) + test('displays validation error only for first input', async () => { + await convertStablesDialog.fillAmountInAction(20_000) + await convertStablesDialog.expectSingleInputError('Exceeds your balance') + }) +}) diff --git a/packages/app/src/features/dialogs/convert-stables/e2e/base/UsdcToUsds.test-e2e.ts b/packages/app/src/features/dialogs/convert-stables/e2e/base/UsdcToUsds.test-e2e.ts index e3b5f98e7..0ac9048ad 100644 --- a/packages/app/src/features/dialogs/convert-stables/e2e/base/UsdcToUsds.test-e2e.ts +++ b/packages/app/src/features/dialogs/convert-stables/e2e/base/UsdcToUsds.test-e2e.ts @@ -1,66 +1,69 @@ -// import { SavingsPageObject } from '@/pages/Savings.PageObject' -// import { setupFork } from '@/test/e2e/forking/setupFork' -// import { setup } from '@/test/e2e/setup' -// import { test } from '@playwright/test' -// import { base } from 'viem/chains' -// import { ConvertStablesDialogPageObject } from '../../ConvertStablesDialog.PageObject' +import { SavingsPageObject } from '@/pages/Savings.PageObject' +import { BASE_DEFAULT_BLOCK_NUMBER } from '@/test/e2e/constants' +import { setup } from '@/test/e2e/setup' +import { test } from '@playwright/test' +import { base } from 'viem/chains' +import { ConvertStablesDialogPageObject } from '../../ConvertStablesDialog.PageObject' -// test.describe('Convert USDC to USDS', () => { -// const fork = setupFork({ chainId: base.id, blockNumber: 22143788n, useTenderlyVnet: true }) -// let savingsPage: SavingsPageObject -// let convertStablesDialog: ConvertStablesDialogPageObject +test.describe('Convert USDC to USDS', () => { + let savingsPage: SavingsPageObject + let convertStablesDialog: ConvertStablesDialogPageObject -// test.beforeEach(async ({ page }) => { -// await setup(page, fork, { -// initialPage: 'savings', -// account: { -// type: 'connected-random', -// assetBalances: { -// ETH: 1, -// USDC: 10_000, -// }, -// }, -// }) + test.beforeEach(async ({ page }) => { + const testContext = await setup(page, { + blockchain: { + blockNumber: BASE_DEFAULT_BLOCK_NUMBER, + chainId: base.id, + }, + initialPage: 'savings', + account: { + type: 'connected-random', + assetBalances: { + ETH: 1, + USDC: 10_000, + }, + }, + }) -// savingsPage = new SavingsPageObject(page) -// await savingsPage.clickConvertStablesButtonAction() + savingsPage = new SavingsPageObject(testContext) + await savingsPage.clickConvertStablesButtonAction() -// convertStablesDialog = new ConvertStablesDialogPageObject(page) -// await convertStablesDialog.selectAssetInAction('USDC') -// await convertStablesDialog.selectAssetOutAction('USDS') -// await convertStablesDialog.fillAmountInAction(10_000) -// }) + convertStablesDialog = new ConvertStablesDialogPageObject(testContext) + await convertStablesDialog.selectAssetInAction('USDC') + await convertStablesDialog.selectAssetOutAction('USDS') + await convertStablesDialog.fillAmountInAction(10_000) + }) -// test('uses psm convert action', async () => { -// await convertStablesDialog.actionsContainer.expectEnabledActionAtIndex(0) -// await convertStablesDialog.actionsContainer.expectActions([ -// { type: 'approve', asset: 'USDC' }, -// { type: 'psmConvert', inToken: 'USDC', outToken: 'USDS' }, -// ]) -// }) + test('uses psm convert action', async () => { + await convertStablesDialog.actionsContainer.expectEnabledActionAtIndex(0) + await convertStablesDialog.actionsContainer.expectActions([ + { type: 'approve', asset: 'USDC' }, + { type: 'psmConvert', inToken: 'USDC', outToken: 'USDS' }, + ]) + }) -// test('displays transaction overview', async () => { -// await convertStablesDialog.expectTransactionOverview({ -// routeItems: [ -// { -// tokenAmount: '10,000.00 USDC', -// tokenUsdValue: '$10,000.00', -// }, -// { -// tokenAmount: '10,000.00 USDS', -// tokenUsdValue: '$10,000.00', -// }, -// ], -// outcome: '10,000.00 USDS', -// outcomeUsd: '$10,000.00', -// }) -// }) + test('displays transaction overview', async () => { + await convertStablesDialog.expectTransactionOverview({ + routeItems: [ + { + tokenAmount: '10,000.00 USDC', + tokenUsdValue: '$10,000.00', + }, + { + tokenAmount: '10,000.00 USDS', + tokenUsdValue: '$10,000.00', + }, + ], + outcome: '10,000.00 USDS', + outcomeUsd: '$10,000.00', + }) + }) -// test('executes conversion', async () => { -// await convertStablesDialog.actionsContainer.acceptAllActionsAction(2) -// await convertStablesDialog.expectSuccessPage() -// await convertStablesDialog.clickBackToSavingsButton() -// await savingsPage.expectStablecoinsInWalletAssetBalance('USDC', '-') -// await savingsPage.expectStablecoinsInWalletAssetBalance('USDS', '10,000.00') -// }) -// }) + test('executes conversion', async () => { + await convertStablesDialog.actionsContainer.acceptAllActionsAction(2) + await convertStablesDialog.expectSuccessPage() + await convertStablesDialog.clickBackToSavingsButton() + await savingsPage.expectStablecoinsInWalletAssetBalance('USDC', '-') + await savingsPage.expectStablecoinsInWalletAssetBalance('USDS', '10,000.00') + }) +}) diff --git a/packages/app/src/features/dialogs/convert-stables/e2e/base/UsdsToUsdc.test-e2e.ts b/packages/app/src/features/dialogs/convert-stables/e2e/base/UsdsToUsdc.test-e2e.ts index 0591f3253..bd59d4e1e 100644 --- a/packages/app/src/features/dialogs/convert-stables/e2e/base/UsdsToUsdc.test-e2e.ts +++ b/packages/app/src/features/dialogs/convert-stables/e2e/base/UsdsToUsdc.test-e2e.ts @@ -1,66 +1,69 @@ -// import { SavingsPageObject } from '@/pages/Savings.PageObject' -// import { setupFork } from '@/test/e2e/forking/setupFork' -// import { setup } from '@/test/e2e/setup' -// import { test } from '@playwright/test' -// import { base } from 'viem/chains' -// import { ConvertStablesDialogPageObject } from '../../ConvertStablesDialog.PageObject' +import { SavingsPageObject } from '@/pages/Savings.PageObject' +import { BASE_DEFAULT_BLOCK_NUMBER } from '@/test/e2e/constants' +import { setup } from '@/test/e2e/setup' +import { test } from '@playwright/test' +import { base } from 'viem/chains' +import { ConvertStablesDialogPageObject } from '../../ConvertStablesDialog.PageObject' -// test.describe('Convert USDS to USDC', () => { -// const fork = setupFork({ chainId: base.id, blockNumber: 22143788n, useTenderlyVnet: true }) -// let savingsPage: SavingsPageObject -// let convertStablesDialog: ConvertStablesDialogPageObject +test.describe('Convert USDS to USDC', () => { + let savingsPage: SavingsPageObject + let convertStablesDialog: ConvertStablesDialogPageObject -// test.beforeEach(async ({ page }) => { -// await setup(page, fork, { -// initialPage: 'savings', -// account: { -// type: 'connected-random', -// assetBalances: { -// ETH: 1, -// USDS: 10_000, -// }, -// }, -// }) + test.beforeEach(async ({ page }) => { + const testContext = await setup(page, { + blockchain: { + blockNumber: BASE_DEFAULT_BLOCK_NUMBER, + chainId: base.id, + }, + initialPage: 'savings', + account: { + type: 'connected-random', + assetBalances: { + ETH: 1, + USDS: 10_000, + }, + }, + }) -// savingsPage = new SavingsPageObject(page) -// await savingsPage.clickConvertStablesButtonAction() + savingsPage = new SavingsPageObject(testContext) + await savingsPage.clickConvertStablesButtonAction() -// convertStablesDialog = new ConvertStablesDialogPageObject(page) -// await convertStablesDialog.selectAssetInAction('USDS') -// await convertStablesDialog.selectAssetOutAction('USDC') -// await convertStablesDialog.fillAmountInAction(10_000) -// }) + convertStablesDialog = new ConvertStablesDialogPageObject(testContext) + await convertStablesDialog.selectAssetInAction('USDS') + await convertStablesDialog.selectAssetOutAction('USDC') + await convertStablesDialog.fillAmountInAction(10_000) + }) -// test('uses psm convert action', async () => { -// await convertStablesDialog.actionsContainer.expectEnabledActionAtIndex(0) -// await convertStablesDialog.actionsContainer.expectActions([ -// { type: 'approve', asset: 'USDS' }, -// { type: 'psmConvert', inToken: 'USDS', outToken: 'USDC' }, -// ]) -// }) + test('uses psm convert action', async () => { + await convertStablesDialog.actionsContainer.expectEnabledActionAtIndex(0) + await convertStablesDialog.actionsContainer.expectActions([ + { type: 'approve', asset: 'USDS' }, + { type: 'psmConvert', inToken: 'USDS', outToken: 'USDC' }, + ]) + }) -// test('displays transaction overview', async () => { -// await convertStablesDialog.expectTransactionOverview({ -// routeItems: [ -// { -// tokenAmount: '10,000.00 USDS', -// tokenUsdValue: '$10,000.00', -// }, -// { -// tokenAmount: '10,000.00 USDC', -// tokenUsdValue: '$10,000.00', -// }, -// ], -// outcome: '10,000.00 USDC', -// outcomeUsd: '$10,000.00', -// }) -// }) + test('displays transaction overview', async () => { + await convertStablesDialog.expectTransactionOverview({ + routeItems: [ + { + tokenAmount: '10,000.00 USDS', + tokenUsdValue: '$10,000.00', + }, + { + tokenAmount: '10,000.00 USDC', + tokenUsdValue: '$10,000.00', + }, + ], + outcome: '10,000.00 USDC', + outcomeUsd: '$10,000.00', + }) + }) -// test('executes conversion', async () => { -// await convertStablesDialog.actionsContainer.acceptAllActionsAction(2) -// await convertStablesDialog.expectSuccessPage() -// await convertStablesDialog.clickBackToSavingsButton() -// await savingsPage.expectStablecoinsInWalletAssetBalance('USDS', '-') -// await savingsPage.expectStablecoinsInWalletAssetBalance('USDC', '10,000.00') -// }) -// }) + test('executes conversion', async () => { + await convertStablesDialog.actionsContainer.acceptAllActionsAction(2) + await convertStablesDialog.expectSuccessPage() + await convertStablesDialog.clickBackToSavingsButton() + await savingsPage.expectStablecoinsInWalletAssetBalance('USDS', '-') + await savingsPage.expectStablecoinsInWalletAssetBalance('USDC', '10,000.00') + }) +}) diff --git a/packages/app/src/features/dialogs/convert-stables/e2e/mainnet/DaiToUsdc.test-e2e.ts b/packages/app/src/features/dialogs/convert-stables/e2e/mainnet/DaiToUsdc.test-e2e.ts index 29f46ec5d..fd535b167 100644 --- a/packages/app/src/features/dialogs/convert-stables/e2e/mainnet/DaiToUsdc.test-e2e.ts +++ b/packages/app/src/features/dialogs/convert-stables/e2e/mainnet/DaiToUsdc.test-e2e.ts @@ -1,67 +1,69 @@ -// import { SavingsPageObject } from '@/pages/Savings.PageObject' -// import { DEFAULT_BLOCK_NUMBER } from '@/test/e2e/constants' -// import { setupFork } from '@/test/e2e/forking/setupFork' -// import { setup } from '@/test/e2e/setup' -// import { test } from '@playwright/test' -// import { mainnet } from 'viem/chains' -// import { ConvertStablesDialogPageObject } from '../../ConvertStablesDialog.PageObject' +import { SavingsPageObject } from '@/pages/Savings.PageObject' +import { DEFAULT_BLOCK_NUMBER } from '@/test/e2e/constants' +import { setup } from '@/test/e2e/setup' +import { test } from '@playwright/test' +import { mainnet } from 'viem/chains' +import { ConvertStablesDialogPageObject } from '../../ConvertStablesDialog.PageObject' -// test.describe('Convert DAI to USDC', () => { -// const fork = setupFork({ blockNumber: DEFAULT_BLOCK_NUMBER, chainId: mainnet.id, useTenderlyVnet: true }) -// let savingsPage: SavingsPageObject -// let convertStablesDialog: ConvertStablesDialogPageObject +test.describe('Convert DAI to USDC', () => { + let savingsPage: SavingsPageObject + let convertStablesDialog: ConvertStablesDialogPageObject -// test.beforeEach(async ({ page }) => { -// await setup(page, fork, { -// initialPage: 'savings', -// account: { -// type: 'connected-random', -// assetBalances: { -// ETH: 1, -// DAI: 10_000, -// }, -// }, -// }) + test.beforeEach(async ({ page }) => { + const testContext = await setup(page, { + blockchain: { + blockNumber: DEFAULT_BLOCK_NUMBER, + chainId: mainnet.id, + }, + initialPage: 'savings', + account: { + type: 'connected-random', + assetBalances: { + ETH: 1, + DAI: 10_000, + }, + }, + }) -// savingsPage = new SavingsPageObject(page) -// await savingsPage.clickConvertStablesButtonAction() + savingsPage = new SavingsPageObject(testContext) + await savingsPage.clickConvertStablesButtonAction() -// convertStablesDialog = new ConvertStablesDialogPageObject(page) -// await convertStablesDialog.selectAssetInAction('DAI') -// await convertStablesDialog.selectAssetOutAction('USDC') -// await convertStablesDialog.fillAmountInAction(10_000) -// }) + convertStablesDialog = new ConvertStablesDialogPageObject(testContext) + await convertStablesDialog.selectAssetInAction('DAI') + await convertStablesDialog.selectAssetOutAction('USDC') + await convertStablesDialog.fillAmountInAction(10_000) + }) -// test('uses psm convert action', async () => { -// await convertStablesDialog.actionsContainer.expectEnabledActionAtIndex(0) -// await convertStablesDialog.actionsContainer.expectActions([ -// { type: 'approve', asset: 'DAI' }, -// { type: 'psmConvert', inToken: 'DAI', outToken: 'USDC' }, -// ]) -// }) + test('uses psm convert action', async () => { + await convertStablesDialog.actionsContainer.expectEnabledActionAtIndex(0) + await convertStablesDialog.actionsContainer.expectActions([ + { type: 'approve', asset: 'DAI' }, + { type: 'psmConvert', inToken: 'DAI', outToken: 'USDC' }, + ]) + }) -// test('displays transaction overview', async () => { -// await convertStablesDialog.expectTransactionOverview({ -// routeItems: [ -// { -// tokenAmount: '10,000.00 DAI', -// tokenUsdValue: '$10,000.00', -// }, -// { -// tokenAmount: '10,000.00 USDC', -// tokenUsdValue: '$10,000.00', -// }, -// ], -// outcome: '10,000.00 USDC', -// outcomeUsd: '$10,000.00', -// }) -// }) + test('displays transaction overview', async () => { + await convertStablesDialog.expectTransactionOverview({ + routeItems: [ + { + tokenAmount: '10,000.00 DAI', + tokenUsdValue: '$10,000.00', + }, + { + tokenAmount: '10,000.00 USDC', + tokenUsdValue: '$10,000.00', + }, + ], + outcome: '10,000.00 USDC', + outcomeUsd: '$10,000.00', + }) + }) -// test('executes conversion', async () => { -// await convertStablesDialog.actionsContainer.acceptAllActionsAction(2) -// await convertStablesDialog.expectSuccessPage() -// await convertStablesDialog.clickBackToSavingsButton() -// await savingsPage.expectStablecoinsInWalletAssetBalance('DAI', '-') -// await savingsPage.expectStablecoinsInWalletAssetBalance('USDC', '10,000.00') -// }) -// }) + test('executes conversion', async () => { + await convertStablesDialog.actionsContainer.acceptAllActionsAction(2) + await convertStablesDialog.expectSuccessPage() + await convertStablesDialog.clickBackToSavingsButton() + await savingsPage.expectStablecoinsInWalletAssetBalance('DAI', '-') + await savingsPage.expectStablecoinsInWalletAssetBalance('USDC', '10,000.00') + }) +}) diff --git a/packages/app/src/features/dialogs/convert-stables/e2e/mainnet/DaiToUsds.test-e2e.ts b/packages/app/src/features/dialogs/convert-stables/e2e/mainnet/DaiToUsds.test-e2e.ts index 4951bab59..df67ccb42 100644 --- a/packages/app/src/features/dialogs/convert-stables/e2e/mainnet/DaiToUsds.test-e2e.ts +++ b/packages/app/src/features/dialogs/convert-stables/e2e/mainnet/DaiToUsds.test-e2e.ts @@ -1,67 +1,69 @@ -// import { SavingsPageObject } from '@/pages/Savings.PageObject' -// import { DEFAULT_BLOCK_NUMBER } from '@/test/e2e/constants' -// import { setupFork } from '@/test/e2e/forking/setupFork' -// import { setup } from '@/test/e2e/setup' -// import { test } from '@playwright/test' -// import { mainnet } from 'viem/chains' -// import { ConvertStablesDialogPageObject } from '../../ConvertStablesDialog.PageObject' +import { SavingsPageObject } from '@/pages/Savings.PageObject' +import { DEFAULT_BLOCK_NUMBER } from '@/test/e2e/constants' +import { setup } from '@/test/e2e/setup' +import { test } from '@playwright/test' +import { mainnet } from 'viem/chains' +import { ConvertStablesDialogPageObject } from '../../ConvertStablesDialog.PageObject' -// test.describe('Convert DAI to USDS', () => { -// const fork = setupFork({ blockNumber: DEFAULT_BLOCK_NUMBER, chainId: mainnet.id, useTenderlyVnet: true }) -// let savingsPage: SavingsPageObject -// let convertStablesDialog: ConvertStablesDialogPageObject +test.describe('Convert DAI to USDS', () => { + let savingsPage: SavingsPageObject + let convertStablesDialog: ConvertStablesDialogPageObject -// test.beforeEach(async ({ page }) => { -// await setup(page, fork, { -// initialPage: 'savings', -// account: { -// type: 'connected-random', -// assetBalances: { -// ETH: 1, -// DAI: 10_000, -// }, -// }, -// }) + test.beforeEach(async ({ page }) => { + const testContext = await setup(page, { + blockchain: { + blockNumber: DEFAULT_BLOCK_NUMBER, + chainId: mainnet.id, + }, + initialPage: 'savings', + account: { + type: 'connected-random', + assetBalances: { + ETH: 1, + DAI: 10_000, + }, + }, + }) -// savingsPage = new SavingsPageObject(page) -// await savingsPage.clickConvertStablesButtonAction() + savingsPage = new SavingsPageObject(testContext) + await savingsPage.clickConvertStablesButtonAction() -// convertStablesDialog = new ConvertStablesDialogPageObject(page) -// await convertStablesDialog.selectAssetInAction('DAI') -// await convertStablesDialog.selectAssetOutAction('USDS') -// await convertStablesDialog.fillAmountInAction(10_000) -// }) + convertStablesDialog = new ConvertStablesDialogPageObject(testContext) + await convertStablesDialog.selectAssetInAction('DAI') + await convertStablesDialog.selectAssetOutAction('USDS') + await convertStablesDialog.fillAmountInAction(10_000) + }) -// test('uses upgrade action', async () => { -// await convertStablesDialog.actionsContainer.expectEnabledActionAtIndex(0) -// await convertStablesDialog.actionsContainer.expectActions([ -// { type: 'approve', asset: 'DAI' }, -// { type: 'upgrade', fromToken: 'DAI', toToken: 'USDS' }, -// ]) -// }) + test('uses upgrade action', async () => { + await convertStablesDialog.actionsContainer.expectEnabledActionAtIndex(0) + await convertStablesDialog.actionsContainer.expectActions([ + { type: 'approve', asset: 'DAI' }, + { type: 'upgrade', fromToken: 'DAI', toToken: 'USDS' }, + ]) + }) -// test('displays transaction overview', async () => { -// await convertStablesDialog.expectTransactionOverview({ -// routeItems: [ -// { -// tokenAmount: '10,000.00 DAI', -// tokenUsdValue: '$10,000.00', -// }, -// { -// tokenAmount: '10,000.00 USDS', -// tokenUsdValue: '$10,000.00', -// }, -// ], -// outcome: '10,000.00 USDS', -// outcomeUsd: '$10,000.00', -// }) -// }) + test('displays transaction overview', async () => { + await convertStablesDialog.expectTransactionOverview({ + routeItems: [ + { + tokenAmount: '10,000.00 DAI', + tokenUsdValue: '$10,000.00', + }, + { + tokenAmount: '10,000.00 USDS', + tokenUsdValue: '$10,000.00', + }, + ], + outcome: '10,000.00 USDS', + outcomeUsd: '$10,000.00', + }) + }) -// test('executes conversion', async () => { -// await convertStablesDialog.actionsContainer.acceptAllActionsAction(2) -// await convertStablesDialog.expectSuccessPage() -// await convertStablesDialog.clickBackToSavingsButton() -// await savingsPage.expectStablecoinsInWalletAssetBalance('DAI', '-') -// await savingsPage.expectStablecoinsInWalletAssetBalance('USDS', '10,000.00') -// }) -// }) + test('executes conversion', async () => { + await convertStablesDialog.actionsContainer.acceptAllActionsAction(2) + await convertStablesDialog.expectSuccessPage() + await convertStablesDialog.clickBackToSavingsButton() + await savingsPage.expectStablecoinsInWalletAssetBalance('DAI', '-') + await savingsPage.expectStablecoinsInWalletAssetBalance('USDS', '10,000.00') + }) +}) diff --git a/packages/app/src/features/dialogs/convert-stables/e2e/mainnet/UsdcToDai.test-e2e.ts b/packages/app/src/features/dialogs/convert-stables/e2e/mainnet/UsdcToDai.test-e2e.ts index 8efceca4a..15f35e0eb 100644 --- a/packages/app/src/features/dialogs/convert-stables/e2e/mainnet/UsdcToDai.test-e2e.ts +++ b/packages/app/src/features/dialogs/convert-stables/e2e/mainnet/UsdcToDai.test-e2e.ts @@ -1,67 +1,69 @@ -// import { SavingsPageObject } from '@/pages/Savings.PageObject' -// import { DEFAULT_BLOCK_NUMBER } from '@/test/e2e/constants' -// import { setupFork } from '@/test/e2e/forking/setupFork' -// import { setup } from '@/test/e2e/setup' -// import { test } from '@playwright/test' -// import { mainnet } from 'viem/chains' -// import { ConvertStablesDialogPageObject } from '../../ConvertStablesDialog.PageObject' +import { SavingsPageObject } from '@/pages/Savings.PageObject' +import { DEFAULT_BLOCK_NUMBER } from '@/test/e2e/constants' +import { setup } from '@/test/e2e/setup' +import { test } from '@playwright/test' +import { mainnet } from 'viem/chains' +import { ConvertStablesDialogPageObject } from '../../ConvertStablesDialog.PageObject' -// test.describe('Convert USDC to DAI', () => { -// const fork = setupFork({ blockNumber: DEFAULT_BLOCK_NUMBER, chainId: mainnet.id, useTenderlyVnet: true }) -// let savingsPage: SavingsPageObject -// let convertStablesDialog: ConvertStablesDialogPageObject +test.describe('Convert USDC to DAI', () => { + let savingsPage: SavingsPageObject + let convertStablesDialog: ConvertStablesDialogPageObject -// test.beforeEach(async ({ page }) => { -// await setup(page, fork, { -// initialPage: 'savings', -// account: { -// type: 'connected-random', -// assetBalances: { -// ETH: 1, -// USDC: 10_000, -// }, -// }, -// }) + test.beforeEach(async ({ page }) => { + const testContext = await setup(page, { + blockchain: { + blockNumber: DEFAULT_BLOCK_NUMBER, + chainId: mainnet.id, + }, + initialPage: 'savings', + account: { + type: 'connected-random', + assetBalances: { + ETH: 1, + USDC: 10_000, + }, + }, + }) -// savingsPage = new SavingsPageObject(page) -// await savingsPage.clickConvertStablesButtonAction() + savingsPage = new SavingsPageObject(testContext) + await savingsPage.clickConvertStablesButtonAction() -// convertStablesDialog = new ConvertStablesDialogPageObject(page) -// await convertStablesDialog.selectAssetInAction('USDC') -// await convertStablesDialog.selectAssetOutAction('DAI') -// await convertStablesDialog.fillAmountInAction(10_000) -// }) + convertStablesDialog = new ConvertStablesDialogPageObject(testContext) + await convertStablesDialog.selectAssetInAction('USDC') + await convertStablesDialog.selectAssetOutAction('DAI') + await convertStablesDialog.fillAmountInAction(10_000) + }) -// test('uses psm convert action', async () => { -// await convertStablesDialog.actionsContainer.expectEnabledActionAtIndex(0) -// await convertStablesDialog.actionsContainer.expectActions([ -// { type: 'approve', asset: 'USDC' }, -// { type: 'psmConvert', inToken: 'USDC', outToken: 'DAI' }, -// ]) -// }) + test('uses psm convert action', async () => { + await convertStablesDialog.actionsContainer.expectEnabledActionAtIndex(0) + await convertStablesDialog.actionsContainer.expectActions([ + { type: 'approve', asset: 'USDC' }, + { type: 'psmConvert', inToken: 'USDC', outToken: 'DAI' }, + ]) + }) -// test('displays transaction overview', async () => { -// await convertStablesDialog.expectTransactionOverview({ -// routeItems: [ -// { -// tokenAmount: '10,000.00 USDC', -// tokenUsdValue: '$10,000.00', -// }, -// { -// tokenAmount: '10,000.00 DAI', -// tokenUsdValue: '$10,000.00', -// }, -// ], -// outcome: '10,000.00 DAI', -// outcomeUsd: '$10,000.00', -// }) -// }) + test('displays transaction overview', async () => { + await convertStablesDialog.expectTransactionOverview({ + routeItems: [ + { + tokenAmount: '10,000.00 USDC', + tokenUsdValue: '$10,000.00', + }, + { + tokenAmount: '10,000.00 DAI', + tokenUsdValue: '$10,000.00', + }, + ], + outcome: '10,000.00 DAI', + outcomeUsd: '$10,000.00', + }) + }) -// test('executes conversion', async () => { -// await convertStablesDialog.actionsContainer.acceptAllActionsAction(2) -// await convertStablesDialog.expectSuccessPage() -// await convertStablesDialog.clickBackToSavingsButton() -// await savingsPage.expectStablecoinsInWalletAssetBalance('USDC', '-') -// await savingsPage.expectUpgradableDaiBalance('10,000.00') -// }) -// }) + test('executes conversion', async () => { + await convertStablesDialog.actionsContainer.acceptAllActionsAction(2) + await convertStablesDialog.expectSuccessPage() + await convertStablesDialog.clickBackToSavingsButton() + await savingsPage.expectStablecoinsInWalletAssetBalance('USDC', '-') + await savingsPage.expectUpgradableDaiBalance('10,000.00') + }) +}) diff --git a/packages/app/src/features/dialogs/convert-stables/e2e/mainnet/UsdcToUsds.test-e2e.ts b/packages/app/src/features/dialogs/convert-stables/e2e/mainnet/UsdcToUsds.test-e2e.ts index 92ecc0188..7c8568311 100644 --- a/packages/app/src/features/dialogs/convert-stables/e2e/mainnet/UsdcToUsds.test-e2e.ts +++ b/packages/app/src/features/dialogs/convert-stables/e2e/mainnet/UsdcToUsds.test-e2e.ts @@ -1,67 +1,69 @@ -// import { SavingsPageObject } from '@/pages/Savings.PageObject' -// import { DEFAULT_BLOCK_NUMBER } from '@/test/e2e/constants' -// import { setupFork } from '@/test/e2e/forking/setupFork' -// import { setup } from '@/test/e2e/setup' -// import { test } from '@playwright/test' -// import { mainnet } from 'viem/chains' -// import { ConvertStablesDialogPageObject } from '../../ConvertStablesDialog.PageObject' +import { SavingsPageObject } from '@/pages/Savings.PageObject' +import { DEFAULT_BLOCK_NUMBER } from '@/test/e2e/constants' +import { setup } from '@/test/e2e/setup' +import { test } from '@playwright/test' +import { mainnet } from 'viem/chains' +import { ConvertStablesDialogPageObject } from '../../ConvertStablesDialog.PageObject' -// test.describe('Convert USDC to USDS', () => { -// const fork = setupFork({ blockNumber: DEFAULT_BLOCK_NUMBER, chainId: mainnet.id, useTenderlyVnet: true }) -// let savingsPage: SavingsPageObject -// let convertStablesDialog: ConvertStablesDialogPageObject +test.describe('Convert USDC to USDS', () => { + let savingsPage: SavingsPageObject + let convertStablesDialog: ConvertStablesDialogPageObject -// test.beforeEach(async ({ page }) => { -// await setup(page, fork, { -// initialPage: 'savings', -// account: { -// type: 'connected-random', -// assetBalances: { -// ETH: 1, -// USDC: 10_000, -// }, -// }, -// }) + test.beforeEach(async ({ page }) => { + const testContext = await setup(page, { + blockchain: { + blockNumber: DEFAULT_BLOCK_NUMBER, + chainId: mainnet.id, + }, + initialPage: 'savings', + account: { + type: 'connected-random', + assetBalances: { + ETH: 1, + USDC: 10_000, + }, + }, + }) -// savingsPage = new SavingsPageObject(page) -// await savingsPage.clickConvertStablesButtonAction() + savingsPage = new SavingsPageObject(testContext) + await savingsPage.clickConvertStablesButtonAction() -// convertStablesDialog = new ConvertStablesDialogPageObject(page) -// await convertStablesDialog.selectAssetInAction('USDC') -// await convertStablesDialog.selectAssetOutAction('USDS') -// await convertStablesDialog.fillAmountInAction(10_000) -// }) + convertStablesDialog = new ConvertStablesDialogPageObject(testContext) + await convertStablesDialog.selectAssetInAction('USDC') + await convertStablesDialog.selectAssetOutAction('USDS') + await convertStablesDialog.fillAmountInAction(10_000) + }) -// test('uses psm convert action', async () => { -// await convertStablesDialog.actionsContainer.expectEnabledActionAtIndex(0) -// await convertStablesDialog.actionsContainer.expectActions([ -// { type: 'approve', asset: 'USDC' }, -// { type: 'psmConvert', inToken: 'USDC', outToken: 'USDS' }, -// ]) -// }) + test('uses psm convert action', async () => { + await convertStablesDialog.actionsContainer.expectEnabledActionAtIndex(0) + await convertStablesDialog.actionsContainer.expectActions([ + { type: 'approve', asset: 'USDC' }, + { type: 'psmConvert', inToken: 'USDC', outToken: 'USDS' }, + ]) + }) -// test('displays transaction overview', async () => { -// await convertStablesDialog.expectTransactionOverview({ -// routeItems: [ -// { -// tokenAmount: '10,000.00 USDC', -// tokenUsdValue: '$10,000.00', -// }, -// { -// tokenAmount: '10,000.00 USDS', -// tokenUsdValue: '$10,000.00', -// }, -// ], -// outcome: '10,000.00 USDS', -// outcomeUsd: '$10,000.00', -// }) -// }) + test('displays transaction overview', async () => { + await convertStablesDialog.expectTransactionOverview({ + routeItems: [ + { + tokenAmount: '10,000.00 USDC', + tokenUsdValue: '$10,000.00', + }, + { + tokenAmount: '10,000.00 USDS', + tokenUsdValue: '$10,000.00', + }, + ], + outcome: '10,000.00 USDS', + outcomeUsd: '$10,000.00', + }) + }) -// test('executes conversion', async () => { -// await convertStablesDialog.actionsContainer.acceptAllActionsAction(2) -// await convertStablesDialog.expectSuccessPage() -// await convertStablesDialog.clickBackToSavingsButton() -// await savingsPage.expectStablecoinsInWalletAssetBalance('USDC', '-') -// await savingsPage.expectStablecoinsInWalletAssetBalance('USDS', '10,000.00') -// }) -// }) + test('executes conversion', async () => { + await convertStablesDialog.actionsContainer.acceptAllActionsAction(2) + await convertStablesDialog.expectSuccessPage() + await convertStablesDialog.clickBackToSavingsButton() + await savingsPage.expectStablecoinsInWalletAssetBalance('USDC', '-') + await savingsPage.expectStablecoinsInWalletAssetBalance('USDS', '10,000.00') + }) +}) diff --git a/packages/app/src/features/dialogs/convert-stables/e2e/mainnet/UsdsToDai.test-e2e.ts b/packages/app/src/features/dialogs/convert-stables/e2e/mainnet/UsdsToDai.test-e2e.ts index e9bbf16df..9c04e05f4 100644 --- a/packages/app/src/features/dialogs/convert-stables/e2e/mainnet/UsdsToDai.test-e2e.ts +++ b/packages/app/src/features/dialogs/convert-stables/e2e/mainnet/UsdsToDai.test-e2e.ts @@ -1,67 +1,69 @@ -// import { SavingsPageObject } from '@/pages/Savings.PageObject' -// import { DEFAULT_BLOCK_NUMBER } from '@/test/e2e/constants' -// import { setupFork } from '@/test/e2e/forking/setupFork' -// import { setup } from '@/test/e2e/setup' -// import { test } from '@playwright/test' -// import { mainnet } from 'viem/chains' -// import { ConvertStablesDialogPageObject } from '../../ConvertStablesDialog.PageObject' +import { SavingsPageObject } from '@/pages/Savings.PageObject' +import { DEFAULT_BLOCK_NUMBER } from '@/test/e2e/constants' +import { setup } from '@/test/e2e/setup' +import { test } from '@playwright/test' +import { mainnet } from 'viem/chains' +import { ConvertStablesDialogPageObject } from '../../ConvertStablesDialog.PageObject' -// test.describe('Convert USDS to DAI', () => { -// const fork = setupFork({ blockNumber: DEFAULT_BLOCK_NUMBER, chainId: mainnet.id, useTenderlyVnet: true }) -// let savingsPage: SavingsPageObject -// let convertStablesDialog: ConvertStablesDialogPageObject +test.describe('Convert USDS to DAI', () => { + let savingsPage: SavingsPageObject + let convertStablesDialog: ConvertStablesDialogPageObject -// test.beforeEach(async ({ page }) => { -// await setup(page, fork, { -// initialPage: 'savings', -// account: { -// type: 'connected-random', -// assetBalances: { -// ETH: 1, -// USDS: 10_000, -// }, -// }, -// }) + test.beforeEach(async ({ page }) => { + const testContext = await setup(page, { + blockchain: { + blockNumber: DEFAULT_BLOCK_NUMBER, + chainId: mainnet.id, + }, + initialPage: 'savings', + account: { + type: 'connected-random', + assetBalances: { + ETH: 1, + USDS: 10_000, + }, + }, + }) -// savingsPage = new SavingsPageObject(page) -// await savingsPage.clickConvertStablesButtonAction() + savingsPage = new SavingsPageObject(testContext) + await savingsPage.clickConvertStablesButtonAction() -// convertStablesDialog = new ConvertStablesDialogPageObject(page) -// await convertStablesDialog.selectAssetInAction('USDS') -// await convertStablesDialog.selectAssetOutAction('DAI') -// await convertStablesDialog.fillAmountInAction(10_000) -// }) + convertStablesDialog = new ConvertStablesDialogPageObject(testContext) + await convertStablesDialog.selectAssetInAction('USDS') + await convertStablesDialog.selectAssetOutAction('DAI') + await convertStablesDialog.fillAmountInAction(10_000) + }) -// test('uses downgrade action', async () => { -// await convertStablesDialog.actionsContainer.expectEnabledActionAtIndex(0) -// await convertStablesDialog.actionsContainer.expectActions([ -// { type: 'approve', asset: 'USDS' }, -// { type: 'downgrade', fromToken: 'USDS', toToken: 'DAI' }, -// ]) -// }) + test('uses downgrade action', async () => { + await convertStablesDialog.actionsContainer.expectEnabledActionAtIndex(0) + await convertStablesDialog.actionsContainer.expectActions([ + { type: 'approve', asset: 'USDS' }, + { type: 'downgrade', fromToken: 'USDS', toToken: 'DAI' }, + ]) + }) -// test('displays transaction overview', async () => { -// await convertStablesDialog.expectTransactionOverview({ -// routeItems: [ -// { -// tokenAmount: '10,000.00 USDS', -// tokenUsdValue: '$10,000.00', -// }, -// { -// tokenAmount: '10,000.00 DAI', -// tokenUsdValue: '$10,000.00', -// }, -// ], -// outcome: '10,000.00 DAI', -// outcomeUsd: '$10,000.00', -// }) -// }) + test('displays transaction overview', async () => { + await convertStablesDialog.expectTransactionOverview({ + routeItems: [ + { + tokenAmount: '10,000.00 USDS', + tokenUsdValue: '$10,000.00', + }, + { + tokenAmount: '10,000.00 DAI', + tokenUsdValue: '$10,000.00', + }, + ], + outcome: '10,000.00 DAI', + outcomeUsd: '$10,000.00', + }) + }) -// test('executes conversion', async () => { -// await convertStablesDialog.actionsContainer.acceptAllActionsAction(2) -// await convertStablesDialog.expectSuccessPage() -// await convertStablesDialog.clickBackToSavingsButton() -// await savingsPage.expectStablecoinsInWalletAssetBalance('USDS', '-') -// await savingsPage.expectUpgradableDaiBalance('10,000.00') -// }) -// }) + test('executes conversion', async () => { + await convertStablesDialog.actionsContainer.acceptAllActionsAction(2) + await convertStablesDialog.expectSuccessPage() + await convertStablesDialog.clickBackToSavingsButton() + await savingsPage.expectStablecoinsInWalletAssetBalance('USDS', '-') + await savingsPage.expectUpgradableDaiBalance('10,000.00') + }) +}) diff --git a/packages/app/src/features/dialogs/convert-stables/e2e/mainnet/UsdsToUsdc.test-e2e.ts b/packages/app/src/features/dialogs/convert-stables/e2e/mainnet/UsdsToUsdc.test-e2e.ts index ce075748b..1e84f5d25 100644 --- a/packages/app/src/features/dialogs/convert-stables/e2e/mainnet/UsdsToUsdc.test-e2e.ts +++ b/packages/app/src/features/dialogs/convert-stables/e2e/mainnet/UsdsToUsdc.test-e2e.ts @@ -1,67 +1,69 @@ -// import { SavingsPageObject } from '@/pages/Savings.PageObject' -// import { DEFAULT_BLOCK_NUMBER } from '@/test/e2e/constants' -// import { setupFork } from '@/test/e2e/forking/setupFork' -// import { setup } from '@/test/e2e/setup' -// import { test } from '@playwright/test' -// import { mainnet } from 'viem/chains' -// import { ConvertStablesDialogPageObject } from '../../ConvertStablesDialog.PageObject' +import { SavingsPageObject } from '@/pages/Savings.PageObject' +import { DEFAULT_BLOCK_NUMBER } from '@/test/e2e/constants' +import { setup } from '@/test/e2e/setup' +import { test } from '@playwright/test' +import { mainnet } from 'viem/chains' +import { ConvertStablesDialogPageObject } from '../../ConvertStablesDialog.PageObject' -// test.describe('Convert USDS to USDC', () => { -// const fork = setupFork({ blockNumber: DEFAULT_BLOCK_NUMBER, chainId: mainnet.id, useTenderlyVnet: true }) -// let savingsPage: SavingsPageObject -// let convertStablesDialog: ConvertStablesDialogPageObject +test.describe('Convert USDS to USDC', () => { + let savingsPage: SavingsPageObject + let convertStablesDialog: ConvertStablesDialogPageObject -// test.beforeEach(async ({ page }) => { -// await setup(page, fork, { -// initialPage: 'savings', -// account: { -// type: 'connected-random', -// assetBalances: { -// ETH: 1, -// USDS: 10_000, -// }, -// }, -// }) + test.beforeEach(async ({ page }) => { + const testContext = await setup(page, { + blockchain: { + blockNumber: DEFAULT_BLOCK_NUMBER, + chainId: mainnet.id, + }, + initialPage: 'savings', + account: { + type: 'connected-random', + assetBalances: { + ETH: 1, + USDS: 10_000, + }, + }, + }) -// savingsPage = new SavingsPageObject(page) -// await savingsPage.clickConvertStablesButtonAction() + savingsPage = new SavingsPageObject(testContext) + await savingsPage.clickConvertStablesButtonAction() -// convertStablesDialog = new ConvertStablesDialogPageObject(page) -// await convertStablesDialog.selectAssetInAction('USDS') -// await convertStablesDialog.selectAssetOutAction('USDC') -// await convertStablesDialog.fillAmountInAction(10_000) -// }) + convertStablesDialog = new ConvertStablesDialogPageObject(testContext) + await convertStablesDialog.selectAssetInAction('USDS') + await convertStablesDialog.selectAssetOutAction('USDC') + await convertStablesDialog.fillAmountInAction(10_000) + }) -// test('uses psm convert action', async () => { -// await convertStablesDialog.actionsContainer.expectEnabledActionAtIndex(0) -// await convertStablesDialog.actionsContainer.expectActions([ -// { type: 'approve', asset: 'USDS' }, -// { type: 'psmConvert', inToken: 'USDS', outToken: 'USDC' }, -// ]) -// }) + test('uses psm convert action', async () => { + await convertStablesDialog.actionsContainer.expectEnabledActionAtIndex(0) + await convertStablesDialog.actionsContainer.expectActions([ + { type: 'approve', asset: 'USDS' }, + { type: 'psmConvert', inToken: 'USDS', outToken: 'USDC' }, + ]) + }) -// test('displays transaction overview', async () => { -// await convertStablesDialog.expectTransactionOverview({ -// routeItems: [ -// { -// tokenAmount: '10,000.00 USDS', -// tokenUsdValue: '$10,000.00', -// }, -// { -// tokenAmount: '10,000.00 USDC', -// tokenUsdValue: '$10,000.00', -// }, -// ], -// outcome: '10,000.00 USDC', -// outcomeUsd: '$10,000.00', -// }) -// }) + test('displays transaction overview', async () => { + await convertStablesDialog.expectTransactionOverview({ + routeItems: [ + { + tokenAmount: '10,000.00 USDS', + tokenUsdValue: '$10,000.00', + }, + { + tokenAmount: '10,000.00 USDC', + tokenUsdValue: '$10,000.00', + }, + ], + outcome: '10,000.00 USDC', + outcomeUsd: '$10,000.00', + }) + }) -// test('executes conversion', async () => { -// await convertStablesDialog.actionsContainer.acceptAllActionsAction(2) -// await convertStablesDialog.expectSuccessPage() -// await convertStablesDialog.clickBackToSavingsButton() -// await savingsPage.expectStablecoinsInWalletAssetBalance('USDS', '-') -// await savingsPage.expectStablecoinsInWalletAssetBalance('USDC', '10,000.00') -// }) -// }) + test('executes conversion', async () => { + await convertStablesDialog.actionsContainer.acceptAllActionsAction(2) + await convertStablesDialog.expectSuccessPage() + await convertStablesDialog.clickBackToSavingsButton() + await savingsPage.expectStablecoinsInWalletAssetBalance('USDS', '-') + await savingsPage.expectStablecoinsInWalletAssetBalance('USDC', '10,000.00') + }) +})