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

General fixes #3981

Merged
merged 2 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
40 changes: 20 additions & 20 deletions packages/e2e/pages/pool-page.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
/* eslint-disable import/no-extraneous-dependencies */
import type { Locator, Page } from "@playwright/test";
import type { Locator, Page } from '@playwright/test'

import { BasePage } from "./base-page";
import { BasePage } from './base-page'

import { SwapPage } from "./swap-page";
import { SwapPage } from './swap-page'

export class PoolPage extends BasePage {
readonly page: Page;
readonly viewMore: Locator;
readonly poolsLink: Locator;
readonly balance: Locator;
readonly tradeBtn: Locator;
readonly page: Page
readonly viewMore: Locator
readonly poolsLink: Locator
readonly balance: Locator
readonly tradeBtn: Locator

constructor(page: Page) {
super(page);
this.page = page;
this.viewMore = page.getByText("View more");
this.poolsLink = page.locator('//a//div[contains(text(), "Pools")]');
super(page)
this.page = page
this.viewMore = page.getByText('View more')
this.poolsLink = page.locator('//a//div[contains(text(), "Pools")]')
this.balance = page.locator(
'//span[.="Total balance"]/..//h4[contains(@class, "text-osmoverse-100")]'
);
this.tradeBtn = page.locator('//button/span[.="Trade Pair"]');
'//span[.="Total balance"]/..//h4[contains(@class, "text-osmoverse-100")]',
)
this.tradeBtn = page.locator('//button/span[.="Trade Pair"]')
}

async getBalance() {
const totalBalance: string = await this.balance.innerText();
console.log(`Total Balance for a Pool [${totalBalance}]`);
return totalBalance;
const totalBalance: string = await this.balance.innerText()
console.log(`Total Balance for a Pool [${totalBalance}]`)
return totalBalance
}

async getTradeModal() {
await this.tradeBtn.click();
return new SwapPage(this.page);
await this.tradeBtn.click()
return new SwapPage(this.page)
}
}
110 changes: 55 additions & 55 deletions packages/e2e/pages/pools-page.ts
Original file line number Diff line number Diff line change
@@ -1,99 +1,99 @@
/* eslint-disable import/no-extraneous-dependencies */
import type { Locator, Page } from "@playwright/test";
import type { Locator, Page } from '@playwright/test'

import { BasePage } from "./base-page";
import { BasePage } from './base-page'

import { PoolPage } from "./pool-page";
import { PoolPage } from './pool-page'

export class PoolsPage extends BasePage {
readonly page: Page;
readonly viewMore: Locator;
readonly poolsLink: Locator;
readonly balance: Locator;
readonly searchInput: Locator;
readonly page: Page
readonly viewMore: Locator
readonly poolsLink: Locator
readonly balance: Locator
readonly searchInput: Locator

constructor(page: Page) {
super(page);
this.page = page;
this.viewMore = page.getByText("View more");
this.poolsLink = page.locator('//a//div[contains(text(), "Pools")]');
super(page)
this.page = page
this.viewMore = page.getByText('View more')
this.poolsLink = page.locator('//a//div[contains(text(), "Pools")]')
this.balance = page.locator(
'//span[.="Total balance"]/..//h4[contains(@class, "text-osmoverse-100")]'
);
this.searchInput = page.locator('//input[@id="search-input"]');
'//span[.="Total balance"]/..//h4[contains(@class, "text-osmoverse-100")]',
)
this.searchInput = page.locator('//input[@id="search-input"]')
}

async goto() {
await this.page.goto("/");
await this.page.waitForTimeout(2000);
await this.poolsLink.click();
await this.page.waitForTimeout(2000);
await this.page.goto('/')
await this.page.waitForTimeout(2000)
await this.poolsLink.click()
await this.page.waitForTimeout(2000)
// Sometimes pools take longer to load
// we expect that after 10 seconds tokens are loaded and any failure after this point should be considered a bug.
// 1464 is an OSMO/USDC pool
const locRows = '//tr/td/a[contains(@href, "pool/1464")]/../..';
await this.page.locator(locRows).hover({ timeout: 10000 });
await super.printUrl();
const locRows = '//tr/td/a[contains(@href, "pool/1464")]/../..'
await this.page.locator(locRows).hover({ timeout: 10000 })
await super.printUrl()
}

async viewPool(id: number, pair: string) {
await this.page
.locator(`//table//td/a[@href="/pool/${id}"]//span[.="${pair}"]`)
.click();
.click()
// we expect that after 2 seconds tokens are loaded and any failure after this point should be considered a bug.
await this.page.waitForTimeout(2000);
await super.printUrl();
return new PoolPage(this.page);
await this.page.waitForTimeout(2000)
await super.printUrl()
return new PoolPage(this.page)
}

async searchForPool(poolName: string) {
await this.searchInput.fill(poolName);
await this.searchInput.fill(poolName)
// we expect that after 2 seconds tokens are loaded and any failure after this point should be considered a bug.
await this.page.waitForTimeout(2000);
await this.page.waitForTimeout(2000)
}

async getPoolsNumber() {
const loc = '//tr/td//a[contains(@href, "/pool/")]/../..';
const num = await this.page.locator(loc).count();
console.log(`Pools Count: ${num}`);
return num;
const loc = '//tr/td//a[contains(@href, "/pool/")]/../..'
const num = await this.page.locator(loc).count()
console.log(`Pools Count: ${num}`)
return num
}

async getTopTenPoolsByLiquidity() {
const loc = '//tr/td//a[contains(@href, "/pool/")]/../..';
const liquidityList = [];
const loc = '//tr/td//a[contains(@href, "/pool/")]/../..'
const liquidityList = []
for (let i = 0; i < 10; i++) {
const tt = this.page.locator(loc).nth(i).locator("//td").nth(2);
const text: string = await tt.innerText();
const n: number = Number(text.replace(/[^0-9.-]+/g, ""));
liquidityList.push(n);
const tt = this.page.locator(loc).nth(i).locator('//td').nth(2)
const text: string = await tt.innerText()
const n: number = Number(text.replace(/[^0-9.-]+/g, ''))
liquidityList.push(n)
}
console.log(`Top 10 pools Liquidity: ${liquidityList}`);
return liquidityList;
console.log(`Top 10 pools Liquidity: ${liquidityList}`)
return liquidityList
}

async getTopTenPoolsByVolume() {
const loc = '//tr/td//a[contains(@href, "/pool/")]/../..';
const volumeList = [];
const loc = '//tr/td//a[contains(@href, "/pool/")]/../..'
const volumeList = []
for (let i = 0; i < 10; i++) {
const tt = this.page.locator(loc).nth(i).locator("//td").nth(1);
const text: string = await tt.innerText();
const n: number = Number(text.replace(/[^0-9.-]+/g, ""));
volumeList.push(n);
const tt = this.page.locator(loc).nth(i).locator('//td').nth(1)
const text: string = await tt.innerText()
const n: number = Number(text.replace(/[^0-9.-]+/g, ''))
volumeList.push(n)
}
console.log(`Top 10 pools Volume: ${volumeList}`);
return volumeList;
console.log(`Top 10 pools Volume: ${volumeList}`)
return volumeList
}

async getTopTenPoolsByAPR() {
const loc = '//tr/td//a[contains(@href, "/pool/")]/../..';
const aprList = [];
const loc = '//tr/td//a[contains(@href, "/pool/")]/../..'
const aprList = []
for (let i = 0; i < 10; i++) {
const tt = this.page.locator(loc).nth(i).locator("//td").nth(3);
const text: string = await tt.innerText();
aprList.push(text);
const tt = this.page.locator(loc).nth(i).locator('//td').nth(3)
const text: string = await tt.innerText()
aprList.push(text)
}
console.log(`Top 10 pools APRs: ${aprList}`);
return aprList;
console.log(`Top 10 pools APRs: ${aprList}`)
return aprList
}
}
74 changes: 36 additions & 38 deletions packages/e2e/pages/portfolio-page.ts
Original file line number Diff line number Diff line change
@@ -1,73 +1,71 @@
/* eslint-disable import/no-extraneous-dependencies */
import type { Locator, Page } from "@playwright/test";
import type { Locator, Page } from '@playwright/test'

import { BasePage } from "./base-page";
import { TransactionsPage } from "./transactions-page";
import { BasePage } from './base-page'
import { TransactionsPage } from './transactions-page'

export class PortfolioPage extends BasePage {
readonly hideZeros: Locator;
readonly viewMore: Locator;
readonly portfolioLink: Locator;
readonly viewTransactions: Locator;
readonly searchInput: Locator;
readonly hideZeros: Locator
readonly viewMore: Locator
readonly portfolioLink: Locator
readonly viewTransactions: Locator
readonly searchInput: Locator

constructor(page: Page) {
super(page);
super(page)
this.hideZeros = page.locator(
'//label[.="Hide zero balances"]/following-sibling::button'
);
this.viewMore = page.getByText("View more");
this.portfolioLink = page.locator(
'//a//div[contains(text(), "Portfolio")]'
);
this.viewTransactions = page.locator('//div/a[.="View all"]');
this.searchInput = page.locator('//input[@id="search-input"]');
'//label[.="Hide zero balances"]/following-sibling::button',
)
this.viewMore = page.getByText('View more')
this.portfolioLink = page.locator('//a//div[contains(text(), "Portfolio")]')
this.viewTransactions = page.locator('//div/a[.="View all"]')
this.searchInput = page.locator('//input[@id="search-input"]')
}

async goto() {
await this.page.goto("/");
await this.portfolioLink.click();
await this.page.goto('/')
await this.portfolioLink.click()
// we expect that after 2 seconds tokens are loaded and any failure after this point should be considered a bug.
await this.page.waitForTimeout(2000);
const currentUrl = this.page.url();
console.log(`FE opened at: ${currentUrl}`);
await this.page.waitForTimeout(2000)
const currentUrl = this.page.url()
console.log(`FE opened at: ${currentUrl}`)
}

async getBalanceFor(token: string) {
await this.page.evaluate(() => window.scrollBy(0, 250));
await this.page.evaluate(() => window.scrollBy(0, 250))
const bal = this.page
.locator(`//tbody/tr//a[contains(@href, "/assets/${token}")]`)
.nth(1);
const tokenBalance: string = await bal.innerText();
console.log(`Balance for ${token}: ${tokenBalance}`);
return tokenBalance;
.nth(1)
const tokenBalance: string = await bal.innerText()
console.log(`Balance for ${token}: ${tokenBalance}`)
return tokenBalance
}

async viewTransactionsPage() {
await this.viewTransactions.click();
await this.page.waitForTimeout(1000);
return new TransactionsPage(this.page);
await this.viewTransactions.click()
await this.page.waitForTimeout(1000)
return new TransactionsPage(this.page)
}

async hideZeroBalances() {
const isVisible = await this.hideZeros.isVisible({ timeout: 2000 });
const isVisible = await this.hideZeros.isVisible({ timeout: 2000 })
if (isVisible) {
await this.hideZeros.click();
await this.page.waitForTimeout(1000);
await this.hideZeros.click()
await this.page.waitForTimeout(1000)
}
}

async viewMoreBalances() {
const isVisible = await this.viewMore.isVisible({ timeout: 2000 });
const isVisible = await this.viewMore.isVisible({ timeout: 2000 })
if (isVisible) {
await this.viewMore.click();
await this.page.waitForTimeout(1000);
await this.viewMore.click()
await this.page.waitForTimeout(1000)
}
}

async searchForToken(tokenName: string) {
await this.searchInput.fill(tokenName);
await this.searchInput.fill(tokenName)
// we expect that after 2 seconds tokens are loaded and any failure after this point should be considered a bug.
await this.page.waitForTimeout(2000);
await this.page.waitForTimeout(2000)
}
}
Loading