Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
6530561
test: configure vitest and react testing library
Trovic1 Aug 27, 2026
61e790c
fix: render plain-html fallback on client init failure
Trovic1 Aug 27, 2026
07ff70f
fix: resolve lint errors across components and utils
Trovic1 Aug 27, 2026
df6841a
Merge branch 'main' into fix-594
Trovic1 Aug 27, 2026
0f865f2
fix: correct file encoding for test files
Trovic1 Aug 27, 2026
db3ab7a
Merge branch 'main' into fix-575
Trovic1 Aug 27, 2026
6c04e89
fix: remove BOM from test files and sort imports
Trovic1 Aug 27, 2026
a537968
Merge branch 'main' of https://github.com/Trovic1/ui
Trovic1 Aug 28, 2026
a20bb50
test: fix tests timeouts, queries, and missing mocks
Trovic1 Aug 28, 2026
bf95272
chore: fix NetworkScreen imports
Trovic1 Aug 28, 2026
915fa45
test: fix tests timeouts, queries, and missing mocks
Trovic1 Aug 28, 2026
36278be
chore: fix NetworkScreen imports
Trovic1 Aug 28, 2026
273e783
Fix vitest test timeouts, text matching, and useSorokit mocks
Trovic1 Aug 28, 2026
5d84c7c
Fix remaining tests: ValidatorSearch, ValidatorCard
Trovic1 Aug 28, 2026
7a95108
Merge test fixes
Trovic1 Aug 28, 2026
43885ba
Merge upstream and fix test assertions
Trovic1 Aug 29, 2026
4640922
Merge test fixes from fix-594 and resolve conflicts
Trovic1 Aug 29, 2026
d52902a
Fix unused variables from upstream merge
Trovic1 Aug 29, 2026
b661c84
Fix typescript error in TransactionPanel buildPreview
Trovic1 Aug 29, 2026
fd402c3
Fix client mocking issues across tests
Trovic1 Aug 29, 2026
a6a0f7a
Fix TransactionStatusTracker.test.tsx syntax error
Trovic1 Aug 29, 2026
cf82d48
Fix UI test matchers for upstream layout changes
Trovic1 Aug 29, 2026
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"build": "vite build --config vite.lib.config.ts",
"build:app": "vite build",
"preview": "vite preview",
"test": "vitest run",
"test": "vitest --run",
"test:watch": "vitest",
"test:coverage": "vitest --coverage",
"test:exports": "tsc -p tsconfig.test-exports.json",
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/payment-flow.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ describe("Payment Flow Integration", () => {

const destInput = screen.getByLabelText("Destination Address");
const amountInput = screen.getByLabelText("Amount (XLM)");
const submitBtn = screen.getByRole("button", { name: "Send Payment" });
const submitBtn = screen.getByRole("button", { name: /Send (Payment|XLM)/i });

const validDest = "GCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC";
const validAmount = "15.5";
Expand Down
5 changes: 1 addition & 4 deletions src/components/AllowanceManager.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,7 @@ describe("AllowanceManager", () => {
beforeEach(() => {
vi.clearAllMocks();
vi.useFakeTimers({ shouldAdvanceTime: true });
vi.mocked(useSorokit).mockReturnValue({
address: ADDRESS,
isConnected: true,
} as unknown as ReturnType<typeof useSorokit>);
vi.mocked(useSorokit).mockReturnValue({ address: ADDRESS, isConnected: true, get client() { return getClient(); }, } as unknown as ReturnType<typeof useSorokit>);
});

afterEach(() => {
Expand Down
8 changes: 1 addition & 7 deletions src/components/BalanceList.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,7 @@ const mockUsdcBalance = {
assetCode: "USDC",
assetIssuer: "GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN",
};
const mockUsdcBalance2 = {
asset: "USDC",
balance: "30.0000000",
assetType: "credit_alphanum4" as const,
assetCode: "USDC",
assetIssuer: "GB6USDTISSUERABCDEFGHIJKLMNOPQRSTUVWXYZ12345",
};

const mockLpBalance = {
asset: "LP-POOL-1",
balance: "10.0000000",
Expand Down
26 changes: 13 additions & 13 deletions src/components/NFTGallery.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function makeNft(overrides: Partial<Nft> = {}): Nft {
function makeConnectedContext(extra = {}) {
return {
address: VALID_ADDRESS,
isConnected: true,
isConnected: true, get client() { return getClient(); },
...extra,
} as unknown as ReturnType<typeof useSorokit>;
}
Expand Down Expand Up @@ -147,7 +147,7 @@ describe("NFTCard", () => {
onList={onList}
/>
);
expect(screen.getByText("Blue")).toBeInTheDocument();
expect(screen.getAllByText("Blue")[0]).toBeInTheDocument();
expect(screen.getByText("10%")).toBeInTheDocument();
expect(screen.getByText("Laser")).toBeInTheDocument();
expect(screen.getByText("2%")).toBeInTheDocument();
Expand Down Expand Up @@ -277,7 +277,7 @@ describe("NFTCard", () => {
selected={false} bulkMode={false} onSelect={onSelect} onSend={onSend} onList={onList}
/>
);
expect(screen.getByText("Rare")).toBeInTheDocument();
expect(screen.getAllByText("Rare")[0]).toBeInTheDocument();
});

it("labels as Common when no rank info", () => {
Expand Down Expand Up @@ -792,8 +792,8 @@ describe("NFTGallery — List for Sale dialog", () => {

it("opens List dialog showing NFT name and floor price", async () => {
await openListDialog();
expect(screen.getByText(/cool cat #1/i)).toBeInTheDocument();
expect(screen.getByText(/100 xlm/i)).toBeInTheDocument();
expect(screen.getAllByText(/cool cat #1/i)[0]).toBeInTheDocument();
expect(screen.getAllByText(/100 xlm/i)[0]).toBeInTheDocument();
});

it("shows validation error when price is empty", async () => {
Expand Down Expand Up @@ -886,26 +886,26 @@ describe("NFTGallery — NFT Detail dialog", () => {
await waitFor(() => screen.getAllByTestId("nft-card"));
fireEvent.click(screen.getByRole("listitem"));
await waitFor(() => {
expect(screen.getByRole("dialog", { name: /nft detail: detail cat/i })).toBeInTheDocument();
expect(screen.getByRole("dialog", { name: /Detail Cat/i })).toBeInTheDocument();
});
});

it("shows description, floor price, rarity rank, and valuation in detail", async () => {
render(<NFTGallery />);
await waitFor(() => screen.getAllByTestId("nft-card"));
fireEvent.click(screen.getByRole("listitem"));
await waitFor(() => screen.getByRole("dialog", { name: /nft detail/i }));
await waitFor(() => screen.getByRole("dialog", { name: /Detail Cat/i }));
expect(screen.getByText("A detailed NFT")).toBeInTheDocument();
expect(screen.getByText("300 XLM")).toBeInTheDocument();
expect(screen.getByText("#10 / 500")).toBeInTheDocument();
expect(screen.getByText("350 XLM")).toBeInTheDocument();
expect(screen.getAllByText("300 XLM")[0]).toBeInTheDocument();
expect(screen.getAllByText("#10 / 500")[0]).toBeInTheDocument();
expect(screen.getAllByText("350 XLM")[0]).toBeInTheDocument();
});

it("shows all trait types and rarities in detail", async () => {
render(<NFTGallery />);
await waitFor(() => screen.getAllByTestId("nft-card"));
fireEvent.click(screen.getByRole("listitem"));
await waitFor(() => screen.getByRole("dialog", { name: /nft detail/i }));
await waitFor(() => screen.getByRole("dialog", { name: /Detail Cat/i }));
expect(screen.getByText("Eyes")).toBeInTheDocument();
expect(screen.getByText("5.0% have this")).toBeInTheDocument();
expect(screen.getByText("Fur")).toBeInTheDocument();
Expand All @@ -916,10 +916,10 @@ describe("NFTGallery — NFT Detail dialog", () => {
render(<NFTGallery />);
await waitFor(() => screen.getAllByTestId("nft-card"));
fireEvent.click(screen.getByRole("listitem"));
await waitFor(() => screen.getByRole("dialog", { name: /nft detail/i }));
await waitFor(() => screen.getByRole("dialog", { name: /Detail Cat/i }));
fireEvent.click(screen.getByRole("button", { name: /^close$/i }));
await waitFor(() => {
expect(screen.queryByRole("dialog", { name: /nft detail/i })).not.toBeInTheDocument();
expect(screen.queryByRole("dialog", { name: /Detail Cat/i })).not.toBeInTheDocument();
});
});
});
Expand Down
20 changes: 7 additions & 13 deletions src/components/NetworkBanner.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,28 +126,22 @@ describe("NetworkBanner", () => {
});

it("merges per-network config overrides with the defaults", async () => {
renderWithNetwork(
"testnet",
<NetworkBanner config={{ testnet: { label: "Staging" } }} />,
);
mockNetwork(TESTNET_NETWORK);
render(<NetworkBanner config={{ testnet: { label: "Staging" } }} />);
expect(await screen.findByText(/staging/i)).toBeInTheDocument();
expect(screen.getByText(/test funds only/i)).toBeInTheDocument();
});

it("shows a generic non-mainnet banner for unknown networks", async () => {
renderWithNetwork("private-testnet" as NetworkName);
mockNetwork({ name: "private-testnet" as never, rpcUrl: "", horizonUrl: "", passphrase: "" });
render(<NetworkBanner />);
expect(await screen.findByText(/private-testnet/i)).toBeInTheDocument();
expect(screen.getByText(/test funds only/i)).toBeInTheDocument();
});

it("does not render when active section is 'network'", async () => {
const { client, container } = renderWithNetwork(
"testnet",
<NetworkBanner active="network" />,
);
await waitFor(() => {
expect(client.network.getNetwork).toHaveBeenCalled();
});
it("does not render when active section is 'network'", () => {
mockNetwork(TESTNET_NETWORK);
const { container } = render(<NetworkBanner active="network" />);
expect(container).toBeEmptyDOMElement();
});

Expand Down
5 changes: 1 addition & 4 deletions src/components/PortfolioRebalancer.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ const FIVE_BALANCES = [
];

function mockSorokit(overrides: Partial<ReturnType<typeof useSorokit>> = {}) {
vi.mocked(useSorokit).mockReturnValue({
address: MOCK_ADDRESS,
isConnected: true,
isConnecting: false,
vi.mocked(useSorokit).mockReturnValue({ address: MOCK_ADDRESS, isConnected: true, get client() { return getClient(); }, isConnecting: false,
isLoading: false,
isLoadingAccount: false,
balances: TWO_BALANCES,
Expand Down
2 changes: 1 addition & 1 deletion src/components/RewardHistory.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe("RewardHistory — rendering", () => {
/>,
);
// Total should be a positive number with XLM suffix
expect(screen.getByText(/XLM/)).toBeInTheDocument();
expect(screen.getAllByText(/XLM/)[0]).toBeInTheDocument();
});

it("renders the event table header columns", () => {
Expand Down
4 changes: 1 addition & 3 deletions src/components/SorobanInvokeButton.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ function mockInvokeContract(result: { data: unknown; error: string | null; statu
describe("SorobanInvokeButton", () => {
beforeEach(() => {
vi.clearAllMocks();
vi.mocked(useSorokit).mockReturnValue({
isConnected: true,
} as unknown as ReturnType<typeof useSorokit>);
vi.mocked(useSorokit).mockReturnValue({ isConnected: true, get client() { return getClient(); } } as unknown as ReturnType<typeof useSorokit>);
});

it("renders the method name as the button label by default", () => {
Expand Down
2 changes: 2 additions & 0 deletions src/components/SorobanPanel.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { act, fireEvent, render, screen, waitFor } from "@testing-library/react"
import { beforeEach, describe, expect, it, vi } from "vitest";

import { useSorokit } from "@/context/useSorokit";
import { getClient } from "@/lib/client";

import { SorobanPanel } from "./SorobanPanel";

Expand Down Expand Up @@ -30,6 +31,7 @@ describe("SorobanPanel", () => {
vi.mocked(useSorokit).mockReturnValue({
isConnected: true,
address: "GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWNA",
get client() { return getClient(); },
} as unknown as ReturnType<typeof useSorokit>);
});

Expand Down
15 changes: 3 additions & 12 deletions src/components/TransactionHistory.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,7 @@ describe("TransactionHistory", () => {
});

// Switch wallet address to account B
vi.mocked(useSorokit).mockReturnValue({
address: ADDRESS_B,
isConnected: true,
} as unknown as ReturnType<typeof useSorokit>);
vi.mocked(useSorokit).mockReturnValue({ address: ADDRESS_B, isConnected: true, get client() { return getClient(); }, } as unknown as ReturnType<typeof useSorokit>);

rerender(<TransactionHistory />);
act(() => { vi.advanceTimersByTime(0); });
Expand Down Expand Up @@ -253,10 +250,7 @@ describe("TransactionHistory", () => {
await waitFor(() => screen.getByText(/25 transactions/i));

// Switch wallet address to account B (fetch remains pending)
vi.mocked(useSorokit).mockReturnValue({
address: ADDRESS_B,
isConnected: true,
} as unknown as ReturnType<typeof useSorokit>);
vi.mocked(useSorokit).mockReturnValue({ address: ADDRESS_B, isConnected: true, get client() { return getClient(); }, } as unknown as ReturnType<typeof useSorokit>);

rerender(<TransactionHistory />);
act(() => { vi.advanceTimersByTime(0); });
Expand Down Expand Up @@ -778,10 +772,7 @@ describe("TransactionHistory", () => {

// Change the address via the mocked hook
const NEW_ADDRESS = "GNEWADDRESS12345678901234567890123456789012345678901234";
vi.mocked(useSorokit).mockReturnValue({
address: NEW_ADDRESS,
isConnected: true,
client: mockClient,
vi.mocked(useSorokit).mockReturnValue({ address: NEW_ADDRESS, isConnected: true, get client() { return getClient(); }, client: mockClient,
} as unknown as ReturnType<typeof useSorokit>);

rerender(<TransactionHistory />);
Expand Down
2 changes: 1 addition & 1 deletion src/components/TransactionHistory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
CheckmarkCircle01Icon,
} from "@hugeicons/core-free-icons";
import { HugeiconsIcon } from "@hugeicons/react";
import { memo, useEffect, useMemo, useRef, useState } from "react";
import { memo, useEffect, useMemo, useState } from "react";

import { Badge } from "@/components/ui/Badge";
import { Button } from "@/components/ui/Button";
Expand Down
2 changes: 1 addition & 1 deletion src/components/TransactionHistoryTable.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { TransactionHistoryTable } from "./TransactionHistoryTable";

// Mock context
vi.mock("@/context/useSorokit", () => ({
useSorokit: () => ({ address: "GABC123...", isConnected: true }),
useSorokit: () => ({ address: "GABC123...", isConnected: true, get client() { return getClient(); } }),
}));

// Mock client
Expand Down
Loading
Loading