Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor e2e tests setup #491

Open
wants to merge 30 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
f366183
Comment all e2e tests
yivlad Dec 13, 2024
2ab7012
wip
yivlad Dec 13, 2024
2f2c31f
Wip
yivlad Dec 13, 2024
5346d0d
Make claim tests deterministic
yivlad Dec 13, 2024
26074fa
Fix eslint and biome errors
oskarvu Dec 16, 2024
1d37353
Extract account creation to helper function and simplify
oskarvu Dec 16, 2024
0532c67
Simplify setup function
yivlad Dec 16, 2024
f359307
Introduce test context
yivlad Dec 17, 2024
6b47fca
Rename file
oskarvu Dec 17, 2024
df5350c
Rewrite easy borrow e2e tests (#499)
oskarvu Dec 18, 2024
3ff97d2
Rewrite markets and market details tests (#500)
oskarvu Dec 18, 2024
058fdd0
Rewrite app layout E2E tests (#502)
yivlad Dec 18, 2024
49ebaf8
Rewrite savings, farm and my portfolio pages tests (#501)
oskarvu Dec 18, 2024
0a2e07c
Rewrite e-Mode E2E tests (#503)
yivlad Dec 19, 2024
f86cf6b
Rewrite deposit dialog E2E tests (#505)
yivlad Dec 19, 2024
4b26e8e
Update topbar tests (#504)
oskarvu Dec 19, 2024
5ef23d2
Farm unstake tests (#506)
oskarvu Dec 19, 2024
cb71779
Rewrite farm stake dialog tests (#507)
oskarvu Dec 19, 2024
c068e8f
Rewrite claim rewards dialog tests (#508)
oskarvu Dec 19, 2024
846543d
Rewrite deposit to savings E2E tests (#511)
yivlad Dec 20, 2024
048e5d9
Fix browser time management in tests and rewrite repay tests (#512)
oskarvu Dec 20, 2024
070568f
Rewrite migrate E2E tests (#515)
yivlad Dec 20, 2024
3a8aa84
Rewrite convert stables tests (#517)
oskarvu Dec 21, 2024
891b8ed
Rewrite collateral dialog tests (#518)
oskarvu Dec 21, 2024
65dc12e
Rewrite withdraw dialog tests (#516)
oskarvu Dec 21, 2024
440a6a7
Rewrite borrow dialog tests (#519)
oskarvu Dec 21, 2024
08c5e32
Finish savings deposit E2E tests rewrite (#520)
yivlad Dec 21, 2024
70d2d7b
Rewrite savings withdraw E2E tests (#521)
yivlad Dec 21, 2024
6dc8f70
Merge branch 'main' into yivlad/refactor-e2e-tests-setup
yivlad Dec 21, 2024
b30f98d
Fix cleanup on exit
yivlad Dec 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@
"zustand": "^4.4.1"
},
"devDependencies": {
"@marsfoundation/common-nodejs": "workspace:^",
"@marsfoundation/common-testnets": "workspace:^",
"@chromatic-com/storybook": "^1.5.0",
"@playwright/test": "^1.47.2",
"@sentry/react": "^7.114.0",
Expand Down
50 changes: 19 additions & 31 deletions packages/app/src/config/chain/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { zeroAddress } from 'viem'
import { base, gnosis, mainnet } from 'viem/chains'
import { NATIVE_ASSET_MOCK_ADDRESS, infoSkyApiUrl } from '../consts'
import { AppConfig } from '../feature-flags'
import { PLAYWRIGHT_USDS_CONTRACTS_NOT_AVAILABLE_KEY } from '../wagmi/config.e2e'
import { SUPPORTED_CHAINS, farmAddresses, farmStablecoinsEntryGroup, susdsAddresses } from './constants'
import { ChainConfigEntry, ChainMeta, SupportedChainId } from './types'

Expand All @@ -32,16 +31,13 @@ const commonTokenSymbolToReplacedName = {
[TokenSymbol('weETH')]: { name: 'Ether.fi Staked ETH', symbol: TokenSymbol('weETH') },
}

const PLAYWRIGHT_MAINNET_USDS_CONTRACTS_NOT_AVAILABLE =
import.meta.env.VITE_PLAYWRIGHT === '1' && (window as any)[PLAYWRIGHT_USDS_CONTRACTS_NOT_AVAILABLE_KEY] === true

const chainConfig: Record<SupportedChainId, ChainConfigEntry> = {
[mainnet.id]: {
originChainId: mainnet.id,
daiSymbol: TokenSymbol('DAI'),
sdaiSymbol: TokenSymbol('sDAI'),
usdsSymbol: PLAYWRIGHT_MAINNET_USDS_CONTRACTS_NOT_AVAILABLE ? undefined : TokenSymbol('USDS'),
susdsSymbol: PLAYWRIGHT_MAINNET_USDS_CONTRACTS_NOT_AVAILABLE ? undefined : TokenSymbol('sUSDS'),
usdsSymbol: TokenSymbol('USDS'),
susdsSymbol: TokenSymbol('sUSDS'),
psmStables: [TokenSymbol('DAI'), TokenSymbol('USDC'), TokenSymbol('USDS')],
meta: {
name: 'Ethereum Mainnet',
Expand Down Expand Up @@ -89,25 +85,21 @@ const chainConfig: Record<SupportedChainId, ChainConfigEntry> = {
oracleType: 'vault',
address: CheckedAddress('0x83f20f44975d03b1b09e64809b757c47f942beea'),
},
...(PLAYWRIGHT_MAINNET_USDS_CONTRACTS_NOT_AVAILABLE
? []
: ([
{
symbol: TokenSymbol('sUSDS'),
oracleType: 'vault',
address: susdsAddresses[mainnet.id],
},
{
symbol: TokenSymbol('USDS'),
oracleType: 'fixed-usd',
address: CheckedAddress('0xdC035D45d973E3EC169d2276DDab16f1e407384F'),
},
{
symbol: TokenSymbol('SKY'),
oracleType: 'zero-price',
address: CheckedAddress('0x56072C95FAA701256059aa122697B133aDEd9279'),
},
] as const)),
{
symbol: TokenSymbol('sUSDS'),
oracleType: 'vault',
address: susdsAddresses[mainnet.id],
},
{
symbol: TokenSymbol('USDS'),
oracleType: 'fixed-usd',
address: CheckedAddress('0xdC035D45d973E3EC169d2276DDab16f1e407384F'),
},
{
symbol: TokenSymbol('SKY'),
oracleType: 'zero-price',
address: CheckedAddress('0x56072C95FAA701256059aa122697B133aDEd9279'),
},
],
markets: {
defaultAssetToBorrow: TokenSymbol('DAI'),
Expand Down Expand Up @@ -165,12 +157,8 @@ const chainConfig: Record<SupportedChainId, ChainConfigEntry> = {
},
savings: {
savingsDaiInfoQuery: mainnetSavingsDaiInfoQuery,
savingsUsdsInfoQuery: PLAYWRIGHT_MAINNET_USDS_CONTRACTS_NOT_AVAILABLE ? undefined : mainnetSavingsUsdsInfoQuery,
inputTokens: [
TokenSymbol('DAI'),
TokenSymbol('USDC'),
...(PLAYWRIGHT_MAINNET_USDS_CONTRACTS_NOT_AVAILABLE ? [] : [TokenSymbol('USDS')]),
],
savingsUsdsInfoQuery: mainnetSavingsUsdsInfoQuery,
inputTokens: [TokenSymbol('DAI'), TokenSymbol('USDC'), TokenSymbol('USDS')],
getEarningsApiUrl: (address) => `${infoSkyApiUrl}/savings-rate/wallets/${address.toLowerCase()}/?days_ago=9999`,
savingsRateApiUrl: `${infoSkyApiUrl}/savings-rate/`,
},
Expand Down
4 changes: 4 additions & 0 deletions packages/app/src/config/feature-flags/appConfig.default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ export function getDefaultAppConfig(): AppConfig {
address: '0xdC035D45d973E3EC169d2276DDab16f1e407384F',
decimals: 18,
},
cbBTC: {
address: '0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf',
decimals: 8,
},
},
},
},
Expand Down
1 change: 0 additions & 1 deletion packages/app/src/config/wagmi/config.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export const PLAYWRIGHT_CHAIN_ID = '__PLAYWRIGHT_CHAIN_ID' as const
export const PLAYWRIGHT_WALLET_ADDRESS_KEY = '__PLAYWRIGHT_WALLET_ADDRESS' as const
export const PLAYWRIGHT_WALLET_PRIVATE_KEY_KEY = '__PLAYWRIGHT_WALLET_PRIVATE_KEY' as const
export const PLAYWRIGHT_WALLET_FORK_URL_KEY = '__PLAYWRIGHT_WALLET_FORK_URL_KEY' as const
export const PLAYWRIGHT_USDS_CONTRACTS_NOT_AVAILABLE_KEY = '__PLAYWRIGHT_USDS_CONTRACTS_NOT_AVAILABLE' as const

export const VIEM_TIMEOUT_ON_FORKS = 60_000 // forks tend to be slow. This improves reliability/performance. Default is 10_000

Expand Down
29 changes: 11 additions & 18 deletions packages/app/src/features/actions/ActionsContainer.PageObject.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
import { Locator, Page, expect } from '@playwright/test'
import { Locator, expect } from '@playwright/test'

import { formatPercentage } from '@/domain/common/format'
import { BasePageObject } from '@/test/e2e/BasePageObject'
import { ForkContext } from '@/test/e2e/forking/setupFork'
import { isPage } from '@/test/e2e/utils'
import { TestContext } from '@/test/e2e/setup'
import { testIds } from '@/ui/utils/testIds'
import { Percentage } from '@marsfoundation/common-universal'
import { ActionType } from './logic/types'

export class ActionsPageObject extends BasePageObject {
constructor(pageOrLocator: Page | Locator) {
if (isPage(pageOrLocator)) {
super(pageOrLocator)
constructor(testContext: TestContext<any>, locator?: Locator) {
super(testContext, locator)
if (!locator) {
this.region = this.locatePanelByHeader('Actions')
} else {
super(pageOrLocator)
}
}

Expand All @@ -27,27 +24,23 @@ export class ActionsPageObject extends BasePageObject {
}

// #region actions
async acceptAllActionsAction(expectedNumberOfActions: number, forkContext?: ForkContext): Promise<void> {
async acceptAllActionsAction(expectedNumberOfActions: number): Promise<void> {
for (let index = 0; index < expectedNumberOfActions; index++) {
const row = this.region.getByTestId(testIds.actions.row(index))

await row.getByRole('button', { name: actionButtonRegex }).click()
await expect(row.getByRole('button', { name: actionButtonRegex })).not.toBeVisible()
// @note: we are setting block timestamp of the next tx (especially after executing all txs)
if (forkContext?.isVnet) {
await expect(row.getByRole('button', { name: actionButtonRegex })).not.toBeVisible()
await forkContext.progressSimulation(this.page, 5)
}
await this.testContext.testnetController.progressSimulation(5)
}
}

async acceptActionAtIndex(index: number, forkContext?: ForkContext): Promise<void> {
async acceptActionAtIndex(index: number): Promise<void> {
const row = this.region.getByTestId(testIds.actions.row(index))
await row.getByRole('button', { name: actionButtonRegex }).click()
await expect(row.getByRole('button', { name: actionButtonRegex })).not.toBeVisible()
// @note: we are setting block timestamp of the next tx (especially after executing all txs)
if (forkContext?.isVnet) {
await expect(row.getByRole('button', { name: actionButtonRegex })).not.toBeVisible()
await forkContext.progressSimulation(this.page, 5)
}
await this.testContext.testnetController.progressSimulation(5)
}

async switchPreferPermitsAction(): Promise<void> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ export function createApproveActionConfig(action: ApproveAction, context: Action
account,
chainId,
}),
select: (data) => ({ canBeSkipped: data >= toBigInt(action.token.toBaseUnit(action.value)) }),
select: (data) => ({
canBeSkipped: data >= toBigInt(action.token.toBaseUnit(action.requiredValue ?? action.value)),
}),
})
},

Expand Down
Loading
Loading