update on the agents and registry side

This commit is contained in:
2026-09-30 12:03:13 +05:30
parent 92e8da2842
commit 53199127ba
73 changed files with 7268 additions and 1134 deletions

View File

@@ -12,96 +12,80 @@ jest.mock('lucide-react', () =>
);
import Agents from '@/pages/doormile/agents/Agents';
import { SNAPSHOT_AT, SNAPSHOT_LABEL, networkStats } from '@/lib/agentNetwork';
/**
* The Agents page.
*
* It renders a hand-maintained table (lib/agentNetwork.js) rather than a live
* feed, so the risk here is not stale data — agentNetwork.test.js guards the
* table — it is that the page silently drops something. A detail panel that
* renders an empty string, or a card whose status has no colour, looks like a
* quiet page rather than a broken one.
* It is drawn from a hand-maintained snapshot (lib/agentNetwork.js) plus a
* scenario player (AgentFlowVisualizer) — neither is a feed from AI_engine,
* which exposes nothing this console can read. The risk these tests guard is
* the page PRESENTING that as live: a status board that looks real-time and is
* days old is worse than one that says how old it is.
*
* Rewritten 2026-09-29 for the flow-visualizer layout (the card grid these
* tests used to target is gone). The honesty checks were kept, not dropped.
*/
describe('the Agents page', () => {
it('lists all nine agents', () => {
it('says how old its figures are, as a machine-readable date', () => {
render(<Agents />);
['JARVIS', 'Dispatch', 'Exception', 'Express Dispatch', 'Order', 'Route Optimizer', 'Hub', 'Fleet', 'Customer'].forEach(
const stamp = screen.getByText(new RegExp(SNAPSHOT_LABEL));
expect(stamp.tagName).toBe('TIME');
expect(stamp).toHaveAttribute('dateTime', SNAPSHOT_AT);
expect(stamp).toHaveTextContent(/Snapshot/);
});
it('does not call itself real-time or live', () => {
const { container } = render(<Agents />);
expect(screen.queryByText(/Real-Time/i)).not.toBeInTheDocument();
expect(screen.queryByText(/^Live Activity$/i)).not.toBeInTheDocument();
// The pulsing "on air" dot is gone from the header.
expect(container.querySelector('h1').parentElement.querySelector('.animate-pulse')).toBeNull();
});
it('labels the activity panel as a simulation', () => {
render(<Agents />);
expect(screen.getByText('Sample Activity')).toBeInTheDocument();
expect(screen.getByText(/Simulation · not live data/)).toBeInTheDocument();
});
it('takes its status counts from the snapshot, not hard-coded numbers', () => {
render(<Agents />);
const s = networkStats();
expect(screen.getByText(`${s.working} Processing`)).toBeInTheDocument();
expect(screen.getByText(`${s.degraded} Warning`)).toBeInTheDocument();
expect(screen.getByText(`${s.total - s.working - s.degraded} Idle`)).toBeInTheDocument();
});
it('states that no autonomy gate is on, out of the agents that have one', () => {
// The page's central claim: the swarm observes and alerts, and does not
// write to the system. The denominator is gated agents, not all agents.
render(<Agents />);
const s = networkStats();
expect(s.autonomyOn).toBe(0);
expect(screen.getByText(`Autonomy gates on: 0 / ${s.gated}`)).toBeInTheDocument();
});
it('lists all nine agents in the flow', () => {
render(<Agents />);
['JARVIS Orchestrator', 'Order', 'Dispatch', 'Exception', 'Route Optimizer', 'Fleet', 'Hub', 'Express Dispatch', 'Customer'].forEach(
(name) => {
expect(screen.getAllByText(name).length).toBeGreaterThan(0);
expect(screen.getByRole('button', { name })).toBeInTheDocument();
}
);
});
it('opens on Dispatch rather than an empty panel', () => {
// It is the only agent with anything to show. Landing on a blank detail
// panel reads as a broken page.
it('opens the technical record of the agent that was clicked', () => {
render(<Agents />);
expect(screen.getByText('DISPATCH_AGENT')).toBeInTheDocument();
expect(screen.getByText(/only agent doing real work/i)).toBeInTheDocument();
fireEvent.click(screen.getByRole('button', { name: 'Exception' }));
fireEvent.click(screen.getByRole('button', { name: /Technical Specs/ }));
expect(screen.getAllByText(/EXCEPTION_AGENT/).length).toBeGreaterThan(0);
});
it('swaps the whole detail panel when another agent is picked', () => {
it('shows the grouped error counts from the run log', () => {
render(<Agents />);
fireEvent.click(screen.getByRole('button', { name: /Exception/ }));
expect(screen.getByText('EXCEPTION_AGENT')).toBeInTheDocument();
expect(screen.getByText(/17,188 of the 18,146 lines/)).toBeInTheDocument();
// and the previous agent's record is gone, not merely scrolled away
expect(screen.queryByText('DISPATCH_AGENT')).not.toBeInTheDocument();
});
it('marks the selected card for a screen reader, not just with a colour', () => {
render(<Agents />);
const exception = screen.getByRole('button', { name: /Exception/ });
expect(exception).toHaveAttribute('aria-pressed', 'false');
fireEvent.click(exception);
expect(exception).toHaveAttribute('aria-pressed', 'true');
});
it('says a task-driven agent listens to nothing, rather than leaving a blank', () => {
render(<Agents />);
fireEvent.click(screen.getByRole('button', { name: /Fleet/ }));
expect(screen.getByText(/runs only when JARVIS hands it a task/i)).toBeInTheDocument();
});
it('shows the pipeline, both halves of it', () => {
render(<Agents />);
expect(screen.getByText('doormile_backend')).toBeInTheDocument();
expect(screen.getByText('NATS JetStream')).toBeInTheDocument();
expect(screen.getByText('Event-driven')).toBeInTheDocument();
expect(screen.getByText('Task-driven')).toBeInTheDocument();
expect(screen.getByText('Alert, never act')).toBeInTheDocument();
});
it('states that nothing is switched on, in the KPI row', () => {
// The page's central claim: the swarm observes and alerts, and does not
// write to the system.
render(<Agents />);
expect(screen.getByText(/Gates on/)).toBeInTheDocument();
expect(screen.getByText(/All autonomy gates OFF/)).toBeInTheDocument();
});
it('admits the figures are a snapshot, not a feed', () => {
// A status board that looks live and is four days old is worse than one
// that says how old it is.
render(<Agents />);
expect(screen.getAllByText(/Last run · 16–20 Sep 2026/).length).toBeGreaterThan(0);
});
it('shows the repeated-error count on the log rows', () => {
render(<Agents />);
const errs = screen.getAllByText('×8,594');
expect(errs).toHaveLength(2);
});
it('every card carries a real trigger label, not undefined', () => {
const { container } = render(<Agents />);
const cards = container.querySelectorAll('button[aria-pressed]');
expect(cards).toHaveLength(9);
cards.forEach((card) => {
const text = within(card).getByText(/NATS event|NATS pull|JARVIS task|In-process/);
expect(text).toBeInTheDocument();
});
const diagnostics = screen.getByText('System Diagnostics').closest('div.flex-col');
expect(within(diagnostics).getByText('8,594 occurrences')).toBeInTheDocument();
});
});