Skip to content
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
93 changes: 0 additions & 93 deletions frontend/components/ClaimButton.resolution.test.tsx

This file was deleted.

52 changes: 51 additions & 1 deletion frontend/components/ClaimButton.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const mockClaimRefund = jest.fn();

const fighter = (name: string) => ({ name, record: "10-0", nationality: "USA", weightClass: "Heavyweight" });

const makeMarket = (overrides: Partial<{ status: string; outcome: string | null }> = {}) =>
const makeMarket = (overrides: Partial<{ status: string; outcome: string | null; resolvedAt: string | null }> = {}) =>
({
id: "market-1",
contractAddress: "market-1",
Expand All @@ -28,6 +28,7 @@ const makeMarket = (overrides: Partial<{ status: string; outcome: string | null
totalPool: "0",
oracleAddress: "GORACLE",
createdBy: "GCREATOR",
resolvedAt: null as string | null,
...overrides,
}) as never;

Expand Down Expand Up @@ -136,4 +137,53 @@ describe("ClaimButton", () => {
await waitFor(() => expect(screen.getByRole("button", { name: "Claim Winnings" })).toBeEnabled());
expect(onClaimed).not.toHaveBeenCalled();
});

// ── Dispute window blocking (merged from resolution test) ────────────────

const RESOLVED_AT = "2026-10-01T12:00:00Z";
const RESOLVED_AT_MS = new Date(RESOLVED_AT).getTime();
const DAY_MS = 24 * 60 * 60 * 1000;

it("shows a disabled claim with the reason during the dispute window", () => {
jest.spyOn(Date, "now").mockReturnValue(RESOLVED_AT_MS + 1000);
render(
<ClaimButton
bet={makeBet()}
market={makeMarket({ resolvedAt: RESOLVED_AT })}
onClaimed={jest.fn()}
/>
);

expect(screen.getByRole("button", { name: "Claim Winnings" })).toBeDisabled();
expect(screen.getByText("Claimable after the dispute window closes.")).toBeInTheDocument();
jest.restoreAllMocks();
});

it("shows a disabled claim with the reason while the result is disputed", () => {
render(
<ClaimButton
bet={makeBet()}
market={makeMarket({ status: "Disputed", outcome: "FighterA" })}
onClaimed={jest.fn()}
/>
);

expect(screen.getByRole("button", { name: "Claim Winnings" })).toBeDisabled();
expect(screen.getByText(/decided by an admin/)).toBeInTheDocument();
});

it("enables the claim once the dispute window has passed", () => {
jest.spyOn(Date, "now").mockReturnValue(RESOLVED_AT_MS + DAY_MS + 1);
render(
<ClaimButton
bet={makeBet()}
market={makeMarket({ resolvedAt: RESOLVED_AT })}
onClaimed={jest.fn()}
/>
);

expect(screen.getByRole("button", { name: "Claim Winnings" })).toBeEnabled();
expect(screen.queryByText(/dispute window/)).not.toBeInTheDocument();
jest.restoreAllMocks();
});
});
156 changes: 0 additions & 156 deletions frontend/components/DisputeModal.f105-f108.test.tsx

This file was deleted.

15 changes: 15 additions & 0 deletions frontend/components/DisputeModal.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { render, screen, fireEvent, waitFor } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { DisputeModal } from "./DisputeModal";
import { Market } from "@/lib/api";
import * as stellar from "@/lib/stellar";

jest.mock("@/hooks/useWallet", () => ({
useWallet: jest.fn(() => ({
Expand Down Expand Up @@ -132,6 +133,20 @@ describe("DisputeModal", () => {
expect(onClose).toHaveBeenCalledTimes(1);
});

it("builds dispute_resolution against the market contract address", async () => {
const user = userEvent.setup();
render(
<DisputeModal market={buildMarket()} userBets={mockUserBets} isOpen onDisputed={jest.fn()} onClose={jest.fn()} />
);
await user.type(screen.getByRole("textbox"), "This is a valid reason with enough characters.");
await user.click(screen.getByRole("button", { name: /Submit Dispute/i }));
await waitFor(() =>
expect(stellar.buildSorobanInvocation).toHaveBeenCalledWith(
expect.objectContaining({ contractId: "CA1", method: "dispute_resolution" })
)
);
});

it("matches snapshot when open within window", () => {
jest.useFakeTimers();
jest.setSystemTime(now);
Expand Down
32 changes: 0 additions & 32 deletions frontend/components/MarketStatusBadge.f105-f108.test.tsx

This file was deleted.

Loading