Skip to content

Commit

Permalink
try output fail
Browse files Browse the repository at this point in the history
  • Loading branch information
yury-dubinin committed Nov 27, 2024
1 parent 656c69f commit a2d1038
Showing 1 changed file with 79 additions and 71 deletions.
150 changes: 79 additions & 71 deletions packages/e2e/tests/monitoring.market.wallet.spec.ts
Original file line number Diff line number Diff line change
@@ -1,89 +1,97 @@
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: <explanation>
test.afterEach(async ({}, testInfo) => {
if (testInfo.status === "failed") {
const name = testInfo.title;
process.env.GITHUB_STEP_SUMMARY = `Test ${name} failed.`;
}
});

// biome-ignore lint/complexity/noForEach: <explanation>
;[{ 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();
});
});

0 comments on commit a2d1038

Please sign in to comment.