Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
545 changes: 451 additions & 94 deletions packages/e2e/pages/trade-page.ts

Large diffs are not rendered by default.

357 changes: 251 additions & 106 deletions packages/e2e/pages/transactions-page.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/e2e/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default defineConfig({
["junit", { outputFile: "./playwright-report/test-results.xml" }],
["json", { outputFile: "./playwright-report/test-results.json" }],
],
timeout: 90000, // Increased from 60s to 90s for slippage tolerance + balance checks + network latency
timeout: 90000, // Increased from default 60s to 90s for slippage tolerance + balance checks + network latency
testDir: "./tests",
/* Run tests in files in parallel. */
fullyParallel: true,
Expand Down
2 changes: 1 addition & 1 deletion packages/e2e/setup-keplr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { WalletPage } from "./pages/keplr-page";

export class SetupKeplr {
async setupWalletKeplr(privateKey: string, headless = false) {
const pathToKeplrExtension = new UnzipExtension().getPathToExtension();
const pathToKeplrExtension = await new UnzipExtension().getPathToExtension();
const testConfig = new TestConfig().getBrowserExtensionConfig(
headless,
pathToKeplrExtension
Expand Down
117 changes: 59 additions & 58 deletions packages/e2e/tests/monitoring.limit.wallet.spec.ts
Original file line number Diff line number Diff line change
@@ -1,76 +1,77 @@
import * as core from '@actions/core'
import { type BrowserContext, expect, test } from '@playwright/test'
import { TradePage } from '../pages/trade-page'
import { SetupKeplr } from '../setup-keplr'
import { ensureBalances } from '../utils/balance-checker'
import * as core from "@actions/core";
import { type BrowserContext, expect, test } from "@playwright/test";
import { TradePage } from "../pages/trade-page";
import { SetupKeplr } from "../setup-keplr";
import { ensureBalances } from "../utils/balance-checker";

test.describe('Test Filled Limit Order feature', () => {
let context: BrowserContext
const privateKey = process.env.PRIVATE_KEY ?? 'private_key'
const walletId = process.env.WALLET_ID ?? 'wallet_id'
let tradePage: TradePage
test.describe("Test Filled Limit Order feature", () => {
let context: BrowserContext;
const privateKey = process.env.PRIVATE_KEY ?? "private_key";
const walletId = process.env.WALLET_ID ?? "wallet_id";
let tradePage: TradePage;

test.beforeAll(async () => {
context = await new SetupKeplr().setupWallet(privateKey)
context = await new SetupKeplr().setupWallet(privateKey);

// Check balances before running tests - warn only mode
await ensureBalances(walletId, [
{ token: 'OSMO', amount: 1.1 }, // For limit sell OSMO
{ token: 'USDC', amount: 1.1 }, // For limit buy OSMO
], { warnOnly: true })

tradePage = new TradePage(context.pages()[0])
await tradePage.goto()
})
await ensureBalances(
walletId,
[
{ token: "OSMO", amount: 1.1 }, // For limit sell OSMO
{ token: "USDC", amount: 1.1 }, // For limit buy OSMO
],
{ warnOnly: true }
);

tradePage = new TradePage(context.pages()[0]);
await tradePage.goto();
});

test.beforeEach(async () => {
await tradePage.connectWallet()
expect(await tradePage.isError(), 'Swap is not available!').toBeFalsy()
})
await tradePage.connectWallet();
expect(await tradePage.isError(), "Swap is not available!").toBeFalsy();
});

test.afterEach(async () => {
await tradePage.logOut()
})
await tradePage.logOut();
});

// biome-ignore lint/correctness/noEmptyPattern: <explanation>
test.afterEach(async ({}, testInfo) => {
console.log(`Test [${testInfo.title}] status: ${testInfo.status}`)
if (testInfo.status === 'failed') {
const name = testInfo.title
core.notice(`Test ${name} failed.`)
console.log(`Test [${testInfo.title}] status: ${testInfo.status}`);
if (testInfo.status === "failed") {
const name = testInfo.title;
core.notice(`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')
await tradePage.sellAndApprove(context)
await tradePage.isTransactionSuccesful()
await tradePage.getTransactionUrl()
})
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");
await tradePage.sellAndApprove(context);
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))
await tradePage.buyAndApprove(context)
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
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));
await tradePage.buyAndApprove(context);
await tradePage.getTransactionUrl();
//await tradePage.gotoOrdersHistory(ORDER_HISTORY_TIMEOUT);
//const p = context.pages()[0]
//const trxPage = new TransactionsPage(p)
//await trxPage.isFilledByLimitPrice(highLimitPrice)
})
})
});
});
138 changes: 69 additions & 69 deletions packages/e2e/tests/monitoring.market.wallet.spec.ts
Original file line number Diff line number Diff line change
@@ -1,89 +1,89 @@
import * as core from '@actions/core'
import { type BrowserContext, expect, test } from '@playwright/test'
import { TradePage } from '../pages/trade-page'
import { SetupKeplr } from '../setup-keplr'
import { ensureBalances } from '../utils/balance-checker'
import * as core from "@actions/core";
import { type BrowserContext, expect, test } from "@playwright/test";
import { TradePage } from "../pages/trade-page";
import { SetupKeplr } from "../setup-keplr";
import { ensureBalances } from "../utils/balance-checker";

test.describe('Test Market Buy/Sell Order feature', () => {
let context: BrowserContext
const privateKey = process.env.PRIVATE_KEY ?? 'private_key'
const walletId = process.env.WALLET_ID ?? 'wallet_id'
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";
const walletId = process.env.WALLET_ID ?? "wallet_id";
let tradePage: TradePage;

test.beforeAll(async () => {
context = await new SetupKeplr().setupWallet(privateKey)
context = await new SetupKeplr().setupWallet(privateKey);

// Check balances before running tests - warn only mode
await ensureBalances(walletId, [
{ token: 'USDC', amount: 3.2 }, // For market buy BTC and OSMO (1.55 each)
{ token: 'BTC', amount: 1.6 }, // For market sell BTC
{ token: 'OSMO', amount: 1.6 }, // For market sell OSMO
], { warnOnly: true })

tradePage = new TradePage(context.pages()[0])
await tradePage.goto()
})
await ensureBalances(
walletId,
[
{ token: "USDC", amount: 3.2 }, // For market buy BTC and OSMO (1.55 each)
{ token: "BTC", amount: 1.6 }, // For market sell BTC
{ token: "OSMO", amount: 1.6 }, // For market sell OSMO
],
{ warnOnly: true }
);

tradePage = new TradePage(context.pages()[0]);
await tradePage.goto();
});

test.afterAll(async () => {
await context.close()
})
await context.close();
});

test.beforeEach(async () => {
await tradePage.connectWallet()
expect(await tradePage.isError(), 'Swap is not available!').toBeFalsy()
})
await tradePage.connectWallet();
expect(await tradePage.isError(), "Swap is not available!").toBeFalsy();
});

test.afterEach(async () => {
await tradePage.logOut()
})
await tradePage.logOut();
});

// biome-ignore lint/correctness/noEmptyPattern: <explanation>
test.afterEach(async ({}, testInfo) => {
console.log(`Test [${testInfo.title}] status: ${testInfo.status}`)
if (testInfo.status === 'failed') {
const name = testInfo.title
core.notice(`Test ${name} failed.`)
console.log(`Test [${testInfo.title}] status: ${testInfo.status}`);
if (testInfo.status === "failed") {
const name = testInfo.title;
core.notice(`Test ${name} failed.`);
}
})
});

// biome-ignore lint/complexity/noForEach: <explanation>
;[{ name: 'BTC' }, { name: 'OSMO' }].forEach(({ name }) => {
[{ name: "BTC" }, { 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()
await tradePage.buyAndApprove(context, { slippagePercent: '3' })
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();
await tradePage.buyAndApprove(context, { slippagePercent: "3" });
await tradePage.getTransactionUrl();
});
});

// unwrapped market sell tests just in case this affects anything.
test('User should be able to Market Sell BTC', async () => {
await tradePage.goto()
await tradePage.openSellTab()
await tradePage.selectAsset('BTC')
await tradePage.enterAmount('1.54')
await tradePage.isSufficientBalanceForTrade()
await tradePage.showSwapInfo()
await tradePage.sellAndApprove(context, { slippagePercent: '3' })
await tradePage.isTransactionSuccesful(TRX_SUCCESS_TIMEOUT)
await tradePage.getTransactionUrl()
})
test("User should be able to Market Sell BTC", async () => {
await tradePage.goto();
await tradePage.openSellTab();
await tradePage.selectAsset("BTC");
await tradePage.enterAmount("1.54");
await tradePage.isSufficientBalanceForTrade();
await tradePage.showSwapInfo();
await tradePage.sellAndApprove(context, { slippagePercent: "3" });
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()
await tradePage.sellAndApprove(context, { slippagePercent: '3' })
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();
await tradePage.sellAndApprove(context, { slippagePercent: "3" });
await tradePage.getTransactionUrl();
});
});
Loading