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
42 changes: 32 additions & 10 deletions __tests__/components/brain/notifications/Notifications.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import { render, screen, waitFor } from '@testing-library/react';
import React from 'react';

const mutateAsyncMock = jest.fn();
const requestAuthMock = jest.fn().mockResolvedValue({ success: true });
const setActiveProfileProxyMock = jest.fn().mockResolvedValue(undefined);
const setToastMock = jest.fn();

jest.mock('@tanstack/react-query', () => ({
useMutation: () => ({ mutateAsync: mutateAsyncMock }),
Expand All @@ -19,11 +22,19 @@ jest.mock('@/components/auth/Auth', () => {
const React = require('react');
return {
AuthContext: React.createContext({
connectedProfile: { handle: 'bob' },
activeProfileProxy: false,
setToast: jest.fn(),
connectedProfile: { handle: 'bob', id: '1' },
activeProfileProxy: null,
fetchingProfile: false,
requestAuth: requestAuthMock,
setToast: setToastMock,
setActiveProfileProxy: setActiveProfileProxyMock,
}),
useAuth: () => ({
setTitle: setTitleMock,
requestAuth: requestAuthMock,
setToast: setToastMock,
setActiveProfileProxy: setActiveProfileProxyMock,
}),
useAuth: () => ({ setTitle: setTitleMock }),
};
});

Expand Down Expand Up @@ -91,6 +102,11 @@ describe('Notifications component', () => {
mutateAsyncMock.mockResolvedValue(undefined);
useNotificationsQueryMock.mockReset();
setTitleMock.mockClear();
requestAuthMock.mockClear();
requestAuthMock.mockResolvedValue({ success: true });
setActiveProfileProxyMock.mockClear();
setActiveProfileProxyMock.mockResolvedValue(undefined);
setToastMock.mockClear();
});

it('shows loader when fetching and no items', async () => {
Expand All @@ -99,9 +115,11 @@ describe('Notifications component', () => {
isFetching: true,
isFetchingNextPage: false,
hasNextPage: false,
fetchNextPage: jest.fn(),
refetch: jest.fn(),
fetchNextPage: jest.fn().mockResolvedValue(undefined),
refetch: jest.fn().mockResolvedValue(undefined),
isInitialQueryDone: false,
isSuccess: false,
error: null,
});

render(<Notifications activeDrop={null} setActiveDrop={jest.fn()} />);
Expand All @@ -119,9 +137,11 @@ describe('Notifications component', () => {
isFetching: false,
isFetchingNextPage: false,
hasNextPage: false,
fetchNextPage: jest.fn(),
refetch: jest.fn(),
fetchNextPage: jest.fn().mockResolvedValue(undefined),
refetch: jest.fn().mockResolvedValue(undefined),
isInitialQueryDone: true,
isSuccess: true,
error: null,
});

render(<Notifications activeDrop={null} setActiveDrop={jest.fn()} />);
Expand All @@ -138,9 +158,11 @@ describe('Notifications component', () => {
isFetching: false,
isFetchingNextPage: false,
hasNextPage: false,
fetchNextPage: jest.fn(),
refetch: jest.fn(),
fetchNextPage: jest.fn().mockResolvedValue(undefined),
refetch: jest.fn().mockResolvedValue(undefined),
isInitialQueryDone: true,
isSuccess: true,
error: null,
});

render(<Notifications activeDrop={null} setActiveDrop={jest.fn()} />);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { FilterTargetType } from "@/components/utils/CommonFilterTargetSelect";
import { ProfileActivityLogType } from "@/enums";
import {
ProfileActivityFilterTargetType,
ProfileActivityLogType,
} from "@/enums";
import { convertActivityLogParams } from "@/helpers/profile-logs.helpers";

describe("convertActivityLogParams", () => {
Expand All @@ -8,7 +10,7 @@ describe("convertActivityLogParams", () => {
pageSize: 10,
logTypes: [ProfileActivityLogType.DROP_CREATED],
matter: null,
targetType: FilterTargetType.ALL,
targetType: ProfileActivityFilterTargetType.ALL,
handleOrWallet: null,
groupId: "g1",
};
Expand Down Expand Up @@ -43,7 +45,7 @@ describe("convertActivityLogParams", () => {
params: {
...base,
handleOrWallet: "u",
targetType: FilterTargetType.INCOMING,
targetType: ProfileActivityFilterTargetType.INCOMING,
},
disableActiveGroup: false,
});
Expand All @@ -52,7 +54,7 @@ describe("convertActivityLogParams", () => {
params: {
...base,
handleOrWallet: "u",
targetType: FilterTargetType.OUTGOING,
targetType: ProfileActivityFilterTargetType.OUTGOING,
},
disableActiveGroup: false,
});
Expand Down
5 changes: 2 additions & 3 deletions app/[user]/identity/page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { createUserTabPage } from "@/app/[user]/_lib/userTabPageFactory";
import type { ActivityLogParams } from "@/components/profile-activity/ProfileActivityLogs";
import UserPageIdentityWrapper from "@/components/user/identity/UserPageIdentityWrapper";
import { FilterTargetType } from "@/components/utils/CommonFilterTargetSelect";
import { RateMatter } from "@/enums";
import { ProfileActivityFilterTargetType, RateMatter } from "@/enums";
import type { ApiIdentity } from "@/generated/models/ApiIdentity";
import { getProfileLogTypes } from "@/helpers/profile-logs.helpers";
import { getInitialRatersParams } from "@/helpers/server.helpers";
Expand All @@ -18,7 +17,7 @@ const getInitialActivityLogParams = (
logTypes: [],
}),
matter: null,
targetType: FilterTargetType.ALL,
targetType: ProfileActivityFilterTargetType.ALL,
handleOrWallet,
groupId: null,
});
Expand Down
5 changes: 2 additions & 3 deletions app/[user]/rep/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { createUserTabPage } from "@/app/[user]/_lib/userTabPageFactory";
import type { ActivityLogParams } from "@/components/profile-activity/ProfileActivityLogs";
import UserPageRepWrapper from "@/components/user/rep/UserPageRepWrapper";
import { FilterTargetType } from "@/components/utils/CommonFilterTargetSelect";
import { ApiProfileRepRatesState } from "@/entities/IProfile";
import { RateMatter } from "@/enums";
import { ProfileActivityFilterTargetType, RateMatter } from "@/enums";
import type { ApiIdentity } from "@/generated/models/ApiIdentity";
import { getProfileLogTypes } from "@/helpers/profile-logs.helpers";
import { getInitialRatersParams } from "@/helpers/server.helpers";
Expand All @@ -24,7 +23,7 @@ const getInitialActivityLogParams = (
logTypes: [],
}),
matter: RateMatter.REP,
targetType: FilterTargetType.ALL,
targetType: ProfileActivityFilterTargetType.ALL,
handleOrWallet,
groupId: null,
});
Expand Down
Loading