diff --git a/frontend/src/v2/__tests__/V2PodInspectorScopedManager.test.tsx b/frontend/src/v2/__tests__/V2PodInspectorScopedManager.test.tsx new file mode 100644 index 000000000..6b32e035a --- /dev/null +++ b/frontend/src/v2/__tests__/V2PodInspectorScopedManager.test.tsx @@ -0,0 +1,71 @@ +/* eslint-disable react/display-name */ +import React from 'react'; +import { fireEvent, render, screen } from '@testing-library/react'; +import { MemoryRouter } from 'react-router-dom'; +import V2PodInspector from '../components/V2PodInspector'; + +const mockNavigate = jest.fn(); + +jest.mock('react-router-dom', () => { + const actual = jest.requireActual('react-router-dom'); + return { ...actual, useNavigate: () => mockNavigate }; +}); + +jest.mock('react-i18next', () => ({ + useTranslation: () => ({ t: (key: string) => key }), +})); + +jest.mock('../hooks/useV2Api', () => ({ + useV2Api: () => ({ + get: jest.fn().mockResolvedValue({}), + post: jest.fn(), patch: jest.fn(), del: jest.fn(), + }), +})); + +jest.mock('../../context/AuthContext', () => ({ + useAuth: () => ({ currentUser: { _id: 'human-1', username: 'sam' } }), +})); + +jest.mock('../../context/SocketContext', () => ({ + useSocket: () => ({ socket: null, connected: false }), +})); + +jest.mock('../components/V2Avatar', () => () => ); + +const detail = { + pod: { _id: 'pod-1', name: 'Workspace', type: 'team' }, + members: [], + agents: [], + messages: [], + loading: false, + error: null, + sendError: null, + hasMore: false, + loadingOlder: false, + loadOlder: jest.fn(), + refresh: jest.fn(), + sendMessage: jest.fn(), +}; + +describe('V2PodInspector scoped manager action', () => { + beforeEach(() => jest.clearAllMocks()); + + test('opens the agent manager with the current pod preselected', () => { + render( + + + , + ); + + fireEvent.click(screen.getByRole('tab', { name: /inspector\.tabs\.members/ })); + fireEvent.click(screen.getByTitle('inspector.members.manageTitle')); + + expect(mockNavigate).toHaveBeenCalledWith('/v2/agents/manage?podId=pod-1'); + }); +}); diff --git a/frontend/src/v2/components/V2PodInspector.tsx b/frontend/src/v2/components/V2PodInspector.tsx index 8193990d4..20dfce0ae 100644 --- a/frontend/src/v2/components/V2PodInspector.tsx +++ b/frontend/src/v2/components/V2PodInspector.tsx @@ -1405,7 +1405,7 @@ const V2PodInspector: React.FC = ({