-
Notifications
You must be signed in to change notification settings - Fork 427
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
6 changed files
with
183 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* eslint-disable import/no-extraneous-dependencies */ | ||
import { Locator, Page } from "@playwright/test"; | ||
|
||
import { BasePage } from "~/e2e/pages/base-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; | ||
|
||
constructor(page: Page) { | ||
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"]'); | ||
} | ||
|
||
async getBalance() { | ||
let 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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* eslint-disable import/no-extraneous-dependencies */ | ||
import { Locator, Page } from "@playwright/test"; | ||
|
||
import { BasePage } from "~/e2e/pages/base-page"; | ||
|
||
import { PoolPage } from "./pool-page"; | ||
|
||
export class PoolsPage extends BasePage { | ||
readonly page: Page; | ||
readonly viewMore: Locator; | ||
readonly poolsLink: Locator; | ||
readonly balance: Locator; | ||
|
||
constructor(page: Page) { | ||
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")]' | ||
); | ||
} | ||
|
||
async goto() { | ||
await this.page.goto("/"); | ||
await this.page.waitForTimeout(2000); | ||
await this.poolsLink.click(); | ||
// we expect that after 4 seconds tokens are loaded and any failure after this point should be considered a bug. | ||
await this.page.waitForTimeout(4000); | ||
await super.printUrl(); | ||
} | ||
|
||
async viewPool(id: number, pair: string) { | ||
await this.page | ||
.locator(`//table//td/a[@href="/pool/${id}"]//span[.="${pair}"]`) | ||
.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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* eslint-disable import/no-extraneous-dependencies */ | ||
import { BrowserContext, chromium, expect, test } from "@playwright/test"; | ||
|
||
import { PoolsPage } from "../pages/pools-page"; | ||
|
||
test.describe("Test Select Pool feature", () => { | ||
let context: BrowserContext; | ||
let poolsPage: PoolsPage; | ||
|
||
test.beforeAll(async () => { | ||
context = await chromium.launchPersistentContext("", { | ||
headless: true, | ||
viewport: { width: 1280, height: 1024 }, | ||
}); | ||
poolsPage = new PoolsPage(context.pages()[0]); | ||
}); | ||
|
||
test.afterAll(async () => { | ||
await context.close(); | ||
}); | ||
|
||
test("User should be able to select ATOM/USDC", async () => { | ||
await poolsPage.goto(); | ||
const poolPage = await poolsPage.viewPool(1282, "ATOM/USDC"); | ||
const balance = await poolPage.getBalance(); | ||
expect(balance).toEqual("$0"); | ||
const tradeModal = await poolPage.getTradeModal(); | ||
const pair = await tradeModal.getSelectedPair(); | ||
expect(pair).toEqual("ATOM/USDC"); | ||
await tradeModal.enterAmount("1"); | ||
await tradeModal.showSwapInfo(); | ||
}); | ||
|
||
test("User should be able to select OSMO/USDC Pool", async () => { | ||
await poolsPage.goto(); | ||
const poolPage = await poolsPage.viewPool(1464, "OSMO/USDC"); | ||
const balance = await poolPage.getBalance(); | ||
expect(balance).toEqual("$0"); | ||
const tradeModal = await poolPage.getTradeModal(); | ||
const pair = await tradeModal.getSelectedPair(); | ||
expect(pair).toEqual("OSMO/USDC"); | ||
await tradeModal.enterAmount("1"); | ||
await tradeModal.showSwapInfo(); | ||
}); | ||
}); |