Skip to content
Open
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
43 changes: 39 additions & 4 deletions src/renderer/features/agents/components/AgentContextPanel.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,16 @@

import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { describe, expect, it, vi } from 'vitest';
import {
afterEach,
beforeEach,
describe,
expect,
it,
vi,
} from 'vitest';

import { resetAppStore } from '@/renderer/app/store/use-app-store';
import { AgentContextPanel } from '@/renderer/features/agents/components/AgentContextPanel';
import { createEmptyAgentCustomizationDraft } from '@/renderer/features/agents/model/agent-customization';
import type { PresentedAgent } from '@/renderer/features/agents/types';
Expand Down Expand Up @@ -78,6 +86,14 @@ function createAgent(
}

describe('AgentContextPanel', () => {
beforeEach(() => {
resetAppStore();
});

afterEach(() => {
resetAppStore();
});

it('surfaces agent identity while preserving connection details and filtered cards', () => {
render(
<AgentContextPanel
Expand Down Expand Up @@ -190,7 +206,7 @@ describe('AgentContextPanel', () => {

it('lets the inspector switch a Telegram agent back to Dune chat', async () => {
const user = userEvent.setup();
const onUpdateChannel = vi.fn(async () => undefined);
const onUpdateChannel = vi.fn(() => Promise.resolve(undefined));

render(
<AgentContextPanel
Expand Down Expand Up @@ -248,7 +264,7 @@ describe('AgentContextPanel', () => {
agent={createAgent()}
onClose={vi.fn()}
onOpenTelegramSetup={onOpenTelegramSetup}
onUpdateChannel={vi.fn(async () => undefined)}
onUpdateChannel={vi.fn(() => Promise.resolve(undefined))}
/>,
);

Expand All @@ -265,7 +281,7 @@ describe('AgentContextPanel', () => {

it('saves a paired Telegram channel from the inspector', async () => {
const user = userEvent.setup();
const onUpdateChannel = vi.fn(async () => undefined);
const onUpdateChannel = vi.fn(() => Promise.resolve(undefined));

render(
<AgentContextPanel
Expand Down Expand Up @@ -303,4 +319,23 @@ describe('AgentContextPanel', () => {
telegramSetupSessionId: 'telegram-session-1',
});
});

it('switches between overview and timeline tabs', async () => {
const user = userEvent.setup();

render(
<AgentContextPanel
agent={createAgent()}
onClose={vi.fn()}
/>,
);

expect(screen.getByText('Connection')).toBeInTheDocument();

await user.click(screen.getByRole('tab', { name: /Timeline/i }));

expect(screen.getByTestId('agent-timeline')).toBeInTheDocument();
expect(screen.queryByText('Connection')).not.toBeInTheDocument();
expect(screen.getByText('No timeline events are recorded yet for this agent.')).toBeInTheDocument();
});
});
Loading