@oliverpople/agency-x
Version:
🚀 **Transform feature requests into production-ready code in seconds**
103 lines (78 loc) • 3.15 kB
text/typescript
import { setVoiceEnabled, speak, isVoiceEnabled } from '../utils/voice';
import { createContext, getContext, resetContext } from '../utils/contextStore';
// Mock the LLM router to avoid requiring real API keys
jest.mock('../llm/llmRouter', () => ({
getLlmClient: jest.fn(() => ({
generate: jest.fn().mockResolvedValue('Mock LLM response for testing')
}))
}));
describe('Voice-Activated Test Flow', () => {
beforeEach(() => {
// Reset context and voice state before each test
resetContext();
setVoiceEnabled(false);
});
afterEach(() => {
// Clean up - disable voice after tests
setVoiceEnabled(false);
});
it('should handle voice activation toggling during workflow', () => {
console.log('🔧 Testing voice activation controls...');
// Test initial state
expect(isVoiceEnabled()).toBe(false);
// Test enabling voice
setVoiceEnabled(true);
expect(isVoiceEnabled()).toBe(true);
speak('Voice is now enabled');
// Test disabling voice
setVoiceEnabled(false);
expect(isVoiceEnabled()).toBe(false);
speak('This should not be spoken'); // This won't actually speak
// Re-enable for confirmation
setVoiceEnabled(true);
expect(isVoiceEnabled()).toBe(true);
speak('Voice controls test completed');
console.log('✅ Voice controls test completed');
});
it('should create context with voice narration', () => {
console.log('📋 Testing context creation with voice narration...');
// Enable voice for this test
setVoiceEnabled(true);
const testFeature = 'Test context creation feature';
speak(`Creating context for: ${testFeature}`);
// Create context
const specId = createContext(testFeature);
// Verify context was created
expect(specId).toBeDefined();
expect(specId).toMatch(/^SPEC-\d{8}-[A-Z0-9]{4}$/);
const context = getContext();
expect(context.specId).toBe(specId);
expect(context.featurePrompt).toBe(testFeature);
console.log(`✅ Context created successfully: ${specId}`);
speak('Context creation test completed successfully');
});
it('should provide voice feedback during development simulation', () => {
console.log('🎙️ Testing voice feedback during development workflow...');
setVoiceEnabled(true);
const testFeature = 'Create a simple hello world API endpoint';
speak('Starting development workflow simulation');
// Create context
const specId = createContext(testFeature);
speak('Context created successfully');
// Simulate development phases with voice feedback
const phases = [
'Product specification phase',
'Development phase starting',
'Testing phase initiated',
'Security review complete',
'Deployment preparation ready'
];
phases.forEach((phase, index) => {
console.log(`📊 Phase ${index + 1}: ${phase}`);
speak(phase);
});
speak('Development workflow simulation completed');
console.log('✅ Voice feedback test completed');
expect(specId).toBeDefined();
});
});