-
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 #713 from OasisDEX/earn-protocol-tests-jan-20-3
Earn protocol - Tests
- Loading branch information
Showing
4 changed files
with
141 additions
and
2 deletions.
There are no files selected for viewing
79 changes: 79 additions & 0 deletions
79
srcEarnProtocol/pages/portfolio/rewards/claimAndDelegate.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,79 @@ | ||
import { expect } from '#earnProtocolFixtures'; | ||
import { step } from '#noWalletFixtures'; | ||
import { Page } from '@playwright/test'; | ||
|
||
export class ClaimAndDelegate { | ||
readonly page: Page; | ||
|
||
constructor(page: Page) { | ||
this.page = page; | ||
} | ||
|
||
@step | ||
async shouldBeVisible() { | ||
await expect( | ||
this.page.getByText('Claim & Delegate'), | ||
'"Claim & Delegate" header should be visible' | ||
).toBeVisible(); | ||
} | ||
|
||
@step | ||
async shouldHaveButton( | ||
button: 'Reject' | 'Accept & Sign' | 'Loading' | 'Continue', | ||
args?: { hidden: boolean } | ||
) { | ||
if (args?.hidden) { | ||
await expect(this.page.locator(`button:has-text("${button}")`)).not.toBeVisible(); | ||
} else { | ||
await expect(this.page.locator(`button:has-text("${button}")`)).toBeVisible(); | ||
} | ||
} | ||
|
||
@step | ||
async reject() { | ||
await this.page.locator('button:has-text("Reject terms")').click(); | ||
} | ||
|
||
@step | ||
async acceptAndSign() { | ||
await this.page.locator('button:has-text("Accept & Sign")').click(); | ||
} | ||
|
||
@step | ||
async continue() { | ||
await this.page.locator('button:has-text("Continue")').click(); | ||
} | ||
|
||
@step | ||
async shouldHaveEarnedRewards({ sumr, usd }: { sumr: string; usd: string }) { | ||
const sumrRegExp = new RegExp(sumr); | ||
const usdRegExp = new RegExp(`\\$.*${usd}`); | ||
const haveEarnedLocator = this.page.locator('p:has-text("You have earned")'); | ||
|
||
await expect(haveEarnedLocator.locator('xpath=//following-sibling::div[1]')).toContainText( | ||
sumrRegExp | ||
); | ||
await expect(haveEarnedLocator.locator('xpath=//following-sibling::p[1]')).toContainText( | ||
usdRegExp | ||
); | ||
} | ||
|
||
@step | ||
async claim() { | ||
await this.page.locator('button:has-text("Claim")').click(); | ||
} | ||
|
||
@step | ||
async shouldHaveClaimedRewards({ sumr, usd }: { sumr: string; usd: string }) { | ||
const sumrRegExp = new RegExp(sumr); | ||
const usdRegExp = new RegExp(`\\$.*${usd}`); | ||
const haveEarnedLocator = this.page.locator('p:has-text("You have claimed")'); | ||
|
||
await expect(haveEarnedLocator.locator('xpath=//following-sibling::div[1]')).toContainText( | ||
sumrRegExp | ||
); | ||
await expect(haveEarnedLocator.locator('xpath=//following-sibling::p[1]')).toContainText( | ||
usdRegExp | ||
); | ||
} | ||
} |
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
52 changes: 52 additions & 0 deletions
52
testsEarnProtocol/withRealWallet/portfolio/sumrRewards.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,52 @@ | ||
import { testWithSynpress } from '@synthetixio/synpress'; | ||
import { test as withRealWalletBaseFixtures } from '../../../srcEarnProtocol/fixtures/withRealWalletBase'; | ||
import { logInWithWalletAddress } from 'srcEarnProtocol/utils/logIn'; | ||
|
||
const test = testWithSynpress(withRealWalletBaseFixtures); | ||
|
||
test.describe('Realwallet - Portfolio - SUMR rewards', async () => { | ||
test.beforeEach(async ({ app, metamask }, testInfo) => { | ||
// Extending tests timeout by 25 extra seconds due to beforeEach actions | ||
testInfo.setTimeout(testInfo.timeout + 25_000); | ||
|
||
await logInWithWalletAddress({ | ||
metamask, | ||
app, | ||
wallet: 'MetaMask', | ||
}); | ||
|
||
await app.portfolio.open('0x10649c79428d718621821Cf6299e91920284743F?tab=rewards'); | ||
}); | ||
|
||
test('It should claim rewards and reject terms', async ({ app }) => { | ||
await app.portfolio.rewards.claim(); | ||
|
||
await app.portfolio.rewards.claimAndDelegate.shouldBeVisible(); | ||
|
||
await app.portfolio.rewards.claimAndDelegate.reject(); | ||
await app.portfolio.rewards.shouldBeVisible(); | ||
}); | ||
|
||
test('It should claim rewards (until tx))', async ({ app, metamask }) => { | ||
await app.portfolio.rewards.claim(); | ||
|
||
await app.portfolio.rewards.claimAndDelegate.shouldBeVisible(); | ||
|
||
await app.portfolio.rewards.claimAndDelegate.acceptAndSign(); | ||
await metamask.confirmSignature(); | ||
|
||
await app.portfolio.rewards.claimAndDelegate.continue(); | ||
await app.portfolio.rewards.claimAndDelegate.shouldHaveEarnedRewards({ | ||
sumr: '[0-9].[0-9]', | ||
usd: '[0-9].[0-9]', | ||
}); | ||
|
||
await app.portfolio.rewards.claimAndDelegate.claim(); | ||
await app.portfolio.rewards.claimAndDelegate.continue(); | ||
|
||
await app.portfolio.rewards.claimAndDelegate.shouldHaveClaimedRewards({ | ||
sumr: '[0-9].[0-9]', | ||
usd: '[0-9].[0-9]', | ||
}); | ||
}); | ||
}); |
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