-
Notifications
You must be signed in to change notification settings - Fork 1
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 #567 from OasisDEX/daily-improvements-16-oct-andea…
…rn-protocol Daily improvements - 16 October - And Earn protocol
- Loading branch information
Showing
12 changed files
with
300 additions
and
7 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
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,51 @@ | ||
import { Page } from '@playwright/test'; | ||
// import { Modals } from './modals'; | ||
import { | ||
// Borrow, | ||
// Earn, | ||
Header, | ||
// Homepage, | ||
// Multiply, | ||
// Portfolio, | ||
// Position, | ||
// Rays, | ||
} from './pages'; | ||
|
||
export class App { | ||
readonly page: Page; | ||
|
||
// readonly borrow: Borrow; | ||
|
||
// readonly earn: Earn; | ||
|
||
readonly header: Header; | ||
|
||
// readonly homepage: Homepage; | ||
|
||
// readonly modals: Modals; | ||
|
||
// readonly multiply: Multiply; | ||
|
||
// readonly portfolio: Portfolio; | ||
|
||
// readonly position: Position; | ||
|
||
// readonly rays: Rays; | ||
|
||
constructor(page: Page) { | ||
this.page = page; | ||
// this.borrow = new Borrow(page); | ||
// this.earn = new Earn(page); | ||
this.header = new Header(page); | ||
// this.homepage = new Homepage(page); | ||
// this.modals = new Modals(page); | ||
// this.multiply = new Multiply(page); | ||
// this.portfolio = new Portfolio(page); | ||
// this.position = new Position(page); | ||
// this.rays = new Rays(page); | ||
} | ||
|
||
async pause() { | ||
await this.page.pause(); | ||
} | ||
} |
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,42 @@ | ||
import { test as base } from '@playwright/test'; | ||
import { App } from '../app'; | ||
import { updateFlagsAndRejectCookies } from 'utils/localStorage'; | ||
|
||
type MyFixtures = { | ||
app: App; | ||
}; | ||
|
||
export const test = base.extend<MyFixtures>({ | ||
app: async ({ page }, use) => { | ||
const app = new App(page); | ||
|
||
await app.page.goto(''); | ||
// await app.homepage.shouldBeVisible(); | ||
|
||
// const featuresFlags = process.env.FLAGS_FEATURES ? process.env.FLAGS_FEATURES.split(' ') : null; | ||
// const automationMinNetValueFlags = process.env.FLAGS_AUTOMATION_MIN_NET_VALUE | ||
// ? process.env.FLAGS_AUTOMATION_MIN_NET_VALUE.split(' ') | ||
// : null; | ||
|
||
// await updateFlagsAndRejectCookies({ | ||
// app, | ||
// featuresFlags, | ||
// automationMinNetValueFlags, | ||
// }); | ||
|
||
await use(app); | ||
|
||
await app.page.close(); | ||
}, | ||
}); | ||
|
||
export function step(target: Function, context: ClassMethodDecoratorContext) { | ||
return function replacementMethod(...args: any) { | ||
const name = this.constructor.name + '.' + (context.name as string); | ||
return test.step(name, async () => { | ||
return await target.call(this, ...args); | ||
}); | ||
}; | ||
} | ||
|
||
export const expect = test.expect; |
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,68 @@ | ||
import { test as base, chromium } from '@playwright/test'; | ||
import { initialSetup } from '@synthetixio/synpress/commands/metamask'; | ||
import { setExpectInstance } from '@synthetixio/synpress/commands/playwright'; | ||
import { prepareMetamask } from '@synthetixio/synpress/helpers'; | ||
import { App } from '../app'; | ||
|
||
type MyFixtures = { | ||
app: App; | ||
}; | ||
|
||
type BrowserContext = { | ||
context: BrowserContext; | ||
}; | ||
|
||
export const test = base.extend<MyFixtures & BrowserContext>({ | ||
context: async ({}, use) => { | ||
// required for synpress as it shares same expect instance as playwright | ||
await setExpectInstance(expect); | ||
|
||
// download metamask | ||
const metamaskPath = await prepareMetamask(process.env.METAMASK_VERSION || '10.25.0'); | ||
|
||
// prepare browser args | ||
const browserArgs = [ | ||
`--disable-extensions-except=${metamaskPath}`, | ||
`--load-extension=${metamaskPath}`, | ||
'--remote-debugging-port=9222', | ||
]; | ||
|
||
if (process.env.CI) { | ||
browserArgs.push('--disable-gpu'); | ||
} | ||
|
||
if (process.env.HEADLESS_MODE) { | ||
browserArgs.push('--headless=new'); | ||
} | ||
|
||
// launch browser | ||
const context = await chromium.launchPersistentContext('', { | ||
headless: false, | ||
args: browserArgs, | ||
}); | ||
|
||
// wait for metamask | ||
await context.pages()[0].waitForTimeout(3000); | ||
|
||
// setup metamask | ||
await initialSetup(chromium, { | ||
secretWordsOrPrivateKey: 'test test test test test test test test test test test junk', | ||
network: 'mainnet', | ||
password: 'Tester@1234', | ||
enableAdvancedSettings: true, | ||
enableExperimentalSettings: false, | ||
}); | ||
|
||
await use(context); | ||
}, | ||
|
||
app: async ({ page }, use) => { | ||
const app = new App(page); | ||
|
||
await use(app); | ||
|
||
await app.page.close(); | ||
}, | ||
}); | ||
|
||
export const expect = test.expect; |
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,26 @@ | ||
import { expect, step } from '#earnProtocolFixtures'; | ||
import { Locator, Page } from '@playwright/test'; | ||
|
||
export class Header { | ||
readonly page: Page; | ||
|
||
readonly headerLocator: Locator; | ||
|
||
constructor(page: Page) { | ||
this.page = page; | ||
this.headerLocator = page.locator('header'); | ||
} | ||
|
||
@step | ||
async shouldHaveSummerfiLogo() { | ||
await expect( | ||
this.headerLocator.locator('img[alt="Summer.fi"]').nth(0), | ||
'Summer.fi logo should be visible' | ||
).toBeVisible(); | ||
} | ||
|
||
@step | ||
async earn() { | ||
await this.headerLocator.getByRole('link', { name: 'Earn' }).click(); | ||
} | ||
} |
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,3 @@ | ||
import { Header } from './header'; | ||
|
||
export { Header }; |
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,13 @@ | ||
import { test } from '#earnProtocolFixtures'; | ||
|
||
test('Header - Open Earn page', async ({ app }) => { | ||
await app.header.shouldHaveSummerfiLogo(); | ||
|
||
await app.header.earn(); | ||
|
||
// TO BE COMPOLETED | ||
|
||
// | ||
// await app.pause(); | ||
// | ||
}); |
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,61 @@ | ||
import { BrowserContext, expect, test } from '@playwright/test'; | ||
import { resetState } from '@synthetixio/synpress/commands/synpress'; | ||
import { metamaskSetUp, setup } from 'utils/setup'; | ||
import { extremelyLongTestTimeout } from 'utils/config'; | ||
import * as tx from 'utils/tx'; | ||
import { App } from 'src/app'; | ||
|
||
let context: BrowserContext; | ||
let app: App; | ||
|
||
const walletPK: string = process.env.VERY_OLD_TEST_WALLET_PK; | ||
|
||
test.describe.configure({ mode: 'serial' }); | ||
|
||
test.describe('Aave v3 Multiply - Optimism - Wallet connected', async () => { | ||
test.afterAll(async () => { | ||
await app.page.close(); | ||
|
||
await context.close(); | ||
|
||
await resetState(); | ||
}); | ||
|
||
test('It should open an Aave v3 Multiply Optimism position - ETH/USDC @regression', async () => { | ||
test.info().annotations.push({ | ||
type: 'Test case', | ||
description: '12067', | ||
}); | ||
|
||
test.setTimeout(extremelyLongTestTimeout); | ||
|
||
await test.step('Test setup', async () => { | ||
({ context } = await metamaskSetUp({ network: 'optimism' })); | ||
let page = await context.newPage(); | ||
app = new App(page); | ||
|
||
await setup({ | ||
app, | ||
network: 'optimism', | ||
withoutFork: true, | ||
withExistingWallet: { | ||
privateKey: walletPK, | ||
}, | ||
}); | ||
}); | ||
|
||
await app.page.goto('/optimism/aave/v3/multiply/eth-usdc#setup'); | ||
|
||
await app.position.setup.deposit({ token: 'ETH', amount: '0.001' }); | ||
|
||
await app.position.setup.confirm(); | ||
// Thre are two 'confirm' steps | ||
await app.position.setup.confirm(); | ||
|
||
await test.step('Reject Permission To Spend', async () => { | ||
await expect(async () => { | ||
await tx.rejectPermissionToSpend(); | ||
}).toPass(); | ||
}); | ||
}); | ||
}); |
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