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
4 changes: 4 additions & 0 deletions .ts-prunerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"project": "tsconfig.json",
"ignore": "(^generated/|^src/generated/|\\.test\\.|\\.spec\\.|/__tests__/|/stories/|^src/middleware\\.ts|/route\\.(ts|tsx)$|^src/(app|pages)/)"
}
22 changes: 22 additions & 0 deletions .unimportedrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"entry": [
"src/app/**/page.{ts,tsx,js,jsx}",
"src/app/**/layout.{ts,tsx,js,jsx}",
"src/app/**/route.{ts,tsx,js,jsx}",
"src/pages/**/*.{ts,tsx,js,jsx}",
"src/middleware.ts",
"scripts/**/*.{ts,js,cjs,mjs}"
],
"extensions": [".ts", ".tsx", ".js", ".jsx"],
"ignorePatterns": [
"**/.next/**",
"coverage/**",
"generated/**",
"tmp_gen_outp/**"
],
"aliases": { "@/*": ["./src/*"] },
"rootDir": ".",
"respectGitignore": true,
"scannedDirs": ["src", "app", "pages", "components", "lib", "hooks", "scripts"]
}

4 changes: 2 additions & 2 deletions __tests__/app/api/farcaster.route.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const UrlGuardError = MockUrlGuardError;
const originalFetch = global.fetch;
const mockFetch = jest.fn();

let GET: typeof import("../../app/api/farcaster/route").GET;
let GET: typeof import("@/app/api/farcaster/route").GET;

const resetUrlGuardMocks = () => {
parsePublicUrlMock.mockReset();
Expand All @@ -58,7 +58,7 @@ const resetUrlGuardMocks = () => {
const loadRoute = async () => {
jest.resetModules();
resetUrlGuardMocks();
({ GET } = await import("../../../app/api/farcaster/route"));
({ GET } = await import("@/app/api/farcaster/route"));
};

describe("farcaster API route", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { render } from '@testing-library/react';
import React from 'react';
import ReviewDistributionPlanTable from 'components/distribution-plan-tool/review-distribution-plan/table/ReviewDistributionPlanTable';
import { DistributionPlanToolContext } from 'components/distribution-plan-tool/DistributionPlanToolContext';
import ReviewDistributionPlanTable from '@/components/distribution-plan-tool/review-distribution-plan/table/ReviewDistributionPlanTable';
import { DistributionPlanToolContext } from '@/components/distribution-plan-tool/DistributionPlanToolContext';

const headerMock = jest.fn(() => <div data-testid="header" />);
const bodyMock = jest.fn(() => <div data-testid="body" />);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { render, screen, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import React from 'react';
import ReviewDistributionPlanTableRow from 'components/distribution-plan-tool/review-distribution-plan/table/ReviewDistributionPlanTableRow';
import { DistributionPlanToolContext } from 'components/distribution-plan-tool/DistributionPlanToolContext';
import { ReviewDistributionPlanTableItemType } from 'components/distribution-plan-tool/review-distribution-plan/table/ReviewDistributionPlanTable';
import { distributionPlanApiFetch } from 'services/distribution-plan-api';
import ReviewDistributionPlanTableRow from '@/components/distribution-plan-tool/review-distribution-plan/table/ReviewDistributionPlanTableRow';
import { DistributionPlanToolContext } from '@/components/distribution-plan-tool/DistributionPlanToolContext';
import { ReviewDistributionPlanTableItemType } from '@/components/distribution-plan-tool/review-distribution-plan/table/ReviewDistributionPlanTable';
import { distributionPlanApiFetch } from '@/services/distribution-plan-api';

jest.mock('services/distribution-plan-api', () => ({
distributionPlanApiFetch: jest.fn(async () => ({ success: true, data: [{ wallet: '0x1', amount: 1, phaseId: 'p1', phaseComponentId: 'c1' }] }))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jest.mock('react-use', () => ({
useKeyPressEvent: mockUseKeyPressEvent
}));

import MentionsTypeaheadMenu from 'components/drops/create/lexical/plugins/mentions/MentionsTypeaheadMenu';
import MentionsTypeaheadMenu from '@/components/drops/create/lexical/plugins/mentions/MentionsTypeaheadMenu';

const options = [{ key: '1', label: 'one' }];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ jest.mock("@/components/drops/view/part/dropPartMarkdown/renderers", () => ({
renderTweetEmbed: jest.fn((href: string) => (
<div data-testid="tweet" data-href={href} />
)),
TweetFallback: () => null,
}));

jest.mock("@/src/components/waves/ArtBlocksTokenCard", () => ({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { render, screen, fireEvent } from '@testing-library/react';
import CreateGroupWalletsEmma from 'components/groups/page/create/config/wallets/CreateGroupWalletsEmma';
import { AuthContext } from 'components/auth/Auth';
import CreateGroupWalletsEmma from '@/components/groups/page/create/config/wallets/CreateGroupWalletsEmma';
import { AuthContext } from '@/components/auth/Auth';

jest.mock('components/utils/input/emma/EmmaListSearch', () => ({
__esModule: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { render, screen } from '@testing-library/react';
import React from 'react';
import GroupCardActionStats from 'components/groups/page/list/card/utils/GroupCardActionStats';
import { AuthContext } from 'components/auth/Auth';
import GroupCardActionStats from '@/components/groups/page/list/card/utils/GroupCardActionStats';
import { AuthContext } from '@/components/auth/Auth';
import { useQuery } from '@tanstack/react-query';
import { ApiRateMatter } from 'generated/models/ApiRateMatter';
import { ApiRateMatter } from '@/generated/models/ApiRateMatter';

jest.mock('@tanstack/react-query', () => ({ useQuery: jest.fn() }));
jest.mock('components/distribution-plan-tool/common/CircleLoader', () => ({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import MemeDropVoteStats from '@/components/memes/drops/meme-participation-drop/MemeDropVoteStats';
import { ApiDropRater } from '@/__tests__/generated/models/ApiDropRater';
import { ApiDropRater } from '@/generated/models/ApiDropRater';

jest.mock('next/link', () => ({__esModule:true, default: ({href,children}:any) => <a href={href}>{children}</a>}));

Expand Down
55 changes: 31 additions & 24 deletions __tests__/components/providers/AppKitAdapterManager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import { WalletValidationError } from '@/src/errors/wallet-validation'
import { AppWallet } from '@/components/app-wallets/AppWalletsContext'
import { WagmiAdapter } from '@reown/appkit-adapter-wagmi'

const VALID_PRIVATE_KEY =
'0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef'

// Jest helper
const fail = (message?: string): never => {
throw new Error(message || 'Test failed')
Expand All @@ -29,7 +32,7 @@ describe('AppKitAdapterManager', () => {
name: 'Test Wallet',
created_at: Date.now(),
mnemonic: '',
private_key: '',
private_key: VALID_PRIVATE_KEY,
imported: false
}

Expand All @@ -49,7 +52,7 @@ describe('AppKitAdapterManager', () => {
name: 'Test Wallet 2',
created_at: Date.now(),
mnemonic: '',
private_key: '',
private_key: VALID_PRIVATE_KEY,
imported: false
}

Expand Down Expand Up @@ -127,12 +130,13 @@ describe('AppKitAdapterManager', () => {
})

it('should validate mnemonic format without exposing content', () => {
const walletWithValidMnemonic = {
address: '0x742D35A1CbF05C7A56C1Bf2dF5e8Dd6cf0DA8c4c',
address_hashed: 'hash123456789012345678901234567890123456789012345678901234567890',
name: 'Test',
mnemonic: 'word1 word2 word3' // Valid mnemonic with proper words
}
const walletWithValidMnemonic = {
address: '0x742D35A1CbF05C7A56C1Bf2dF5e8Dd6cf0DA8c4c',
address_hashed: 'hash123456789012345678901234567890123456789012345678901234567890',
name: 'Test',
mnemonic: 'word1 word2 word3 word4 word5 word6 word7 word8 word9 word10 word11 word12',
private_key: VALID_PRIVATE_KEY
}

// Current implementation only validates empty words, which won't occur with split(/\s+/)
// So any mnemonic with actual words should pass
Expand Down Expand Up @@ -169,12 +173,13 @@ describe('AppKitAdapterManager', () => {
})

it('should throw WalletSecurityError for invalid mnemonic type', () => {
const walletWithInvalidMnemonicType = {
address: '0x742D35A1CbF05C7A56C1Bf2dF5e8Dd6cf0DA8c4c',
address_hashed: 'hash123456789012345678901234567890123456789012345678901234567890',
name: 'Test Wallet',
mnemonic: 123
} as any
const walletWithInvalidMnemonicType = {
address: '0x742D35A1CbF05C7A56C1Bf2dF5e8Dd6cf0DA8c4c',
address_hashed: 'hash123456789012345678901234567890123456789012345678901234567890',
name: 'Test Wallet',
mnemonic: 123,
private_key: VALID_PRIVATE_KEY
} as any

expect(() => manager.createAdapter([walletWithInvalidMnemonicType]))
.toThrow(WalletValidationError)
Expand All @@ -183,12 +188,14 @@ describe('AppKitAdapterManager', () => {
})

it('should accept mnemonic with multiple spaces between words', () => {
const walletWithSpacedMnemonic = {
address: '0x742D35A1CbF05C7A56C1Bf2dF5e8Dd6cf0DA8c4c',
address_hashed: 'hash123456789012345678901234567890123456789012345678901234567890',
name: 'Test Wallet',
mnemonic: 'word1 word2 word3' // Multiple spaces between words - should be normalized
} as AppWallet
const walletWithSpacedMnemonic = {
address: '0x742D35A1CbF05C7A56C1Bf2dF5e8Dd6cf0DA8c4c',
address_hashed: 'hash123456789012345678901234567890123456789012345678901234567890',
name: 'Test Wallet',
mnemonic:
'word1 word2 word3 word4 word5 word6 word7 word8 word9 word10 word11 word12',
private_key: VALID_PRIVATE_KEY
} as AppWallet

// Current implementation trims and splits by /\s+/ which handles multiple spaces correctly
expect(() => manager.createAdapter([walletWithSpacedMnemonic]))
Expand Down Expand Up @@ -592,7 +599,7 @@ describe('AppKitAdapterManager', () => {
name: `Wallet ${i}`,
created_at: Date.now(),
mnemonic: '',
private_key: '',
private_key: VALID_PRIVATE_KEY,
imported: false
}
manager.createAdapterWithCache([wallet])
Expand Down Expand Up @@ -651,7 +658,7 @@ describe('AppKitAdapterManager', () => {
name: 'Test Wallet',
created_at: Date.now(),
mnemonic: '',
private_key: '',
private_key: VALID_PRIVATE_KEY,
imported: false
} as AppWallet

Expand Down Expand Up @@ -683,7 +690,7 @@ describe('AppKitAdapterManager', () => {
name: 'Test Wallet',
created_at: Date.now(),
mnemonic: 'word1 word2 word3 word4 word5 word6 word7 word8 word9 word10 word11 word12',
private_key: '',
private_key: VALID_PRIVATE_KEY,
imported: false
} as AppWallet

Expand All @@ -692,4 +699,4 @@ describe('AppKitAdapterManager', () => {
expect(adapter).toBeDefined()
})
})
})
})
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import UserPageIdentityAddStatements, { STATEMENT_ADD_VIEW } from "@/components/user/identity/statements/add/UserPageIdentityAddStatements";
import { ApiIdentity } from '@/__tests__/generated/models/ApiIdentity';
import { ApiIdentity } from '@/generated/models/ApiIdentity';

let clickAway: () => void;
let escapeCb: () => void;
Expand Down
23 changes: 14 additions & 9 deletions __tests__/components/utils/CommonFilterTargetSelect.test.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import CommonFilterTargetSelect, {
FilterTargetType,
} from "@/components/utils/CommonFilterTargetSelect";
import CommonFilterTargetSelect from "@/components/utils/CommonFilterTargetSelect";
import { render, screen } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { ProfileActivityFilterTargetType } from "@/enums";

describe("CommonFilterTargetSelect", () => {
it("renders the filter target options and triggers change on click", async () => {
Expand All @@ -11,7 +10,7 @@ describe("CommonFilterTargetSelect", () => {

render(
<CommonFilterTargetSelect
selected={FilterTargetType.ALL}
selected={ProfileActivityFilterTargetType.ALL}
onChange={onChange}
/>
);
Expand All @@ -24,7 +23,9 @@ describe("CommonFilterTargetSelect", () => {

await user.click(screen.getByLabelText("Outgoing"));

expect(onChange).toHaveBeenCalledWith(FilterTargetType.OUTGOING);
expect(onChange).toHaveBeenCalledWith(
ProfileActivityFilterTargetType.OUTGOING
);
});

it("supports keyboard navigation between targets", async () => {
Expand All @@ -33,7 +34,7 @@ describe("CommonFilterTargetSelect", () => {

const { rerender } = render(
<CommonFilterTargetSelect
selected={FilterTargetType.ALL}
selected={ProfileActivityFilterTargetType.ALL}
onChange={onChange}
/>
);
Expand All @@ -45,13 +46,15 @@ describe("CommonFilterTargetSelect", () => {

await user.keyboard("{ArrowRight}");

expect(onChange).toHaveBeenCalledWith(FilterTargetType.OUTGOING);
expect(onChange).toHaveBeenCalledWith(
ProfileActivityFilterTargetType.OUTGOING
);

onChange.mockClear();

rerender(
<CommonFilterTargetSelect
selected={FilterTargetType.OUTGOING}
selected={ProfileActivityFilterTargetType.OUTGOING}
onChange={onChange}
/>
);
Expand All @@ -62,6 +65,8 @@ describe("CommonFilterTargetSelect", () => {

await user.keyboard("{ArrowLeft}");

expect(onChange).toHaveBeenCalledWith(FilterTargetType.ALL);
expect(onChange).toHaveBeenCalledWith(
ProfileActivityFilterTargetType.ALL
);
});
});
2 changes: 1 addition & 1 deletion __tests__/components/waves/CreateDropReplying.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import CreateDropReplying from '@/components/waves/CreateDropReplying';
import { ApiDrop } from '@/__tests__/generated/models/ApiDrop';
import { ApiDrop } from '@/generated/models/ApiDrop';
import { ActiveDropAction } from '@/types/dropInteractionTypes';

describe('CreateDropReplying', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('WaveDropQuoteWithSerialNo', () => {
limit: 1,
dropId: null,
serialNo: 5,
strategy: WaveDropsSearchStrategy.FIND_BOTH,
strategy: WaveDropsSearchStrategy.Both,
},
],
queryFn: expect.any(Function),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { render } from '@testing-library/react';
import WinnerDropBadge from 'components/waves/drops/winner/WinnerDropBadge';
import WinnerDropBadge from '@/components/waves/drops/winner/WinnerDropBadge';

describe('WinnerDropBadge', () => {
it('returns null when no rank or position', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { render, screen, fireEvent } from '@testing-library/react';
import { DropdownTrait } from 'components/waves/memes/traits/DropdownTrait';
import { DropdownTrait } from '@/components/waves/memes/traits/DropdownTrait';

jest.mock('components/waves/memes/traits/TraitWrapper', () => ({
Comment thread
simo6529 marked this conversation as resolved.
TraitWrapper: ({ children }: any) => <div data-testid="wrapper">{children}</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as mod from 'components/waves/winners/drops/DefaultWaveWinnerDrop';
import * as mod from '@/components/waves/winners/drops/DefaultWaveWinnerDrop';

describe('DefaultWaveWinnerDrop module', () => {
it('exports component', () => {
Expand Down
2 changes: 1 addition & 1 deletion __tests__/fixtures/gradientFixtures.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { GRADIENT_CONTRACT } from '@/constants';

export const mockGradientNFT = (overrides: Partial<any> = {}) => ({
const mockGradientNFT = (overrides: Partial<any> = {}) => ({
id: 1,
contract: GRADIENT_CONTRACT,
name: 'Gradient #1',
Expand Down
2 changes: 1 addition & 1 deletion __tests__/helpers/time.types.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'helpers/waves/time.types';
import '@/helpers/waves/time.types';

test('module loads', () => {
expect(true).toBe(true);
Expand Down
Loading