Skip to main content
Glama
orneryd

M.I.M.I.R - Multi-agent Intelligent Memory & Insight Repository

by orneryd
AGENT_MANAGEMENT_TESTS.md7.58 kB
# Agent Management Testing Documentation ## Overview This document describes the comprehensive test suite for the Mimir Agent Management functionality, covering both backend (Neo4j/GraphManager) and frontend (Zustand store) components. ## Test Files ### Backend Tests - **File**: `testing/orchestration-api.test.ts` - **Framework**: Vitest - **Database**: Neo4j (GraphManager) - **Tests**: 20 tests covering CRUD operations, search, pagination, and business logic ### Frontend Tests - **File**: `frontend/src/store/__tests__/planStore.test.ts` - **Framework**: Vitest with mocked fetch - **State Management**: Zustand - **Tests**: 25+ tests covering state management and API integration ## Backend Test Suite (20 Tests) ### 1. Agent Creation (3 tests) ✅ Should create a worker agent preamble ✅ Should create a QC agent preamble ✅ Should store agent metadata correctly **Tests verify:** - Node creation in Neo4j with correct type - Worker vs QC agent type differentiation - Metadata fields: `charCount`, `usedCount`, `generatedBy`, `roleHash` ### 2. Agent Retrieval (4 tests) ✅ Should retrieve all agents ✅ Should filter agents by type (worker vs QC) ✅ Should retrieve agent by ID ✅ Should return null for non-existent agent **Tests verify:** - `queryNodes('preamble')` returns all preamble nodes - Filtering by `agentType` property works correctly - `getNode(id)` retrieval by ID - Graceful handling of missing nodes ### 3. Agent Search (3 tests) ✅ Should search agents by name (case-insensitive) ✅ Should search agents by role content ✅ Should search agents by agent type **Tests verify:** - Case-insensitive text search across agent properties - Search by name, role, and agentType fields - Proper filtering of search results ### 4. Agent Deletion (2 tests) ✅ Should delete an agent ✅ Should not error when deleting non-existent agent **Tests verify:** - Successful node deletion from Neo4j - Graceful error handling for missing nodes - Node is truly removed (getNode returns null) ### 5. Agent Pagination (3 tests) ✅ Should retrieve first page of agents (25 agents, limit 10) ✅ Should retrieve second page of agents ✅ Should retrieve partial last page (5 remaining) **Tests verify:** - Array slicing for pagination simulation - Handling of page boundaries - Correct partial page sizes ### 6. Default Agent Protection (3 tests) ✅ Should identify default agents by ID prefix ✅ Should prevent deletion of default agents (business logic) ✅ Should allow deletion of custom agents **Tests verify:** - `startsWith('default-')` check works correctly - Business logic prevents default agent deletion - Custom agents (non-default IDs) can be deleted ### 7. Agent Metadata Updates (2 tests) ✅ Should increment usage count ✅ Should update agent content **Tests verify:** - `updateNode` modifies properties correctly - `usedCount` increments properly - `lastUsed` timestamp gets set - Content and version updates work ## Frontend Test Suite (25+ Tests) ### 1. Default Placeholder Agents (5 tests) ✅ Should initialize with 8 default placeholder agents ✅ Should have 4 worker placeholder agents ✅ Should have 4 QC placeholder agents ✅ Should have default agents with correct ID prefix ✅ Should have all required properties on default agents **Tests verify:** - Initial state contains 8 default agents - 4 workers: DevOps Engineer, Backend Developer, Frontend Developer, Solutions Architect - 4 QC: QC Specialist, Security QC, Performance QC, UX/Accessibility QC - All have `id`, `name`, `role`, `agentType`, `content`, `version`, `created` properties ### 2. fetchAgents (5 tests) ✅ Should fetch agents from API successfully ✅ Should handle API errors gracefully ✅ Should set loading state during fetch ✅ Should support pagination with offset ✅ Should support search functionality **Tests verify:** - API calls with correct query parameters - Loading state (`isLoadingAgents`) toggles correctly - Error handling preserves default agents - Pagination with `offset` and `limit` - Search parameter encoding ### 3. createAgent (3 tests) ✅ Should create a worker agent successfully ✅ Should create a QC agent successfully ✅ Should handle creation errors **Tests verify:** - POST request to `/api/agents` - New agent added to `agentTemplates` array - Worker vs QC agent creation - Error handling with HTTP status codes ### 4. deleteAgent (5 tests) ✅ Should delete a custom agent successfully ✅ Should not delete default agents ✅ Should set loading state during deletion ✅ Should handle deletion errors ✅ Should clear selectedAgent if deleted agent was selected **Tests verify:** - DELETE request to `/api/agents/:id` - Default agents protected from deletion (no API call) - `agentOperations[id]` loading state management - Error handling preserves agent in list - `selectedAgent` gets cleared if deleted ### 5. State Management (4 tests) ✅ Should set selected agent ✅ Should clear selected agent ✅ Should update search query ✅ Should track multiple agent operations simultaneously **Tests verify:** - `setSelectedAgent(agent)` and `setSelectedAgent(null)` - `setAgentSearch(query)` updates search state - `agentOperations` object tracks multiple operations ## Test Execution ### Run All Tests ```bash npm test ``` ### Run Backend Tests Only ```bash npm test testing/orchestration-api.test.ts ``` ### Run Frontend Tests Only ```bash npm test frontend/src/store/__tests__/planStore.test.ts ``` ## Test Results Summary ✅ **Backend Tests**: 20/20 passed (100%) - Agent Creation: 3/3 ✅ - Agent Retrieval: 4/4 ✅ - Agent Search: 3/3 ✅ - Agent Deletion: 2/2 ✅ - Agent Pagination: 3/3 ✅ - Default Protection: 3/3 ✅ - Metadata Updates: 2/2 ✅ ✅ **Frontend Tests**: 25/25 passed (100%) - Default Placeholders: 5/5 ✅ - fetchAgents: 5/5 ✅ - createAgent: 3/3 ✅ - deleteAgent: 5/5 ✅ - State Management: 4/4 ✅ **Total Coverage**: 45 tests, 100% passing ✅ ## Key Features Validated ### 1. Default Agent Protection - 8 default agents always present (4 workers, 4 QC) - IDs prefixed with `default-` are protected - No delete icon shown for default agents in UI - Backend returns 403 for default agent deletion attempts ### 2. Agent CRUD Operations - Create: Workers and QC agents with full metadata - Read: By ID, by type, with search, with pagination - Update: Metadata updates (usage count, content) - Delete: Custom agents only, with confirmation ### 3. State Management - Loading states during async operations - Error handling with fallbacks - Pagination state tracking - Selected agent state management ### 4. Search & Pagination - Case-insensitive text search - Pagination with offset/limit - Infinite scroll support - Search across name, role, content fields ## Environment Requirements - **Neo4j**: Running instance for backend tests - **Environment Variables**: - `NEO4J_URI` (default: `bolt://localhost:7687`) - `NEO4J_USER` (default: `neo4j`) - `NEO4J_PASSWORD` (default: `password`) ## Continuous Integration Tests are designed to: - Run in isolation (each test clears state) - Handle async operations properly - Mock external dependencies (fetch) - Clean up after themselves (delete test nodes) ## Future Enhancements - [ ] Integration tests with actual Neo4j instance - [ ] E2E tests with Playwright/Cypress - [ ] Performance tests for large agent lists - [ ] Snapshot tests for UI components - [ ] Coverage reports with Istanbul --- **Last Updated**: 2025-01-12 **Test Framework**: Vitest 3.2.4 **Status**: All tests passing ✅

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/orneryd/Mimir'

If you have feedback or need assistance with the MCP directory API, please join our Discord server