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
1 change: 0 additions & 1 deletion frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,6 @@ export default function App() {
owners={owners}
ownerAddresses={ownerAddresses}
threshold={threshold}
totalOwners={owners.length}
walletAddress={wallet.address}
onProposalSubmitted={refresh}
/>
Expand Down
10 changes: 8 additions & 2 deletions frontend/src/pages/OwnersPage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from "react";
import { render, screen } from "@testing-library/react";
import { beforeEach, describe, expect, test, vi } from "vitest";
import { useOwnerWeights } from "../hooks/useOwnerWeights";
import { getWeightCapPct, getRequiredQuorumWeight, getSpendingLimit } from "../lib/contract";
import type { Owner } from "../types/accord";
import { OwnersPage } from "./OwnersPage";

Expand All @@ -15,6 +16,9 @@ vi.mock("../lib/contract", () => ({
}));

const mockUseOwnerWeights = vi.mocked(useOwnerWeights);
const mockGetWeightCapPct = vi.mocked(getWeightCapPct);
const mockGetRequiredQuorumWeight = vi.mocked(getRequiredQuorumWeight);
const mockGetSpendingLimit = vi.mocked(getSpendingLimit);

const ownerAddresses = ["GOWNER111", "GOWNER222"];
const owners: Owner[] = [
Expand All @@ -28,17 +32,19 @@ function renderOwnersPage() {
owners={owners}
ownerAddresses={ownerAddresses}
threshold={5}
totalOwners={owners.length}
/>,
);
}

describe("OwnersPage", () => {
beforeEach(() => {
vi.clearAllMocks();
mockGetWeightCapPct.mockResolvedValue(50);
mockGetRequiredQuorumWeight.mockResolvedValue(10);
mockGetSpendingLimit.mockResolvedValue(-1n);
});

test("shows weighted quorum and each owner voting share", () => {
test("shows weighted quorum and each owner voting share", async () => {
mockUseOwnerWeights.mockReturnValue({
weights: { GOWNER111: 5, GOWNER222: 15 },
totalWeight: 20,
Expand Down
9 changes: 7 additions & 2 deletions frontend/src/pages/OwnersPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ type OwnersPageProps = {
owners: Owner[];
ownerAddresses: string[];
threshold: number;
totalOwners: number;
walletAddress: string | null;
onProposalSubmitted: () => void;
};
Expand All @@ -56,7 +55,6 @@ export function OwnersPage({
owners,
ownerAddresses,
threshold,
totalOwners,
walletAddress,
onProposalSubmitted,
}: OwnersPageProps) {
Expand Down Expand Up @@ -186,6 +184,13 @@ export function OwnersPage({
};
}, [ownerAddresses]);

const hasOwnerWeights = totalWeight > 0;
const ownerWeightsLoading = weightsLoading;
const weightsUnavailable = !weightsLoading && totalWeight === 0;
const weightsStale = false;
const ownerCountLabel = `${ownerAddresses.length} ${ownerAddresses.length === 1 ? "owner" : "owners"}`;
const quorumPercent = totalWeight > 0 ? ((threshold / totalWeight) * 100).toFixed(1) : "0";

const visibleOwners = owners
.map((owner, idx) => {
const fullAddress = ownerAddresses[idx] ?? owner.address;
Expand Down