-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #684 from OasisDEX/earn-protocol-position-page
Earn protocol - Tests for position pages
- Loading branch information
Showing
10 changed files
with
180 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,17 @@ | ||
import { Page } from '@playwright/test'; | ||
import { VaultExposure } from './vaultExposure'; | ||
import { VaultSidebar } from '../vaultSidebar'; | ||
|
||
export class PositionPage { | ||
readonly page: Page; | ||
|
||
readonly exposure: VaultExposure; | ||
|
||
readonly sideBar: VaultSidebar; | ||
|
||
constructor(page: Page) { | ||
this.page = page; | ||
this.exposure = new VaultExposure(page); | ||
this.sideBar = new VaultSidebar(page, this.page.locator('[class*="_sidebarWrapper_"]')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { expect, step } from '#noWalletFixtures'; | ||
import { Locator, Page } from '@playwright/test'; | ||
|
||
export class VaultExposure { | ||
readonly page: Page; | ||
|
||
readonly vaultExposureLocator: Locator; | ||
|
||
constructor(page: Page) { | ||
this.page = page; | ||
this.vaultExposureLocator = page.locator('button:has-text("Vault exposure")').locator('..'); | ||
} | ||
|
||
@step | ||
async viewMore() { | ||
await this.vaultExposureLocator.getByText('View more').click(); | ||
expect(this.vaultExposureLocator.getByText('View less')).toBeVisible(); | ||
} | ||
|
||
@step | ||
async viewLess() { | ||
await this.vaultExposureLocator.getByText('View less').click(); | ||
expect(this.vaultExposureLocator.getByText('View more')).toBeVisible(); | ||
} | ||
|
||
@step | ||
async getStrategiesTotalAllocation() { | ||
const strategyAllocationLocator = this.vaultExposureLocator.locator('tr > td:nth-child(2)'); | ||
// Wait for table to load | ||
await expect(strategyAllocationLocator.first()).toBeVisible(); | ||
|
||
const viewMoreIsVisible = await this.vaultExposureLocator.getByText('View more').isVisible(); | ||
if (viewMoreIsVisible) await this.viewMore(); | ||
|
||
const allocations = (await strategyAllocationLocator.allInnerTexts()).map((text) => | ||
parseFloat(text.replace('%', '')) | ||
); | ||
|
||
const totalAllocation = allocations.reduce((a, b) => a + b, 0); | ||
|
||
return totalAllocation; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { expect, test } from '#earnProtocolFixtures'; | ||
|
||
test.describe(`Earn page`, async () => { | ||
test.beforeEach(async ({ app }) => { | ||
await app.page.goto('/earn/arbitrum/position/earn-mcyieldface-usdc'); | ||
}); | ||
|
||
test('It should show strategies exposure and be 100% in total', async ({ app }) => { | ||
const totalAllocation = await app.positionPage.exposure.getStrategiesTotalAllocation(); | ||
|
||
expect(totalAllocation).toBeCloseTo(100); | ||
expect(totalAllocation).toBeLessThanOrEqual(100); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { expect, test } from '#earnProtocolFixtures'; | ||
|
||
test.describe(`Earn page`, async () => { | ||
test.beforeEach(async ({ app }) => { | ||
await app.page.goto('/earn/base/position/usdc-ya-later'); | ||
}); | ||
|
||
test('It should show strategies exposure and be 100% in total', async ({ app }) => { | ||
const totalAllocation = await app.positionPage.exposure.getStrategiesTotalAllocation(); | ||
|
||
expect(totalAllocation).toBeCloseTo(100); | ||
expect(totalAllocation).toBeLessThanOrEqual(100); | ||
}); | ||
}); |
51 changes: 51 additions & 0 deletions
51
testsEarnProtocol/withRealWallet/arbitrum/positionPage.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { testWithSynpress } from '@synthetixio/synpress'; | ||
import { test as withWalletArbitrumFixtures } from '../../../srcEarnProtocol/fixtures/withTestWalletArbitrum'; | ||
import { logInWithWalletAddress } from 'srcEarnProtocol/utils/logIn'; | ||
import { expectDefaultTimeout, longTestTimeout } from 'utils/config'; | ||
|
||
const test = testWithSynpress(withWalletArbitrumFixtures); | ||
|
||
const { expect } = test; | ||
|
||
test.describe('With reaal wallet - Arbitrum', async () => { | ||
test.beforeEach(async ({ app, metamask }) => { | ||
await logInWithWalletAddress({ | ||
metamask, | ||
app, | ||
wallet: 'MetaMask', | ||
network: 'Arbitrum', | ||
}); | ||
}); | ||
|
||
test('It should show USDC balance in Arbitrum USDC position', async ({ app, metamask }) => { | ||
await app.page.goto('/earn/arbitrum/position/earn-mcyieldface-usdc'); | ||
|
||
/* | ||
Changing network in position page to avoid weird issue with Arbitrum | ||
when switching network in main page (/) and the visiting position page | ||
*/ | ||
await app.positionPage.sideBar.changeNetwork({ delay: 500 }); | ||
await metamask.approveSwitchNetwork(); | ||
await app.page.reload(); | ||
|
||
await app.positionPage.sideBar.shouldHaveBalance({ | ||
balance: '1.00', | ||
token: 'USDC', | ||
timeout: expectDefaultTimeout * 2, | ||
}); | ||
}); | ||
|
||
// TODO - Add one or more tokens once it'sworking | ||
// test.skip('It should show ??? balance in Arbitrum USDC position', async ({ app }) => { | ||
// await app.page.goto('/earn/arbitrum/position/earn-mcyieldface-usdc'); | ||
|
||
// await app.positionPage.sideBar.openBalanceTokens(); | ||
// await app.positionPage.sideBar.selectBalanceToken('USDBC'); | ||
|
||
// await app.positionPage.sideBar.shouldHaveBalance({ | ||
// balance: '1.05', | ||
// token: 'USDBC', | ||
// timeout: expectDefaultTimeout * 2, | ||
// }); | ||
// }); | ||
}); |
18 changes: 0 additions & 18 deletions
18
testsEarnProtocol/withRealWallet/arbitrum/withRealWalletSampleTest.spec.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters