The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
test(5805): cover the wallet gate — diff coverage 67% -> 100%
M3gA-Mindef1f5a5f36db
diff --git a/app/src/components/intelligence/TinyPlaceOrchestrationTab.test.tsx b/app/src/components/intelligence/TinyPlaceOrchestrationTab.test.tsxindex c89ed13dd2..06d934d27a 100644--- a/app/src/components/intelligence/TinyPlaceOrchestrationTab.test.tsx+++ b/app/src/components/intelligence/TinyPlaceOrchestrationTab.test.tsx@@ -40,9 +40,8 @@ vi.mock('../../lib/orchestration/orchestrationClient', async importOriginal => {// The #5805 wallet gate runs before the identity fetch; mock it to a configured// wallet so these cases exercise the same path they always did.-vi.mock('../../services/walletApi', () => ({- fetchWalletStatus: vi.fn().mockResolvedValue({ configured: true }),-}));+const fetchWalletStatusMock = vi.hoisted(() => vi.fn());+vi.mock('../../services/walletApi', () => ({ fetchWalletStatus: fetchWalletStatusMock }));vi.mock('../../services/socketService', () => {return { socketService: { on: vi.fn(), off: vi.fn(), getSocket: vi.fn(() => null) } };@@ -96,6 +95,9 @@ const PINNED_SESSIONS = [describe('TinyPlaceOrchestrationTab', () => {beforeEach(() => {vi.clearAllMocks();+ // Default to a configured wallet so every pre-existing case exercises the+ // same path it always did; the #5805 case overrides it.+ fetchWalletStatusMock.mockResolvedValue({ configured: true });sessionsListMock.mockResolvedValue({ sessions: [...PINNED_SESSIONS] });sessionsCreateMock.mockResolvedValue({session: {@@ -206,6 +208,22 @@ describe('TinyPlaceOrchestrationTab', () => {expect(screen.queryByTestId('tinyplace-self-identity')).not.toBeInTheDocument();});+ // #5805 — with no wallet the identity read is skipped rather than attempted:+ // selfIdentity() could only reject, and that rejection was reaching Sentry.+ // The relay badge must still render, which is the property the wallet-less+ // path shares with the locked-wallet path above.+ it('skips the identity read entirely when no wallet is configured', async () => {+ fetchWalletStatusMock.mockResolvedValue({ configured: false });++ render(<TinyPlaceOrchestrationTab />);++ const badge = await screen.findByTestId('tinyplace-relay-badge');+ expect(badge).toHaveAttribute('data-network', 'staging');+ expect(screen.queryByTestId('tinyplace-self-identity')).not.toBeInTheDocument();+ // The point of the gate: not attempted, as opposed to attempted and failed.+ expect(selfIdentityMock).not.toHaveBeenCalled();+ });+it('loads and renders messages for the opened chat', async () => {sessionsListMock.mockResolvedValue({sessions: [diff --git a/app/src/hooks/useWalletConfigured.test.ts b/app/src/hooks/useWalletConfigured.test.tsnew file mode 100644index 0000000000..885921362d--- /dev/null+++ b/app/src/hooks/useWalletConfigured.test.ts@@ -0,0 +1,89 @@+import { renderHook, waitFor } from '@testing-library/react';+import { beforeEach, describe, expect, it, vi } from 'vitest';++import { resolveWalletConfigured, useWalletConfigured } from './useWalletConfigured';++const fetchWalletStatus = vi.fn();+vi.mock('../services/walletApi', () => ({ fetchWalletStatus: () => fetchWalletStatus() }));++describe('wallet-configured gate (#5805)', () => {+ beforeEach(() => {+ vi.clearAllMocks();+ });++ describe('resolveWalletConfigured', () => {+ it('reports `yes` when a wallet is configured', async () => {+ fetchWalletStatus.mockResolvedValue({ configured: true });+ await expect(resolveWalletConfigured()).resolves.toBe('yes');+ });++ it('reports `no` when wallet_status resolves with no wallet', async () => {+ fetchWalletStatus.mockResolvedValue({ configured: false });+ await expect(resolveWalletConfigured()).resolves.toBe('no');+ });++ // The load-bearing case: a failed status fetch must NOT be reported as+ // `no`. Callers skip their wallet-gated call only on a positive `no`, so+ // collapsing this into `no` would let a transport blip hide a wallet that+ // actually exists.+ it('reports `unknown` — never `no` — when the status fetch itself fails', async () => {+ fetchWalletStatus.mockRejectedValue(new Error('rpc transport failed'));+ await expect(resolveWalletConfigured()).resolves.toBe('unknown');+ });++ // It is awaited inline before a gated call, so a rejection here would+ // propagate into the caller it was meant to protect.+ it('never rejects', async () => {+ fetchWalletStatus.mockRejectedValue(new Error('boom'));+ await expect(resolveWalletConfigured()).resolves.toBeDefined();+ });+ });++ describe('useWalletConfigured', () => {+ it('starts at `resolving` so callers fire nothing before the answer', async () => {+ fetchWalletStatus.mockResolvedValue({ configured: true });+ const { result } = renderHook(() => useWalletConfigured());++ // Synchronously after mount, before the promise settles.+ expect(result.current).toBe('resolving');+ await waitFor(() => expect(result.current).toBe('yes'));+ });++ it('settles to `no` when no wallet is configured', async () => {+ fetchWalletStatus.mockResolvedValue({ configured: false });+ const { result } = renderHook(() => useWalletConfigured());++ await waitFor(() => expect(result.current).toBe('no'));+ });++ it('settles to `unknown` when the status fetch fails', async () => {+ fetchWalletStatus.mockRejectedValue(new Error('rpc transport failed'));+ const { result } = renderHook(() => useWalletConfigured());++ await waitFor(() => expect(result.current).toBe('unknown'));+ });++ // Unmounting before the probe settles must not set state on a dead+ // component — that is what the `cancelled` flag in the effect cleanup is+ // for, and it is only exercised if a test unmounts mid-flight.+ it('does not set state after unmount', async () => {+ let settle: (value: { configured: boolean }) => void = () => {};+ fetchWalletStatus.mockReturnValue(+ new Promise<{ configured: boolean }>(resolve => {+ settle = resolve;+ })+ );+ const errors: unknown[] = [];+ const spy = vi.spyOn(console, 'error').mockImplementation((...args) => errors.push(args));++ const { result, unmount } = renderHook(() => useWalletConfigured());+ expect(result.current).toBe('resolving');+ unmount();+ settle({ configured: true });+ await Promise.resolve();++ expect(errors).toHaveLength(0);+ spy.mockRestore();+ });+ });+});