From 3d288ea44da6f3fdd09388caf604a5b71b4372a9 Mon Sep 17 00:00:00 2001 From: Jose Felix Date: Sat, 30 Nov 2024 15:33:18 -0400 Subject: [PATCH] feat: many fixes --- packages/e2e/pages/pool-page.ts | 40 +- packages/e2e/pages/pools-page.ts | 110 ++--- packages/e2e/pages/portfolio-page.ts | 74 ++- packages/e2e/pages/swap-page.ts | 228 ++++----- packages/e2e/pages/trade-page.ts | 390 ++++++++-------- packages/e2e/pages/transactions-page.ts | 186 ++++---- packages/e2e/tests/claim.spec.ts | 88 ++-- .../e2e/tests/monitoring.limit.wallet.spec.ts | 152 +++--- .../tests/monitoring.market.wallet.spec.ts | 152 +++--- .../e2e/tests/monitoring.swap.wallet.spec.ts | 166 +++---- packages/e2e/tests/pools.spec.ts | 122 ++--- packages/e2e/tests/portfolio.wallet.spec.ts | 120 ++--- packages/e2e/tests/select.spec.ts | 186 ++++---- packages/e2e/tests/swap.wallet.spec.ts | 432 +++++++++--------- packages/e2e/tests/trade.wallet.spec.ts | 206 ++++----- .../e2e/tests/transactions.wallet.spec.ts | 144 +++--- .../complex/portfolio/assets-overview.tsx | 2 +- .../nomic/nomic-pending-transfers.tsx | 137 +++--- .../one-click-remaining-time.tsx | 7 +- .../use-one-click-trading-session.ts | 2 +- .../use-one-click-trading-swap-review.ts | 24 +- packages/web/localizations/de.json | 2 +- packages/web/localizations/en.json | 2 +- packages/web/localizations/es.json | 2 +- packages/web/localizations/fa.json | 2 +- packages/web/localizations/fr.json | 2 +- packages/web/localizations/gu.json | 2 +- packages/web/localizations/hi.json | 2 +- packages/web/localizations/ja.json | 2 +- packages/web/localizations/ko.json | 2 +- packages/web/localizations/pl.json | 2 +- packages/web/localizations/pt-br.json | 2 +- packages/web/localizations/ro.json | 2 +- packages/web/localizations/ru.json | 2 +- packages/web/localizations/tr.json | 2 +- packages/web/localizations/zh-cn.json | 2 +- packages/web/localizations/zh-hk.json | 2 +- packages/web/localizations/zh-tw.json | 2 +- packages/web/modals/profile.tsx | 2 +- .../web/server/api/routers/bridge-transfer.ts | 1 + .../__tests__/transfer-history.spec.tsx | 12 +- packages/web/stores/transfer-history.tsx | 14 +- 42 files changed, 1518 insertions(+), 1513 deletions(-) diff --git a/packages/e2e/pages/pool-page.ts b/packages/e2e/pages/pool-page.ts index 448a70c205..e178249d71 100644 --- a/packages/e2e/pages/pool-page.ts +++ b/packages/e2e/pages/pool-page.ts @@ -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) } } diff --git a/packages/e2e/pages/pools-page.ts b/packages/e2e/pages/pools-page.ts index b06bdaf300..5aae46887a 100644 --- a/packages/e2e/pages/pools-page.ts +++ b/packages/e2e/pages/pools-page.ts @@ -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 } } diff --git a/packages/e2e/pages/portfolio-page.ts b/packages/e2e/pages/portfolio-page.ts index 04f8b329b4..e09864ec1e 100644 --- a/packages/e2e/pages/portfolio-page.ts +++ b/packages/e2e/pages/portfolio-page.ts @@ -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) } } diff --git a/packages/e2e/pages/swap-page.ts b/packages/e2e/pages/swap-page.ts index fdc6a155f3..721be13bf0 100644 --- a/packages/e2e/pages/swap-page.ts +++ b/packages/e2e/pages/swap-page.ts @@ -1,215 +1,215 @@ /* eslint-disable import/no-extraneous-dependencies */ import { type BrowserContext, - expect, type Locator, type Page, -} from "@playwright/test"; + expect, +} from '@playwright/test' -import { BasePage } from "./base-page"; +import { BasePage } from './base-page' export class SwapPage extends BasePage { - readonly page: Page; - readonly swapBtn: Locator; - readonly swapMaxBtn: Locator; - readonly swapInput: Locator; - readonly flipAssetsBtn: Locator; - readonly exchangeRate: Locator; - readonly trxSuccessful: Locator; - readonly trxBroadcasting: Locator; - readonly trxLink: Locator; + readonly page: Page + readonly swapBtn: Locator + readonly swapMaxBtn: Locator + readonly swapInput: Locator + readonly flipAssetsBtn: Locator + readonly exchangeRate: Locator + readonly trxSuccessful: Locator + readonly trxBroadcasting: Locator + readonly trxLink: Locator constructor(page: Page) { - super(page); - this.page = page; - this.swapBtn = page.getByRole("button", { name: "Swap", exact: true }); - this.swapMaxBtn = page.getByRole("button", { name: "MAX", exact: true }); - this.swapInput = page.locator('//input[@data-testid="trade-input-swap"]'); + super(page) + this.page = page + this.swapBtn = page.getByRole('button', { name: 'Swap', exact: true }) + this.swapMaxBtn = page.getByRole('button', { name: 'MAX', exact: true }) + this.swapInput = page.locator('//input[@data-testid="trade-input-swap"]') this.flipAssetsBtn = page.locator( - '//div/button[contains(@class, "ease-bounce")]' - ); - this.exchangeRate = page.locator('//span[@data-testid="token-price"]'); - this.trxSuccessful = page.locator('//h6[.="Transaction Succesful"]'); - this.trxLink = page.getByText("View explorer"); - this.trxBroadcasting = page.locator('//h6[.="Transaction Broadcasting"]'); + '//div/button[contains(@class, "ease-bounce")]', + ) + this.exchangeRate = page.locator('//span[@data-testid="token-price"]') + this.trxSuccessful = page.locator('//h6[.="Transaction Succesful"]') + this.trxLink = page.getByText('View explorer') + this.trxBroadcasting = page.locator('//h6[.="Transaction Broadcasting"]') } async goto() { - const assetPromise = this.page.waitForRequest("**/assets.json"); - await this.page.goto("/"); - const request = await assetPromise; - expect(request).toBeTruthy(); + const assetPromise = this.page.waitForRequest('**/assets.json') + await this.page.goto('/') + const request = await assetPromise + expect(request).toBeTruthy() // 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 flipTokenPair() { - await this.flipAssetsBtn.click(); - await this.page.waitForTimeout(2000); - console.log("Fliped token pair."); + await this.flipAssetsBtn.click() + await this.page.waitForTimeout(2000) + console.log('Fliped token pair.') } async enterAmount(amount: string) { // Just enter an amount for the swap and wait for a quote - await this.swapInput.fill(amount, { timeout: 2000 }); - await this.page.waitForTimeout(2000); - await expect(this.swapInput).toHaveValue(amount, { timeout: 3000 }); - const exchangeRate = await this.getExchangeRate(); - console.log(`Swap ${amount} with rate: ${exchangeRate}`); + await this.swapInput.fill(amount, { timeout: 2000 }) + await this.page.waitForTimeout(2000) + await expect(this.swapInput).toHaveValue(amount, { timeout: 3000 }) + const exchangeRate = await this.getExchangeRate() + console.log(`Swap ${amount} with rate: ${exchangeRate}`) } async swapAndGetWalletMsg(context: BrowserContext) { // Make sure to have sufficient balance and swap button is enabled expect( await this.isInsufficientBalance(), - "Insufficient balance for the swap!" - ).toBeFalsy(); - await expect(this.swapBtn).toBeEnabled({ timeout: 7000 }); + 'Insufficient balance for the swap!', + ).toBeFalsy() + await expect(this.swapBtn).toBeEnabled({ timeout: 7000 }) // Handle Pop-up page -> - const pageApprove = context.waitForEvent("page"); - await this.swapBtn.click(); - const approvePage = await pageApprove; - await approvePage.waitForLoadState(); - const approvePageTitle = approvePage.url(); - console.log(`Approve page is opened at: ${approvePageTitle}`); - const approveBtn = approvePage.getByRole("button", { - name: "Approve", - }); - await expect(approveBtn).toBeEnabled(); + const pageApprove = context.waitForEvent('page') + await this.swapBtn.click() + const approvePage = await pageApprove + await approvePage.waitForLoadState() + const approvePageTitle = approvePage.url() + console.log(`Approve page is opened at: ${approvePageTitle}`) + const approveBtn = approvePage.getByRole('button', { + name: 'Approve', + }) + await expect(approveBtn).toBeEnabled() const msgContentAmount = await approvePage - .getByText("type: osmosis/poolmanager/") - .textContent(); - console.log(`Wallet is approving this msg: \n${msgContentAmount}`); + .getByText('type: osmosis/poolmanager/') + .textContent() + console.log(`Wallet is approving this msg: \n${msgContentAmount}`) // Approve trx - await approveBtn.click(); + await approveBtn.click() // wait for trx confirmation - await this.page.waitForTimeout(4000); + await this.page.waitForTimeout(4000) //await approvePage.close(); // Handle Pop-up page <- - return { msgContentAmount }; + return { msgContentAmount } } async selectPair(from: string, to: string) { // Filter does not show already selected tokens - console.log(`Select pair ${from} to ${to}`); + console.log(`Select pair ${from} to ${to}`) const tokenLocator = - '//img[@alt="token icon"]/../..//h5 | //img[@alt="token icon"]/../..//span[@class="subtitle1"]'; - const fromToken = this.page.locator(tokenLocator).nth(0); - const toToken = this.page.locator(tokenLocator).nth(1); + '//img[@alt="token icon"]/../..//h5 | //img[@alt="token icon"]/../..//span[@class="subtitle1"]' + const fromToken = this.page.locator(tokenLocator).nth(0) + const toToken = this.page.locator(tokenLocator).nth(1) - const fromTokenText = await fromToken.innerText(); - const toTokenText = await toToken.innerText(); - console.log(`Current pair: ${fromTokenText} / ${toTokenText}`); + const fromTokenText = await fromToken.innerText() + const toTokenText = await toToken.innerText() + console.log(`Current pair: ${fromTokenText} / ${toTokenText}`) if (fromTokenText === from && toTokenText === to) { console.log( - `Current pair: ${fromTokenText}${toTokenText} is already matching.` - ); - return; + `Current pair: ${fromTokenText}${toTokenText} is already matching.`, + ) + return } if (fromTokenText === to && toTokenText === from) { - await this.flipTokenPair(); - console.log(`Current pair: ${fromTokenText}${toTokenText} is fliped.`); - return; + await this.flipTokenPair() + console.log(`Current pair: ${fromTokenText}${toTokenText} is fliped.`) + return } if (from === toTokenText || to === fromTokenText) { - await this.flipTokenPair(); + await this.flipTokenPair() } if (fromTokenText !== from && toTokenText !== from) { - await fromToken.click(); + await fromToken.click() // we expect that after 1 second token filter is displayed. - await this.page.waitForTimeout(1000); - await this.page.getByPlaceholder("Search").fill(from); + await this.page.waitForTimeout(1000) + await this.page.getByPlaceholder('Search').fill(from) const fromLocator = this.page.locator( - `//div/button[@data-testid]//h6[.='${from}']` - ); - await fromLocator.click(); + `//div/button[@data-testid]//h6[.='${from}']`, + ) + await fromLocator.click() } if (toTokenText !== to && fromTokenText !== to) { - await toToken.click(); + await toToken.click() // we expect that after 1 second token filter is displayed. - await this.page.waitForTimeout(1000); - await this.page.getByPlaceholder("Search").fill(to); + await this.page.waitForTimeout(1000) + await this.page.getByPlaceholder('Search').fill(to) const toLocator = this.page.locator( - `//div/button[@data-testid]//h6[.='${to}']` - ); - await toLocator.click(); + `//div/button[@data-testid]//h6[.='${to}']`, + ) + await toLocator.click() } // we expect that after 2 seconds exchange rate is populated. - await this.page.waitForTimeout(2000); - expect(await this.getExchangeRate()).toContain(from); - expect(await this.getExchangeRate()).toContain(to); + await this.page.waitForTimeout(2000) + expect(await this.getExchangeRate()).toContain(from) + expect(await this.getExchangeRate()).toContain(to) } async getExchangeRate() { - return await this.exchangeRate.innerText(); + return await this.exchangeRate.innerText() } async isTransactionSuccesful(delay = 7) { - console.log("Wait for a transaction success for 7 seconds."); + console.log('Wait for a transaction success for 7 seconds.') return await this.trxSuccessful.isVisible({ timeout: delay * 1000, - }); + }) } async getTransactionUrl() { - const trxUrl = await this.trxLink.getAttribute("href"); - console.log(`Trx url: ${trxUrl}`); - return trxUrl; + const trxUrl = await this.trxLink.getAttribute('href') + console.log(`Trx url: ${trxUrl}`) + return trxUrl } async isTransactionBroadcasted(delay = 5) { - console.log("Wait for a transaction broadcasting for 5 seconds."); - return await this.trxBroadcasting.isVisible({ timeout: delay * 1000 }); + console.log('Wait for a transaction broadcasting for 5 seconds.') + return await this.trxBroadcasting.isVisible({ timeout: delay * 1000 }) } async isInsufficientBalance() { const issufBalanceBtn = this.page.locator( - '//button[.="Insufficient balance"]' - ); - return await issufBalanceBtn.isVisible({ timeout: 2000 }); + '//button[.="Insufficient balance"]', + ) + return await issufBalanceBtn.isVisible({ timeout: 2000 }) } async isError() { - const errorBtn = this.page.locator('//button[.="Error"]'); - return await errorBtn.isVisible({ timeout: 2000 }); + const errorBtn = this.page.locator('//button[.="Error"]') + return await errorBtn.isVisible({ timeout: 2000 }) } async showSwapInfo() { - const swapInfo = this.page.locator("//button//span[.='Show details']"); - await swapInfo.click(); - console.log(`Price Impact: ${await this.getPriceInpact()}`); + const swapInfo = this.page.locator("//button//span[.='Show details']") + await swapInfo.click() + console.log(`Price Impact: ${await this.getPriceInpact()}`) } async getPriceInpact() { const priceInpactSpan = this.page.locator( - '//span[.="Price Impact"]/..//span[@class="text-bullish-400"]' - ); - return await priceInpactSpan.textContent(); + '//span[.="Price Impact"]/..//span[@class="text-bullish-400"]', + ) + return await priceInpactSpan.textContent() } async takeScreenshot(name: string) { await this.page.screenshot({ path: `screenshot-swap-${name}.png`, fullPage: true, - }); + }) } async getSelectedPair() { const tokenLocator = - '//img[@alt="token icon"]/../..//h5 | //img[@alt="token icon"]/../..//span[@class="subtitle1"]'; - const fromToken = this.page.locator(tokenLocator).nth(0); - const toToken = this.page.locator(tokenLocator).nth(1); - - const fromTokenText = await fromToken.innerText(); - const toTokenText = await toToken.innerText(); - console.log(`Current pair: ${fromTokenText}/${toTokenText}`); - return `${fromTokenText}/${toTokenText}`; + '//img[@alt="token icon"]/../..//h5 | //img[@alt="token icon"]/../..//span[@class="subtitle1"]' + const fromToken = this.page.locator(tokenLocator).nth(0) + const toToken = this.page.locator(tokenLocator).nth(1) + + const fromTokenText = await fromToken.innerText() + const toTokenText = await toToken.innerText() + console.log(`Current pair: ${fromTokenText}/${toTokenText}`) + return `${fromTokenText}/${toTokenText}` } } diff --git a/packages/e2e/pages/trade-page.ts b/packages/e2e/pages/trade-page.ts index 75907a8351..32c14d9298 100644 --- a/packages/e2e/pages/trade-page.ts +++ b/packages/e2e/pages/trade-page.ts @@ -3,350 +3,350 @@ import { type Locator, type Page, expect, -} from "@playwright/test"; +} from '@playwright/test' -import { BasePage } from "./base-page"; +import { BasePage } from './base-page' export class TradePage extends BasePage { - readonly page: Page; - readonly swapBtn: Locator; - readonly swapMaxBtn: Locator; - readonly flipAssetsBtn: Locator; - readonly exchangeRate: Locator; - readonly trxSuccessful: Locator; - readonly trxBroadcasting: Locator; - readonly trxLink: Locator; - readonly inputAmount: Locator; - readonly confirmSwapBtn: Locator; - readonly buyTabBtn: Locator; - readonly buyBtn: Locator; - readonly sellTabBtn: Locator; - readonly sellBtn: Locator; - readonly limitTabBtn: Locator; - readonly orderHistoryLink: Locator; - readonly limitPrice: Locator; + readonly page: Page + readonly swapBtn: Locator + readonly swapMaxBtn: Locator + readonly flipAssetsBtn: Locator + readonly exchangeRate: Locator + readonly trxSuccessful: Locator + readonly trxBroadcasting: Locator + readonly trxLink: Locator + readonly inputAmount: Locator + readonly confirmSwapBtn: Locator + readonly buyTabBtn: Locator + readonly buyBtn: Locator + readonly sellTabBtn: Locator + readonly sellBtn: Locator + readonly limitTabBtn: Locator + readonly orderHistoryLink: Locator + readonly limitPrice: Locator constructor(page: Page) { - super(page); - this.page = page; - this.swapBtn = page.locator('//button[@data-testid="trade-button-swap"]'); - this.buyTabBtn = page.locator('//div[@class]/button[.="Buy"]/p[@class]/..'); - this.buyBtn = page.locator('//div[@class]/button[@class]/h6[.="Buy"]/..'); - this.sellBtn = page.locator('//div[@class]/button[@class]/h6[.="Sell"]/..'); + super(page) + this.page = page + this.swapBtn = page.locator('//button[@data-testid="trade-button-swap"]') + this.buyTabBtn = page.locator('//div[@class]/button[.="Buy"]/p[@class]/..') + this.buyBtn = page.locator('//div[@class]/button[@class]/h6[.="Buy"]/..') + this.sellBtn = page.locator('//div[@class]/button[@class]/h6[.="Sell"]/..') this.sellTabBtn = page.locator( - '//div[@class]/button[.="Sell"]/p[@class]/..' - ); - this.confirmSwapBtn = page.locator('//div[@class]/button[.="Confirm"]'); - this.swapMaxBtn = page.locator('//span[.="Max"]'); + '//div[@class]/button[.="Sell"]/p[@class]/..', + ) + this.confirmSwapBtn = page.locator('//div[@class]/button[.="Confirm"]') + this.swapMaxBtn = page.locator('//span[.="Max"]') this.flipAssetsBtn = page.locator( - '//div/button[contains(@class, "ease-bounce")]' - ); - this.exchangeRate = page.locator('//span[@data-testid="token-price"]'); - this.trxSuccessful = page.getByText("Transaction Successful"); - this.trxLink = page.getByText("View explorer"); - this.trxBroadcasting = page.locator('//h6[.="Transaction Broadcasting"]'); + '//div/button[contains(@class, "ease-bounce")]', + ) + this.exchangeRate = page.locator('//span[@data-testid="token-price"]') + this.trxSuccessful = page.getByText('Transaction Successful') + this.trxLink = page.getByText('View explorer') + this.trxBroadcasting = page.locator('//h6[.="Transaction Broadcasting"]') this.inputAmount = page.locator( - "//input[contains(@data-testid, 'trade-input')]" - ); - this.limitTabBtn = page.locator('//div[@class="w-full"]/button[.="Limit"]'); - this.orderHistoryLink = page.getByText("Order history"); - this.limitPrice = page.locator("//div/input[@type='text']"); + "//input[contains(@data-testid, 'trade-input')]", + ) + this.limitTabBtn = page.locator('//div[@class="w-full"]/button[.="Limit"]') + this.orderHistoryLink = page.getByText('Order history') + this.limitPrice = page.locator("//div/input[@type='text']") } async goto() { - const assetPromise = this.page.waitForRequest("**/assets.json"); - await this.page.goto("/"); - const request = await assetPromise; - expect(request).toBeTruthy(); + const assetPromise = this.page.waitForRequest('**/assets.json') + await this.page.goto('/') + const request = await assetPromise + expect(request).toBeTruthy() // 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 gotoOrdersHistory(timeout = 1) { - await this.page.waitForTimeout(1000); - await this.orderHistoryLink.click(); - await this.page.waitForTimeout(1000); - await new Promise((f) => setTimeout(f, timeout * 1000)); - const currentUrl = this.page.url(); - console.log(`FE opened at: ${currentUrl}`); + await this.page.waitForTimeout(1000) + await this.orderHistoryLink.click() + await this.page.waitForTimeout(1000) + await new Promise((f) => setTimeout(f, timeout * 1000)) + const currentUrl = this.page.url() + console.log(`FE opened at: ${currentUrl}`) } async openBuyTab() { - await this.buyTabBtn.click(); + await this.buyTabBtn.click() } async openSellTab() { - await this.sellTabBtn.click(); + await this.sellTabBtn.click() } async openLimit() { - await this.limitTabBtn.click(); - await this.page.waitForTimeout(1000); + await this.limitTabBtn.click() + await this.page.waitForTimeout(1000) } async getLimitPrice() { - const lp = await this.limitPrice.inputValue(); - console.log(`Current limit price is: ${lp}`); - return lp; + const lp = await this.limitPrice.inputValue() + console.log(`Current limit price is: ${lp}`) + return lp } async setLimitPriceChange(change: string) { - const locator = `//button/span[contains(@class, "body2") and .="${change}"]`; - await this.page.locator(locator).click(); - await this.page.waitForTimeout(1000); + const locator = `//button/span[contains(@class, "body2") and .="${change}"]` + await this.page.locator(locator).click() + await this.page.waitForTimeout(1000) } async setLimitPrice(price: string) { - console.log(`Set Order Limit Price to: ${price}`); - await this.limitPrice.fill(price, { timeout: 2000 }); + console.log(`Set Order Limit Price to: ${price}`) + await this.limitPrice.fill(price, { timeout: 2000 }) } async flipTokenPair() { - await this.flipAssetsBtn.click(); - await this.page.waitForTimeout(2000); - console.log("Fliped token pair."); + await this.flipAssetsBtn.click() + await this.page.waitForTimeout(2000) + console.log('Fliped token pair.') } async clickMaxAmountButton() { - await this.swapMaxBtn.click({ timeout: 2000 }); - await this.page.waitForTimeout(1000); - console.log("Clicked Max token amount button."); + await this.swapMaxBtn.click({ timeout: 2000 }) + await this.page.waitForTimeout(1000) + console.log('Clicked Max token amount button.') } async enterAmount(amount: string) { // Just enter an amount for the swap and wait for a quote - await this.inputAmount.fill(amount, { timeout: 2000 }); - await this.page.waitForTimeout(1000); - await expect(this.inputAmount).toHaveValue(amount, { timeout: 1000 }); - const exchangeRate = await this.getExchangeRate(); - console.log(`Swap ${amount} with rate: ${exchangeRate}`); + await this.inputAmount.fill(amount, { timeout: 2000 }) + await this.page.waitForTimeout(1000) + await expect(this.inputAmount).toHaveValue(amount, { timeout: 1000 }) + const exchangeRate = await this.getExchangeRate() + console.log(`Swap ${amount} with rate: ${exchangeRate}`) } async swapAndGetWalletMsg(context: BrowserContext) { // Make sure to have sufficient balance and swap button is enabled expect( await this.isInsufficientBalanceForSwap(), - "Insufficient balance for the swap!" - ).toBeFalsy(); - await expect(this.swapBtn).toBeEnabled({ timeout: 7000 }); + 'Insufficient balance for the swap!', + ).toBeFalsy() + await expect(this.swapBtn).toBeEnabled({ timeout: 7000 }) // Handle Pop-up page -> - await this.swapBtn.click(); - const pageApprove = context.waitForEvent("page"); - await this.confirmSwapBtn.click(); - const approvePage = await pageApprove; - await approvePage.waitForLoadState(); - const approvePageTitle = approvePage.url(); - console.log(`Approve page is opened at: ${approvePageTitle}`); - const approveBtn = approvePage.getByRole("button", { - name: "Approve", - }); - await expect(approveBtn).toBeEnabled(); + await this.swapBtn.click() + const pageApprove = context.waitForEvent('page') + await this.confirmSwapBtn.click() + const approvePage = await pageApprove + await approvePage.waitForLoadState() + const approvePageTitle = approvePage.url() + console.log(`Approve page is opened at: ${approvePageTitle}`) + const approveBtn = approvePage.getByRole('button', { + name: 'Approve', + }) + await expect(approveBtn).toBeEnabled() const msgContentAmount = await approvePage - .getByText("type: osmosis/poolmanager/") - .textContent(); - console.log(`Wallet is approving this msg: \n${msgContentAmount}`); + .getByText('type: osmosis/poolmanager/') + .textContent() + console.log(`Wallet is approving this msg: \n${msgContentAmount}`) // Approve trx - await approveBtn.click(); + await approveBtn.click() // wait for trx confirmation - await this.page.waitForTimeout(4000); + await this.page.waitForTimeout(4000) //await approvePage.close(); // Handle Pop-up page <- - return { msgContentAmount }; + return { msgContentAmount } } async selectAsset(token: string) { - const tokenLocator = "//div//button[@type]//img[@alt]"; - const fromToken = this.page.locator(tokenLocator).nth(0); - await fromToken.click(); + const tokenLocator = '//div//button[@type]//img[@alt]' + const fromToken = this.page.locator(tokenLocator).nth(0) + await fromToken.click() // we expect that after 1 second token filter is displayed. - await this.page.waitForTimeout(1000); - await this.page.getByPlaceholder("Search").fill(token); + await this.page.waitForTimeout(1000) + await this.page.getByPlaceholder('Search').fill(token) const fromLocator = this.page.locator( - `//div/button[@data-testid='token-select-asset']//span[.='${token}']` - ); - await fromLocator.click(); + `//div/button[@data-testid='token-select-asset']//span[.='${token}']`, + ) + await fromLocator.click() } async selectPair(from: string, to: string) { // Filter does not show already selected tokens - console.log(`Select pair ${from} to ${to}`); + console.log(`Select pair ${from} to ${to}`) const fromToken = this.page.locator( - "//div//button[@data-testid='token-in']//img[@alt]" - ); + "//div//button[@data-testid='token-in']//img[@alt]", + ) const toToken = this.page.locator( - "//div//button[@data-testid='token-out']//img[@alt]" - ); + "//div//button[@data-testid='token-out']//img[@alt]", + ) // Select From Token - await fromToken.click({ timeout: 4000 }); + await fromToken.click({ timeout: 4000 }) // we expect that after 1 second token filter is displayed. - await this.page.waitForTimeout(1000); - await this.page.getByPlaceholder("Search").fill(from); + await this.page.waitForTimeout(1000) + await this.page.getByPlaceholder('Search').fill(from) const fromLocator = this.page .locator( - `//div/button[@data-testid='token-select-asset']//span[.='${from}']` + `//div/button[@data-testid='token-select-asset']//span[.='${from}']`, ) - .first(); - await fromLocator.click({ timeout: 4000 }); + .first() + await fromLocator.click({ timeout: 4000 }) // Select To Token - await toToken.click({ timeout: 4000 }); + await toToken.click({ timeout: 4000 }) // we expect that after 1 second token filter is displayed. - await this.page.waitForTimeout(1000); - await this.page.getByPlaceholder("Search").fill(to); + await this.page.waitForTimeout(1000) + await this.page.getByPlaceholder('Search').fill(to) const toLocator = this.page .locator( - `//div/button[@data-testid='token-select-asset']//span[.='${to}']` + `//div/button[@data-testid='token-select-asset']//span[.='${to}']`, ) - .first(); - await toLocator.click(); + .first() + await toLocator.click() // we expect that after 2 seconds exchange rate is populated. - await this.page.waitForTimeout(2000); - expect(await this.getExchangeRate()).toContain(from); - expect(await this.getExchangeRate()).toContain(to); + await this.page.waitForTimeout(2000) + expect(await this.getExchangeRate()).toContain(from) + expect(await this.getExchangeRate()).toContain(to) } async getExchangeRate() { - return await this.exchangeRate.innerText(); + return await this.exchangeRate.innerText() } async isTransactionSuccesful(delay = 7) { - console.log(`Wait for a transaction success for ${delay} seconds.`); + console.log(`Wait for a transaction success for ${delay} seconds.`) await expect(this.trxSuccessful).toBeVisible({ timeout: delay * 1000, visible: true, - }); + }) } async getTransactionUrl() { - const trxUrl = await this.trxLink.getAttribute("href"); - console.log(`Trx url: ${trxUrl}`); - await this.page.reload(); - return trxUrl; + const trxUrl = await this.trxLink.getAttribute('href') + console.log(`Trx url: ${trxUrl}`) + await this.page.reload() + return trxUrl } async isTransactionBroadcasted(delay = 5) { - console.log(`Wait for a transaction broadcasting for ${delay} seconds.`); - return await this.trxBroadcasting.isVisible({ timeout: delay * 1000 }); + console.log(`Wait for a transaction broadcasting for ${delay} seconds.`) + return await this.trxBroadcasting.isVisible({ timeout: delay * 1000 }) } async isInsufficientBalance() { const issufBalanceBtn = this.page.locator( - '//span[.="Insufficient balance"]' - ); - return await issufBalanceBtn.isVisible({ timeout: 2000 }); + '//span[.="Insufficient balance"]', + ) + return await issufBalanceBtn.isVisible({ timeout: 2000 }) } async isInsufficientBalanceForSwap() { const issufBalanceBtn = this.page.locator( - '//button[.="Insufficient balance"]' - ); - return await issufBalanceBtn.isVisible({ timeout: 2000 }); + '//button[.="Insufficient balance"]', + ) + return await issufBalanceBtn.isVisible({ timeout: 2000 }) } async isSufficientBalanceForTrade() { // Make sure to have sufficient balance for a trade expect( await this.isInsufficientBalance(), - "Insufficient balance for the swap!" - ).toBeFalsy(); + 'Insufficient balance for the swap!', + ).toBeFalsy() } async isError() { - const errorBtn = this.page.locator('//button[.="Error"]'); - return await errorBtn.isVisible({ timeout: 2000 }); + const errorBtn = this.page.locator('//button[.="Error"]') + return await errorBtn.isVisible({ timeout: 2000 }) } async showSwapInfo() { - const swapInfo = this.page.locator("//button//span[.='Show details']"); - await swapInfo.click({ timeout: 2000 }); + const swapInfo = this.page.locator("//button//span[.='Show details']") + await swapInfo.click({ timeout: 2000 }) } async getPriceInpact() { const priceInpactSpan = this.page.locator( - '//span[.="Price Impact"]/..//span[@class="text-bullish-400"]' - ); - return await priceInpactSpan.textContent(); + '//span[.="Price Impact"]/..//span[@class="text-bullish-400"]', + ) + return await priceInpactSpan.textContent() } async takeScreenshot(name: string) { await this.page.screenshot({ path: `screenshot-trade-${name}.png`, fullPage: true, - }); + }) } async getSelectedSwapPair() { - const tokenLocator = "//div//button[@type]//img[@alt]/../h5"; - const fromToken = this.page.locator(tokenLocator).nth(0); - const toToken = this.page.locator(tokenLocator).nth(1); - await expect(fromToken).toBeVisible({ timeout: 2000 }); - const fromTokenText = await fromToken.innerText(); - const toTokenText = await toToken.innerText(); - console.log(`Current pair: ${fromTokenText}/${toTokenText}`); - return `${fromTokenText}/${toTokenText}`; + const tokenLocator = '//div//button[@type]//img[@alt]/../h5' + const fromToken = this.page.locator(tokenLocator).nth(0) + const toToken = this.page.locator(tokenLocator).nth(1) + await expect(fromToken).toBeVisible({ timeout: 2000 }) + const fromTokenText = await fromToken.innerText() + const toTokenText = await toToken.innerText() + console.log(`Current pair: ${fromTokenText}/${toTokenText}`) + return `${fromTokenText}/${toTokenText}` } async buyAndGetWalletMsg(context: BrowserContext, limit = false) { - await expect(this.buyBtn, "Buy button is disabled!").toBeEnabled({ + await expect(this.buyBtn, 'Buy button is disabled!').toBeEnabled({ timeout: 9000, - }); + }) // Handle Pop-up page -> - await this.buyBtn.click(); - const pageApprove = context.waitForEvent("page"); - await this.confirmSwapBtn.click(); - await this.page.waitForTimeout(200); - const approvePage = await pageApprove; - await approvePage.waitForLoadState(); - const approveBtn = approvePage.getByRole("button", { - name: "Approve", - }); - await expect(approveBtn).toBeEnabled(); - let msgTextLocator = "type: osmosis/poolmanager/"; + await this.buyBtn.click() + const pageApprove = context.waitForEvent('page') + await this.confirmSwapBtn.click() + await this.page.waitForTimeout(200) + const approvePage = await pageApprove + await approvePage.waitForLoadState() + const approveBtn = approvePage.getByRole('button', { + name: 'Approve', + }) + await expect(approveBtn).toBeEnabled() + let msgTextLocator = 'type: osmosis/poolmanager/' if (limit) { - msgTextLocator = "Execute contract"; + msgTextLocator = 'Execute contract' } const msgContentAmount = await approvePage .getByText(msgTextLocator) - .textContent(); - console.log(`Wallet is approving this msg: \n${msgContentAmount}`); + .textContent() + console.log(`Wallet is approving this msg: \n${msgContentAmount}`) // Approve trx - await approveBtn.click(); + await approveBtn.click() // wait for trx confirmation - await this.page.waitForTimeout(2000); + await this.page.waitForTimeout(2000) // Handle Pop-up page <- - return { msgContentAmount }; + return { msgContentAmount } } async sellAndGetWalletMsg(context: BrowserContext, limit = false) { // Make sure Sell button is enabled - await expect(this.sellBtn, "Sell button is disabled!").toBeEnabled({ + await expect(this.sellBtn, 'Sell button is disabled!').toBeEnabled({ timeout: 9000, - }); + }) // Handle Pop-up page -> - await this.sellBtn.click(); - const pageApprove = context.waitForEvent("page"); - await this.confirmSwapBtn.click(); - await this.page.waitForTimeout(200); - const approvePage = await pageApprove; - await approvePage.waitForLoadState(); - const approveBtn = approvePage.getByRole("button", { - name: "Approve", - }); - await expect(approveBtn).toBeEnabled(); - let msgTextLocator = "type: osmosis/poolmanager/"; + await this.sellBtn.click() + const pageApprove = context.waitForEvent('page') + await this.confirmSwapBtn.click() + await this.page.waitForTimeout(200) + const approvePage = await pageApprove + await approvePage.waitForLoadState() + const approveBtn = approvePage.getByRole('button', { + name: 'Approve', + }) + await expect(approveBtn).toBeEnabled() + let msgTextLocator = 'type: osmosis/poolmanager/' if (limit) { - msgTextLocator = "Execute contract"; + msgTextLocator = 'Execute contract' } const msgContentAmount = await approvePage .getByText(msgTextLocator) - .textContent(); - console.log(`Wallet is approving this msg: \n${msgContentAmount}`); + .textContent() + console.log(`Wallet is approving this msg: \n${msgContentAmount}`) // Approve trx - await approveBtn.click(); + await approveBtn.click() // wait for trx confirmation - await this.page.waitForTimeout(2000); + await this.page.waitForTimeout(2000) // Handle Pop-up page <- - return { msgContentAmount }; + return { msgContentAmount } } } diff --git a/packages/e2e/pages/transactions-page.ts b/packages/e2e/pages/transactions-page.ts index ce2327e76a..89c60b8216 100644 --- a/packages/e2e/pages/transactions-page.ts +++ b/packages/e2e/pages/transactions-page.ts @@ -3,175 +3,175 @@ import { type Locator, type Page, expect, -} from "@playwright/test"; +} from '@playwright/test' -import { BasePage } from "./base-page"; -const TRANSACTION_CONFIRMATION_TIMEOUT = 2000; +import { BasePage } from './base-page' +const TRANSACTION_CONFIRMATION_TIMEOUT = 2000 export class TransactionsPage extends BasePage { - readonly transactionRow: Locator; - readonly viewExplorerLink: Locator; - readonly closeTransactionBtn: Locator; - readonly page: Page; - readonly claimAndClose: Locator; - readonly claimAllBtn: Locator; + readonly transactionRow: Locator + readonly viewExplorerLink: Locator + readonly closeTransactionBtn: Locator + readonly page: Page + readonly claimAndClose: Locator + readonly claimAllBtn: Locator constructor(page: Page) { - super(page); - this.page = page; - this.transactionRow = page.locator('//div/p[.="Swapped"]'); - this.viewExplorerLink = page.locator('//a/span["View on explorer"]/..'); - this.closeTransactionBtn = page.locator('//button[@data-testid="close"]'); - this.claimAndClose = page.getByRole("button", { - name: "Claim and close", + super(page) + this.page = page + this.transactionRow = page.locator('//div/p[.="Swapped"]') + this.viewExplorerLink = page.locator('//a/span["View on explorer"]/..') + this.closeTransactionBtn = page.locator('//button[@data-testid="close"]') + this.claimAndClose = page.getByRole('button', { + name: 'Claim and close', exact: true, - }); - this.claimAllBtn = page.getByRole("button", { - name: "Claim all", + }) + this.claimAllBtn = page.getByRole('button', { + name: 'Claim all', exact: true, - }); + }) } async open() { - await this.page.goto("/transactions"); - return this; + await this.page.goto('/transactions') + return this } async viewTransactionByNumber(number: number) { - await this.transactionRow.nth(number).click(); - await this.page.waitForTimeout(1000); + await this.transactionRow.nth(number).click() + await this.page.waitForTimeout(1000) } async viewBySwapAmount(amount: string | number) { // Transactions need some time to get loaded, wait for 30 seconds. - await this.page.waitForTimeout(30000); - await this.page.reload(); - const loc = `//div/div[@class="subtitle1 text-osmoverse-100" and contains(text(), "${amount}")]`; + await this.page.waitForTimeout(30000) + await this.page.reload() + const loc = `//div/div[@class="subtitle1 text-osmoverse-100" and contains(text(), "${amount}")]` const isTransactionVisible = await this.page .locator(loc) - .isVisible({ timeout: 3000 }); + .isVisible({ timeout: 3000 }) if (!isTransactionVisible) { - await this.page.waitForTimeout(30000); - await this.page.reload(); + await this.page.waitForTimeout(30000) + await this.page.reload() } - await this.page.waitForTimeout(1000); - await this.page.locator(loc).click({ timeout: 3000 }); + await this.page.waitForTimeout(1000) + await this.page.locator(loc).click({ timeout: 3000 }) } async closeTransaction() { - await this.closeTransactionBtn.click(); + await this.closeTransactionBtn.click() } async viewOnExplorerIsVisible() { - await expect(this.viewExplorerLink).toBeVisible(); + await expect(this.viewExplorerLink).toBeVisible() } async getOnExplorerLink() { - const trxUrl = await this.viewExplorerLink.getAttribute("href"); - console.log(`Trx url: ${trxUrl}`); - return trxUrl; + const trxUrl = await this.viewExplorerLink.getAttribute('href') + console.log(`Trx url: ${trxUrl}`) + return trxUrl } async takeScreenshot(name: string) { await this.page.screenshot({ path: `screenshot-transactions-${name}.png`, fullPage: true, - }); + }) } async cancelLimitOrder( amount: string, price: string, - context: BrowserContext + context: BrowserContext, ) { - const cancelBtn = `//td//span[.='${amount}']/../../../../..//td//p[.='$${price}']/../../..//button`; - console.log(`Use locator for a cancel btn: ${cancelBtn}`); - await this.page.locator(cancelBtn).first().click(); - const pageApprove = context.waitForEvent("page"); - const approvePage = await pageApprove; - await approvePage.waitForLoadState(); - const approveBtn = approvePage.getByRole("button", { - name: "Approve", - }); - await expect(approveBtn).toBeEnabled(); + const cancelBtn = `//td//span[.='${amount}']/../../../../..//td//p[.='$${price}']/../../..//button` + console.log(`Use locator for a cancel btn: ${cancelBtn}`) + await this.page.locator(cancelBtn).first().click() + const pageApprove = context.waitForEvent('page') + const approvePage = await pageApprove + await approvePage.waitForLoadState() + const approveBtn = approvePage.getByRole('button', { + name: 'Approve', + }) + await expect(approveBtn).toBeEnabled() const msgContentAmount = await approvePage - .getByText("Execute contract") - .textContent(); - console.log(`Wallet is approving this msg: \n${msgContentAmount}`); + .getByText('Execute contract') + .textContent() + console.log(`Wallet is approving this msg: \n${msgContentAmount}`) // Approve trx - await approveBtn.click(); + await approveBtn.click() // Expect that this is a cancel limit call - expect(msgContentAmount).toContain("cancel_limit"); + expect(msgContentAmount).toContain('cancel_limit') // wait for trx confirmation - await this.page.waitForTimeout(TRANSACTION_CONFIRMATION_TIMEOUT); + await this.page.waitForTimeout(TRANSACTION_CONFIRMATION_TIMEOUT) } async isFilledByLimitPrice(price: string | number) { - const loc = `//td//span[.='Filled']/../../..//td//p[.='$${price}']`; - console.log(`Use Limit Order locator: ${loc}`); + const loc = `//td//span[.='Filled']/../../..//td//p[.='$${price}']` + console.log(`Use Limit Order locator: ${loc}`) await expect(this.page.locator(loc).first()).toBeVisible({ timeout: 120_000, visible: true, - }); + }) } async claimAndCloseAny(context: BrowserContext) { const isClaimable = await this.claimAndClose .first() - .isVisible({ timeout: 3000 }); + .isVisible({ timeout: 3000 }) if (!isClaimable) { - console.log("No partially filled orders to claim."); - return; + console.log('No partially filled orders to claim.') + return } - await this.claimAndClose.first().click(); - const pageApprove = context.waitForEvent("page"); - const approvePage = await pageApprove; - await approvePage.waitForLoadState(); - const approveBtn = approvePage.getByRole("button", { - name: "Approve", - }); - await expect(approveBtn).toBeEnabled(); + await this.claimAndClose.first().click() + const pageApprove = context.waitForEvent('page') + const approvePage = await pageApprove + await approvePage.waitForLoadState() + const approveBtn = approvePage.getByRole('button', { + name: 'Approve', + }) + await expect(approveBtn).toBeEnabled() const msgContentAmount1 = await approvePage - .getByText("Execute contract") + .getByText('Execute contract') .first() - .textContent(); + .textContent() const msgContentAmount2 = await approvePage - .getByText("Execute contract") + .getByText('Execute contract') .last() - .textContent(); + .textContent() console.log( - `Wallet is approving this msg: \n${msgContentAmount1}---- \n${msgContentAmount2}` - ); + `Wallet is approving this msg: \n${msgContentAmount1}---- \n${msgContentAmount2}`, + ) // Approve trx - await approveBtn.click(); - expect(msgContentAmount1).toContain("claim_limit"); - expect(msgContentAmount2).toContain("cancel_limit"); + await approveBtn.click() + expect(msgContentAmount1).toContain('claim_limit') + expect(msgContentAmount2).toContain('cancel_limit') // wait for trx confirmation - await this.page.waitForTimeout(TRANSACTION_CONFIRMATION_TIMEOUT); + await this.page.waitForTimeout(TRANSACTION_CONFIRMATION_TIMEOUT) } async claimAll(context: BrowserContext) { - await this.claimAllBtn.click(); - const pageApprove = context.waitForEvent("page"); - const approvePage = await pageApprove; - await approvePage.waitForLoadState(); - const approveBtn = approvePage.getByRole("button", { - name: "Approve", - }); - await expect(approveBtn).toBeEnabled(); + await this.claimAllBtn.click() + const pageApprove = context.waitForEvent('page') + const approvePage = await pageApprove + await approvePage.waitForLoadState() + const approveBtn = approvePage.getByRole('button', { + name: 'Approve', + }) + await expect(approveBtn).toBeEnabled() // Approve trx - await approveBtn.click(); + await approveBtn.click() // wait for trx confirmation - await this.page.waitForTimeout(TRANSACTION_CONFIRMATION_TIMEOUT); + await this.page.waitForTimeout(TRANSACTION_CONFIRMATION_TIMEOUT) } async claimAllIfPresent(context: BrowserContext) { - const isClaimable = await this.claimAllBtn.isVisible({ timeout: 4000 }); + const isClaimable = await this.claimAllBtn.isVisible({ timeout: 4000 }) if (isClaimable) { - console.log("Claim All filled limit orders!"); - await this.claimAll(context); + console.log('Claim All filled limit orders!') + await this.claimAll(context) } else { - console.log("No Claim All button."); + console.log('No Claim All button.') } } } diff --git a/packages/e2e/tests/claim.spec.ts b/packages/e2e/tests/claim.spec.ts index cae6bc055c..b64af411c0 100644 --- a/packages/e2e/tests/claim.spec.ts +++ b/packages/e2e/tests/claim.spec.ts @@ -1,58 +1,58 @@ -import { type BrowserContext, chromium, test } from "@playwright/test"; +import { type BrowserContext, chromium, test } from '@playwright/test' -import { TransactionsPage } from "../pages/transactions-page"; -import { TestConfig } from "../test-config"; -import { UnzipExtension } from "../unzip-extension"; +import { TransactionsPage } from '../pages/transactions-page' +import { TestConfig } from '../test-config' +import { UnzipExtension } from '../unzip-extension' -import { WalletPage } from "../pages/keplr-page"; -import { TradePage } from "../pages/trade-page"; +import { WalletPage } from '../pages/keplr-page' +import { TradePage } from '../pages/trade-page' -test.describe("Test Claim All Orders feature", () => { - let context: BrowserContext; - const privateKey = process.env.PRIVATE_KEY ?? "private_key"; - let tradePage: TradePage; +test.describe('Test Claim All Orders feature', () => { + let context: BrowserContext + const privateKey = process.env.PRIVATE_KEY ?? 'private_key' + let tradePage: TradePage test.beforeAll(async () => { - const pathToExtension = new UnzipExtension().getPathToExtension(); - console.log("\nSetup Wallet Extension before tests."); + const pathToExtension = new UnzipExtension().getPathToExtension() + console.log('\nSetup Wallet Extension before tests.') // Launch Chrome with a Keplr wallet extension context = await chromium.launchPersistentContext( - "", - new TestConfig().getBrowserExtensionConfig(false, pathToExtension) - ); + '', + new TestConfig().getBrowserExtensionConfig(false, pathToExtension), + ) // Get all new pages (including Extension) in the context and wait - const emptyPage = context.pages()[0]; - await emptyPage.waitForTimeout(2000); - const page = context.pages()[1]; - const walletPage = new WalletPage(page); + const emptyPage = context.pages()[0] + await emptyPage.waitForTimeout(2000) + const page = context.pages()[1] + const walletPage = new WalletPage(page) // Import existing Wallet (could be aggregated in one function). - await walletPage.importWalletWithPrivateKey(privateKey); - await walletPage.setWalletNameAndPassword("Claim All Orders"); - await walletPage.selectChainsAndSave(); - await walletPage.finish(); + await walletPage.importWalletWithPrivateKey(privateKey) + await walletPage.setWalletNameAndPassword('Claim All Orders') + await walletPage.selectChainsAndSave() + await walletPage.finish() // Switch to Application - tradePage = new TradePage(context.pages()[0]); - await tradePage.goto(); - await tradePage.connectWallet(); - }); + tradePage = new TradePage(context.pages()[0]) + await tradePage.goto() + await tradePage.connectWallet() + }) test.afterAll(async () => { - await context.close(); - }); + await context.close() + }) - test("User should be able to Claim All filled limit orders", async () => { - await tradePage.goto(); - await tradePage.gotoOrdersHistory(10); - const p = context.pages()[0]; - const trxPage = new TransactionsPage(p); - await trxPage.claimAllIfPresent(context); - }); + test('User should be able to Claim All filled limit orders', async () => { + await tradePage.goto() + await tradePage.gotoOrdersHistory(10) + const p = context.pages()[0] + const trxPage = new TransactionsPage(p) + await trxPage.claimAllIfPresent(context) + }) - test("User should be able to Claim and Close partialy filled limit orders", async () => { - await tradePage.goto(); - await tradePage.gotoOrdersHistory(10); - const p = context.pages()[0]; - const trxPage = new TransactionsPage(p); - await trxPage.claimAndCloseAny(context); - }); -}); + test('User should be able to Claim and Close partialy filled limit orders', async () => { + await tradePage.goto() + await tradePage.gotoOrdersHistory(10) + const p = context.pages()[0] + const trxPage = new TransactionsPage(p) + await trxPage.claimAndCloseAny(context) + }) +}) diff --git a/packages/e2e/tests/monitoring.limit.wallet.spec.ts b/packages/e2e/tests/monitoring.limit.wallet.spec.ts index 073cdc3d87..a688f9e18e 100644 --- a/packages/e2e/tests/monitoring.limit.wallet.spec.ts +++ b/packages/e2e/tests/monitoring.limit.wallet.spec.ts @@ -1,99 +1,99 @@ -import { type BrowserContext, chromium, expect, test } from "@playwright/test"; +import { type BrowserContext, chromium, expect, test } from '@playwright/test' -import { TransactionsPage } from "../pages/transactions-page"; -import { TestConfig } from "../test-config"; -import { UnzipExtension } from "../unzip-extension"; +import { TransactionsPage } from '../pages/transactions-page' +import { TestConfig } from '../test-config' +import { UnzipExtension } from '../unzip-extension' -import { WalletPage } from "../pages/keplr-page"; -import { TradePage } from "../pages/trade-page"; +import { WalletPage } from '../pages/keplr-page' +import { TradePage } from '../pages/trade-page' -test.describe("Test Filled Limit Order feature", () => { - let context: BrowserContext; - const privateKey = process.env.PRIVATE_KEY ?? "private_key"; - let tradePage: TradePage; +test.describe('Test Filled Limit Order feature', () => { + let context: BrowserContext + const privateKey = process.env.PRIVATE_KEY ?? 'private_key' + let tradePage: TradePage test.beforeAll(async () => { - const pathToExtension = new UnzipExtension().getPathToExtension(); - console.log("\nSetup Wallet Extension before tests."); + const pathToExtension = new UnzipExtension().getPathToExtension() + console.log('\nSetup Wallet Extension before tests.') // Launch Chrome with a Keplr wallet extension context = await chromium.launchPersistentContext( - "", - new TestConfig().getBrowserExtensionConfig(false, pathToExtension) - ); + '', + new TestConfig().getBrowserExtensionConfig(false, pathToExtension), + ) // Get all new pages (including Extension) in the context and wait - const emptyPage = context.pages()[0]; - await emptyPage.waitForTimeout(2000); - const page = context.pages()[1]; - const walletPage = new WalletPage(page); + const emptyPage = context.pages()[0] + await emptyPage.waitForTimeout(2000) + const page = context.pages()[1] + const walletPage = new WalletPage(page) // Import existing Wallet (could be aggregated in one function). - await walletPage.importWalletWithPrivateKey(privateKey); - await walletPage.setWalletNameAndPassword("Monitoring E2E Tests"); - await walletPage.selectChainsAndSave(); - await walletPage.finish(); + await walletPage.importWalletWithPrivateKey(privateKey) + await walletPage.setWalletNameAndPassword('Monitoring E2E Tests') + await walletPage.selectChainsAndSave() + await walletPage.finish() // Switch to Application - tradePage = new TradePage(context.pages()[0]); - await tradePage.goto(); - await tradePage.connectWallet(); - expect(await tradePage.isError(), "Swap is not available!").toBeFalsy(); - }); + tradePage = new TradePage(context.pages()[0]) + await tradePage.goto() + await tradePage.connectWallet() + expect(await tradePage.isError(), 'Swap is not available!').toBeFalsy() + }) test.afterAll(async () => { - await context.close(); - }); + await context.close() + }) // biome-ignore lint/correctness/noEmptyPattern: test.afterEach(async ({}, testInfo) => { - console.log(`Test [${testInfo.title}] status: ${testInfo.status}`); - if (testInfo.status === "failed") { - const name = testInfo.title; - process.env.GITHUB_STEP_SUMMARY = `Test ${name} failed.`; + console.log(`Test [${testInfo.title}] status: ${testInfo.status}`) + if (testInfo.status === 'failed') { + const name = testInfo.title + process.env.GITHUB_STEP_SUMMARY = `Test ${name} failed.` } - }); + }) - test("User should be able to limit sell OSMO", async () => { - await tradePage.goto(); - await tradePage.openSellTab(); - await tradePage.openLimit(); - await tradePage.selectAsset("OSMO"); - await tradePage.enterAmount("1.08"); - await tradePage.setLimitPriceChange("Market"); + test('User should be able to limit sell OSMO', async () => { + await tradePage.goto() + await tradePage.openSellTab() + await tradePage.openLimit() + await tradePage.selectAsset('OSMO') + await tradePage.enterAmount('1.08') + await tradePage.setLimitPriceChange('Market') const { msgContentAmount } = await tradePage.sellAndGetWalletMsg( context, - true - ); - expect(msgContentAmount, "No msg from the wallet!").toBeTruthy(); + true, + ) + expect(msgContentAmount, 'No msg from the wallet!').toBeTruthy() // now this is converted from USDC - expect(msgContentAmount).toContain("place_limit"); - expect(msgContentAmount).toContain('"order_direction": "ask"'); - await tradePage.isTransactionSuccesful(); - await tradePage.getTransactionUrl(); - }); + expect(msgContentAmount).toContain('place_limit') + expect(msgContentAmount).toContain('"order_direction": "ask"') + await tradePage.isTransactionSuccesful() + await tradePage.getTransactionUrl() + }) - test("User should be able to limit buy OSMO", async () => { - const PRICE_INCREASE_FACTOR = 1.07; // 7% increase for limit price - const ORDER_HISTORY_TIMEOUT = 30; // Seconds to wait for order history - await tradePage.goto(); - await tradePage.openBuyTab(); - await tradePage.openLimit(); - await tradePage.selectAsset("OSMO"); - await tradePage.enterAmount("1.04"); - await tradePage.setLimitPriceChange("Market"); - const limitPrice = Number(await tradePage.getLimitPrice()); - const highLimitPrice = (limitPrice * PRICE_INCREASE_FACTOR).toFixed(4); - await tradePage.setLimitPrice(String(highLimitPrice)); + test('User should be able to limit buy OSMO', async () => { + const PRICE_INCREASE_FACTOR = 1.07 // 7% increase for limit price + const ORDER_HISTORY_TIMEOUT = 30 // Seconds to wait for order history + await tradePage.goto() + await tradePage.openBuyTab() + await tradePage.openLimit() + await tradePage.selectAsset('OSMO') + await tradePage.enterAmount('1.04') + await tradePage.setLimitPriceChange('Market') + const limitPrice = Number(await tradePage.getLimitPrice()) + const highLimitPrice = (limitPrice * PRICE_INCREASE_FACTOR).toFixed(4) + await tradePage.setLimitPrice(String(highLimitPrice)) const { msgContentAmount } = await tradePage.buyAndGetWalletMsg( context, - true - ); - expect(msgContentAmount, "No msg from the wallet!").toBeTruthy(); - expect(msgContentAmount).toContain('"quantity": "1040000"'); - expect(msgContentAmount).toContain("place_limit"); - expect(msgContentAmount).toContain('"order_direction": "bid"'); - await tradePage.isTransactionSuccesful(); - await tradePage.getTransactionUrl(); - await tradePage.gotoOrdersHistory(ORDER_HISTORY_TIMEOUT); - const p = context.pages()[0]; - const trxPage = new TransactionsPage(p); - await trxPage.isFilledByLimitPrice(highLimitPrice); - }); -}); + true, + ) + expect(msgContentAmount, 'No msg from the wallet!').toBeTruthy() + expect(msgContentAmount).toContain('"quantity": "1040000"') + expect(msgContentAmount).toContain('place_limit') + expect(msgContentAmount).toContain('"order_direction": "bid"') + await tradePage.isTransactionSuccesful() + await tradePage.getTransactionUrl() + await tradePage.gotoOrdersHistory(ORDER_HISTORY_TIMEOUT) + const p = context.pages()[0] + const trxPage = new TransactionsPage(p) + await trxPage.isFilledByLimitPrice(highLimitPrice) + }) +}) diff --git a/packages/e2e/tests/monitoring.market.wallet.spec.ts b/packages/e2e/tests/monitoring.market.wallet.spec.ts index 8a78f18664..a14d0ad53b 100644 --- a/packages/e2e/tests/monitoring.market.wallet.spec.ts +++ b/packages/e2e/tests/monitoring.market.wallet.spec.ts @@ -1,98 +1,98 @@ -import { type BrowserContext, chromium, expect, test } from "@playwright/test"; +import { type BrowserContext, chromium, expect, test } from '@playwright/test' -import { TestConfig } from "../test-config"; -import { UnzipExtension } from "../unzip-extension"; +import { TestConfig } from '../test-config' +import { UnzipExtension } from '../unzip-extension' -import { WalletPage } from "../pages/keplr-page"; -import { TradePage } from "../pages/trade-page"; +import { WalletPage } from '../pages/keplr-page' +import { TradePage } from '../pages/trade-page' -test.describe("Test Market Buy/Sell Order feature", () => { - let context: BrowserContext; - const privateKey = process.env.PRIVATE_KEY ?? "private_key"; - let tradePage: TradePage; - const TRX_SUCCESS_TIMEOUT = 10000; +test.describe('Test Market Buy/Sell Order feature', () => { + let context: BrowserContext + const privateKey = process.env.PRIVATE_KEY ?? 'private_key' + let tradePage: TradePage + const TRX_SUCCESS_TIMEOUT = 10000 test.beforeAll(async () => { - const pathToExtension = new UnzipExtension().getPathToExtension(); - console.log("\nSetup Wallet Extension before tests."); + const pathToExtension = new UnzipExtension().getPathToExtension() + console.log('\nSetup Wallet Extension before tests.') // Launch Chrome with a Keplr wallet extension context = await chromium.launchPersistentContext( - "", - new TestConfig().getBrowserExtensionConfig(false, pathToExtension) - ); + '', + new TestConfig().getBrowserExtensionConfig(false, pathToExtension), + ) // Get all new pages (including Extension) in the context and wait - const emptyPage = context.pages()[0]; - await emptyPage.waitForTimeout(2000); - const page = context.pages()[1]; - const walletPage = new WalletPage(page); + const emptyPage = context.pages()[0] + await emptyPage.waitForTimeout(2000) + const page = context.pages()[1] + const walletPage = new WalletPage(page) // Import existing Wallet (could be aggregated in one function). - await walletPage.importWalletWithPrivateKey(privateKey); - await walletPage.setWalletNameAndPassword("Monitoring E2E Tests"); - await walletPage.selectChainsAndSave(); - await walletPage.finish(); + await walletPage.importWalletWithPrivateKey(privateKey) + await walletPage.setWalletNameAndPassword('Monitoring E2E Tests') + await walletPage.selectChainsAndSave() + await walletPage.finish() // Switch to Application - tradePage = new TradePage(context.pages()[0]); - await tradePage.goto(); - await tradePage.connectWallet(); - expect(await tradePage.isError(), "Swap is not available!").toBeFalsy(); - }); + tradePage = new TradePage(context.pages()[0]) + await tradePage.goto() + await tradePage.connectWallet() + expect(await tradePage.isError(), 'Swap is not available!').toBeFalsy() + }) test.afterAll(async () => { - await context.close(); - }); + await context.close() + }) // biome-ignore lint/correctness/noEmptyPattern: test.afterEach(async ({}, testInfo) => { - console.log(`Test [${testInfo.title}] status: ${testInfo.status}`); - if (testInfo.status === "failed") { - const name = testInfo.title; - process.env.GITHUB_STEP_SUMMARY = `Test ${name} failed.`; + console.log(`Test [${testInfo.title}] status: ${testInfo.status}`) + if (testInfo.status === 'failed') { + const name = testInfo.title + process.env.GITHUB_STEP_SUMMARY = `Test ${name} failed.` } - }); + }) // biome-ignore lint/complexity/noForEach: - [{ name: "WBTC" }, { name: "OSMO" }].forEach(({ name }) => { + ;[{ name: 'WBTC' }, { name: 'OSMO' }].forEach(({ name }) => { test(`User should be able to Market Buy ${name}`, async () => { - await tradePage.goto(); - await tradePage.openBuyTab(); - await tradePage.selectAsset(name); - await tradePage.enterAmount("1.55"); - await tradePage.isSufficientBalanceForTrade(); - await tradePage.showSwapInfo(); - const { msgContentAmount } = await tradePage.buyAndGetWalletMsg(context); - expect(msgContentAmount).toBeTruthy(); - expect(msgContentAmount).toContain("type: osmosis/poolmanager/"); - await tradePage.isTransactionSuccesful(TRX_SUCCESS_TIMEOUT); - await tradePage.getTransactionUrl(); - }); - }); + await tradePage.goto() + await tradePage.openBuyTab() + await tradePage.selectAsset(name) + await tradePage.enterAmount('1.55') + await tradePage.isSufficientBalanceForTrade() + await tradePage.showSwapInfo() + const { msgContentAmount } = await tradePage.buyAndGetWalletMsg(context) + expect(msgContentAmount).toBeTruthy() + expect(msgContentAmount).toContain('type: osmosis/poolmanager/') + await tradePage.isTransactionSuccesful(TRX_SUCCESS_TIMEOUT) + await tradePage.getTransactionUrl() + }) + }) // unwrapped market sell tests just in case this affects anything. - test("User should be able to Market Sell WBTC", async () => { - await tradePage.goto(); - await tradePage.openSellTab(); - await tradePage.selectAsset("WBTC"); - await tradePage.enterAmount("1.54"); - await tradePage.isSufficientBalanceForTrade(); - await tradePage.showSwapInfo(); - const { msgContentAmount } = await tradePage.sellAndGetWalletMsg(context); - expect(msgContentAmount).toBeTruthy(); - expect(msgContentAmount).toContain("type: osmosis/poolmanager/"); - await tradePage.isTransactionSuccesful(TRX_SUCCESS_TIMEOUT); - await tradePage.getTransactionUrl(); - }); + test('User should be able to Market Sell WBTC', async () => { + await tradePage.goto() + await tradePage.openSellTab() + await tradePage.selectAsset('WBTC') + await tradePage.enterAmount('1.54') + await tradePage.isSufficientBalanceForTrade() + await tradePage.showSwapInfo() + const { msgContentAmount } = await tradePage.sellAndGetWalletMsg(context) + expect(msgContentAmount).toBeTruthy() + expect(msgContentAmount).toContain('type: osmosis/poolmanager/') + await tradePage.isTransactionSuccesful(TRX_SUCCESS_TIMEOUT) + await tradePage.getTransactionUrl() + }) - test("User should be able to Market Sell OSMO", async () => { - await tradePage.goto(); - await tradePage.openSellTab(); - await tradePage.selectAsset("OSMO"); - await tradePage.enterAmount("1.54"); - await tradePage.isSufficientBalanceForTrade(); - await tradePage.showSwapInfo(); - const { msgContentAmount } = await tradePage.sellAndGetWalletMsg(context); - expect(msgContentAmount).toBeTruthy(); - expect(msgContentAmount).toContain("type: osmosis/poolmanager/"); - await tradePage.isTransactionSuccesful(TRX_SUCCESS_TIMEOUT); - await tradePage.getTransactionUrl(); - }); -}); + test('User should be able to Market Sell OSMO', async () => { + await tradePage.goto() + await tradePage.openSellTab() + await tradePage.selectAsset('OSMO') + await tradePage.enterAmount('1.54') + await tradePage.isSufficientBalanceForTrade() + await tradePage.showSwapInfo() + const { msgContentAmount } = await tradePage.sellAndGetWalletMsg(context) + expect(msgContentAmount).toBeTruthy() + expect(msgContentAmount).toContain('type: osmosis/poolmanager/') + await tradePage.isTransactionSuccesful(TRX_SUCCESS_TIMEOUT) + await tradePage.getTransactionUrl() + }) +}) diff --git a/packages/e2e/tests/monitoring.swap.wallet.spec.ts b/packages/e2e/tests/monitoring.swap.wallet.spec.ts index 5960a6a472..5127f85525 100644 --- a/packages/e2e/tests/monitoring.swap.wallet.spec.ts +++ b/packages/e2e/tests/monitoring.swap.wallet.spec.ts @@ -1,101 +1,101 @@ -import { type BrowserContext, chromium, expect, test } from "@playwright/test"; +import { type BrowserContext, chromium, expect, test } from '@playwright/test' -import { WalletPage } from "../pages/keplr-page"; -import { TradePage } from "../pages/trade-page"; -import { TestConfig } from "../test-config"; -import { UnzipExtension } from "../unzip-extension"; +import { WalletPage } from '../pages/keplr-page' +import { TradePage } from '../pages/trade-page' +import { TestConfig } from '../test-config' +import { UnzipExtension } from '../unzip-extension' -test.describe("Test Swap Stables feature", () => { - let context: BrowserContext; - const privateKey = process.env.PRIVATE_KEY ?? "private_key"; - let tradePage: TradePage; +test.describe('Test Swap Stables feature', () => { + let context: BrowserContext + const privateKey = process.env.PRIVATE_KEY ?? 'private_key' + let tradePage: TradePage const USDC = - "ibc/498A0751C798A0D9A389AA3691123DADA57DAA4FE165D5C75894505B876BA6E4"; + 'ibc/498A0751C798A0D9A389AA3691123DADA57DAA4FE165D5C75894505B876BA6E4' const USDCa = - "ibc/D189335C6E4A68B513C10AB227BF1C1D38C746766278BA3EEB4FB14124F1D858"; + 'ibc/D189335C6E4A68B513C10AB227BF1C1D38C746766278BA3EEB4FB14124F1D858' const allUSDT = - "factory/osmo1em6xs47hd82806f5cxgyufguxrrc7l0aqx7nzzptjuqgswczk8csavdxek/alloyed/allUSDT"; - const swapAmount = "0.55"; + 'factory/osmo1em6xs47hd82806f5cxgyufguxrrc7l0aqx7nzzptjuqgswczk8csavdxek/alloyed/allUSDT' + const swapAmount = '0.55' test.beforeAll(async () => { - const pathToExtension = new UnzipExtension().getPathToExtension(); - console.log("\nSetup Wallet Extension before tests."); + const pathToExtension = new UnzipExtension().getPathToExtension() + console.log('\nSetup Wallet Extension before tests.') // Launch Chrome with a Keplr wallet extension context = await chromium.launchPersistentContext( - "", - new TestConfig().getBrowserExtensionConfig(false, pathToExtension) - ); + '', + new TestConfig().getBrowserExtensionConfig(false, pathToExtension), + ) // Get all new pages (including Extension) in the context and wait - const emptyPage = context.pages()[0]; - await emptyPage.waitForTimeout(2000); - let page = context.pages()[1]; - const walletPage = new WalletPage(page); + const emptyPage = context.pages()[0] + await emptyPage.waitForTimeout(2000) + let page = context.pages()[1] + const walletPage = new WalletPage(page) // Import existing Wallet (could be aggregated in one function). - await walletPage.importWalletWithPrivateKey(privateKey); - await walletPage.setWalletNameAndPassword("Test Stables"); - await walletPage.selectChainsAndSave(); - await walletPage.finish(); - page = context.pages()[0]; - tradePage = new TradePage(page); + await walletPage.importWalletWithPrivateKey(privateKey) + await walletPage.setWalletNameAndPassword('Test Stables') + await walletPage.selectChainsAndSave() + await walletPage.finish() + page = context.pages()[0] + tradePage = new TradePage(page) - await tradePage.goto(); - await tradePage.connectWallet(); - expect(await tradePage.isError(), "Swap is not available!").toBeFalsy(); - }); + await tradePage.goto() + await tradePage.connectWallet() + expect(await tradePage.isError(), 'Swap is not available!').toBeFalsy() + }) test.afterAll(async () => { - await context.close(); - }); + await context.close() + }) - test("User should be able to swap USDC to USDC.eth.axl", async () => { - await tradePage.goto(); - await tradePage.selectPair("USDC", "USDC.eth.axl"); - await tradePage.enterAmount(swapAmount); - await tradePage.showSwapInfo(); - const { msgContentAmount } = await tradePage.swapAndGetWalletMsg(context); - expect(msgContentAmount).toBeTruthy(); - expect(msgContentAmount).toContain(`denom: ${USDC}`); - expect(msgContentAmount).toContain(`token_out_denom: ${USDCa}`); - await tradePage.isTransactionSuccesful(); - await tradePage.getTransactionUrl(); - }); + test('User should be able to swap USDC to USDC.eth.axl', async () => { + await tradePage.goto() + await tradePage.selectPair('USDC', 'USDC.eth.axl') + await tradePage.enterAmount(swapAmount) + await tradePage.showSwapInfo() + const { msgContentAmount } = await tradePage.swapAndGetWalletMsg(context) + expect(msgContentAmount).toBeTruthy() + expect(msgContentAmount).toContain(`denom: ${USDC}`) + expect(msgContentAmount).toContain(`token_out_denom: ${USDCa}`) + await tradePage.isTransactionSuccesful() + await tradePage.getTransactionUrl() + }) - test("User should be able to swap USDC.eth.axl to USDC", async () => { - await tradePage.goto(); - await tradePage.selectPair("USDC.eth.axl", "USDC"); - await tradePage.enterAmount(swapAmount); - await tradePage.showSwapInfo(); - const { msgContentAmount } = await tradePage.swapAndGetWalletMsg(context); - expect(msgContentAmount).toBeTruthy(); - expect(msgContentAmount).toContain(`denom: ${USDCa}`); - expect(msgContentAmount).toContain(`token_out_denom: ${USDC}`); - await tradePage.isTransactionSuccesful(); - await tradePage.getTransactionUrl(); - }); + test('User should be able to swap USDC.eth.axl to USDC', async () => { + await tradePage.goto() + await tradePage.selectPair('USDC.eth.axl', 'USDC') + await tradePage.enterAmount(swapAmount) + await tradePage.showSwapInfo() + const { msgContentAmount } = await tradePage.swapAndGetWalletMsg(context) + expect(msgContentAmount).toBeTruthy() + expect(msgContentAmount).toContain(`denom: ${USDCa}`) + expect(msgContentAmount).toContain(`token_out_denom: ${USDC}`) + await tradePage.isTransactionSuccesful() + await tradePage.getTransactionUrl() + }) - test("User should be able to swap USDT to USDC", async () => { - await tradePage.goto(); - await tradePage.selectPair("USDT", "USDC"); - await tradePage.enterAmount(swapAmount); - await tradePage.showSwapInfo(); - const { msgContentAmount } = await tradePage.swapAndGetWalletMsg(context); - expect(msgContentAmount).toBeTruthy(); - expect(msgContentAmount).toContain(USDC); - expect(msgContentAmount).toContain(allUSDT); - await tradePage.isTransactionSuccesful(); - await tradePage.getTransactionUrl(); - }); + test('User should be able to swap USDT to USDC', async () => { + await tradePage.goto() + await tradePage.selectPair('USDT', 'USDC') + await tradePage.enterAmount(swapAmount) + await tradePage.showSwapInfo() + const { msgContentAmount } = await tradePage.swapAndGetWalletMsg(context) + expect(msgContentAmount).toBeTruthy() + expect(msgContentAmount).toContain(USDC) + expect(msgContentAmount).toContain(allUSDT) + await tradePage.isTransactionSuccesful() + await tradePage.getTransactionUrl() + }) - test("User should be able to swap USDC to USDT", async () => { - await tradePage.goto(); - await tradePage.selectPair("USDC", "USDT"); - await tradePage.enterAmount(swapAmount); - await tradePage.showSwapInfo(); - const { msgContentAmount } = await tradePage.swapAndGetWalletMsg(context); - expect(msgContentAmount).toBeTruthy(); - expect(msgContentAmount).toContain(`denom: ${USDC}`); - expect(msgContentAmount).toContain(allUSDT); - await tradePage.isTransactionSuccesful(); - await tradePage.getTransactionUrl(); - }); -}); + test('User should be able to swap USDC to USDT', async () => { + await tradePage.goto() + await tradePage.selectPair('USDC', 'USDT') + await tradePage.enterAmount(swapAmount) + await tradePage.showSwapInfo() + const { msgContentAmount } = await tradePage.swapAndGetWalletMsg(context) + expect(msgContentAmount).toBeTruthy() + expect(msgContentAmount).toContain(`denom: ${USDC}`) + expect(msgContentAmount).toContain(allUSDT) + await tradePage.isTransactionSuccesful() + await tradePage.getTransactionUrl() + }) +}) diff --git a/packages/e2e/tests/pools.spec.ts b/packages/e2e/tests/pools.spec.ts index ce5e3073bc..73e9ad04e7 100644 --- a/packages/e2e/tests/pools.spec.ts +++ b/packages/e2e/tests/pools.spec.ts @@ -1,77 +1,77 @@ import { type BrowserContext, + type Page, chromium, expect, - type Page, test, -} from "@playwright/test"; +} from '@playwright/test' -import { TestConfig } from "../test-config"; +import { TestConfig } from '../test-config' -import { PoolsPage } from "../pages/pools-page"; +import { PoolsPage } from '../pages/pools-page' -test.describe("Test Select Pool feature", () => { - let context: BrowserContext; - let poolsPage: PoolsPage; - let page: Page; +test.describe('Test Select Pool feature', () => { + let context: BrowserContext + let poolsPage: PoolsPage + let page: Page test.beforeAll(async () => { context = await chromium.launchPersistentContext( - "", - new TestConfig().getBrowserConfig(true) - ); - page = context.pages()[0]; - poolsPage = new PoolsPage(page); - }); + '', + new TestConfig().getBrowserConfig(true), + ) + page = context.pages()[0] + poolsPage = new PoolsPage(page) + }) test.afterAll(async () => { - await context.close(); - }); + await context.close() + }) - test("User should be able to see at least 10 pools", async () => { - await poolsPage.goto(); - expect(await poolsPage.getPoolsNumber()).toBeGreaterThan(10); - const topLiquidity = await poolsPage.getTopTenPoolsByLiquidity(); - topLiquidity.every(function (element) { - expect(element).toBeGreaterThan(10_000); - }); - const topVolume = await poolsPage.getTopTenPoolsByVolume(); - topVolume.every(function (element) { - expect(element).toBeGreaterThan(10_000); - }); - const topAPR = await poolsPage.getTopTenPoolsByAPR(); - topAPR.every(function (element) { - expect(element).toContain("%"); - }); - }); + test('User should be able to see at least 10 pools', async () => { + await poolsPage.goto() + expect(await poolsPage.getPoolsNumber()).toBeGreaterThan(10) + const topLiquidity = await poolsPage.getTopTenPoolsByLiquidity() + topLiquidity.every((element) => { + expect(element).toBeGreaterThan(10_000) + }) + const topVolume = await poolsPage.getTopTenPoolsByVolume() + topVolume.every((element) => { + expect(element).toBeGreaterThan(10_000) + }) + const topAPR = await poolsPage.getTopTenPoolsByAPR() + topAPR.every((element) => { + expect(element).toContain('%') + }) + }) - test("User should be able to select ATOM/USDC pool", async () => { - const poolName = "ATOM/USDC"; - await poolsPage.goto(); - await poolsPage.searchForPool(poolName); - const poolPage = await poolsPage.viewPool(1282, poolName); - const balance = await poolPage.getBalance(); - expect(balance).toEqual("$0"); - const tradeModal = await poolPage.getTradeModal(); - await tradeModal.enterAmount("1"); - const rate = await tradeModal.getExchangeRate(); - await tradeModal.showSwapInfo(); - expect(rate).toContain("ATOM"); - expect(rate).toContain("USDC"); - }); + test('User should be able to select ATOM/USDC pool', async () => { + const poolName = 'ATOM/USDC' + await poolsPage.goto() + await poolsPage.searchForPool(poolName) + const poolPage = await poolsPage.viewPool(1282, poolName) + const balance = await poolPage.getBalance() + expect(balance).toEqual('$0') + const tradeModal = await poolPage.getTradeModal() + await tradeModal.enterAmount('1') + const rate = await tradeModal.getExchangeRate() + await tradeModal.showSwapInfo() + expect(rate).toContain('ATOM') + expect(rate).toContain('USDC') + }) - test("User should be able to select OSMO/USDC pool", async () => { - const poolName = "OSMO/USDC"; - await poolsPage.goto(); - await poolsPage.searchForPool(poolName); - const poolPage = await poolsPage.viewPool(1464, poolName); - const balance = await poolPage.getBalance(); - expect(balance).toEqual("$0"); - const tradeModal = await poolPage.getTradeModal(); - await tradeModal.enterAmount("1"); - const rate = await tradeModal.getExchangeRate(); - await tradeModal.showSwapInfo(); - expect(rate).toContain("OSMO"); - expect(rate).toContain("USDC"); - }); -}); + test('User should be able to select OSMO/USDC pool', async () => { + const poolName = 'OSMO/USDC' + await poolsPage.goto() + await poolsPage.searchForPool(poolName) + const poolPage = await poolsPage.viewPool(1464, poolName) + const balance = await poolPage.getBalance() + expect(balance).toEqual('$0') + const tradeModal = await poolPage.getTradeModal() + await tradeModal.enterAmount('1') + const rate = await tradeModal.getExchangeRate() + await tradeModal.showSwapInfo() + expect(rate).toContain('OSMO') + expect(rate).toContain('USDC') + }) +}) diff --git a/packages/e2e/tests/portfolio.wallet.spec.ts b/packages/e2e/tests/portfolio.wallet.spec.ts index 4c379fcdf2..7ceba58f4b 100644 --- a/packages/e2e/tests/portfolio.wallet.spec.ts +++ b/packages/e2e/tests/portfolio.wallet.spec.ts @@ -1,85 +1,85 @@ import { type BrowserContext, + type Page, chromium, expect, - type Page, test, -} from "@playwright/test"; +} from '@playwright/test' -import { TestConfig } from "../test-config"; -import { UnzipExtension } from "../unzip-extension"; +import { TestConfig } from '../test-config' +import { UnzipExtension } from '../unzip-extension' -import { PortfolioPage } from "../pages/portfolio-page"; -import { WalletPage } from "../pages/keplr-page"; +import { WalletPage } from '../pages/keplr-page' +import { PortfolioPage } from '../pages/portfolio-page' -test.describe("Test Portfolio feature", () => { - let context: BrowserContext; - const privateKey = process.env.PRIVATE_KEY ?? "pk"; - let portfolioPage: PortfolioPage; - const dollarBalanceRegEx = /\$\d+/; - let page: Page; +test.describe('Test Portfolio feature', () => { + let context: BrowserContext + const privateKey = process.env.PRIVATE_KEY ?? 'pk' + let portfolioPage: PortfolioPage + const dollarBalanceRegEx = /\$\d+/ + let page: Page test.beforeAll(async () => { - const pathToExtension = new UnzipExtension().getPathToExtension(); - console.log("\nSetup Wallet Extension before tests."); + const pathToExtension = new UnzipExtension().getPathToExtension() + console.log('\nSetup Wallet Extension before tests.') // Launch Chrome with a Keplr wallet extension context = await chromium.launchPersistentContext( - "", - new TestConfig().getBrowserExtensionConfig(false, pathToExtension) - ); + '', + new TestConfig().getBrowserExtensionConfig(false, pathToExtension), + ) // Get all new pages (including Extension) in the context and wait - const emptyPage = context.pages()[0]; - await emptyPage.waitForTimeout(2000); - page = context.pages()[1]; - const walletPage = new WalletPage(page); + const emptyPage = context.pages()[0] + await emptyPage.waitForTimeout(2000) + page = context.pages()[1] + const walletPage = new WalletPage(page) // Import existing Wallet (could be aggregated in one function). - await walletPage.importWalletWithPrivateKey(privateKey); - await walletPage.setWalletNameAndPassword("Test Portfolio"); - await walletPage.selectChainsAndSave(); - await walletPage.finish(); + await walletPage.importWalletWithPrivateKey(privateKey) + await walletPage.setWalletNameAndPassword('Test Portfolio') + await walletPage.selectChainsAndSave() + await walletPage.finish() // Switch to Application - page = context.pages()[0]; - portfolioPage = new PortfolioPage(page); - await portfolioPage.goto(); - await portfolioPage.connectWallet(); - await portfolioPage.hideZeroBalances(); - await portfolioPage.viewMoreBalances(); - }); + page = context.pages()[0] + portfolioPage = new PortfolioPage(page) + await portfolioPage.goto() + await portfolioPage.connectWallet() + await portfolioPage.hideZeroBalances() + await portfolioPage.viewMoreBalances() + }) test.afterAll(async () => { - await context.close(); - }); + await context.close() + }) // biome-ignore lint/complexity/noForEach: - [ - { name: "OSMO" }, - { name: "ATOM" }, - { name: "USDT" }, - { name: "USDC" }, - { name: "TIA" }, - { name: "DAI" }, + ;[ + { name: 'OSMO' }, + { name: 'ATOM' }, + { name: 'USDT' }, + { name: 'USDC' }, + { name: 'TIA' }, + { name: 'DAI' }, ].forEach(({ name }) => { test(`User should be able to see native balances for ${name}`, async () => { - await portfolioPage.searchForToken(name); - const osmoBalance = await portfolioPage.getBalanceFor(name); - expect(osmoBalance).toMatch(dollarBalanceRegEx); - }); - }); + await portfolioPage.searchForToken(name) + const osmoBalance = await portfolioPage.getBalanceFor(name) + expect(osmoBalance).toMatch(dollarBalanceRegEx) + }) + }) // biome-ignore lint/complexity/noForEach: - [ - { name: "INJ" }, - { name: "ETH.axl" }, - { name: "SOL" }, - { name: "milkTIA" }, - { name: "BTC" }, - { name: "WBTC" }, - { name: "ETH" }, + ;[ + { name: 'INJ' }, + { name: 'ETH.axl' }, + { name: 'SOL' }, + { name: 'milkTIA' }, + { name: 'BTC' }, + { name: 'WBTC' }, + { name: 'ETH' }, ].forEach(({ name }) => { test(`User should be able to see bridged balances for ${name}`, async () => { - await portfolioPage.searchForToken(name); - const osmoBalance = await portfolioPage.getBalanceFor(name); - expect(osmoBalance).toMatch(dollarBalanceRegEx); - }); - }); -}); + await portfolioPage.searchForToken(name) + const osmoBalance = await portfolioPage.getBalanceFor(name) + expect(osmoBalance).toMatch(dollarBalanceRegEx) + }) + }) +}) diff --git a/packages/e2e/tests/select.spec.ts b/packages/e2e/tests/select.spec.ts index 8d11c1b588..2356287647 100644 --- a/packages/e2e/tests/select.spec.ts +++ b/packages/e2e/tests/select.spec.ts @@ -1,109 +1,109 @@ /* eslint-disable import/no-extraneous-dependencies */ import { type BrowserContext, - chromium, type Page, + chromium, test, -} from "@playwright/test"; +} from '@playwright/test' -import { TradePage } from "../pages/trade-page"; -import { TestConfig } from "../test-config"; +import { TradePage } from '../pages/trade-page' +import { TestConfig } from '../test-config' // Pairs are selected from top 10 -test.describe("Test Select Swap Pair feature", () => { - let context: BrowserContext; - let swapPage: TradePage; - let page: Page; +test.describe('Test Select Swap Pair feature', () => { + let context: BrowserContext + let swapPage: TradePage + let page: Page test.beforeAll(async () => { context = await chromium.launchPersistentContext( - "", - new TestConfig().getBrowserConfig(true) - ); - page = context.pages()[0]; - swapPage = new TradePage(page); - await swapPage.goto(); - }); + '', + new TestConfig().getBrowserConfig(true), + ) + page = context.pages()[0] + swapPage = new TradePage(page) + await swapPage.goto() + }) test.afterAll(async () => { - console.log(test.info()); - await context.close(); - }); + console.log(test.info()) + await context.close() + }) // Price Impact-54.768% -> no liquidity - test("User should be able to select nBTC/USDC", async () => { - await swapPage.goto(); - await swapPage.selectPair("nBTC", "USDC"); - await swapPage.enterAmount("0.01"); - await swapPage.showSwapInfo(); - }); - - test("User should be able to select WBTC/USDC", async () => { - await swapPage.goto(); - await swapPage.selectPair("WBTC", "USDC"); - await swapPage.enterAmount("0.1"); - await swapPage.showSwapInfo(); - }); - - test("User should be able to select OSMO/USDC", async () => { - await swapPage.goto(); - await swapPage.selectPair("OSMO", "USDC"); - await swapPage.enterAmount("1"); - await swapPage.showSwapInfo(); - }); - - test("User should be able to select INJ/USDC", async () => { - await swapPage.goto(); - await swapPage.selectPair("INJ", "USDC"); - await swapPage.enterAmount("10"); - await swapPage.showSwapInfo(); - }); - - test("User should be able to select TIA/USDC", async () => { - await swapPage.goto(); - await swapPage.selectPair("TIA", "USDC"); - await swapPage.enterAmount("100"); - await swapPage.showSwapInfo(); - }); - - test("User should be able to select ATOM/USDC", async () => { - await swapPage.selectPair("ATOM", "USDC"); - await swapPage.enterAmount("100"); - }); - - test("User should be able to select USDT/USDC", async () => { - await swapPage.selectPair("USDT", "USDC"); - await swapPage.enterAmount("10000"); - }); - - test("User should be able to select TIA/OSMO", async () => { - await swapPage.selectPair("TIA", "OSMO"); - await swapPage.enterAmount("100"); - }); - - test("User should be able to select AKT/OSMO", async () => { - await swapPage.selectPair("AKT", "OSMO"); - await swapPage.enterAmount("100"); - }); - - test("User should be able to select PICA/OSMO", async () => { - await swapPage.selectPair("PICA", "OSMO"); - await swapPage.enterAmount("100"); - }); - - test("User should be able to select USDT/OSMO", async () => { - await swapPage.selectPair("USDT", "OSMO"); - await swapPage.enterAmount("100"); - }); - - test("User should be able to select TIA/BOOT", async () => { + test('User should be able to select nBTC/USDC', async () => { + await swapPage.goto() + await swapPage.selectPair('nBTC', 'USDC') + await swapPage.enterAmount('0.01') + await swapPage.showSwapInfo() + }) + + test('User should be able to select WBTC/USDC', async () => { + await swapPage.goto() + await swapPage.selectPair('WBTC', 'USDC') + await swapPage.enterAmount('0.1') + await swapPage.showSwapInfo() + }) + + test('User should be able to select OSMO/USDC', async () => { + await swapPage.goto() + await swapPage.selectPair('OSMO', 'USDC') + await swapPage.enterAmount('1') + await swapPage.showSwapInfo() + }) + + test('User should be able to select INJ/USDC', async () => { + await swapPage.goto() + await swapPage.selectPair('INJ', 'USDC') + await swapPage.enterAmount('10') + await swapPage.showSwapInfo() + }) + + test('User should be able to select TIA/USDC', async () => { + await swapPage.goto() + await swapPage.selectPair('TIA', 'USDC') + await swapPage.enterAmount('100') + await swapPage.showSwapInfo() + }) + + test('User should be able to select ATOM/USDC', async () => { + await swapPage.selectPair('ATOM', 'USDC') + await swapPage.enterAmount('100') + }) + + test('User should be able to select USDT/USDC', async () => { + await swapPage.selectPair('USDT', 'USDC') + await swapPage.enterAmount('10000') + }) + + test('User should be able to select TIA/OSMO', async () => { + await swapPage.selectPair('TIA', 'OSMO') + await swapPage.enterAmount('100') + }) + + test('User should be able to select AKT/OSMO', async () => { + await swapPage.selectPair('AKT', 'OSMO') + await swapPage.enterAmount('100') + }) + + test('User should be able to select PICA/OSMO', async () => { + await swapPage.selectPair('PICA', 'OSMO') + await swapPage.enterAmount('100') + }) + + test('User should be able to select USDT/OSMO', async () => { + await swapPage.selectPair('USDT', 'OSMO') + await swapPage.enterAmount('100') + }) + + test('User should be able to select TIA/BOOT', async () => { // Just to verify some odd pair - await swapPage.selectPair("TIA", "BOOT"); - await swapPage.enterAmount("100"); - }); - - test("User should be able to select stATOM/USDC", async () => { - await swapPage.selectPair("stATOM", "USDC"); - await swapPage.enterAmount("100"); - }); -}); + await swapPage.selectPair('TIA', 'BOOT') + await swapPage.enterAmount('100') + }) + + test('User should be able to select stATOM/USDC', async () => { + await swapPage.selectPair('stATOM', 'USDC') + await swapPage.enterAmount('100') + }) +}) diff --git a/packages/e2e/tests/swap.wallet.spec.ts b/packages/e2e/tests/swap.wallet.spec.ts index d240eded99..394b6fbe4c 100644 --- a/packages/e2e/tests/swap.wallet.spec.ts +++ b/packages/e2e/tests/swap.wallet.spec.ts @@ -1,234 +1,234 @@ -import { type BrowserContext, chromium, expect, test } from "@playwright/test"; +import { type BrowserContext, chromium, expect, test } from '@playwright/test' -import { TestConfig } from "../test-config"; -import { UnzipExtension } from "../unzip-extension"; +import { TestConfig } from '../test-config' +import { UnzipExtension } from '../unzip-extension' -import { WalletPage } from "../pages/keplr-page"; -import { TradePage } from "../pages/trade-page"; +import { WalletPage } from '../pages/keplr-page' +import { TradePage } from '../pages/trade-page' -test.describe("Test Swap feature", () => { - let context: BrowserContext; +test.describe('Test Swap feature', () => { + let context: BrowserContext const walletId = - process.env.WALLET_ID ?? "osmo1qyc8u7cn0zjxcu9dvrjz5zwfnn0ck92v62ak9l"; - const privateKey = process.env.PRIVATE_KEY ?? "private_key"; - let tradePage: TradePage; + process.env.WALLET_ID ?? 'osmo1qyc8u7cn0zjxcu9dvrjz5zwfnn0ck92v62ak9l' + const privateKey = process.env.PRIVATE_KEY ?? 'private_key' + let tradePage: TradePage const USDC = - "ibc/498A0751C798A0D9A389AA3691123DADA57DAA4FE165D5C75894505B876BA6E4"; + 'ibc/498A0751C798A0D9A389AA3691123DADA57DAA4FE165D5C75894505B876BA6E4' const ATOM = - "ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2"; + 'ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2' const TIA = - "ibc/D79E7D83AB399BFFF93433E54FAA480C191248FC556924A2A8351AE2638B3877"; + 'ibc/D79E7D83AB399BFFF93433E54FAA480C191248FC556924A2A8351AE2638B3877' const INJ = - "ibc/64BA6E31FE887D66C6F8F31C7B1A80C7CA179239677B4088BB55F5EA07DBE273"; + 'ibc/64BA6E31FE887D66C6F8F31C7B1A80C7CA179239677B4088BB55F5EA07DBE273' const AKT = - "ibc/1480B8FD20AD5FCAE81EA87584D269547DD4D436843C1D20F15E00EB64743EF4"; + 'ibc/1480B8FD20AD5FCAE81EA87584D269547DD4D436843C1D20F15E00EB64743EF4' test.beforeAll(async () => { - const pathToExtension = new UnzipExtension().getPathToExtension(); - console.log("\nSetup Wallet Extension before tests."); + const pathToExtension = new UnzipExtension().getPathToExtension() + console.log('\nSetup Wallet Extension before tests.') // Launch Chrome with a Keplr wallet extension context = await chromium.launchPersistentContext( - "", - new TestConfig().getBrowserExtensionConfig(false, pathToExtension) - ); + '', + new TestConfig().getBrowserExtensionConfig(false, pathToExtension), + ) // Get all new pages (including Extension) in the context and wait - const emptyPage = context.pages()[0]; - await emptyPage.waitForTimeout(2000); - const page = context.pages()[1]; - const walletPage = new WalletPage(page); + const emptyPage = context.pages()[0] + await emptyPage.waitForTimeout(2000) + const page = context.pages()[1] + const walletPage = new WalletPage(page) // Import existing Wallet (could be aggregated in one function). - await walletPage.importWalletWithPrivateKey(privateKey); - await walletPage.setWalletNameAndPassword("Test Swaps"); - await walletPage.selectChainsAndSave(); - await walletPage.finish(); + await walletPage.importWalletWithPrivateKey(privateKey) + await walletPage.setWalletNameAndPassword('Test Swaps') + await walletPage.selectChainsAndSave() + await walletPage.finish() // Switch to Application - tradePage = new TradePage(context.pages()[0]); - await tradePage.goto(); - await tradePage.connectWallet(); - expect(await tradePage.isError(), "Swap is not available!").toBeFalsy(); - }); + tradePage = new TradePage(context.pages()[0]) + await tradePage.goto() + await tradePage.connectWallet() + expect(await tradePage.isError(), 'Swap is not available!').toBeFalsy() + }) test.afterAll(async () => { - await context.close(); - }); - - test("User should be able to swap OSMO to ATOM", async () => { - await tradePage.goto(); - await tradePage.selectPair("OSMO", "ATOM"); - await tradePage.enterAmount("0.2"); - const { msgContentAmount } = await tradePage.swapAndGetWalletMsg(context); - expect(msgContentAmount).toBeTruthy(); - expect(msgContentAmount).toContain(`token_out_denom: ${ATOM}`); - expect(msgContentAmount).toContain(`sender: ${walletId}`); - expect(msgContentAmount).toContain("denom: uosmo"); - await tradePage.isTransactionSuccesful(); - await tradePage.getTransactionUrl(); - }); - - test("User should be able to swap ATOM to OSMO", async () => { - await tradePage.goto(); - await tradePage.selectPair("ATOM", "OSMO"); - await tradePage.enterAmount("0.01"); - await tradePage.showSwapInfo(); - const { msgContentAmount } = await tradePage.swapAndGetWalletMsg(context); - expect(msgContentAmount).toBeTruthy(); - expect(msgContentAmount).toContain(`denom: ${ATOM}`); - expect(msgContentAmount).toContain(`sender: ${walletId}`); - expect(msgContentAmount).toContain("token_out_denom: uosmo"); - await tradePage.isTransactionSuccesful(); - await tradePage.getTransactionUrl(); - }); - - test("User should be able to swap OSMO to USDC", async () => { - await tradePage.goto(); - await tradePage.selectPair("OSMO", "USDC"); - await tradePage.enterAmount("0.2"); - await tradePage.showSwapInfo(); - const { msgContentAmount } = await tradePage.swapAndGetWalletMsg(context); - expect(msgContentAmount).toBeTruthy(); - expect(msgContentAmount).toContain(`token_out_denom: ${USDC}`); - expect(msgContentAmount).toContain(`sender: ${walletId}`); - expect(msgContentAmount).toContain("denom: uosmo"); - await tradePage.isTransactionSuccesful(); - await tradePage.getTransactionUrl(); - }); - - test("User should be able to swap OSMO to WBTC", async () => { - await tradePage.goto(); - await tradePage.selectPair("OSMO", "WBTC"); - await tradePage.enterAmount("0.9"); - await tradePage.showSwapInfo(); - const { msgContentAmount } = await tradePage.swapAndGetWalletMsg(context); - expect(msgContentAmount).toBeTruthy(); - expect(msgContentAmount).toContain(`sender: ${walletId}`); - expect(msgContentAmount).toContain("denom: uosmo"); - await tradePage.isTransactionSuccesful(); - await tradePage.getTransactionUrl(); - }); - - test("User should be able to swap USDC to OSMO", async () => { - await tradePage.goto(); - await tradePage.selectPair("USDC", "OSMO"); - await tradePage.enterAmount("0.1"); - await tradePage.showSwapInfo(); - const { msgContentAmount } = await tradePage.swapAndGetWalletMsg(context); - expect(msgContentAmount).toBeTruthy(); - expect(msgContentAmount).toContain("token_out_denom: uosmo"); - expect(msgContentAmount).toContain(`sender: ${walletId}`); - expect(msgContentAmount).toContain(`denom: ${USDC}`); - await tradePage.isTransactionSuccesful(); - await tradePage.getTransactionUrl(); - }); - - test("User should be able to swap ATOM to USDC", async () => { - await tradePage.goto(); - await tradePage.selectPair("ATOM", "USDC"); - await tradePage.enterAmount("0.015"); - await tradePage.showSwapInfo(); - const { msgContentAmount } = await tradePage.swapAndGetWalletMsg(context); - expect(msgContentAmount).toBeTruthy(); - expect(msgContentAmount).toContain(`denom: ${ATOM}`); - expect(msgContentAmount).toContain(`sender: ${walletId}`); - expect(msgContentAmount).toContain(`token_out_denom: ${USDC}`); - await tradePage.isTransactionSuccesful(); - await tradePage.getTransactionUrl(); - }); - - test("User should be able to swap USDC to ATOM", async () => { - await tradePage.goto(); - await tradePage.selectPair("USDC", "ATOM"); - await tradePage.enterAmount("0.1"); - await tradePage.showSwapInfo(); - const { msgContentAmount } = await tradePage.swapAndGetWalletMsg(context); - expect(msgContentAmount).toBeTruthy(); - expect(msgContentAmount).toContain(`denom: ${USDC}`); - expect(msgContentAmount).toContain(`sender: ${walletId}`); - expect(msgContentAmount).toContain(`token_out_denom: ${ATOM}`); - await tradePage.isTransactionSuccesful(); - await tradePage.getTransactionUrl(); - }); - - test("User should be able to swap USDC to TIA", async () => { - await tradePage.goto(); - await tradePage.selectPair("USDC", "TIA"); - await tradePage.enterAmount("0.1"); - await tradePage.showSwapInfo(); - const { msgContentAmount } = await tradePage.swapAndGetWalletMsg(context); - expect(msgContentAmount).toBeTruthy(); - expect(msgContentAmount).toContain(`denom: ${USDC}`); - expect(msgContentAmount).toContain(`sender: ${walletId}`); - expect(msgContentAmount).toContain(`token_out_denom: ${TIA}`); - await tradePage.isTransactionSuccesful(); - await tradePage.getTransactionUrl(); - }); - - test("User should be able to swap TIA to USDC", async () => { - await tradePage.goto(); - await tradePage.selectPair("TIA", "USDC"); - await tradePage.enterAmount("0.02"); - await tradePage.showSwapInfo(); - const { msgContentAmount } = await tradePage.swapAndGetWalletMsg(context); - expect(msgContentAmount).toBeTruthy(); - expect(msgContentAmount).toContain(`denom: ${TIA}`); - expect(msgContentAmount).toContain(`sender: ${walletId}`); - expect(msgContentAmount).toContain(`token_out_denom: ${USDC}`); - await tradePage.isTransactionSuccesful(); - await tradePage.getTransactionUrl(); - }); - - test("User should be able to swap USDC to INJ", async () => { - await tradePage.goto(); - await tradePage.selectPair("USDC", "INJ"); - await tradePage.enterAmount("0.2"); - await tradePage.showSwapInfo(); - const { msgContentAmount } = await tradePage.swapAndGetWalletMsg(context); - expect(msgContentAmount).toBeTruthy(); - expect(msgContentAmount).toContain(`denom: ${USDC}`); - expect(msgContentAmount).toContain(`sender: ${walletId}`); - expect(msgContentAmount).toContain(`token_out_denom: ${INJ}`); - await tradePage.isTransactionSuccesful(); - await tradePage.getTransactionUrl(); - }); - - test("User should be able to swap INJ to USDC", async () => { - await tradePage.goto(); - await tradePage.selectPair("INJ", "USDC"); - await tradePage.enterAmount("0.01"); - await tradePage.showSwapInfo(); - const { msgContentAmount } = await tradePage.swapAndGetWalletMsg(context); - expect(msgContentAmount).toBeTruthy(); - expect(msgContentAmount).toContain(`denom: ${INJ}`); - expect(msgContentAmount).toContain(`sender: ${walletId}`); - expect(msgContentAmount).toContain(`token_out_denom: ${USDC}`); - await tradePage.isTransactionSuccesful(); - await tradePage.getTransactionUrl(); - }); - - test("User should be able to swap USDC to AKT", async () => { - await tradePage.goto(); - await tradePage.selectPair("USDC", "AKT"); - await tradePage.enterAmount("0.1"); - await tradePage.showSwapInfo(); - const { msgContentAmount } = await tradePage.swapAndGetWalletMsg(context); - expect(msgContentAmount).toBeTruthy(); - expect(msgContentAmount).toContain(`denom: ${USDC}`); - expect(msgContentAmount).toContain(`sender: ${walletId}`); - expect(msgContentAmount).toContain(`token_out_denom: ${AKT}`); - await tradePage.isTransactionSuccesful(); - await tradePage.getTransactionUrl(); - }); - - test("User should be able to swap AKT to USDC", async () => { - await tradePage.goto(); - await tradePage.selectPair("AKT", "USDC"); - await tradePage.enterAmount("0.025"); - await tradePage.showSwapInfo(); - const { msgContentAmount } = await tradePage.swapAndGetWalletMsg(context); - expect(msgContentAmount).toBeTruthy(); - expect(msgContentAmount).toContain(`denom: ${AKT}`); - expect(msgContentAmount).toContain(`sender: ${walletId}`); - expect(msgContentAmount).toContain(`token_out_denom: ${USDC}`); - await tradePage.isTransactionSuccesful(); - await tradePage.getTransactionUrl(); - }); -}); + await context.close() + }) + + test('User should be able to swap OSMO to ATOM', async () => { + await tradePage.goto() + await tradePage.selectPair('OSMO', 'ATOM') + await tradePage.enterAmount('0.2') + const { msgContentAmount } = await tradePage.swapAndGetWalletMsg(context) + expect(msgContentAmount).toBeTruthy() + expect(msgContentAmount).toContain(`token_out_denom: ${ATOM}`) + expect(msgContentAmount).toContain(`sender: ${walletId}`) + expect(msgContentAmount).toContain('denom: uosmo') + await tradePage.isTransactionSuccesful() + await tradePage.getTransactionUrl() + }) + + test('User should be able to swap ATOM to OSMO', async () => { + await tradePage.goto() + await tradePage.selectPair('ATOM', 'OSMO') + await tradePage.enterAmount('0.01') + await tradePage.showSwapInfo() + const { msgContentAmount } = await tradePage.swapAndGetWalletMsg(context) + expect(msgContentAmount).toBeTruthy() + expect(msgContentAmount).toContain(`denom: ${ATOM}`) + expect(msgContentAmount).toContain(`sender: ${walletId}`) + expect(msgContentAmount).toContain('token_out_denom: uosmo') + await tradePage.isTransactionSuccesful() + await tradePage.getTransactionUrl() + }) + + test('User should be able to swap OSMO to USDC', async () => { + await tradePage.goto() + await tradePage.selectPair('OSMO', 'USDC') + await tradePage.enterAmount('0.2') + await tradePage.showSwapInfo() + const { msgContentAmount } = await tradePage.swapAndGetWalletMsg(context) + expect(msgContentAmount).toBeTruthy() + expect(msgContentAmount).toContain(`token_out_denom: ${USDC}`) + expect(msgContentAmount).toContain(`sender: ${walletId}`) + expect(msgContentAmount).toContain('denom: uosmo') + await tradePage.isTransactionSuccesful() + await tradePage.getTransactionUrl() + }) + + test('User should be able to swap OSMO to WBTC', async () => { + await tradePage.goto() + await tradePage.selectPair('OSMO', 'WBTC') + await tradePage.enterAmount('0.9') + await tradePage.showSwapInfo() + const { msgContentAmount } = await tradePage.swapAndGetWalletMsg(context) + expect(msgContentAmount).toBeTruthy() + expect(msgContentAmount).toContain(`sender: ${walletId}`) + expect(msgContentAmount).toContain('denom: uosmo') + await tradePage.isTransactionSuccesful() + await tradePage.getTransactionUrl() + }) + + test('User should be able to swap USDC to OSMO', async () => { + await tradePage.goto() + await tradePage.selectPair('USDC', 'OSMO') + await tradePage.enterAmount('0.1') + await tradePage.showSwapInfo() + const { msgContentAmount } = await tradePage.swapAndGetWalletMsg(context) + expect(msgContentAmount).toBeTruthy() + expect(msgContentAmount).toContain('token_out_denom: uosmo') + expect(msgContentAmount).toContain(`sender: ${walletId}`) + expect(msgContentAmount).toContain(`denom: ${USDC}`) + await tradePage.isTransactionSuccesful() + await tradePage.getTransactionUrl() + }) + + test('User should be able to swap ATOM to USDC', async () => { + await tradePage.goto() + await tradePage.selectPair('ATOM', 'USDC') + await tradePage.enterAmount('0.015') + await tradePage.showSwapInfo() + const { msgContentAmount } = await tradePage.swapAndGetWalletMsg(context) + expect(msgContentAmount).toBeTruthy() + expect(msgContentAmount).toContain(`denom: ${ATOM}`) + expect(msgContentAmount).toContain(`sender: ${walletId}`) + expect(msgContentAmount).toContain(`token_out_denom: ${USDC}`) + await tradePage.isTransactionSuccesful() + await tradePage.getTransactionUrl() + }) + + test('User should be able to swap USDC to ATOM', async () => { + await tradePage.goto() + await tradePage.selectPair('USDC', 'ATOM') + await tradePage.enterAmount('0.1') + await tradePage.showSwapInfo() + const { msgContentAmount } = await tradePage.swapAndGetWalletMsg(context) + expect(msgContentAmount).toBeTruthy() + expect(msgContentAmount).toContain(`denom: ${USDC}`) + expect(msgContentAmount).toContain(`sender: ${walletId}`) + expect(msgContentAmount).toContain(`token_out_denom: ${ATOM}`) + await tradePage.isTransactionSuccesful() + await tradePage.getTransactionUrl() + }) + + test('User should be able to swap USDC to TIA', async () => { + await tradePage.goto() + await tradePage.selectPair('USDC', 'TIA') + await tradePage.enterAmount('0.1') + await tradePage.showSwapInfo() + const { msgContentAmount } = await tradePage.swapAndGetWalletMsg(context) + expect(msgContentAmount).toBeTruthy() + expect(msgContentAmount).toContain(`denom: ${USDC}`) + expect(msgContentAmount).toContain(`sender: ${walletId}`) + expect(msgContentAmount).toContain(`token_out_denom: ${TIA}`) + await tradePage.isTransactionSuccesful() + await tradePage.getTransactionUrl() + }) + + test('User should be able to swap TIA to USDC', async () => { + await tradePage.goto() + await tradePage.selectPair('TIA', 'USDC') + await tradePage.enterAmount('0.02') + await tradePage.showSwapInfo() + const { msgContentAmount } = await tradePage.swapAndGetWalletMsg(context) + expect(msgContentAmount).toBeTruthy() + expect(msgContentAmount).toContain(`denom: ${TIA}`) + expect(msgContentAmount).toContain(`sender: ${walletId}`) + expect(msgContentAmount).toContain(`token_out_denom: ${USDC}`) + await tradePage.isTransactionSuccesful() + await tradePage.getTransactionUrl() + }) + + test('User should be able to swap USDC to INJ', async () => { + await tradePage.goto() + await tradePage.selectPair('USDC', 'INJ') + await tradePage.enterAmount('0.2') + await tradePage.showSwapInfo() + const { msgContentAmount } = await tradePage.swapAndGetWalletMsg(context) + expect(msgContentAmount).toBeTruthy() + expect(msgContentAmount).toContain(`denom: ${USDC}`) + expect(msgContentAmount).toContain(`sender: ${walletId}`) + expect(msgContentAmount).toContain(`token_out_denom: ${INJ}`) + await tradePage.isTransactionSuccesful() + await tradePage.getTransactionUrl() + }) + + test('User should be able to swap INJ to USDC', async () => { + await tradePage.goto() + await tradePage.selectPair('INJ', 'USDC') + await tradePage.enterAmount('0.01') + await tradePage.showSwapInfo() + const { msgContentAmount } = await tradePage.swapAndGetWalletMsg(context) + expect(msgContentAmount).toBeTruthy() + expect(msgContentAmount).toContain(`denom: ${INJ}`) + expect(msgContentAmount).toContain(`sender: ${walletId}`) + expect(msgContentAmount).toContain(`token_out_denom: ${USDC}`) + await tradePage.isTransactionSuccesful() + await tradePage.getTransactionUrl() + }) + + test('User should be able to swap USDC to AKT', async () => { + await tradePage.goto() + await tradePage.selectPair('USDC', 'AKT') + await tradePage.enterAmount('0.1') + await tradePage.showSwapInfo() + const { msgContentAmount } = await tradePage.swapAndGetWalletMsg(context) + expect(msgContentAmount).toBeTruthy() + expect(msgContentAmount).toContain(`denom: ${USDC}`) + expect(msgContentAmount).toContain(`sender: ${walletId}`) + expect(msgContentAmount).toContain(`token_out_denom: ${AKT}`) + await tradePage.isTransactionSuccesful() + await tradePage.getTransactionUrl() + }) + + test('User should be able to swap AKT to USDC', async () => { + await tradePage.goto() + await tradePage.selectPair('AKT', 'USDC') + await tradePage.enterAmount('0.025') + await tradePage.showSwapInfo() + const { msgContentAmount } = await tradePage.swapAndGetWalletMsg(context) + expect(msgContentAmount).toBeTruthy() + expect(msgContentAmount).toContain(`denom: ${AKT}`) + expect(msgContentAmount).toContain(`sender: ${walletId}`) + expect(msgContentAmount).toContain(`token_out_denom: ${USDC}`) + await tradePage.isTransactionSuccesful() + await tradePage.getTransactionUrl() + }) +}) diff --git a/packages/e2e/tests/trade.wallet.spec.ts b/packages/e2e/tests/trade.wallet.spec.ts index d445aa4551..84125c9a6a 100644 --- a/packages/e2e/tests/trade.wallet.spec.ts +++ b/packages/e2e/tests/trade.wallet.spec.ts @@ -1,127 +1,127 @@ -import { type BrowserContext, chromium, expect, test } from "@playwright/test"; +import { type BrowserContext, chromium, expect, test } from '@playwright/test' -import { TransactionsPage } from "../pages/transactions-page"; -import { TestConfig } from "../test-config"; -import { UnzipExtension } from "../unzip-extension"; +import { TransactionsPage } from '../pages/transactions-page' +import { TestConfig } from '../test-config' +import { UnzipExtension } from '../unzip-extension' -import { WalletPage } from "../pages/keplr-page"; -import { TradePage } from "../pages/trade-page"; +import { WalletPage } from '../pages/keplr-page' +import { TradePage } from '../pages/trade-page' -test.describe("Test Trade feature", () => { - let context: BrowserContext; - const privateKey = process.env.PRIVATE_KEY ?? "private_key"; - let tradePage: TradePage; +test.describe('Test Trade feature', () => { + let context: BrowserContext + const privateKey = process.env.PRIVATE_KEY ?? 'private_key' + let tradePage: TradePage const USDC = - "ibc/498A0751C798A0D9A389AA3691123DADA57DAA4FE165D5C75894505B876BA6E4"; + 'ibc/498A0751C798A0D9A389AA3691123DADA57DAA4FE165D5C75894505B876BA6E4' const ATOM = - "ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2"; + 'ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2' test.beforeAll(async () => { - const pathToExtension = new UnzipExtension().getPathToExtension(); - console.log("\nSetup Keplr Wallet Extension before tests."); + const pathToExtension = new UnzipExtension().getPathToExtension() + console.log('\nSetup Keplr Wallet Extension before tests.') // Launch Chrome with a Keplr wallet extension context = await chromium.launchPersistentContext( - "", - new TestConfig().getBrowserExtensionConfig(false, pathToExtension) - ); + '', + new TestConfig().getBrowserExtensionConfig(false, pathToExtension), + ) // Get all new pages (including Extension) in the context and wait - const emptyPage = context.pages()[0]; - await emptyPage.waitForTimeout(2000); - const page = context.pages()[1]; - const walletPage = new WalletPage(page); + const emptyPage = context.pages()[0] + await emptyPage.waitForTimeout(2000) + const page = context.pages()[1] + const walletPage = new WalletPage(page) // Import existing Wallet (could be aggregated in one function). - await walletPage.importWalletWithPrivateKey(privateKey); - await walletPage.setWalletNameAndPassword("Test Trades"); - await walletPage.selectChainsAndSave(); - await walletPage.finish(); + await walletPage.importWalletWithPrivateKey(privateKey) + await walletPage.setWalletNameAndPassword('Test Trades') + await walletPage.selectChainsAndSave() + await walletPage.finish() // Switch to Application - tradePage = new TradePage(context.pages()[0]); - await tradePage.goto(); - await tradePage.connectWallet(); - expect(await tradePage.isError(), "Swap is not available!").toBeFalsy(); - }); + tradePage = new TradePage(context.pages()[0]) + await tradePage.goto() + await tradePage.connectWallet() + expect(await tradePage.isError(), 'Swap is not available!').toBeFalsy() + }) test.afterAll(async () => { - await context.close(); - }); + await context.close() + }) - test("User should be able to Buy ATOM", async () => { - await tradePage.goto(); - await tradePage.openBuyTab(); - await tradePage.selectAsset("ATOM"); - await tradePage.enterAmount("1.12"); - const { msgContentAmount } = await tradePage.buyAndGetWalletMsg(context); - expect(msgContentAmount).toBeTruthy(); - expect(msgContentAmount).toContain(`denom: ${ATOM}`); - expect(msgContentAmount).toContain("type: osmosis/poolmanager/"); - expect(msgContentAmount).toContain(`denom: ${USDC}`); - await tradePage.isTransactionSuccesful(); - await tradePage.getTransactionUrl(); - }); + test('User should be able to Buy ATOM', async () => { + await tradePage.goto() + await tradePage.openBuyTab() + await tradePage.selectAsset('ATOM') + await tradePage.enterAmount('1.12') + const { msgContentAmount } = await tradePage.buyAndGetWalletMsg(context) + expect(msgContentAmount).toBeTruthy() + expect(msgContentAmount).toContain(`denom: ${ATOM}`) + expect(msgContentAmount).toContain('type: osmosis/poolmanager/') + expect(msgContentAmount).toContain(`denom: ${USDC}`) + await tradePage.isTransactionSuccesful() + await tradePage.getTransactionUrl() + }) - test("User should be able to Sell ATOM", async () => { - await tradePage.goto(); - await tradePage.openSellTab(); - await tradePage.selectAsset("ATOM"); - await tradePage.enterAmount("1.11"); - const { msgContentAmount } = await tradePage.sellAndGetWalletMsg(context); - expect(msgContentAmount).toBeTruthy(); - expect(msgContentAmount).toContain(`denom: ${USDC}`); - expect(msgContentAmount).toContain("type: osmosis/poolmanager/"); - expect(msgContentAmount).toContain(`denom: ${ATOM}`); - await tradePage.isTransactionSuccesful(); - await tradePage.getTransactionUrl(); - }); + test('User should be able to Sell ATOM', async () => { + await tradePage.goto() + await tradePage.openSellTab() + await tradePage.selectAsset('ATOM') + await tradePage.enterAmount('1.11') + const { msgContentAmount } = await tradePage.sellAndGetWalletMsg(context) + expect(msgContentAmount).toBeTruthy() + expect(msgContentAmount).toContain(`denom: ${USDC}`) + expect(msgContentAmount).toContain('type: osmosis/poolmanager/') + expect(msgContentAmount).toContain(`denom: ${ATOM}`) + await tradePage.isTransactionSuccesful() + await tradePage.getTransactionUrl() + }) - test("User should be able to limit sell ATOM", async () => { - await tradePage.goto(); - const amount = "1.01"; - await tradePage.openSellTab(); - await tradePage.openLimit(); - await tradePage.selectAsset("ATOM"); - await tradePage.enterAmount(amount); - await tradePage.setLimitPriceChange("5%"); - const limitPrice = await tradePage.getLimitPrice(); + test('User should be able to limit sell ATOM', async () => { + await tradePage.goto() + const amount = '1.01' + await tradePage.openSellTab() + await tradePage.openLimit() + await tradePage.selectAsset('ATOM') + await tradePage.enterAmount(amount) + await tradePage.setLimitPriceChange('5%') + const limitPrice = await tradePage.getLimitPrice() const { msgContentAmount } = await tradePage.sellAndGetWalletMsg( context, - true - ); - expect(msgContentAmount).toBeTruthy(); + true, + ) + expect(msgContentAmount).toBeTruthy() //expect(msgContentAmount).toContain(amount + " ATOM (Cosmos Hub/channel-0)"); - expect(msgContentAmount).toContain("place_limit"); - expect(msgContentAmount).toContain('"order_direction": "ask"'); - await tradePage.isTransactionSuccesful(); - await tradePage.getTransactionUrl(); - await tradePage.gotoOrdersHistory(); - const trxPage = new TransactionsPage(context.pages()[0]); - await trxPage.cancelLimitOrder(`Sell $${amount} of`, limitPrice, context); - await tradePage.isTransactionSuccesful(); - await tradePage.getTransactionUrl(); - }); + expect(msgContentAmount).toContain('place_limit') + expect(msgContentAmount).toContain('"order_direction": "ask"') + await tradePage.isTransactionSuccesful() + await tradePage.getTransactionUrl() + await tradePage.gotoOrdersHistory() + const trxPage = new TransactionsPage(context.pages()[0]) + await trxPage.cancelLimitOrder(`Sell $${amount} of`, limitPrice, context) + await tradePage.isTransactionSuccesful() + await tradePage.getTransactionUrl() + }) - test("User should be able to cancel limit sell OSMO", async () => { - await tradePage.goto(); - const amount = "1.01"; - await tradePage.openSellTab(); - await tradePage.openLimit(); - await tradePage.selectAsset("OSMO"); - await tradePage.enterAmount(amount); - await tradePage.setLimitPriceChange("10%"); - const limitPrice = await tradePage.getLimitPrice(); + test('User should be able to cancel limit sell OSMO', async () => { + await tradePage.goto() + const amount = '1.01' + await tradePage.openSellTab() + await tradePage.openLimit() + await tradePage.selectAsset('OSMO') + await tradePage.enterAmount(amount) + await tradePage.setLimitPriceChange('10%') + const limitPrice = await tradePage.getLimitPrice() const { msgContentAmount } = await tradePage.sellAndGetWalletMsg( context, - true - ); - expect(msgContentAmount).toBeTruthy(); + true, + ) + expect(msgContentAmount).toBeTruthy() //expect(msgContentAmount).toContain(`${amount} OSMO`); - expect(msgContentAmount).toContain("place_limit"); - expect(msgContentAmount).toContain('"order_direction": "ask"'); - await tradePage.isTransactionSuccesful(); - await tradePage.getTransactionUrl(); - await tradePage.gotoOrdersHistory(); - const trxPage = new TransactionsPage(context.pages()[0]); - await trxPage.cancelLimitOrder(`Sell $${amount} of`, limitPrice, context); - await tradePage.isTransactionSuccesful(); - await tradePage.getTransactionUrl(); - }); -}); + expect(msgContentAmount).toContain('place_limit') + expect(msgContentAmount).toContain('"order_direction": "ask"') + await tradePage.isTransactionSuccesful() + await tradePage.getTransactionUrl() + await tradePage.gotoOrdersHistory() + const trxPage = new TransactionsPage(context.pages()[0]) + await trxPage.cancelLimitOrder(`Sell $${amount} of`, limitPrice, context) + await tradePage.isTransactionSuccesful() + await tradePage.getTransactionUrl() + }) +}) diff --git a/packages/e2e/tests/transactions.wallet.spec.ts b/packages/e2e/tests/transactions.wallet.spec.ts index 1fbd83fed0..393cad0994 100644 --- a/packages/e2e/tests/transactions.wallet.spec.ts +++ b/packages/e2e/tests/transactions.wallet.spec.ts @@ -1,92 +1,92 @@ import { type BrowserContext, + type Page, chromium, expect, - type Page, test, -} from "@playwright/test"; +} from '@playwright/test' -import { SwapPage } from "../pages/swap-page"; -import { TransactionsPage } from "../pages/transactions-page"; -import { TestConfig } from "../test-config"; -import { UnzipExtension } from "../unzip-extension"; -import { WalletPage } from "../pages/keplr-page"; -import { PortfolioPage } from "../pages/portfolio-page"; +import { WalletPage } from '../pages/keplr-page' +import { PortfolioPage } from '../pages/portfolio-page' +import { SwapPage } from '../pages/swap-page' +import { TransactionsPage } from '../pages/transactions-page' +import { TestConfig } from '../test-config' +import { UnzipExtension } from '../unzip-extension' -test.describe("Test Transactions feature", () => { - let context: BrowserContext; - let page: Page; +test.describe('Test Transactions feature', () => { + let context: BrowserContext + let page: Page const walletId = - process.env.WALLET_ID ?? "osmo1qyc8u7cn0zjxcu9dvrjz5zwfnn0ck92v62ak9l"; - const privateKey = process.env.PRIVATE_KEY ?? "pk"; - let portfolioPage: PortfolioPage; - let transactionsPage: TransactionsPage; - let swapPage: SwapPage; + process.env.WALLET_ID ?? 'osmo1qyc8u7cn0zjxcu9dvrjz5zwfnn0ck92v62ak9l' + const privateKey = process.env.PRIVATE_KEY ?? 'pk' + let portfolioPage: PortfolioPage + let transactionsPage: TransactionsPage + let swapPage: SwapPage test.beforeAll(async () => { - const pathToExtension = new UnzipExtension().getPathToExtension(); - console.log("\nSetup Wallet Extension before tests."); + const pathToExtension = new UnzipExtension().getPathToExtension() + console.log('\nSetup Wallet Extension before tests.') // Launch Chrome with a Keplr wallet extension context = await chromium.launchPersistentContext( - "", - new TestConfig().getBrowserExtensionConfig(false, pathToExtension) - ); + '', + new TestConfig().getBrowserExtensionConfig(false, pathToExtension), + ) // Get all new pages (including Extension) in the context and wait - const emptyPage = context.pages()[0]; - await emptyPage.waitForTimeout(2000); - page = context.pages()[1]; - const walletPage = new WalletPage(page); + const emptyPage = context.pages()[0] + await emptyPage.waitForTimeout(2000) + page = context.pages()[1] + const walletPage = new WalletPage(page) // Import existing Wallet (could be aggregated in one function). - await walletPage.importWalletWithPrivateKey(privateKey); - await walletPage.setWalletNameAndPassword("Test Transactions"); - await walletPage.selectChainsAndSave(); - await walletPage.finish(); + await walletPage.importWalletWithPrivateKey(privateKey) + await walletPage.setWalletNameAndPassword('Test Transactions') + await walletPage.selectChainsAndSave() + await walletPage.finish() // Switch to Application - page = context.pages()[0]; - portfolioPage = new PortfolioPage(page); - await portfolioPage.goto(); - await portfolioPage.connectWallet(); - transactionsPage = await new TransactionsPage(page).open(); - }); + page = context.pages()[0] + portfolioPage = new PortfolioPage(page) + await portfolioPage.goto() + await portfolioPage.connectWallet() + transactionsPage = await new TransactionsPage(page).open() + }) test.afterAll(async () => { - await context.close(); - }); + await context.close() + }) - test("User should be able to see old transactions", async () => { - await transactionsPage.viewTransactionByNumber(10); - await transactionsPage.viewOnExplorerIsVisible(); - await transactionsPage.closeTransaction(); - await transactionsPage.viewTransactionByNumber(20); - await transactionsPage.viewOnExplorerIsVisible(); - await transactionsPage.closeTransaction(); - await transactionsPage.viewTransactionByNumber(35); - await transactionsPage.viewOnExplorerIsVisible(); - await transactionsPage.closeTransaction(); - }); + test('User should be able to see old transactions', async () => { + await transactionsPage.viewTransactionByNumber(10) + await transactionsPage.viewOnExplorerIsVisible() + await transactionsPage.closeTransaction() + await transactionsPage.viewTransactionByNumber(20) + await transactionsPage.viewOnExplorerIsVisible() + await transactionsPage.closeTransaction() + await transactionsPage.viewTransactionByNumber(35) + await transactionsPage.viewOnExplorerIsVisible() + await transactionsPage.closeTransaction() + }) - test.skip("User should be able to see a new transaction", async () => { - swapPage = new SwapPage(context.pages()[0]); - await swapPage.goto(); - await swapPage.selectPair("USDC", "USDT"); - const rndInt = Math.floor(Math.random() * 99) + 1; - const swapAmount = `0.1${rndInt}`; - await swapPage.enterAmount(swapAmount); - const { msgContentAmount } = await swapPage.swapAndGetWalletMsg(context); - expect(msgContentAmount).toBeTruthy(); - expect(msgContentAmount).toContain(`sender: ${walletId}`); + test.skip('User should be able to see a new transaction', async () => { + swapPage = new SwapPage(context.pages()[0]) + await swapPage.goto() + await swapPage.selectPair('USDC', 'USDT') + const rndInt = Math.floor(Math.random() * 99) + 1 + const swapAmount = `0.1${rndInt}` + await swapPage.enterAmount(swapAmount) + const { msgContentAmount } = await swapPage.swapAndGetWalletMsg(context) + expect(msgContentAmount).toBeTruthy() + expect(msgContentAmount).toContain(`sender: ${walletId}`) expect(msgContentAmount).toContain( - "denom: ibc/498A0751C798A0D9A389AA3691123DADA57DAA4FE165D5C75894505B876BA6E4" - ); - expect(swapPage.isTransactionBroadcasted(10)); - expect(swapPage.isTransactionSuccesful(10)); - const swapTrxUrl = await swapPage.getTransactionUrl(); - await swapPage.gotoPortfolio(); - await portfolioPage.viewTransactionsPage(); - await transactionsPage.viewBySwapAmount(swapAmount); - await transactionsPage.viewOnExplorerIsVisible(); - const trxUrl = await transactionsPage.getOnExplorerLink(); - expect(trxUrl).toContain(swapTrxUrl); - await transactionsPage.closeTransaction(); - }); -}); + 'denom: ibc/498A0751C798A0D9A389AA3691123DADA57DAA4FE165D5C75894505B876BA6E4', + ) + expect(swapPage.isTransactionBroadcasted(10)) + expect(swapPage.isTransactionSuccesful(10)) + const swapTrxUrl = await swapPage.getTransactionUrl() + await swapPage.gotoPortfolio() + await portfolioPage.viewTransactionsPage() + await transactionsPage.viewBySwapAmount(swapAmount) + await transactionsPage.viewOnExplorerIsVisible() + const trxUrl = await transactionsPage.getOnExplorerLink() + expect(trxUrl).toContain(swapTrxUrl) + await transactionsPage.closeTransaction() + }) +}) diff --git a/packages/web/components/complex/portfolio/assets-overview.tsx b/packages/web/components/complex/portfolio/assets-overview.tsx index 73091b5d43..558eab11c1 100644 --- a/packages/web/components/complex/portfolio/assets-overview.tsx +++ b/packages/web/components/complex/portfolio/assets-overview.tsx @@ -157,7 +157,7 @@ export const AssetsOverview: FunctionComponent< value: undefined, }); - const [range, setRange] = useState("1d"); + const [range, setRange] = useState("7d"); const { data: portfolioOverTimeData, diff --git a/packages/web/components/nomic/nomic-pending-transfers.tsx b/packages/web/components/nomic/nomic-pending-transfers.tsx index 35d3ce6c29..007eedad97 100644 --- a/packages/web/components/nomic/nomic-pending-transfers.tsx +++ b/packages/web/components/nomic/nomic-pending-transfers.tsx @@ -3,7 +3,7 @@ import { Dec } from "@osmosis-labs/unit"; import { getBitcoinExplorerUrl, shorten } from "@osmosis-labs/utils"; import classnames from "classnames"; import dayjs from "dayjs"; -import { useEffect, useState } from "react"; +import { useEffect, useMemo, useState } from "react"; import { create } from "zustand"; import { createJSONStorage, persist } from "zustand/middleware"; import { useShallow } from "zustand/react/shallow"; @@ -34,7 +34,7 @@ interface TransactionStore { RouterOutputs["bridgeTransfer"]["getNomicPendingDeposits"]["pendingDeposits"][number] >; upsertTransaction: ( - transactions: RouterOutputs["bridgeTransfer"]["getNomicPendingDeposits"]["pendingDeposits"] + transactions: RouterOutputs["bridgeTransfer"]["getNomicPendingDeposits"]["pendingDeposits"][number][] ) => void; } @@ -101,14 +101,15 @@ export const NomicPendingTransfers = ({ }: NomicPendingTransfersProps) => { const { t } = useTranslation(); const { accountStore } = useStore(); - const { upsertTransaction, transactions } = useNomicTransactionsStore( - useShallow((state) => ({ - upsertTransaction: state.upsertTransaction, - transactions: state.transactions, - })) - ); + const { upsertTransaction, transactions: rawTransactions } = + useNomicTransactionsStore( + useShallow((state) => ({ + upsertTransaction: state.upsertTransaction, + transactions: state.transactions, + })) + ); - const osmosisAddress = accountStore.getWallet( + const userOsmoAddress = accountStore.getWallet( accountStore.osmosisChainId )?.address; @@ -118,10 +119,10 @@ export const NomicPendingTransfers = ({ dataUpdatedAt: nomicDepositsDataUpdatedAt, } = api.bridgeTransfer.getNomicPendingDeposits.useQuery( { - userOsmoAddress: osmosisAddress!, + userOsmoAddress: userOsmoAddress!, }, { - enabled: !!osmosisAddress, + enabled: !!userOsmoAddress, refetchInterval, trpc: { context: { @@ -135,7 +136,13 @@ export const NomicPendingTransfers = ({ if (pendingDepositsData) { upsertTransaction(pendingDepositsData.pendingDeposits); } - }, [pendingDepositsData, upsertTransaction]); + }, [userOsmoAddress, pendingDepositsData, upsertTransaction]); + + const transactions = useMemo(() => { + return Array.from(rawTransactions.values()).filter( + (transaction) => transaction.userOsmoAddress === userOsmoAddress + ); + }, [rawTransactions, userOsmoAddress]); return ( <> @@ -168,62 +175,60 @@ export const NomicPendingTransfers = ({
- {Array.from(transactions.values()) - .reverse() - .map((deposit) => { - const confirmationPercentage = - (deposit.confirmations / successThreshold) * 100; - const isSuccess = deposit.confirmations === successThreshold; + {transactions.reverse().map((deposit) => { + const confirmationPercentage = + (deposit.confirmations / successThreshold) * 100; + const isSuccess = deposit.confirmations === successThreshold; - return ( -
-
-

- {deposit.fiatValue - ?.sub(deposit.networkFee.fiatValue ?? new Dec(0)) - .sub(deposit.providerFee.fiatValue ?? new Dec(0)) - .toString()}{" "} - - ( - {deposit.amount - .sub(deposit.networkFee.amount) - .sub(deposit.providerFee.amount) - .toString()} - ) - -

- -
- {isSuccess ? ( -

- {t("transfer.nomic.depositSuccess")} -

- ) : ( - - )} + return ( +
+
+

+ {deposit.fiatValue + ?.sub(deposit.networkFee.fiatValue ?? new Dec(0)) + .sub(deposit.providerFee.fiatValue ?? new Dec(0)) + .toString()}{" "} + + ( + {deposit.amount + .sub(deposit.networkFee.amount) + .sub(deposit.providerFee.amount) + .toString()} + ) + +

+
- ); - })} + {isSuccess ? ( +

+ {t("transfer.nomic.depositSuccess")} +

+ ) : ( + + )} +
+ ); + })}
); diff --git a/packages/web/components/one-click-trading/one-click-remaining-time.tsx b/packages/web/components/one-click-trading/one-click-remaining-time.tsx index 6c3e3ea92b..f71e868ca2 100644 --- a/packages/web/components/one-click-trading/one-click-remaining-time.tsx +++ b/packages/web/components/one-click-trading/one-click-remaining-time.tsx @@ -55,7 +55,12 @@ export const OneClickTradingRemainingTime: FunctionComponent<{ return (

- {displayHumanizedTime({ humanizedTime, t })} {t("remaining")} + {displayHumanizedTime({ + humanizedTime, + t, + delimitedBy: useShortTimeUnits ? " " : undefined, + })}{" "} + {t("remaining")}

); }; diff --git a/packages/web/hooks/one-click-trading/use-one-click-trading-session.ts b/packages/web/hooks/one-click-trading/use-one-click-trading-session.ts index badca7c9d5..ee170f4f7e 100644 --- a/packages/web/hooks/one-click-trading/use-one-click-trading-session.ts +++ b/packages/web/hooks/one-click-trading/use-one-click-trading-session.ts @@ -103,7 +103,7 @@ export const useOneClickTradingSession = ({ return { oneClickTradingInfo: featureFlags.oneClickTrading ? value?.info : undefined, isOneClickTradingEnabled: featureFlags.oneClickTrading - ? value?.isEnabled + ? value?.isEnabled ?? false : false, isOneClickTradingExpired: featureFlags.oneClickTrading ? isExpired : false, getTimeRemaining, diff --git a/packages/web/hooks/one-click-trading/use-one-click-trading-swap-review.ts b/packages/web/hooks/one-click-trading/use-one-click-trading-swap-review.ts index c2ad1f6a2c..6956a19c53 100644 --- a/packages/web/hooks/one-click-trading/use-one-click-trading-swap-review.ts +++ b/packages/web/hooks/one-click-trading/use-one-click-trading-swap-review.ts @@ -161,17 +161,20 @@ export function use1CTSwapReviewMessages() { const shouldFetchExistingSessionAuthenticator = !!account?.address && !!oneClickTradingInfo; + const enabledFetchingSessionAuthenticator = + isOneClickTradingEnabled && shouldFetchExistingSessionAuthenticator; + const { data: sessionAuthenticator, isLoading: isLoadingSessionAuthenticator, + error: sessionAuthenticatorError, } = api.local.oneClickTrading.getSessionAuthenticator.useQuery( { userOsmoAddress: account?.address ?? "", publicKey: oneClickTradingInfo?.publicKey ?? "", }, { - enabled: - isOneClickTradingEnabled && shouldFetchExistingSessionAuthenticator, + enabled: enabledFetchingSessionAuthenticator, cacheTime: 15_000, // 15 seconds staleTime: 15_000, // 15 seconds retry: false, @@ -244,17 +247,20 @@ export function use1CTSwapReviewMessages() { spendLimitTokenDecimals, transaction1CTParams, ]); + const isLoading = shouldSend1CTTx + ? isLoadingOneClickMessages || + (shouldFetchExistingSessionAuthenticator && + !sessionAuthenticatorError && + enabledFetchingSessionAuthenticator + ? isLoadingSessionAuthenticator + : false) || + isLoadingInfo + : false; return { oneClickMessages, shouldSend1CTTx, - isLoadingOneClickMessages: shouldSend1CTTx - ? isLoadingOneClickMessages || - (shouldFetchExistingSessionAuthenticator - ? isLoadingSessionAuthenticator - : false) || - isLoadingInfo - : false, + isLoadingOneClickMessages: isLoading, }; } diff --git a/packages/web/localizations/de.json b/packages/web/localizations/de.json index 86e46407ff..08f6fcc422 100644 --- a/packages/web/localizations/de.json +++ b/packages/web/localizations/de.json @@ -2,7 +2,7 @@ "404": { "title": "Nicht gefunden" }, - "aboutSecondsRemaining": "Etwa {seconds} verbleibend", + "unknownTimeRemaining": "Unbekannte verbleibende Zeit", "addLiquidity": { "allAssets": "Alle Vermögenswerte", "autoswapCaption": "Verwenden Sie Autoswap, um Liquidität mit einem einzelnen Vermögenswert hinzuzufügen.", diff --git a/packages/web/localizations/en.json b/packages/web/localizations/en.json index 4ffe1ceb80..aa46773eb9 100644 --- a/packages/web/localizations/en.json +++ b/packages/web/localizations/en.json @@ -2,7 +2,7 @@ "404": { "title": "Not found" }, - "aboutSecondsRemaining": "About {seconds} remaining", + "unknownTimeRemaining": "Unknown time remaining", "addLiquidity": { "allAssets": "All assets", "autoswapCaption": "Use autoswap to add liquidity with a single asset.", diff --git a/packages/web/localizations/es.json b/packages/web/localizations/es.json index bf849744fe..6b27ff2ffa 100644 --- a/packages/web/localizations/es.json +++ b/packages/web/localizations/es.json @@ -2,7 +2,7 @@ "404": { "title": "No encontrado" }, - "aboutSecondsRemaining": "Quedan aproximadamente {seconds}", + "unknownTimeRemaining": "Tiempo restante desconocido", "addLiquidity": { "allAssets": "Todos los activos", "autoswapCaption": "Use el intercambio automático para agregar liquidez con un solo activo.", diff --git a/packages/web/localizations/fa.json b/packages/web/localizations/fa.json index f2d2512d6a..1b0a9271ac 100644 --- a/packages/web/localizations/fa.json +++ b/packages/web/localizations/fa.json @@ -2,7 +2,7 @@ "404": { "title": "پیدا نشد" }, - "aboutSecondsRemaining": "درباره {seconds} باقی مانده است", + "unknownTimeRemaining": "زمان نامعلوم باقی مانده است", "addLiquidity": { "allAssets": "همه دارایی های شما", "autoswapCaption": "استفاده از تبدیل خودکار برای تبدیل یک دارایی به سایر دارایی ها", diff --git a/packages/web/localizations/fr.json b/packages/web/localizations/fr.json index 561e14b286..25eb175d9d 100644 --- a/packages/web/localizations/fr.json +++ b/packages/web/localizations/fr.json @@ -2,7 +2,7 @@ "404": { "title": "Page non trouvée" }, - "aboutSecondsRemaining": "Il reste environ {seconds}", + "unknownTimeRemaining": "Temps restant inconnu", "addLiquidity": { "allAssets": "Tous les actifs", "autoswapCaption": "Utilisez l'échange automatique pour ajouter de la liquidité avec un seul actif.", diff --git a/packages/web/localizations/gu.json b/packages/web/localizations/gu.json index d9a7fc3ceb..13e9833538 100644 --- a/packages/web/localizations/gu.json +++ b/packages/web/localizations/gu.json @@ -2,7 +2,7 @@ "404": { "title": "મળી નથી" }, - "aboutSecondsRemaining": "લગભગ {seconds} બાકી", + "unknownTimeRemaining": "અજ્ઞાત સમય બાકી", "addLiquidity": { "allAssets": "બધી સંપત્તિ", "autoswapCaption": "સિંગલ એસેટ સાથે લિક્વિડિટી ઉમેરવા માટે ઑટોસ્વેપનો ઉપયોગ કરો.", diff --git a/packages/web/localizations/hi.json b/packages/web/localizations/hi.json index 408b62ee7b..4c68691593 100644 --- a/packages/web/localizations/hi.json +++ b/packages/web/localizations/hi.json @@ -2,7 +2,7 @@ "404": { "title": "नहीं मिला" }, - "aboutSecondsRemaining": "लगभग {seconds} शेष हैं", + "unknownTimeRemaining": "शेष समय अज्ञात", "addLiquidity": { "allAssets": "सारी संपत्ति", "autoswapCaption": "एकल परिसंपत्ति में तरलता जोड़ने के लिए ऑटोस्वैप का उपयोग करें।", diff --git a/packages/web/localizations/ja.json b/packages/web/localizations/ja.json index 7991d1b1ab..2ce4d3f0b7 100644 --- a/packages/web/localizations/ja.json +++ b/packages/web/localizations/ja.json @@ -2,7 +2,7 @@ "404": { "title": "見つかりません" }, - "aboutSecondsRemaining": "残り約{seconds}", + "unknownTimeRemaining": "残り時間不明", "addLiquidity": { "allAssets": "すべての資産", "autoswapCaption": "自動スワップを使用して、単一の資産に流動性を追加します。", diff --git a/packages/web/localizations/ko.json b/packages/web/localizations/ko.json index 5ac0cb0dfb..4d5933c5a1 100644 --- a/packages/web/localizations/ko.json +++ b/packages/web/localizations/ko.json @@ -2,7 +2,7 @@ "404": { "title": "페이지를 찾을 수 없습니다" }, - "aboutSecondsRemaining": "{seconds} 남음", + "unknownTimeRemaining": "남은 시간을 알 수 없음", "addLiquidity": { "allAssets": "모든 자산", "autoswapCaption": "오토스왑을 통해 단일 자산의 유동성을 추가합니다", diff --git a/packages/web/localizations/pl.json b/packages/web/localizations/pl.json index a69f34e528..d18f03bd41 100644 --- a/packages/web/localizations/pl.json +++ b/packages/web/localizations/pl.json @@ -2,7 +2,7 @@ "404": { "title": "Nie znaleziono" }, - "aboutSecondsRemaining": "Pozostało około {seconds}", + "unknownTimeRemaining": "Nieznany pozostały czas", "addLiquidity": { "allAssets": "Wszystkie tokeny", "autoswapCaption": "Użyj autowymiany, żeby dodać płynność jednym tokenem.", diff --git a/packages/web/localizations/pt-br.json b/packages/web/localizations/pt-br.json index 9c30af4f84..ab1819147b 100644 --- a/packages/web/localizations/pt-br.json +++ b/packages/web/localizations/pt-br.json @@ -2,7 +2,7 @@ "404": { "title": "Não encontrado" }, - "aboutSecondsRemaining": "Cerca de {seconds} restantes", + "unknownTimeRemaining": "Tempo restante desconhecido", "addLiquidity": { "allAssets": "Todos os ativos", "autoswapCaption": "Use autoswap para adicionar liquidez com um único ativo.", diff --git a/packages/web/localizations/ro.json b/packages/web/localizations/ro.json index 76affba517..5dcc28644d 100644 --- a/packages/web/localizations/ro.json +++ b/packages/web/localizations/ro.json @@ -2,7 +2,7 @@ "404": { "title": "Nu a fost gasit" }, - "aboutSecondsRemaining": "Aproximativ {seconds} rămase", + "unknownTimeRemaining": "Timp rămas necunoscut", "addLiquidity": { "allAssets": "Toate activele", "autoswapCaption": "Utilizeaza schimbul automat pentru a adauga lichiditate cu un singur activ.", diff --git a/packages/web/localizations/ru.json b/packages/web/localizations/ru.json index 57ec454cba..d5d312bf64 100644 --- a/packages/web/localizations/ru.json +++ b/packages/web/localizations/ru.json @@ -2,7 +2,7 @@ "404": { "title": "Не найдено" }, - "aboutSecondsRemaining": "Около {seconds} осталось", + "unknownTimeRemaining": "Неизвестно оставшееся время", "addLiquidity": { "allAssets": "Все активы", "autoswapCaption": "Используйте автосвоп, чтобы добавить ликвидность с помощью одного актива.", diff --git a/packages/web/localizations/tr.json b/packages/web/localizations/tr.json index 57e6145fe7..9313a2b0d8 100644 --- a/packages/web/localizations/tr.json +++ b/packages/web/localizations/tr.json @@ -2,7 +2,7 @@ "404": { "title": "Bulunamadı" }, - "aboutSecondsRemaining": "{seconds} kalan süre hakkında", + "unknownTimeRemaining": "Bilinmeyen kalan süre", "addLiquidity": { "allAssets": "Tüm varlıklar", "autoswapCaption": "Tek bir varlıkla likidite eklemek için otomatik takası kullanın.", diff --git a/packages/web/localizations/zh-cn.json b/packages/web/localizations/zh-cn.json index 094c361f06..2d547982a1 100644 --- a/packages/web/localizations/zh-cn.json +++ b/packages/web/localizations/zh-cn.json @@ -2,7 +2,7 @@ "404": { "title": "未找到" }, - "aboutSecondsRemaining": "大约剩余{seconds}", + "unknownTimeRemaining": "剩余时间未知", "addLiquidity": { "allAssets": "全部资产", "autoswapCaption": "使用自动兑换为单边资产添加流动性.", diff --git a/packages/web/localizations/zh-hk.json b/packages/web/localizations/zh-hk.json index 242334e93e..39e9262cc2 100644 --- a/packages/web/localizations/zh-hk.json +++ b/packages/web/localizations/zh-hk.json @@ -2,7 +2,7 @@ "404": { "title": "搵唔到呢一頁喎" }, - "aboutSecondsRemaining": "大約剩餘{seconds}", + "unknownTimeRemaining": "剩餘時間未知", "addLiquidity": { "allAssets": "所有資產", "autoswapCaption": "使用自動兌換以使用單一資產加入流動性", diff --git a/packages/web/localizations/zh-tw.json b/packages/web/localizations/zh-tw.json index f14dba6e3b..878f38f286 100644 --- a/packages/web/localizations/zh-tw.json +++ b/packages/web/localizations/zh-tw.json @@ -2,7 +2,7 @@ "404": { "title": "找不到這頁面" }, - "aboutSecondsRemaining": "大約剩餘{seconds}", + "unknownTimeRemaining": "剩餘時間未知", "addLiquidity": { "allAssets": "所有資產", "autoswapCaption": "使用自動兌換以使用單一資產加入流動性", diff --git a/packages/web/modals/profile.tsx b/packages/web/modals/profile.tsx index da9f73a1eb..df4f3ab94f 100644 --- a/packages/web/modals/profile.tsx +++ b/packages/web/modals/profile.tsx @@ -138,7 +138,7 @@ export const ProfileModal: FunctionComponent< onAfterClose={() => { setShow1CTSettings(false); }} - className="relative max-h-screen overflow-hidden" + className="relative max-h-screen overflow-hidden sm:mx-0" >
{show1CT && show1CTSettings ? ( diff --git a/packages/web/server/api/routers/bridge-transfer.ts b/packages/web/server/api/routers/bridge-transfer.ts index ee0e948081..c74dfe7cde 100644 --- a/packages/web/server/api/routers/bridge-transfer.ts +++ b/packages/web/server/api/routers/bridge-transfer.ts @@ -735,6 +735,7 @@ export const bridgeTransferRouter = createTRPCRouter({ return { ...deposit, + userOsmoAddress: input.userOsmoAddress, amount: new CoinPretty( { coinDecimals: deposit.networkFee.decimals, diff --git a/packages/web/stores/__tests__/transfer-history.spec.tsx b/packages/web/stores/__tests__/transfer-history.spec.tsx index 469088b2e9..5ae6e4a0b8 100644 --- a/packages/web/stores/__tests__/transfer-history.spec.tsx +++ b/packages/web/stores/__tests__/transfer-history.spec.tsx @@ -21,15 +21,15 @@ describe("PendingTransferCaption", () => { if (key === "timeUnits.hours") { return "hours"; } + if (key === "unknownTimeRemaining") { + return "Unknown time remaining"; + } if (key === "transfer.amountToChain") { return `Transfer ${options.amount} to ${options.chain}`; } if (key === "transfer.amountFromChain") { return `Transfer ${options.amount} from ${options.chain}`; } - if (key === "aboutSecondsRemaining") { - return `About ${options.seconds} remaining`; - } if (key === "estimated") { return "Estimated"; } @@ -88,12 +88,12 @@ describe("PendingTransferCaption", () => { /> ); - jest.advanceTimersByTime(296000); // Advance time by 4 minutes and 56 seconds + jest.advanceTimersByTime(300000); // Advance time by 5 minutes - expect(screen.getByText(/About 5 seconds remaining/)).toBeInTheDocument(); + expect(screen.getByText(/Unknown time remaining/)).toBeInTheDocument(); }); - it.only("displays the hours and minutes", () => { + it("displays the hours and minutes", () => { const estimatedArrivalUnix = dayjs() .add(3, "hours") .add(59, "minutes") diff --git a/packages/web/stores/transfer-history.tsx b/packages/web/stores/transfer-history.tsx index 54718f630c..c7cb3f8735 100644 --- a/packages/web/stores/transfer-history.tsx +++ b/packages/web/stores/transfer-history.tsx @@ -331,9 +331,6 @@ export class TransferHistoryStore implements TransferStatusReceiver { (await this.kvStore.get(TRANSFER_HISTORY_STORE_KEY)) ?? []; storedSnapshots.forEach(async (snapshot) => { - if (this.isSnapshotExpired(snapshot)) { - return; - } const statusSource = this.transferStatusProviders.find((source) => snapshot.provider.startsWith(source.providerId) ); @@ -358,11 +355,6 @@ export class TransferHistoryStore implements TransferStatusReceiver { this.isRestoredFromIndexedDB = true; }); } - - protected isSnapshotExpired(snapshot: TxSnapshot): boolean { - const expiryMs = this.historyExpireDays * 86_400_00; - return Date.now() - snapshot.createdAtUnix * 1000 > expiryMs; - } } const PendingTransferLoadingIcon: FunctionComponent<{ @@ -436,10 +428,8 @@ export const PendingTransferCaption: FunctionComponent<{ if (progressRef.current) { // DANGER: We update the HTML directly because react-toastify is having issues while handling react state changes progressRef.current.textContent = - date.diff(dayjs(), "seconds") < 5 - ? t("aboutSecondsRemaining", { - seconds: "5 " + t("timeUnits.seconds"), - }) + date.diff(dayjs(), "seconds") < 1 + ? t("unknownTimeRemaining") : `${t("estimated")} ${displayHumanizedTime({ humanizedTime, t,