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

Rewrite deposit to savings E2E tests #511

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
import { SavingsPageObject } from '@/pages/Savings.PageObject'
import { BASE_DEFAULT_BLOCK_NUMBER, DEFAULT_BLOCK_NUMBER, GNOSIS_DEFAULT_BLOCK_NUMBER } from '@/test/e2e/constants'
import { setup } from '@/test/e2e/setup'
import { test } from '@playwright/test'
import { base, gnosis, mainnet } from 'viem/chains'
import { SavingsDialogPageObject } from '../../common/e2e/SavingsDialog.PageObject'

test.describe('Savings deposit dialog', () => {
test.describe('Mainnet', () => {
let depositDialog: SavingsDialogPageObject
let savingsPage: SavingsPageObject

test.beforeEach(async ({ page }) => {
const testContext = await setup(page, {
blockchain: {
chainId: mainnet.id,
blockNumber: DEFAULT_BLOCK_NUMBER,
},
initialPage: 'savings',
account: {
type: 'connected-random',
assetBalances: {
ETH: 1,
DAI: 10_000,
USDC: 10_000,
},
},
})

savingsPage = new SavingsPageObject(testContext)
await savingsPage.clickStartSavingButtonAction()

depositDialog = new SavingsDialogPageObject({ testContext, type: 'deposit' })
})

test('can switch between tokens', async () => {
await depositDialog.fillAmountAction(1000)
await depositDialog.actionsContainer.expectEnabledActionAtIndex(0)
await depositDialog.actionsContainer.expectActions([
{ type: 'approve', asset: 'DAI' },
{ type: 'depositToSavings', asset: 'DAI', savingsAsset: 'sUSDS' },
])

await depositDialog.selectAssetAction('USDC')
await depositDialog.fillAmountAction(1000)
await depositDialog.actionsContainer.expectEnabledActionAtIndex(0)
await depositDialog.actionsContainer.expectActions([
{ type: 'approve', asset: 'USDC' },
{ type: 'depositToSavings', asset: 'USDC', savingsAsset: 'sUSDS' },
])

await depositDialog.selectAssetAction('DAI')
await depositDialog.fillAmountAction(1000)
await depositDialog.actionsContainer.expectEnabledActionAtIndex(0)
await depositDialog.actionsContainer.expectActions([
{ type: 'approve', asset: 'DAI' },
{ type: 'depositToSavings', asset: 'DAI', savingsAsset: 'sUSDS' },
])
})

test('can select only supported assets', async () => {
await depositDialog.openAssetSelectorAction()
await depositDialog.expectAssetSelectorOptions(['DAI', 'USDC', 'USDS'])
})
})

test.describe('Gnosis', () => {
let savingsPage: SavingsPageObject
let depositDialog: SavingsDialogPageObject

test.beforeEach(async ({ page }) => {
const testContext = await setup(page, {
blockchain: {
chainId: gnosis.id,
blockNumber: GNOSIS_DEFAULT_BLOCK_NUMBER,
},
initialPage: 'savings',
account: {
type: 'connected-random',
assetBalances: {
XDAI: 100,
},
},
})

savingsPage = new SavingsPageObject(testContext)
await savingsPage.clickStartSavingButtonAction()

depositDialog = new SavingsDialogPageObject({ testContext, type: 'deposit' })
})

test('can select only supported assets', async () => {
await depositDialog.openAssetSelectorAction()
await depositDialog.expectAssetSelectorOptions(['XDAI'])
})
})

test.describe('Base', () => {
let depositDialog: SavingsDialogPageObject
let savingsPage: SavingsPageObject

test.beforeEach(async ({ page }) => {
const testContext = await setup(page, {
blockchain: {
chainId: base.id,
blockNumber: BASE_DEFAULT_BLOCK_NUMBER,
},
initialPage: 'savings',
account: {
type: 'connected-random',
assetBalances: {
USDC: 1000,
USDS: 10_000,
},
},
})

savingsPage = new SavingsPageObject(testContext)
await savingsPage.clickStartSavingButtonAction()

depositDialog = new SavingsDialogPageObject({ testContext, type: 'deposit' })
})

test('can switch between tokens', async () => {
await depositDialog.fillAmountAction(1000)
await depositDialog.actionsContainer.expectEnabledActionAtIndex(0)
await depositDialog.actionsContainer.expectActions([
{ type: 'approve', asset: 'USDS' },
{ type: 'depositToSavings', asset: 'USDS', savingsAsset: 'sUSDS' },
])

await depositDialog.selectAssetAction('USDC')
await depositDialog.fillAmountAction(1000)
await depositDialog.actionsContainer.expectEnabledActionAtIndex(0)
await depositDialog.actionsContainer.expectActions([
{ type: 'approve', asset: 'USDC' },
{ type: 'depositToSavings', asset: 'USDC', savingsAsset: 'sUSDS' },
])

await depositDialog.selectAssetAction('USDS')
await depositDialog.fillAmountAction(1000)
await depositDialog.actionsContainer.expectEnabledActionAtIndex(0)
await depositDialog.actionsContainer.expectActions([
{ type: 'approve', asset: 'USDS' },
{ type: 'depositToSavings', asset: 'USDS', savingsAsset: 'sUSDS' },
])
})

test('can select only supported assets', async () => {
await depositDialog.openAssetSelectorAction()
await depositDialog.expectAssetSelectorOptions(['USDC', 'USDS'])
})
})
})
Loading
Loading