feat(gateway): CommandRegistryService + CommandExecutorService (P8-010) (#178)
ci/woodpecker/push/ci Pipeline was successful
ci/woodpecker/push/ci Pipeline was successful
Co-authored-by: Jason Woltje <[email protected]> Co-committed-by: Jason Woltje <[email protected]>
This commit was merged in pull request #178.
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
import { describe, it, expect, beforeEach } from 'vitest';
|
||||
import { CommandRegistryService } from './command-registry.service.js';
|
||||
import type { CommandDef } from '@mosaic/types';
|
||||
|
||||
const mockCmd: CommandDef = {
|
||||
name: 'test',
|
||||
description: 'Test command',
|
||||
aliases: ['t'],
|
||||
scope: 'core',
|
||||
execution: 'local',
|
||||
available: true,
|
||||
};
|
||||
|
||||
describe('CommandRegistryService', () => {
|
||||
let service: CommandRegistryService;
|
||||
|
||||
beforeEach(() => {
|
||||
service = new CommandRegistryService();
|
||||
});
|
||||
|
||||
it('starts with empty manifest', () => {
|
||||
expect(service.getManifest().commands).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('registers a command', () => {
|
||||
service.registerCommand(mockCmd);
|
||||
expect(service.getManifest().commands).toHaveLength(1);
|
||||
});
|
||||
|
||||
it('updates existing command by name', () => {
|
||||
service.registerCommand(mockCmd);
|
||||
service.registerCommand({ ...mockCmd, description: 'Updated' });
|
||||
expect(service.getManifest().commands).toHaveLength(1);
|
||||
expect(service.getManifest().commands[0]?.description).toBe('Updated');
|
||||
});
|
||||
|
||||
it('onModuleInit registers core commands', () => {
|
||||
service.onModuleInit();
|
||||
const manifest = service.getManifest();
|
||||
expect(manifest.commands.length).toBeGreaterThan(5);
|
||||
expect(manifest.commands.some((c) => c.name === 'model')).toBe(true);
|
||||
expect(manifest.commands.some((c) => c.name === 'help')).toBe(true);
|
||||
});
|
||||
|
||||
it('manifest includes skills array', () => {
|
||||
const manifest = service.getManifest();
|
||||
expect(Array.isArray(manifest.skills)).toBe(true);
|
||||
});
|
||||
|
||||
it('manifest version is 1', () => {
|
||||
expect(service.getManifest().version).toBe(1);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user