Files
wehub-resource-sync 23f7624596
ADR-166 MCP Bridge Security Lock / Static-source security lock (push) Failing after 0s
ADR-166 MCP Bridge Security Lock / Compose default binds loopback + Mongo has auth (push) Failing after 2s
CodeQL Advanced / Analyze (rust) (push) Failing after 0s
ADR-166 MCP Bridge Security Lock / plugin-agent-federation bindHost default (push) Failing after 1s
ADR-166 MCP Bridge Security Lock / Runtime behavior — 401 + terminal gate + fail-closed (push) Failing after 4s
business-pods-smoke / smoke (push) Failing after 1s
all-plugins-smoke / smoke-all (push) Failing after 2s
CI/CD Pipeline / Security & Code Quality (push) Failing after 1s
CI/CD Pipeline / Test Suite (ubuntu-latest) (push) Failing after 1s
CI/CD Pipeline / Build & Package (macos-latest) (push) Has been skipped
CI/CD Pipeline / Build & Package (ubuntu-latest) (push) Has been skipped
CI/CD Pipeline / Build & Package (windows-latest) (push) Has been skipped
CI/CD Pipeline / Documentation & Examples (push) Failing after 1s
Clone Tracker (14-day rolling) / Snapshot clones for ruflo ecosystem (push) Failing after 1s
CodeQL Advanced / Analyze (actions) (push) Failing after 1s
CodeQL Advanced / Analyze (javascript-typescript) (push) Failing after 1s
federation-peer-rust / stable-noop (push) Failing after 1s
metaharness-ci / score (push) Failing after 1s
metaharness-ci / router-compat (push) Failing after 0s
metaharness-ci / similarity-tests (push) Failing after 0s
no-agentbbs-smoke / smoke-without-agentbbs (push) Failing after 1s
V3 CI/CD Pipeline / Build V3 (windows-latest) (push) Has been skipped
codex-integration-audit / Codex integration audit (push) Failing after 1s
helpers-manifest-guard / guard (push) Failing after 1s
🔗 Cross-Agent Integration Tests / 🤝 Agent Coordination Tests (push) Has been skipped
🔗 Cross-Agent Integration Tests / 🧠 Memory Sharing Integration (push) Has been skipped
🔗 Cross-Agent Integration Tests / 🛡️ Fault Tolerance Tests (push) Has been skipped
🔗 Cross-Agent Integration Tests / ⚡ Performance Integration Tests (push) Has been skipped
metaharness-ci / mcp-scan (push) Failing after 1s
metaharness-ci / eject-dryrun (push) Failing after 1s
metaharness-ci / metaharness-real-data (push) Failing after 0s
no-cli-optdep-bloat-2561 / guard (push) Failing after 1s
no-metaharness-smoke / smoke-without-metaharness (push) Failing after 1s
no-phantom-agentic-flow-subpath / guard (push) Failing after 1s
🔄 Automated Rollback Manager / 🚨 Failure Detection (push) Failing after 1s
V3 CI/CD Pipeline / Plugin hooks smoke / ubuntu-latest / Node 22 (push) Failing after 1s
V3 CI/CD Pipeline / ruflo-graph-intelligence build + test smoke (#2044, ADR-123) (push) Failing after 1s
CVE Audit Gate / Audit root (critical-blocking) (push) Failing after 2s
cost-tracker-smoke / smoke (push) Failing after 3s
oia-audit-weekly / audit (push) Failing after 2s
ruflo-agent-smoke / ruflo-agent structural smoke (push) Failing after 1s
📊 Status Badges Update / 📊 Update Status Badges (push) Failing after 1s
V3 CI/CD Pipeline / Static regression guards (#2267 YAML + (push) Failing after 1s
V3 CI/CD Pipeline / Test V3 Packages (push) Failing after 0s
V3 CI/CD Pipeline / agent_execute provider routing smoke (#2042) (push) Failing after 0s
CVE Audit Gate / Audit v3 (critical-blocking) (push) Failing after 1s
federation-peer-rust / stable-native (push) Failing after 2s
🔗 Cross-Agent Integration Tests / 🚀 Integration Test Setup (push) Failing after 2s
neural-trader-smoke / runtime-smoke (push) Failing after 1s
V3 CI/CD Pipeline / Build V3 (macos-latest) (push) Has been skipped
V3 CI/CD Pipeline / Build V3 (ubuntu-latest) (push) Has been skipped
V3 CI/CD Pipeline / Type Check V3 (push) Failing after 1s
V3 CI/CD Pipeline / Smoke (no better-sqlite3) / ubuntu-latest / Node 24 (push) Failing after 1s
V3 CI/CD Pipeline / Smoke (no better-sqlite3) / ubuntu-latest / Node 22 (push) Failing after 2s
V3 CI/CD Pipeline / browser rvf create flag smoke (#2015) (push) Failing after 0s
V3 CI/CD Pipeline / Dependency review (#2046) (push) Has been skipped
V3 CI/CD Pipeline / Supply-chain audit (#2046) (push) Failing after 0s
V3 CI/CD Pipeline / witness marker drift smoke (#2021) (push) Failing after 1s
V3 CI/CD Pipeline / neural-trader portfolio CG smoke (#2068, ADR-126 Phase 3) (push) Failing after 1s
V3 CI/CD Pipeline / neural-trader backtest signing smoke (#2068, ADR-126 Phase 4) (push) Failing after 1s
V3 CI/CD Pipeline / kg-extract type-import classification smoke (#2049) (push) Failing after 0s
V3 CI/CD Pipeline / witness verify precondition smoke (#1880) (push) Failing after 2s
V3 CI/CD Pipeline / neural-trader pipeline risk-gate smoke (#2068, ADR-126 Phase 5) (push) Failing after 0s
V3 CI/CD Pipeline / neural-trader feature attribution smoke (#2068, ADR-126 Phase 6) (push) Failing after 0s
V3 CI/CD Pipeline / plugin-registry signature verification smoke (#1922, CWE-347) (push) Failing after 4s
V3 CI/CD Pipeline / memory stats legacy-DB smoke (#2120) (push) Failing after 4s
V3 CI/CD Pipeline / github deprecated actions smoke (#2089, ADR-127 Phase 3) (push) Failing after 1s
V3 CI/CD Pipeline / graph query + pathfinder smoke (ADR-130 P2+P5) (push) Has been skipped
V3 CI/CD Pipeline / graph trajectory hooks smoke (ADR-130 P3) (push) Has been skipped
V3 CI/CD Pipeline / graph plugin adapter smoke (ADR-130 P4) (push) Has been skipped
V3 CI/CD Pipeline / graph benchmark (ADR-130 P6) (push) Has been skipped
V3 CI/CD Pipeline / statusline generator delegation smoke (#2195) (push) Failing after 1s
V3 CI/CD Pipeline / wizard init regression guard (#2206 (push) Failing after 1s
V3 CI/CD Pipeline / memory no-stray-db smoke (ADR-125 P7) (push) Failing after 1s
V3 CI/CD Pipeline / github-safe injection smoke (#2089, ADR-127 Phase 1) (push) Failing after 1s
V3 CI/CD Pipeline / github actions pin smoke (#2089, ADR-127 Phase 1) (push) Failing after 1s
V3 CI/CD Pipeline / github attribution opt-in smoke (#2089, ADR-127 Phase 4) (push) Failing after 1s
V3 CI/CD Pipeline / pre-bash hook safety smoke (#2017) (push) Failing after 1s
V3 CI/CD Pipeline / Memory import smoke / ubuntu-latest (push) Failing after 0s
V3 CI/CD Pipeline / MCP protocol smoke / ubuntu-latest (push) Failing after 2s
V3 CI/CD Pipeline / ruvllm WASM auto-init smoke (#2086) (push) Failing after 4s
V3 CI/CD Pipeline / MCP paired-tool round-trip smoke (#1889) (push) Failing after 1s
V3 CI/CD Pipeline / Plugin package install-safety (#1902/#1903/#1904) (push) Failing after 1s
V3 CI/CD Pipeline / Tool description discoverability (ADR-112) (push) Failing after 3s
V3 CI/CD Pipeline / CLI npx-install smoke (#1147 / (22) (push) Failing after 1s
V3 CI/CD Pipeline / CLI npx-install smoke (#1147 / (24) (push) Failing after 1s
V3 CI/CD Pipeline / Windows hook shim smoke (#2132) / ubuntu-latest (push) Failing after 2s
V3 CI/CD Pipeline / Windows hook execution smoke (#2132) / ubuntu-latest (push) Failing after 1s
V3 CI/CD Pipeline / Windows init hooks smoke (#2132) / ubuntu-latest (push) Failing after 1s
V3 CI/CD Pipeline / Vector-index dimension audit (#1947) (push) Failing after 0s
V3 CI/CD Pipeline / Hook-command install safety (#1921) (push) Failing after 1s
V3 CI/CD Pipeline / ToolOutputGuardrail smoke (ADR-131, (push) Failing after 1s
V3 CI/CD Pipeline / init-bundle invariants smoke (#2095, ADR-128 Phase 5) (push) Failing after 1s
V3 CI/CD Pipeline / wasm provider bridge smoke (ADR-129 P1) (push) Failing after 2s
V3 CI/CD Pipeline / wasm gallery CRUD smoke (ADR-129 P3) (push) Failing after 1s
V3 CI/CD Pipeline / wasm plugin bridge smoke (ADR-129 P4) (push) Failing after 0s
V3 CI/CD Pipeline / wasm compose smoke (ADR-129 P2) (push) Failing after 4s
V3 CI/CD Pipeline / graph schema smoke (ADR-130 P1) (push) Failing after 0s
Validate Marketplace / validate (push) Failing after 1s
🔍 Verification Pipeline / 🚀 Setup Verification (push) Failing after 1s
🔍 Verification Pipeline / 🛡️ Security Verification (push) Has been skipped
🔍 Verification Pipeline / 📝 Code Quality (push) Has been skipped
🔍 Verification Pipeline / 🧪 Test Verification (${{ matrix.os }}, Node ${{ matrix.node }}) (push) Has been skipped
🔍 Verification Pipeline / 🏗️ Build Verification (push) Has been skipped
🔍 Verification Pipeline / 📚 Documentation Verification (push) Has been skipped
CVE Audit Gate / High-severity report (warn only) (push) Has been cancelled
🔄 Automated Rollback Manager / 🔄 Execute Rollback (push) Has been cancelled
🔄 Automated Rollback Manager / ✅ Post-Rollback Verification (push) Has been cancelled
🔄 Automated Rollback Manager / 📊 Rollback Monitoring (push) Has been cancelled
V3 CI/CD Pipeline / Windows init hooks smoke (#2132) / windows-latest (push) Has been cancelled
V3 CI/CD Pipeline / Windows hook execution smoke (#2132) / macos-latest (push) Has been cancelled
V3 CI/CD Pipeline / Windows hook execution smoke (#2132) / windows-latest (push) Has been cancelled
🔄 Automated Rollback Manager / ⏳ Manual Rollback Approval (push) Has been cancelled
V3 CI/CD Pipeline / MCP protocol smoke / macos-latest (push) Has been cancelled
V3 CI/CD Pipeline / Memory import smoke / macos-latest (push) Has been cancelled
V3 CI/CD Pipeline / Windows hook shim smoke (#2132) / macos-latest (push) Has been cancelled
V3 CI/CD Pipeline / Windows hook shim smoke (#2132) / windows-latest (push) Has been cancelled
V3 CI/CD Pipeline / Windows init hooks smoke (#2132) / macos-latest (push) Has been cancelled
V3 CI/CD Pipeline / Witness verify (signed manifest) / macos-latest (push) Has been cancelled
V3 CI/CD Pipeline / Witness verify (signed manifest) / ubuntu-latest (push) Has been cancelled
V3 CI/CD Pipeline / Witness verify (signed manifest) / windows-latest (push) Has been cancelled
V3 CI/CD Pipeline / Publish to npm (alpha) (push) Has been cancelled
V3 CI/CD Pipeline / Smoke (no better-sqlite3) / macos-latest / Node 22 (push) Has been cancelled
V3 CI/CD Pipeline / Plugin hooks smoke / macos-latest / Node 22 (push) Has been cancelled
CI/CD Pipeline / Deploy & Release (push) Has been cancelled
CI/CD Pipeline / CI Status (push) Has been cancelled
🔗 Cross-Agent Integration Tests / 📊 Integration Test Report (push) Has been cancelled
🔄 Automated Rollback Manager / 🔍 Pre-Rollback Validation (push) Has been cancelled
🔍 Verification Pipeline / ⚡ Performance Verification (push) Has been cancelled
🔍 Verification Pipeline / 📊 Verification Report (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:02:19 +08:00

592 lines
17 KiB
TypeScript

/**
* Agentic-QE Plugin Lifecycle Tests
*
* Tests for the agentic-qe plugin initialization, configuration,
* shutdown, and health check functionality.
*/
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
// ============================================================================
// Mock Types (until implementation exists)
// ============================================================================
interface PluginMetadata {
name: string;
version: string;
description?: string;
author?: string;
license?: string;
dependencies?: string[];
tags?: string[];
minCoreVersion?: string;
}
interface PluginContext {
config: {
enabled: boolean;
priority: number;
settings: Record<string, unknown>;
};
eventBus: {
emit: (event: string, data?: unknown) => void;
on: (event: string, handler: (data: unknown) => void) => () => void;
off: (event: string, handler: (data: unknown) => void) => void;
};
logger: {
debug: (msg: string, ...args: unknown[]) => void;
info: (msg: string, ...args: unknown[]) => void;
warn: (msg: string, ...args: unknown[]) => void;
error: (msg: string, ...args: unknown[]) => void;
};
services: Map<string, unknown>;
coreVersion: string;
dataDir: string;
}
interface MCPToolDefinition {
name: string;
description: string;
inputSchema: Record<string, unknown>;
handler: (input: unknown) => Promise<{ content: Array<{ type: string; text: string }> }>;
}
type PluginState = 'uninitialized' | 'initializing' | 'initialized' | 'error' | 'shutdown';
// ============================================================================
// Mock Plugin Implementation
// ============================================================================
class MockAQEPlugin {
public metadata: PluginMetadata;
public state: PluginState = 'uninitialized';
private context?: PluginContext;
private tools: MCPToolDefinition[] = [];
private bridges: Map<string, unknown> = new Map();
constructor(metadata: Partial<PluginMetadata> = {}) {
this.metadata = Object.freeze({
name: 'agentic-qe',
version: '3.2.3',
description: 'Quality Engineering plugin for Claude Flow V3',
author: 'rUv',
license: 'MIT',
dependencies: [
'@claude-flow/plugins',
'@claude-flow/memory',
'@claude-flow/security',
'@claude-flow/embeddings',
],
tags: ['testing', 'quality', 'coverage', 'security', 'tdd'],
minCoreVersion: '3.0.0-alpha.50',
...metadata,
});
}
async initialize(context: PluginContext): Promise<void> {
if (this.state === 'initialized') {
throw new Error('Plugin already initialized');
}
this.state = 'initializing';
this.context = context;
try {
// Validate core version
if (!this.isVersionCompatible(context.coreVersion)) {
throw new Error(`Core version ${context.coreVersion} is not compatible with minimum required ${this.metadata.minCoreVersion}`);
}
// Initialize bridges
await this.initializeBridges();
// Register tools
this.tools = this.createTools();
this.state = 'initialized';
context.logger.info(`${this.metadata.name} initialized successfully`);
} catch (error) {
this.state = 'error';
throw error;
}
}
async shutdown(): Promise<void> {
if (this.state !== 'initialized') {
return;
}
// Cleanup bridges
for (const [name, bridge] of this.bridges) {
if (typeof (bridge as any)?.dispose === 'function') {
await (bridge as any).dispose();
}
}
this.bridges.clear();
// Clear tools
this.tools = [];
this.state = 'shutdown';
this.context?.logger.info(`${this.metadata.name} shut down`);
}
async healthCheck(): Promise<{
healthy: boolean;
status: string;
checks: Record<string, { healthy: boolean; message?: string }>;
}> {
const checks: Record<string, { healthy: boolean; message?: string }> = {
state: {
healthy: this.state === 'initialized',
message: `Plugin state: ${this.state}`,
},
bridges: {
healthy: this.bridges.size > 0,
message: `${this.bridges.size} bridges active`,
},
tools: {
healthy: this.tools.length > 0,
message: `${this.tools.length} tools registered`,
},
};
const healthy = Object.values(checks).every((c) => c.healthy);
return {
healthy,
status: healthy ? 'healthy' : 'unhealthy',
checks,
};
}
registerMCPTools(): MCPToolDefinition[] {
return this.tools;
}
getConfig(): Record<string, unknown> {
return this.context?.config.settings ?? {};
}
getBridge(name: string): unknown {
return this.bridges.get(name);
}
private async initializeBridges(): Promise<void> {
// Mock bridge initialization
this.bridges.set('memory', { type: 'QEMemoryBridge', connected: true });
this.bridges.set('security', { type: 'QESecurityBridge', connected: true });
this.bridges.set('core', { type: 'QECoreBridge', connected: true });
this.bridges.set('hive', { type: 'QEHiveBridge', connected: true });
}
private createTools(): MCPToolDefinition[] {
return [
{
name: 'aqe/generate-tests',
description: 'Generate tests for code using AI-powered test generation',
inputSchema: {
type: 'object',
properties: {
targetPath: { type: 'string' },
testType: { type: 'string', enum: ['unit', 'integration', 'e2e'] },
framework: { type: 'string', enum: ['vitest', 'jest', 'mocha'] },
},
required: ['targetPath'],
},
handler: async (input) => ({
content: [{ type: 'text', text: JSON.stringify({ status: 'generated', input }) }],
}),
},
{
name: 'aqe/analyze-coverage',
description: 'Analyze code coverage with O(log n) gap detection',
inputSchema: {
type: 'object',
properties: {
coverageReport: { type: 'string' },
targetPath: { type: 'string' },
algorithm: { type: 'string', enum: ['johnson-lindenstrauss', 'naive'] },
},
required: ['coverageReport'],
},
handler: async (input) => ({
content: [{ type: 'text', text: JSON.stringify({ status: 'analyzed', input }) }],
}),
},
{
name: 'aqe/security-scan',
description: 'Run SAST/DAST security scans',
inputSchema: {
type: 'object',
properties: {
targetPath: { type: 'string' },
scanType: { type: 'string', enum: ['sast', 'dast', 'both'] },
compliance: { type: 'array', items: { type: 'string' } },
},
required: ['targetPath'],
},
handler: async (input) => ({
content: [{ type: 'text', text: JSON.stringify({ status: 'scanned', input }) }],
}),
},
{
name: 'aqe/chaos-inject',
description: 'Inject chaos failures for resilience testing',
inputSchema: {
type: 'object',
properties: {
target: { type: 'string' },
failureType: { type: 'string' },
duration: { type: 'number' },
intensity: { type: 'number', minimum: 0, maximum: 1 },
dryRun: { type: 'boolean', default: true },
},
required: ['target', 'failureType'],
},
handler: async (input) => ({
content: [{ type: 'text', text: JSON.stringify({ status: 'injected', input }) }],
}),
},
];
}
private isVersionCompatible(coreVersion: string): boolean {
// Simple version check - in real impl would use semver
const minVersion = this.metadata.minCoreVersion?.replace(/-.*$/, '') ?? '0.0.0';
const current = coreVersion.replace(/-.*$/, '');
return current >= minVersion;
}
}
// ============================================================================
// Test Helpers
// ============================================================================
function createMockContext(overrides: Partial<PluginContext> = {}): PluginContext {
return {
config: {
enabled: true,
priority: 50,
settings: {
defaultFramework: 'vitest',
coverageTarget: 80,
tddStyle: 'london',
},
},
eventBus: {
emit: vi.fn(),
on: vi.fn(() => vi.fn()),
off: vi.fn(),
},
logger: {
debug: vi.fn(),
info: vi.fn(),
warn: vi.fn(),
error: vi.fn(),
},
services: new Map(),
coreVersion: '3.0.0',
dataDir: '/tmp/agentic-qe',
...overrides,
};
}
// ============================================================================
// Tests
// ============================================================================
describe('AQEPlugin', () => {
let plugin: MockAQEPlugin;
let context: PluginContext;
beforeEach(() => {
plugin = new MockAQEPlugin();
context = createMockContext();
});
afterEach(async () => {
if (plugin.state === 'initialized') {
await plugin.shutdown();
}
});
describe('metadata', () => {
it('should have correct plugin name', () => {
expect(plugin.metadata.name).toBe('agentic-qe');
});
it('should have correct version', () => {
expect(plugin.metadata.version).toBe('3.2.3');
});
it('should have required dependencies', () => {
expect(plugin.metadata.dependencies).toContain('@claude-flow/plugins');
expect(plugin.metadata.dependencies).toContain('@claude-flow/memory');
expect(plugin.metadata.dependencies).toContain('@claude-flow/security');
});
it('should have expected tags', () => {
expect(plugin.metadata.tags).toContain('testing');
expect(plugin.metadata.tags).toContain('quality');
expect(plugin.metadata.tags).toContain('tdd');
});
it('should freeze metadata', () => {
expect(Object.isFrozen(plugin.metadata)).toBe(true);
});
it('should specify minimum core version', () => {
expect(plugin.metadata.minCoreVersion).toBe('3.0.0-alpha.50');
});
});
describe('initialization', () => {
it('should start in uninitialized state', () => {
expect(plugin.state).toBe('uninitialized');
});
it('should initialize successfully with valid context', async () => {
await plugin.initialize(context);
expect(plugin.state).toBe('initialized');
});
it('should log initialization success', async () => {
await plugin.initialize(context);
expect(context.logger.info).toHaveBeenCalledWith(
expect.stringContaining('initialized successfully')
);
});
it('should reject double initialization', async () => {
await plugin.initialize(context);
await expect(plugin.initialize(context)).rejects.toThrow('already initialized');
});
it('should reject incompatible core version', async () => {
const oldVersionContext = createMockContext({ coreVersion: '2.0.0' });
await expect(plugin.initialize(oldVersionContext)).rejects.toThrow('not compatible');
expect(plugin.state).toBe('error');
});
it('should accept compatible core versions', async () => {
const contexts = [
createMockContext({ coreVersion: '3.0.0' }),
createMockContext({ coreVersion: '3.1.0' }),
createMockContext({ coreVersion: '4.0.0' }),
];
for (const ctx of contexts) {
const p = new MockAQEPlugin();
await p.initialize(ctx);
expect(p.state).toBe('initialized');
await p.shutdown();
}
});
it('should initialize all bridges', async () => {
await plugin.initialize(context);
expect(plugin.getBridge('memory')).toBeDefined();
expect(plugin.getBridge('security')).toBeDefined();
expect(plugin.getBridge('core')).toBeDefined();
expect(plugin.getBridge('hive')).toBeDefined();
});
});
describe('shutdown', () => {
it('should shutdown gracefully', async () => {
await plugin.initialize(context);
await plugin.shutdown();
expect(plugin.state).toBe('shutdown');
});
it('should clear bridges on shutdown', async () => {
await plugin.initialize(context);
await plugin.shutdown();
expect(plugin.getBridge('memory')).toBeUndefined();
});
it('should be safe to call shutdown multiple times', async () => {
await plugin.initialize(context);
await plugin.shutdown();
await plugin.shutdown(); // Should not throw
expect(plugin.state).toBe('shutdown');
});
it('should be safe to shutdown uninitialized plugin', async () => {
await plugin.shutdown(); // Should not throw
expect(plugin.state).toBe('uninitialized');
});
});
describe('health check', () => {
it('should report healthy when initialized', async () => {
await plugin.initialize(context);
const health = await plugin.healthCheck();
expect(health.healthy).toBe(true);
expect(health.status).toBe('healthy');
});
it('should report unhealthy when not initialized', async () => {
const health = await plugin.healthCheck();
expect(health.healthy).toBe(false);
expect(health.status).toBe('unhealthy');
});
it('should include state check', async () => {
await plugin.initialize(context);
const health = await plugin.healthCheck();
expect(health.checks.state.healthy).toBe(true);
});
it('should include bridges check', async () => {
await plugin.initialize(context);
const health = await plugin.healthCheck();
expect(health.checks.bridges.healthy).toBe(true);
expect(health.checks.bridges.message).toContain('bridges active');
});
it('should include tools check', async () => {
await plugin.initialize(context);
const health = await plugin.healthCheck();
expect(health.checks.tools.healthy).toBe(true);
expect(health.checks.tools.message).toContain('tools registered');
});
});
describe('MCP tools', () => {
it('should register MCP tools after initialization', async () => {
await plugin.initialize(context);
const tools = plugin.registerMCPTools();
expect(tools.length).toBeGreaterThan(0);
});
it('should include generate-tests tool', async () => {
await plugin.initialize(context);
const tools = plugin.registerMCPTools();
const generateTool = tools.find((t) => t.name === 'aqe/generate-tests');
expect(generateTool).toBeDefined();
expect(generateTool?.description).toContain('Generate tests');
});
it('should include analyze-coverage tool', async () => {
await plugin.initialize(context);
const tools = plugin.registerMCPTools();
const coverageTool = tools.find((t) => t.name === 'aqe/analyze-coverage');
expect(coverageTool).toBeDefined();
expect(coverageTool?.description).toContain('coverage');
});
it('should include security-scan tool', async () => {
await plugin.initialize(context);
const tools = plugin.registerMCPTools();
const securityTool = tools.find((t) => t.name === 'aqe/security-scan');
expect(securityTool).toBeDefined();
expect(securityTool?.description).toContain('security');
});
it('should include chaos-inject tool', async () => {
await plugin.initialize(context);
const tools = plugin.registerMCPTools();
const chaosTool = tools.find((t) => t.name === 'aqe/chaos-inject');
expect(chaosTool).toBeDefined();
expect(chaosTool?.description).toContain('chaos');
});
it('should have valid input schemas', async () => {
await plugin.initialize(context);
const tools = plugin.registerMCPTools();
for (const tool of tools) {
expect(tool.inputSchema).toBeDefined();
expect(tool.inputSchema.type).toBe('object');
expect(tool.inputSchema.properties).toBeDefined();
}
});
it('should have working handlers', async () => {
await plugin.initialize(context);
const tools = plugin.registerMCPTools();
const tool = tools[0];
const result = await tool.handler({ targetPath: '/test' });
expect(result.content).toBeDefined();
expect(result.content[0].type).toBe('text');
});
});
describe('configuration', () => {
it('should access plugin settings', async () => {
await plugin.initialize(context);
const config = plugin.getConfig();
expect(config.defaultFramework).toBe('vitest');
expect(config.coverageTarget).toBe(80);
expect(config.tddStyle).toBe('london');
});
it('should return empty config when not initialized', () => {
const config = plugin.getConfig();
expect(config).toEqual({});
});
});
});
describe('AQEPlugin Error Handling', () => {
it('should handle bridge initialization failure gracefully', async () => {
// This tests error state handling
const plugin = new MockAQEPlugin();
const badContext = createMockContext({ coreVersion: '1.0.0' });
await expect(plugin.initialize(badContext)).rejects.toThrow();
expect(plugin.state).toBe('error');
});
it('should allow re-creation after error', async () => {
const plugin1 = new MockAQEPlugin();
const badContext = createMockContext({ coreVersion: '1.0.0' });
await expect(plugin1.initialize(badContext)).rejects.toThrow();
// Create new instance and try again
const plugin2 = new MockAQEPlugin();
const goodContext = createMockContext();
await plugin2.initialize(goodContext);
expect(plugin2.state).toBe('initialized');
});
});