task-master-neo-sdlc
Version:
Enhanced task management system with Neo SDLC agents and MCP tools for comprehensive, AI-driven software development lifecycle management.
83 lines (70 loc) • 3.54 kB
JavaScript
import { ProjectSetupAgent } from '../project-setup';
import { KnowledgeGraph } from '../../knowledge-graph'; // Adjust path
import { AgentWorkflowSystem } from '../../agent-workflow'; // Adjust path
// Mocks
const mockKnowledgeGraph = {
addNode: jest.fn(),
findNodes: jest.fn(), // Though not used in current implementation
updateContext: jest.fn() // Though not used in current implementation
};
const mockWorkflow = {};
// Mock potential utils if they were used
// jest.mock('../../utils/scriptRunner', () => ({ run: jest.fn() }));
// jest.mock('../../utils/fsUtils', () => ({
// ensureDirs: jest.fn(),
// writeFile: jest.fn(),
// createLink: jest.fn(),
// updateJsonFile: jest.fn()
// }));
describe('ProjectSetupAgent', () => {
let agent;
beforeEach(() => {
jest.clearAllMocks();
agent = new ProjectSetupAgent(mockKnowledgeGraph, mockWorkflow);
jest.spyOn(console, 'log').mockImplementation(() => {});
});
afterEach(() => {
console.log.mockRestore();
});
it('should generate knowledge graph (placeholder)', async () => {
const projectType = 'React';
const projectRoot = '/path/to/project';
const expectedOutputPath = '.context/initial-knowledge-graph.json';
mockKnowledgeGraph.addNode.mockResolvedValue(undefined);
const outputPath = await agent.generateKnowledgeGraph(projectType, projectRoot);
expect(outputPath).toBe(expectedOutputPath);
// Verify scriptRunner would be called if uncommented
// expect(scriptRunner.run).toHaveBeenCalledWith(projectType, projectRoot, expectedOutputPath);
// Verify file writing would happen if uncommented
// expect(fsUtils.writeFile).toHaveBeenCalledWith(expectedOutputPath, expect.any(String));
// Verify KG nodes were added
expect(mockKnowledgeGraph.addNode).toHaveBeenCalledWith({
id: 'project_root',
type: 'directory',
data: { path: projectRoot, projectType }
});
expect(mockKnowledgeGraph.addNode).toHaveBeenCalledWith({
id: 'generated_kg_file',
type: 'file',
data: { path: expectedOutputPath }
});
});
it('should set up the context directory (placeholder)', async () => {
const projectName = 'TestProject';
const projectDescription = 'A test project';
const kgPath = '.context/initial-knowledge-graph.json';
await agent.setupContextDirectory(projectName, projectDescription, kgPath);
// Verify console logs indicate simulation
expect(console.log).toHaveBeenCalledWith(expect.stringContaining('Simulating creation of directories:'));
expect(console.log).toHaveBeenCalledWith(expect.stringContaining('Simulating creation of files:'));
expect(console.log).toHaveBeenCalledWith(expect.stringContaining('Simulating creation of links:'));
expect(console.log).toHaveBeenCalledWith(expect.stringContaining('Simulating update of index file:'));
// If fsUtils were used, we would verify calls here:
// expect(fsUtils.ensureDirs).toHaveBeenCalled();
// expect(fsUtils.writeFile).toHaveBeenCalledWith('.context/index.md', expect.stringContaining(projectName));
// expect(fsUtils.writeFile).toHaveBeenCalledWith('.context/docs.md', expect.any(String));
// expect(fsUtils.writeFile).toHaveBeenCalledWith('.context/.contextignore', expect.any(String));
// expect(fsUtils.createLink).toHaveBeenCalledWith(kgPath, '.context/knowledge_graph/current.json');
// expect(fsUtils.updateJsonFile).toHaveBeenCalledWith('.context/documentation_index.json', { entries: expect.any(Array) });
});
});