diff --git a/.github/workflows/frontend-e2e-tests.yml b/.github/workflows/frontend-e2e-tests.yml index 29d3a9482d..0bc3d00f60 100644 --- a/.github/workflows/frontend-e2e-tests.yml +++ b/.github/workflows/frontend-e2e-tests.yml @@ -26,7 +26,7 @@ jobs: environment_url: ${{ steps.vercel.outputs.environment_url }} run: echo "$environment_url" - preview-swap-tests: + preview-swap-osmo-tests: timeout-minutes: 15 runs-on: macos-latest needs: wait-for-deployment @@ -65,13 +65,61 @@ jobs: WALLET_ID: ${{ secrets.TEST_WALLET_ID }} run: | cd packages/e2e - npx playwright test -g "Test Swap feature" + npx playwright test swap.osmo.wallet - name: upload Swap test results if: failure() id: swap-test-results uses: actions/upload-artifact@v4 with: - name: preview-swap-test-results + name: osmo-swap-test-results + path: packages/e2e/playwright-report + + preview-swap-usdc-tests: + timeout-minutes: 15 + runs-on: macos-latest + needs: [wait-for-deployment, preview-swap-osmo-tests] + steps: + - name: Check out repository + uses: actions/checkout@v4 + with: + sparse-checkout: | + packages/e2e + - name: print environment_url and BRANCH_NAME + env: + BASE_URL: "https://${{ needs.wait-for-deployment.outputs.environment_url }}" + BRANCH_NAME: ${{ github.head_ref || github.ref_name }} + run: | + echo "$BASE_URL" + echo "$BRANCH_NAME" + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 20.x + - name: Cache dependencies + uses: actions/cache@v4 + with: + path: "**/node_modules" + key: ${{ runner.OS }}-20.x-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.OS }}-20.x- + - name: Install Playwright + run: | + echo "$GITHUB_OUTPUT" + yarn --cwd packages/e2e install --frozen-lockfile && npx playwright install --with-deps chromium + - name: Run Swap Pair tests + env: + BASE_URL: "https://${{ needs.wait-for-deployment.outputs.environment_url }}" + PRIVATE_KEY: ${{ secrets.TEST_PRIVATE_KEY }} + WALLET_ID: ${{ secrets.TEST_WALLET_ID }} + run: | + cd packages/e2e + npx playwright test swap.usdc.wallet + - name: upload Swap test results + if: failure() + id: swap-test-results + uses: actions/upload-artifact@v4 + with: + name: usdc-swap-test-results path: packages/e2e/playwright-report preview-portfolio-trx-tests: @@ -155,7 +203,7 @@ jobs: preview-trade-tests: timeout-minutes: 15 runs-on: macos-latest - needs: [wait-for-deployment, preview-swap-tests] + needs: [wait-for-deployment, preview-swap-osmo-tests] steps: - name: Check out repository uses: actions/checkout@v4 diff --git a/.github/workflows/prod-frontend-e2e-tests.yml b/.github/workflows/prod-frontend-e2e-tests.yml index 22b2ed78c4..240f5ab722 100644 --- a/.github/workflows/prod-frontend-e2e-tests.yml +++ b/.github/workflows/prod-frontend-e2e-tests.yml @@ -62,7 +62,7 @@ jobs: WALLET_ID: ${{ secrets.TEST_WALLET_ID }} run: | cd packages/e2e - npx playwright test transactions portfolio swap.wallet + npx playwright test transactions portfolio swap.osmo.wallet - name: upload test results if: always() id: e2e-test-results diff --git a/packages/e2e/README.md b/packages/e2e/README.md index 77c5e1b589..82362c370a 100644 --- a/packages/e2e/README.md +++ b/packages/e2e/README.md @@ -16,7 +16,7 @@ All you need to add is a private keys for wallets that are being used: To install Playwright, please execute `npx playwright install --with-deps chromium` from the /web folder. To run a Select pair tests, please execute `npx playwright test -g "Test Select Swap Pair feature"` from the /web folder. -To run a Swap E2E tests, please execute `npx playwright test -g "Test Swap feature"` from the /web folder. +To run a Swap E2E tests, please execute `npx playwright test swap.osmo.wallet` from the /web folder. To run a Monitoring E2E tests, please execute `npx playwright test monitoring --timeout 180000` from the /web folder. Tests can be executed locally in a browser by changing `headless: true` to `headless: false`. diff --git a/packages/e2e/tests/swap.osmo.wallet.spec.ts b/packages/e2e/tests/swap.osmo.wallet.spec.ts new file mode 100644 index 0000000000..2443bdd27b --- /dev/null +++ b/packages/e2e/tests/swap.osmo.wallet.spec.ts @@ -0,0 +1,94 @@ +import { type BrowserContext, chromium, expect, test } from "@playwright/test"; + +import { TestConfig } from "../test-config"; +import { UnzipExtension } from "../unzip-extension"; + +import { WalletPage } from "../pages/keplr-page"; +import { TradePage } from "../pages/trade-page"; + +test.describe("Test Swap to/from OSMO feature", () => { + let context: BrowserContext; + const walletId = + process.env.WALLET_ID ?? "osmo1qyc8u7cn0zjxcu9dvrjz5zwfnn0ck92v62ak9l"; + const privateKey = process.env.PRIVATE_KEY ?? "private_key"; + let tradePage: TradePage; + const USDC = + "ibc/498A0751C798A0D9A389AA3691123DADA57DAA4FE165D5C75894505B876BA6E4"; + const ATOM = + "ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2"; + const TIA = + "ibc/D79E7D83AB399BFFF93433E54FAA480C191248FC556924A2A8351AE2638B3877"; + const INJ = + "ibc/64BA6E31FE887D66C6F8F31C7B1A80C7CA179239677B4088BB55F5EA07DBE273"; + const AKT = + "ibc/1480B8FD20AD5FCAE81EA87584D269547DD4D436843C1D20F15E00EB64743EF4"; + + test.beforeAll(async () => { + 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) + ); + // 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); + // Import existing Wallet (could be aggregated in one function). + 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(); + }); + + test.afterAll(async () => { + await context.close(); + }); + + 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 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(); + }); +}); diff --git a/packages/e2e/tests/swap.usdc.wallet.spec.ts b/packages/e2e/tests/swap.usdc.wallet.spec.ts new file mode 100644 index 0000000000..0e19fb1d7c --- /dev/null +++ b/packages/e2e/tests/swap.usdc.wallet.spec.ts @@ -0,0 +1,194 @@ +import { type BrowserContext, chromium, expect, test } from "@playwright/test"; + +import { TestConfig } from "../test-config"; +import { UnzipExtension } from "../unzip-extension"; + +import { WalletPage } from "../pages/keplr-page"; +import { TradePage } from "../pages/trade-page"; + +test.describe("Test Swap to/from USDC feature", () => { + let context: BrowserContext; + const walletId = + process.env.WALLET_ID ?? "osmo1qyc8u7cn0zjxcu9dvrjz5zwfnn0ck92v62ak9l"; + const privateKey = process.env.PRIVATE_KEY ?? "private_key"; + let tradePage: TradePage; + const USDC = + "ibc/498A0751C798A0D9A389AA3691123DADA57DAA4FE165D5C75894505B876BA6E4"; + const ATOM = + "ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2"; + const TIA = + "ibc/D79E7D83AB399BFFF93433E54FAA480C191248FC556924A2A8351AE2638B3877"; + const INJ = + "ibc/64BA6E31FE887D66C6F8F31C7B1A80C7CA179239677B4088BB55F5EA07DBE273"; + const AKT = + "ibc/1480B8FD20AD5FCAE81EA87584D269547DD4D436843C1D20F15E00EB64743EF4"; + + test.beforeAll(async () => { + 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) + ); + // 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); + // Import existing Wallet (could be aggregated in one function). + 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(); + }); + + test.afterAll(async () => { + await context.close(); + }); + + 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 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/swap.wallet.spec.ts b/packages/e2e/tests/swap.wallet.spec.ts deleted file mode 100644 index 394b6fbe4c..0000000000 --- a/packages/e2e/tests/swap.wallet.spec.ts +++ /dev/null @@ -1,234 +0,0 @@ -import { type BrowserContext, chromium, expect, test } from '@playwright/test' - -import { TestConfig } from '../test-config' -import { UnzipExtension } from '../unzip-extension' - -import { WalletPage } from '../pages/keplr-page' -import { TradePage } from '../pages/trade-page' - -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 - const USDC = - 'ibc/498A0751C798A0D9A389AA3691123DADA57DAA4FE165D5C75894505B876BA6E4' - const ATOM = - 'ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2' - const TIA = - 'ibc/D79E7D83AB399BFFF93433E54FAA480C191248FC556924A2A8351AE2638B3877' - const INJ = - 'ibc/64BA6E31FE887D66C6F8F31C7B1A80C7CA179239677B4088BB55F5EA07DBE273' - const AKT = - 'ibc/1480B8FD20AD5FCAE81EA87584D269547DD4D436843C1D20F15E00EB64743EF4' - - test.beforeAll(async () => { - 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), - ) - // 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) - // Import existing Wallet (could be aggregated in one function). - 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() - }) - - 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() - }) -}) diff --git a/packages/web/README.md b/packages/web/README.md index 4e9d18d9c1..c6f67ae29a 100644 --- a/packages/web/README.md +++ b/packages/web/README.md @@ -102,28 +102,3 @@ JavaScript; ``` It returns `unknown` types, so you may need to type cast to resolve TS errors. - -## E2E Tests - -### Run E2E Tests - -To install Playwright, please execute `npx playwright install` from the /web folder. - -To run Select pair tests, please execute `npx playwright test -g "Test Select Swap Pair feature"` from the /web folder. -To run Swap E2E tests, please execute `npx playwright test -g "Test Swap feature"` from the /web folder. - -Tests can be executed locally in a browser by changing `headless: true` to `headless: false`. - -## GitHub E2E Tests workflow - -[Tests Workflow](https://github.com/osmosis-labs/osmosis-frontend/blob/stage/.github/workflows/frontend-e2e-tests.yml) is initiated on `push: branches-ignore: - master` event and awaits a deployment to a Vercel environment. The `await_deployment` script is querying for a building deployment and fails if deployment failed or not started in 30 seconds. - -It contains following jobs: - -- initial `wait-for-deployment` script -- Preview tests `preview-swap-tests` -- Preview tests `preview-portfolio-trx-tests` -- Preview tests `preview-pools-and-select-pair-tests` -- Preview tests `preview-trade-tests` -- Preview tests `preview-claim-tests` -- Test report is uploaded as Artifact on fail.