Skip to content
Open
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
85 changes: 83 additions & 2 deletions ui-dashboard/src/app/pool/[poolId]/__tests__/page.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@ vi.mock("@/components/network-provider", () => ({
hasuraUrl: "https://example.com/v1/graphql",
hasuraSecret: "",
explorerBaseUrl: "https://celoscan.io",
tokenSymbols: {},
tokenSymbols: {
"0xt0": "GBPm",
"0xt1": "USDm",
"0xgbp": "GBPm",
"0xusd": "USDm",
"0xeur": "EURm",
},
addressLabels: {},
local: false,
hasVirtualPools: false,
Expand Down Expand Up @@ -156,7 +162,13 @@ describe("Pool detail LPs tab", () => {
});

const html = renderToStaticMarkup(<PoolDetailPage />);
expect(html).toContain("Net LP Tokens");
expect(html).toContain("GBPm");
expect(html).toContain("USDm");
expect(html).toContain("Total Value");
expect(html).toContain("Share");
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test was updated for the new header, but the PR adds substantial new value-conversion behavior. Please add assertions for: token amount columns, USD total visibility only when conversion is valid, and no ≈ $ rendering when oracle price is unavailable.

expect(html).toContain("0.00 GBPm");
expect(html).toContain("0.00 USDm");
expect(html).toContain("$0.00");
expect(html).toContain("0xa");
expect(html).toContain("0xb");
expect(html.indexOf("0xa")).toBeLessThan(html.indexOf("0xb"));
Expand All @@ -165,6 +177,75 @@ describe("Pool detail LPs tab", () => {
);
});

it("hides USD-specific columns when the pool has no USDm side", () => {
mockUseGQL.mockImplementation((query: string | null) => {
if (!query) return gqlResult(undefined);
if (query.includes("PoolDetailWithHealth")) {
return gqlResult({
Pool: [
{
...BASE_POOL,
token0: "0xgbp",
token1: "0xeur",
},
],
});
}
if (query.includes("TradingLimits"))
return gqlResult({ TradingLimit: [] });
if (query.includes("PoolDeployment")) {
return gqlResult({ FactoryDeployment: [] });
}
if (query.includes("PoolLpPositions")) {
return gqlResult({
LiquidityPosition: [
{ id: "1", poolId: "0xpool", address: "0xb", netLiquidity: "100" },
],
});
}
return gqlResult(undefined);
});

const html = renderToStaticMarkup(<PoolDetailPage />);
expect(html).not.toContain("Total Value");
expect(html).not.toContain("≈ $");
});

it("hides USD-specific columns when oracle price is missing", () => {
mockUseGQL.mockImplementation((query: string | null) => {
if (!query) return gqlResult(undefined);
if (query.includes("PoolDetailWithHealth")) {
return gqlResult({
Pool: [
{
...BASE_POOL,
token0: "0xgbp",
token1: "0xusd",
oraclePrice: "0",
},
],
});
}
if (query.includes("TradingLimits"))
return gqlResult({ TradingLimit: [] });
if (query.includes("PoolDeployment")) {
return gqlResult({ FactoryDeployment: [] });
}
if (query.includes("PoolLpPositions")) {
return gqlResult({
LiquidityPosition: [
{ id: "1", poolId: "0xpool", address: "0xb", netLiquidity: "100" },
],
});
}
return gqlResult(undefined);
});

const html = renderToStaticMarkup(<PoolDetailPage />);
expect(html).not.toContain("Total Value");
expect(html).not.toContain("≈ $");
});

it("shows a migration message when LiquidityPosition schema is unavailable", () => {
mockUseGQL.mockImplementation((query: string | null) => {
if (!query) return gqlResult(undefined);
Expand Down
20 changes: 3 additions & 17 deletions ui-dashboard/src/app/pool/[poolId]/page.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ function renderInteractive(params: Record<string, string> = {}) {
describe("Pool detail tab search", () => {
it("hydrates swaps search from URL and matches full addresses via labels/raw values", () => {
const html = renderWithParams({
tab: "swaps",
swapsQ: "0xsender000000000000000000000000000000000001",
});
expect(html).toContain(
Expand All @@ -317,7 +318,7 @@ describe("Pool detail tab search", () => {
});

it("shows swaps no-match state from URL-backed search", () => {
const html = renderWithParams({ swapsQ: "not-found" });
const html = renderWithParams({ tab: "swaps", swapsQ: "not-found" });
expect(html).toContain("No swaps match your search.");
});

Expand All @@ -333,21 +334,6 @@ describe("Pool detail tab search", () => {
expect(html).toContain("No reserve updates match your search.");
});

it("matches rebalances rows by resolved label", () => {
const html = renderWithParams({ tab: "rebalances", rebalancesQ: "keeper" });
expect(html).toContain('value="keeper"');
expect(html).toContain("Keeper Bot");
expect(html).not.toContain("No rebalances match your search.");
});

it("shows rebalances no-match state", () => {
const html = renderWithParams({
tab: "rebalances",
rebalancesQ: "missing-bot",
});
expect(html).toContain("No rebalances match your search.");
});

it("matches liquidity rows by kind or sender label", () => {
const html = renderWithParams({ tab: "liquidity", liquidityQ: "lp desk" });
expect(html).toContain('value="lp desk"');
Expand Down Expand Up @@ -376,7 +362,7 @@ describe("Pool detail tab search", () => {
});

it("preserves newer url params when a debounced search commit fires later", () => {
const container = renderInteractive();
const container = renderInteractive({ tab: "swaps" });
const input = container.querySelector(
'input[aria-label="Search swaps"]',
) as HTMLInputElement;
Expand Down
Loading
Loading