/**
* Test Data Generators
*
* Provides realistic test data for MCP requests and responses
* using the shared types from askme-shared package.
*/
import {
QueuedRequest,
MultipleChoiceQuestion,
HypothesisChallenge,
ChooseNextChallenge
} from '@ask-me-mcp/askme-shared';
/**
* Generate a single question request
*/
export function createSingleQuestionRequest(overrides: Partial<QueuedRequest> = {}): QueuedRequest {
return {
id: `test-single-${Date.now()}`,
question: 'What is the best approach for implementing user authentication in a microservices architecture?',
context: null,
status: 'pending',
timestamp: new Date(),
type: 'single-question',
...overrides
};
}
/**
* Generate a multiple choice request
*/
export function createMultipleChoiceRequest(overrides: Partial<QueuedRequest> = {}): QueuedRequest {
const questions: MultipleChoiceQuestion[] = [
{
id: 'q1',
text: 'Which programming languages do you prefer for backend development?',
options: [
{ id: 'opt1-1', text: 'Python', selected: false },
{ id: 'opt1-2', text: 'JavaScript/Node.js', selected: false },
{ id: 'opt1-3', text: 'Java', selected: false },
{ id: 'opt1-4', text: 'Go', selected: false },
{ id: 'opt1-5', text: 'Rust', selected: false }
]
},
{
id: 'q2',
text: 'What database type fits your project requirements?',
options: [
{ id: 'opt2-1', text: 'PostgreSQL', selected: false },
{ id: 'opt2-2', text: 'MongoDB', selected: false },
{ id: 'opt2-3', text: 'Redis', selected: false },
{ id: 'opt2-4', text: 'Elasticsearch', selected: false }
]
}
];
return {
id: `test-multiple-${Date.now()}`,
question: 'Technical Stack Preferences',
context: {
type: 'multiple-choice',
questions
},
status: 'pending',
timestamp: new Date(),
type: 'multiple-choice',
...overrides
};
}
/**
* Generate a hypothesis challenge request
*/
export function createHypothesisChallengeRequest(overrides: Partial<QueuedRequest> = {}): QueuedRequest {
const challenge: HypothesisChallenge = {
id: `challenge-${Date.now()}`,
title: 'Architecture Decision Analysis',
hypotheses: [
{
id: 'h1',
statement: 'Microservices architecture will improve system scalability',
agreementLevel: 0,
comment: '',
wontAnswer: false
},
{
id: 'h2',
statement: 'Event-driven communication reduces coupling between services',
agreementLevel: 0,
comment: '',
wontAnswer: false
},
{
id: 'h3',
statement: 'Container orchestration adds unnecessary complexity',
agreementLevel: 0,
comment: '',
wontAnswer: false
}
],
wontAnswerChallenge: false,
challengeExplanation: ''
};
return {
id: `test-hypothesis-${Date.now()}`,
question: 'Please evaluate these architectural hypotheses',
context: {
type: 'hypothesis-challenge',
challenge
},
status: 'pending',
timestamp: new Date(),
type: 'hypothesis-challenge',
...overrides
};
}
/**
* Generate a choose next request
*/
export function createChooseNextRequest(overrides: Partial<QueuedRequest> = {}): QueuedRequest {
const challenge: ChooseNextChallenge = {
id: `choose-next-${Date.now()}`,
title: 'Project Implementation Strategy',
description: 'Choose the next step for implementing the user management system',
options: [
{
id: 'opt1',
title: 'Start with Authentication Service',
description: 'Implement OAuth 2.0 and JWT token management first',
icon: '🔐'
},
{
id: 'opt2',
title: 'Design Database Schema',
description: 'Create user tables and relationship mappings',
icon: '🗄️'
},
{
id: 'opt3',
title: 'Build API Endpoints',
description: 'Develop REST API for user operations',
icon: '🔌'
},
{
id: 'opt4',
title: 'Create Frontend Components',
description: 'Build login/signup UI components',
icon: '🎨'
}
]
};
return {
id: `test-choose-next-${Date.now()}`,
question: 'What should we implement next?',
context: {
type: 'choose-next',
challenge
},
status: 'pending',
timestamp: new Date(),
type: 'choose-next',
...overrides
};
}
/**
* Generate markdown-formatted question for testing markdown rendering
*/
export function createMarkdownQuestionRequest(): QueuedRequest {
return createSingleQuestionRequest({
question: `# Technical Specification Review
Please review the following **API specification** and provide feedback:
## Endpoints
- \`GET /api/users\` - *List all users*
- \`POST /api/users\` - **Create new user**
- \`PUT /api/users/{id}\` - Update user
### Requirements
1. Authentication required
2. Rate limiting: 100 requests/minute
3. Response format: JSON
> **Note**: This is a *critical* system component
What are your thoughts on this design?`
});
}
/**
* Test data for various scenarios
*/
export const TEST_SCENARIOS = {
SINGLE_QUESTION: createSingleQuestionRequest(),
MULTIPLE_CHOICE: createMultipleChoiceRequest(),
HYPOTHESIS_CHALLENGE: createHypothesisChallengeRequest(),
CHOOSE_NEXT: createChooseNextRequest(),
MARKDOWN_QUESTION: createMarkdownQuestionRequest(),
// Edge cases
LONG_QUESTION: createSingleQuestionRequest({
question: 'This is a very long question that should test how the UI handles extensive text content. '.repeat(10)
}),
EMPTY_CONTEXT: createSingleQuestionRequest({
context: null
}),
URGENT_PRIORITY: createMultipleChoiceRequest({
context: {
type: 'multiple-choice',
questions: [
{
id: 'urgent',
text: 'Urgent decision needed',
options: [
{ id: 'urgent-1', text: 'Option A', selected: false },
{ id: 'urgent-2', text: 'Option B', selected: false }
]
}
]
}
})
} as const;
/**
* Generate test data for performance testing
*/
export function generateLargeMultipleChoiceRequest(questionCount: number = 20): QueuedRequest {
const questions: MultipleChoiceQuestion[] = Array.from({ length: questionCount }, (_, i) => ({
id: `q${i + 1}`,
text: `Question ${i + 1}: What is your preference for option set ${i + 1}?`,
options: [
{ id: `opt${i + 1}-1`, text: `Option A${i}`, selected: false },
{ id: `opt${i + 1}-2`, text: `Option B${i}`, selected: false },
{ id: `opt${i + 1}-3`, text: `Option C${i}`, selected: false },
{ id: `opt${i + 1}-4`, text: `Option D${i}`, selected: false }
]
}));
return {
id: `test-large-${Date.now()}`,
question: `Large Multiple Choice Test (${questionCount} questions)`,
context: {
type: 'multiple-choice',
questions
},
status: 'pending',
timestamp: new Date(),
type: 'multiple-choice'
};
}
/**
* SSE message templates for testing real-time communication
*/
export const SSE_MESSAGES = {
CONNECTED: { type: 'connected' },
NEW_REQUEST: (request: QueuedRequest) => ({ type: 'new_request', request }),
REQUEST_TIMEOUT: { type: 'request_timeout', message: 'Request timed out after 5 minutes' },
REQUEST_CANCELLED: { type: 'request_cancelled', message: 'Request was cancelled by client' },
CONNECTION_ERROR: { type: 'error', message: 'Connection error occurred' }
} as const;