Skip to content

Commit 78dc662

Browse files
committed
run build fix
1 parent 3e9244f commit 78dc662

8 files changed

Lines changed: 203 additions & 174 deletions

File tree

frontend/src/__tests__/AuthCallback.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ describe('AuthCallback', () => {
4040
);
4141

4242
await waitFor(() => {
43-
expect(setTokenFromCallbackMock).toHaveBeenCalledWith('test-token');
43+
expect(setTokenFromCallbackMock).toHaveBeenCalledWith('test-token', null);
4444
});
4545

4646
expect(navigateMock).toHaveBeenCalledWith('/employer/payroll', { replace: true });

frontend/src/__tests__/Home.test.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ import Home from '../pages/Home';
55

66
const mockNavigate = vi.fn();
77

8+
vi.mock('@stellar/design-system', () => ({
9+
Icon: {
10+
Rocket01: () => <div data-testid="icon-rocket" />,
11+
CreditCard01: () => <div data-testid="icon-credit-card" />,
12+
Users01: () => <div data-testid="icon-users" />,
13+
ShieldTick: () => <div data-testid="icon-shield-tick" />,
14+
},
15+
}));
16+
817
vi.mock('react-router-dom', async () => {
918
const actual = await vi.importActual<typeof import('react-router-dom')>('react-router-dom');
1019
return {

frontend/src/__tests__/hooks/useWalletManager.test.ts

Lines changed: 33 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -3,59 +3,50 @@ import { describe, expect, it, vi, beforeEach } from 'vitest';
33
import { useWalletManager } from '../../hooks/useWalletManager';
44
import { StellarWalletsKit } from '@creit.tech/stellar-wallets-kit';
55

6-
vi.mock('@creit.tech/stellar-wallets-kit', () => ({
7-
StellarWalletsKit: vi.fn(function () {
8-
return {};
9-
}),
10-
WalletNetwork: { TESTNET: 'TESTNET', PUBLIC: 'PUBLIC' },
11-
FreighterModule: vi.fn(function () {
12-
return {};
13-
}),
14-
xBullModule: vi.fn(function () {
15-
return {};
16-
}),
17-
LobstrModule: vi.fn(function () {
18-
return {};
19-
}),
20-
FREIGHTER_ID: 'freighter',
21-
LOBSTR_ID: 'lobstr',
22-
}));
6+
const mockSetWallet = vi.fn();
7+
const mockGetAddress = vi.fn();
8+
const mockGetSupportedWallets = vi.fn();
9+
const mockDisconnect = vi.fn();
10+
const mockSignTransaction = vi.fn();
11+
12+
vi.mock('@creit.tech/stellar-wallets-kit', () => {
13+
class MockStellarWalletsKit {
14+
setWallet = mockSetWallet;
15+
getAddress = mockGetAddress;
16+
getSupportedWallets = mockGetSupportedWallets;
17+
disconnect = mockDisconnect;
18+
signTransaction = mockSignTransaction;
19+
}
20+
21+
return {
22+
StellarWalletsKit: MockStellarWalletsKit,
23+
WalletNetwork: { TESTNET: 'TESTNET', PUBLIC: 'PUBLIC' },
24+
FreighterModule: vi.fn(),
25+
xBullModule: vi.fn(),
26+
LobstrModule: vi.fn(),
27+
FREIGHTER_ID: 'freighter',
28+
LOBSTR_ID: 'lobstr',
29+
};
30+
});
31+
32+
const mockNotifyWalletEventHook = vi.fn();
2333

2434
vi.mock('../../hooks/useNotification', () => ({
2535
useNotification: () => ({
26-
notifyWalletEvent: vi.fn(),
36+
notifyWalletEvent: mockNotifyWalletEventHook,
2737
}),
2838
}));
2939

30-
interface MockKitInstance {
31-
setWallet: ReturnType<typeof vi.fn>;
32-
getAddress: ReturnType<typeof vi.fn>;
33-
getSupportedWallets: ReturnType<typeof vi.fn>;
34-
disconnect: ReturnType<typeof vi.fn>;
35-
signTransaction: ReturnType<typeof vi.fn>;
36-
}
37-
3840
describe('useWalletManager', () => {
39-
let mockKitInstance: MockKitInstance;
40-
4141
beforeEach(() => {
4242
vi.clearAllMocks();
4343
localStorage.clear();
44-
mockKitInstance = {
45-
setWallet: vi.fn(),
46-
getAddress: vi.fn(),
47-
getSupportedWallets: vi.fn().mockResolvedValue([]),
48-
disconnect: vi.fn(),
49-
signTransaction: vi.fn(),
50-
};
51-
vi.mocked(StellarWalletsKit).mockImplementation(
52-
() => mockKitInstance as unknown as StellarWalletsKit
53-
);
44+
mockGetSupportedWallets.mockResolvedValue([]);
5445
});
5546

5647
it('initializes and attempts silent reconnect if wallet in localStorage', async () => {
5748
localStorage.setItem('payd:last_wallet_name', 'freighter');
58-
mockKitInstance.getAddress.mockResolvedValue({ address: 'G123' });
49+
mockGetAddress.mockResolvedValue({ address: 'G123' });
5950

6051
const { result } = renderHook(() => useWalletManager());
6152

@@ -73,11 +64,12 @@ describe('useWalletManager', () => {
7364
});
7465

7566
it('handles manual connect sequence appropriately', async () => {
76-
mockKitInstance.getSupportedWallets.mockResolvedValue([
67+
mockGetSupportedWallets.mockResolvedValue([
7768
{ id: 'freighter', name: 'Freighter', isAvailable: true },
7869
]);
7970

8071
const { result } = renderHook(() => useWalletManager());
72+
await waitFor(() => expect(result.current.isInitialized).toBe(true));
8173

8274
await act(async () => {
8375
await result.current.connect();
@@ -88,7 +80,7 @@ describe('useWalletManager', () => {
8880
});
8981
expect(result.current.walletOptions.length).toBe(1);
9082

91-
mockKitInstance.getAddress.mockResolvedValue({ address: 'G456' });
83+
mockGetAddress.mockResolvedValue({ address: 'G456' });
9284

9385
await act(async () => {
9486
await result.current.connectWithWallet('freighter');

0 commit comments

Comments
 (0)