Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
33 changes: 0 additions & 33 deletions __tests__/components/user/identity/UserPageIdentity.test.tsx

This file was deleted.

This file was deleted.

This file was deleted.

21 changes: 0 additions & 21 deletions __tests__/components/user/rep/UserPageRepActivityLog.test.tsx

This file was deleted.

16 changes: 11 additions & 5 deletions __tests__/components/user/rep/header/UserPageRepHeader.test.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
import { render, screen } from '@testing-library/react';
import UserPageRepHeader from '@/components/user/rep/header/UserPageRepHeader';

const mockProfile = {
handle: 'testuser',
display: 'Test User',
query: 'testuser',
} as any;

describe('UserPageRepHeader', () => {
it('shows rep totals when provided', () => {
const repRates = {
total_rep_rating: 1500,
number_of_raters: 25,
rating_stats: [],
} as any;
render(<UserPageRepHeader repRates={repRates} />);
render(<UserPageRepHeader repRates={repRates} profile={mockProfile} />);
expect(screen.getByText('1,500')).toBeInTheDocument();
expect(screen.getByText('25')).toBeInTheDocument();
});

it('renders empty values without repRates', () => {
const { container } = render(<UserPageRepHeader repRates={null} />);
expect(container).toHaveTextContent('Rep:');
it('renders without repRates', () => {
const { container } = render(<UserPageRepHeader repRates={null} profile={mockProfile} />);
expect(container).toHaveTextContent('Reputation');
});
Comment thread
ragnep marked this conversation as resolved.
});
10 changes: 3 additions & 7 deletions __tests__/components/user/rep/new-rep/UserPageRepNewRep.test.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import UserPageRepNewRep from '@/components/user/rep/new-rep/UserPageRepNewRep';
import type { ApiIdentity } from '@/generated/models/ApiIdentity';

jest.mock('@/components/user/rep/new-rep/UserPageRepNewRepSearch', () => ({
__esModule: true,
default: ({ onRepSearch }: { onRepSearch: (v: string) => void }) => (
<button onClick={() => onRepSearch('Art')}>search</button>
),
default: () => <div data-testid="search" />,
}));

jest.mock('@/components/user/rep/modify-rep/UserPageRepModifyModal', () => ({
Expand All @@ -19,9 +16,8 @@ describe('UserPageRepNewRep', () => {
const profile = { id: '1' } as ApiIdentity;
const repRates = { rating_stats: [] } as any;

it('opens modal when search selects rep', async () => {
it('renders search component', () => {
render(<UserPageRepNewRep profile={profile} repRates={repRates} />);
await userEvent.click(screen.getByRole('button', { name: 'search' }));
expect(screen.getByTestId('modal')).toBeInTheDocument();
expect(screen.getByTestId('search')).toBeInTheDocument();
});
Comment thread
coderabbitai[bot] marked this conversation as resolved.
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import userEvent from "@testing-library/user-event";
import UserPageRepNewRepSearch from "@/components/user/rep/new-rep/UserPageRepNewRepSearch";
import { useQuery } from "@tanstack/react-query";

jest.mock("@tanstack/react-query", () => ({ useQuery: jest.fn() }));
jest.mock("@tanstack/react-query", () => ({ useQuery: jest.fn(), useMutation: jest.fn().mockReturnValue({ mutateAsync: jest.fn() }) }));

jest.mock("@/components/user/rep/new-rep/UserPageRepNewRepSearchHeader", () => () => <div data-testid="header" />);
jest.mock("@/components/user/rep/new-rep/UserPageRepNewRepSearchDropdown", () => (props: any) => (
Expand All @@ -15,14 +15,14 @@ jest.mock("@/components/user/rep/new-rep/UserPageRepNewRepSearchDropdown", () =>
));
jest.mock("@/components/user/rep/new-rep/UserPageRepNewRepError", () => () => <div data-testid="error" />);
jest.mock("@/components/distribution-plan-tool/common/CircleLoader", () => () => <div data-testid="loader" />);
jest.mock("services/api/common-api", () => ({ commonApiFetch: jest.fn() }));
jest.mock("services/api/common-api", () => ({ commonApiFetch: jest.fn(), commonApiPost: jest.fn() }));

describe("UserPageRepNewRepSearch", () => {
it("shows dropdown results and handles selection", async () => {
(useQuery as jest.Mock).mockReturnValue({ isFetching: false, data: ["cat1"] });
const user = userEvent.setup();
render(
<UserPageRepNewRepSearch repRates={null} onRepSearch={jest.fn()} profile={{} as any} />
<UserPageRepNewRepSearch repRates={null} profile={{} as any} />
);
await user.type(screen.getByPlaceholderText(/Category to grant rep/), "art");
await waitFor(() => screen.getByTestId("dropdown"));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import ProfileRatersTableBody from "@/components/user/utils/raters-table/ProfileRatersTableBody";
import { ProfileRatersTableType } from "@/types/enums";
import { render } from "@testing-library/react";

let itemProps: any[] = [];
Expand Down Expand Up @@ -27,7 +26,6 @@ describe("ProfileRatersTableBody", () => {
<table>
<ProfileRatersTableBody
ratings={ratings}
type={ProfileRatersTableType.CIC_RECEIVED}
/>
</table>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import ProfileRatersTableItem from "@/components/user/utils/raters-table/ProfileRatersTableItem";
import { ProfileRatersTableType } from "@/types/enums";
import { render, screen } from "@testing-library/react";

let cicProps: any;
Expand All @@ -23,7 +22,6 @@ describe("ProfileRatersTableItem", () => {
<tbody>
<ProfileRatersTableItem
rating={baseRating}
type={ProfileRatersTableType.REP_RECEIVED}
/>
</tbody>
</table>
Expand All @@ -41,7 +39,6 @@ describe("ProfileRatersTableItem", () => {
<tbody>
<ProfileRatersTableItem
rating={rating}
type={ProfileRatersTableType.CIC_GIVEN}
/>
</tbody>
</table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('UserSetUpProfileCta', () => {
useCtx.mockReturnValue({ address: '0xabc' });
renderWithProfile({ handle: null });
expect(screen.getByRole('button')).toBeInTheDocument();
expect(screen.getByRole('link')).toHaveAttribute('href', '/0xabc/identity');
expect(screen.getByRole('link')).toHaveAttribute('href', '/0xabc/rep');
});

it('returns null when address missing or handle exists', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ const renderSection = (wave = baseWave) =>
onProfileStatementRemove: jest.fn(),
onIdentityFollowChange: jest.fn(),
initProfileRepPage: jest.fn(),
initProfileIdentityPage: jest.fn(),
initCommunityActivityPage: jest.fn(),
waitAndInvalidateDrops: jest.fn(),
addOptimisticDrop: jest.fn(),
Expand Down
Loading