Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
import { act, fireEvent, render, screen } from '@testing-library/react';
import { beforeEach, describe, expect, it, vi } from 'vitest';
vi.mock('../../../services/api', () => ({
getAgentActivityTimeline: vi.fn(),
}));
import * as api from '../../../services/api';
import ActivityTab from './ActivityTab.jsx';
const page = (action, count, prefix = 'a') => Array.from({ length: count }, (_, i) => ({
id: `${prefix}-${i}`, action, status: 'completed', timestamp: `2026-08-23T00:${String(59 - i).padStart(2, '0')}:00.000Z`,
}));
describe('ActivityTab', () => {
beforeEach(() => {
vi.clearAllMocks();
});
it('sends the selected action for the first page and for Load More', async () => {
api.getAgentActivityTimeline.mockImplementation(async (_l, _a, before) => page('post', 50, before ? 'more' : 'a'));
render(<ActivityTab agentId="agent-1" />);
await screen.findByText('Activity Log');
expect(api.getAgentActivityTimeline).toHaveBeenLastCalledWith(50, ['agent-1'], null, null, { silent: true });
await act(async () => {
fireEvent.change(screen.getByLabelText('Filter by action'), { target: { value: 'post' } });
});
expect(api.getAgentActivityTimeline).toHaveBeenLastCalledWith(50, ['agent-1'], null, 'post', { silent: true });
await act(async () => { fireEvent.click(await screen.findByRole('button', { name: 'Load More' })); });
expect(api.getAgentActivityTimeline).toHaveBeenLastCalledWith(
50, ['agent-1'], '2026-08-23T00:10:00.000Z', 'post'
);
});
it('shows a retryable error instead of an endless spinner when the activity load fails', async () => {
api.getAgentActivityTimeline
.mockRejectedValueOnce(new Error('network unavailable'))
.mockResolvedValueOnce([]);
render(<ActivityTab agentId="agent-1" />);
expect(await screen.findByText(/Could not load activity log/)).toBeInTheDocument();
expect(screen.queryByText('Loading activity')).not.toBeInTheDocument();
expect(api.getAgentActivityTimeline).toHaveBeenLastCalledWith(50, ['agent-1'], null, null, { silent: true });
await act(async () => {
fireEvent.click(screen.getByRole('button', { name: 'Retry' }));
});
expect(await screen.findByRole('heading', { name: 'Activity Log' })).toBeInTheDocument();
expect(api.getAgentActivityTimeline).toHaveBeenCalledTimes(2);
});
});