Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish Stage PR #3922

Merged
merged 3 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 4 additions & 4 deletions .github/workflows/frontend-e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:

preview-swap-tests:
timeout-minutes: 10
runs-on: macos-14
runs-on: macos-latest
needs: wait-for-deployment
steps:
- name: Check out repository
Expand Down Expand Up @@ -74,7 +74,7 @@ jobs:
preview-portfolio-trx-tests:
timeout-minutes: 10
needs: wait-for-deployment
runs-on: macos-14
runs-on: macos-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
Expand Down Expand Up @@ -111,7 +111,7 @@ jobs:
preview-pools-and-select-pair-tests:
timeout-minutes: 10
needs: wait-for-deployment
runs-on: macos-14
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
Expand Down Expand Up @@ -145,7 +145,7 @@ jobs:

preview-trade-tests:
timeout-minutes: 10
runs-on: macos-14
runs-on: macos-latest
needs: [wait-for-deployment, preview-swap-tests]
steps:
- name: Check out repository
Expand Down
42 changes: 39 additions & 3 deletions .github/workflows/prod-frontend-e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:

prod-e2e-tests:
runs-on: macos-latest
timeout-minutes: 15
needs: wait-for-deployment
environment:
name: prod_swap_test
Expand All @@ -55,17 +56,17 @@ jobs:
- name: Run Swap Pair tests on Master
env:
BASE_URL: "https://app.osmosis.zone"
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
PRIVATE_KEY: ${{ secrets.TEST_PRIVATE_KEY }}
WALLET_ID: ${{ secrets.TEST_WALLET_ID }}
run: |
cd packages/web
npx playwright test -g "Test Swap feature"
npx playwright test transactions portfolio swap.wallet
- name: upload test results
if: always()
id: e2e-test-results
uses: actions/upload-artifact@v4
with:
name: main-e2e-test-results-${{ github.run_id }}
name: prod-e2e-test-results-${{ github.run_id }}
path: packages/web/playwright-report
- name: Send Slack alert if test fails
id: slack
Expand Down Expand Up @@ -102,3 +103,38 @@ jobs:
env:
SLACK_WEBHOOK_URL: ${{ secrets.SERVER_E2E_TESTS_SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK

prod-pools-and-select-pair-tests:
timeout-minutes: 10
needs: wait-for-deployment
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- 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: |
yarn --cwd packages/web install --frozen-lockfile && npx playwright install --with-deps chromium
- name: Run Pools tests
env:
BASE_URL: "https://app.osmosis.zone"
run: |
cd packages/web
npx playwright test pools select
- name: upload pools test results
if: failure()
id: pools-test-results
uses: actions/upload-artifact@v4
with:
name: prod-pools-test-results-${{ github.run_id }}
path: packages/web/playwright-report
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ describe("Allocation Functions", () => {
});

describe("calculatePercentAndFiatValues", () => {
it("should calculate the correct asset percentages and fiat values - Total Assets", async () => {
const result = await calculatePercentAndFiatValues(
it("should calculate the correct asset percentages and fiat values - Total Assets", () => {
const result = calculatePercentAndFiatValues(
MOCK_DATA.categories,
assetLists,
"total-assets",
Expand Down Expand Up @@ -156,8 +156,8 @@ describe("Allocation Functions", () => {
]);
});

it("should calculate the correct asset percentages and fiat values - User Balances", async () => {
const result = await calculatePercentAndFiatValues(
it("should calculate the correct asset percentages and fiat values - User Balances", () => {
const result = calculatePercentAndFiatValues(
MOCK_DATA.categories,
assetLists,
"user-balances",
Expand Down Expand Up @@ -186,6 +186,63 @@ describe("Allocation Functions", () => {
},
]);
});

it("should handle zero balances correctly", () => {
const zeroBalanceData = {
...MOCK_DATA.categories,
"total-assets": {
capitalization: "0",
account_coins_result: [
{
coin: {
denom:
"factory/osmo1pfyxruwvtwk00y8z06dh2lqjdj82ldvy74wzm3/WOSMO",
amount: "0",
},
cap_value: "0",
},
{
coin: {
denom:
"factory/osmo1rckme96ptawr4zwexxj5g5gej9s2dmud8r2t9j0k0prn5mch5g4snzzwjv/sail",
amount: "0",
},
cap_value: "0",
},
],
is_best_effort: false,
},
};

const result = calculatePercentAndFiatValues(
zeroBalanceData,
assetLists,
"total-assets",
5
).map((allocation) => ({
...allocation,
percentage: allocation.percentage.toString(),
fiatValue: allocation.fiatValue.toString(),
}));

expect(result).toEqual([
{
key: "WOSMO",
percentage: "0%",
fiatValue: "$0",
},
{
key: "SAIL",
percentage: "0%",
fiatValue: "$0",
},
{
key: "Other",
percentage: "0%",
fiatValue: "$0",
},
]);
});
});
});

Expand Down
12 changes: 9 additions & 3 deletions packages/server/src/queries/complex/portfolio/allocation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ export function getAll(categories: Categories): FormattedAllocation[] {
const formattedAllocations: FormattedAllocation[] = sortedAllocation.map(
(allocation) => ({
key: allocation.key,
percentage: new RatePretty(allocation.fiatValue.quo(totalCap)),
percentage: totalCap.isZero()
? new RatePretty(0)
: new RatePretty(allocation.fiatValue.quo(totalCap)),
fiatValue: new PricePretty(DEFAULT_VS_CURRENCY, allocation.fiatValue),
})
);
Expand Down Expand Up @@ -109,7 +111,9 @@ export function calculatePercentAndFiatValues(

return {
key: assetFromAssetLists.coinDenom,
percentage: new RatePretty(asset.cap_value.quo(totalCap)),
percentage: totalCap.isZero()
? new RatePretty(0)
: new RatePretty(asset.cap_value.quo(totalCap)),
fiatValue: new PricePretty(DEFAULT_VS_CURRENCY, asset.cap_value),
};
}
Expand All @@ -122,7 +126,9 @@ export function calculatePercentAndFiatValues(
new Dec(0)
);

const otherPercentage = new RatePretty(otherAmount).quo(totalCap);
const otherPercentage = totalCap.isZero()
? new RatePretty(0)
: new RatePretty(otherAmount).quo(totalCap);

const other: FormattedAllocation = {
key: "Other",
Expand Down
5 changes: 2 additions & 3 deletions packages/web/e2e/tests/monitoring.limit.wallet.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* eslint-disable import/no-extraneous-dependencies */
import { type BrowserContext, chromium, expect, test } from "@playwright/test";
import process from "process";

import { TransactionsPage } from "~/e2e/pages/transactions-page";
import { TestConfig } from "~/e2e/test-config";
Expand Down Expand Up @@ -69,7 +68,7 @@ test.describe("Test Filled Limit Order feature", () => {
await tradePage.openBuyTab();
await tradePage.openLimit();
await tradePage.selectAsset("OSMO");
await tradePage.enterAmount("1.02");
await tradePage.enterAmount("1.04");
await tradePage.setLimitPriceChange("Market");
const limitPrice = Number(await tradePage.getLimitPrice());
const highLimitPrice = (limitPrice * PRICE_INCREASE_FACTOR).toFixed(4);
Expand All @@ -79,7 +78,7 @@ test.describe("Test Filled Limit Order feature", () => {
true
);
expect(msgContentAmount, "No msg from the wallet!").toBeTruthy();
expect(msgContentAmount).toContain('"quantity": "1020000"');
expect(msgContentAmount).toContain('"quantity": "1040000"');
expect(msgContentAmount).toContain("place_limit");
expect(msgContentAmount).toContain('"order_direction": "bid"');
await tradePage.isTransactionSuccesful();
Expand Down
7 changes: 3 additions & 4 deletions packages/web/e2e/tests/monitoring.market.wallet.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* eslint-disable import/no-extraneous-dependencies */
import { type BrowserContext, chromium, expect, test } from "@playwright/test";
import process from "process";

import { TestConfig } from "~/e2e/test-config";
import { UnzipExtension } from "~/e2e/unzip-extension";
Expand Down Expand Up @@ -49,7 +48,7 @@ test.describe("Test Filled Limit Order feature", () => {
await tradePage.goto();
await tradePage.openBuyTab();
await tradePage.selectAsset(name);
await tradePage.enterAmount("0.75");
await tradePage.enterAmount("1.05");
const { msgContentAmount } = await tradePage.buyAndGetWalletMsg(context);
expect(msgContentAmount).toBeTruthy();
expect(msgContentAmount).toContain("type: osmosis/poolmanager/");
Expand All @@ -63,7 +62,7 @@ test.describe("Test Filled Limit Order feature", () => {
await tradePage.goto();
await tradePage.openSellTab();
await tradePage.selectAsset("WBTC");
await tradePage.enterAmount("0.74");
await tradePage.enterAmount("1.04");
await tradePage.isSufficientBalanceForTrade();
await tradePage.showSwapInfo();
const { msgContentAmount } = await tradePage.sellAndGetWalletMsg(context);
Expand All @@ -77,7 +76,7 @@ test.describe("Test Filled Limit Order feature", () => {
await tradePage.goto();
await tradePage.openSellTab();
await tradePage.selectAsset("OSMO");
await tradePage.enterAmount("0.74");
await tradePage.enterAmount("1.04");
await tradePage.isSufficientBalanceForTrade();
await tradePage.showSwapInfo();
const { msgContentAmount } = await tradePage.sellAndGetWalletMsg(context);
Expand Down
6 changes: 3 additions & 3 deletions packages/web/e2e/tests/portfolio.wallet.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable import/no-extraneous-dependencies */
import {
type BrowserContext,
chromium,
Expand All @@ -7,7 +6,6 @@ import {
test,
} from "@playwright/test";
import { addCoverageReport, attachCoverageReport } from "monocart-reporter";
import process from "process";

import { TestConfig } from "~/e2e/test-config";
import { UnzipExtension } from "~/e2e/unzip-extension";
Expand Down Expand Up @@ -62,6 +60,7 @@ test.describe("Test Portfolio feature", () => {
await context.close();
});

// biome-ignore lint/complexity/noForEach: <explanation>
[
{ name: "OSMO" },
{ name: "ATOM" },
Expand All @@ -77,14 +76,15 @@ test.describe("Test Portfolio feature", () => {
});
});

// biome-ignore lint/complexity/noForEach: <explanation>
[
{ name: "INJ" },
{ name: "ETH.axl" },
{ name: "KUJI" },
{ 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);
Expand Down
Loading