UNPKG

@skyramp/mcp

Version:

Skyramp MCP (Model Context Protocol) Server - AI-powered test generation and execution

267 lines (207 loc) 8.38 kB
import { BASE_SCORES, CONTEXT_RULES } from "../../types/TestMapping.js"; /** * Test Mapping Prompt * Prompt for calculating test priority scores */ export function getTestMappingPrompt(analysis) { return ` Calculate priority scores for Skyramp test types based on repository analysis results and the test definitions below. ## CRITICAL RULES - Do not suggest test scenarios at this stage. # Skyramp Test Types & Requirements Skyramp offers comprehensive testing capabilities across multiple test types. Each test type serves specific purposes and requires different inputs for generation. ## 1. Smoke Tests (Base Score: ${BASE_SCORES.smoke}) **Purpose**: Quickly verify that an endpoint is accessible and returns a valid response. Ideal for identifying critical defects after significant changes. **Required Inputs**: - **OpenAPI Schema** (JSON/YAML) - API specification file - **Sample Request Data** (Optional) - JSON blob or file for request body - **Endpoint URL** - Target endpoint to test - **HTTP Method** (Optional) - Specific method to test **Use Cases**: - Post-deployment verification - Quick health checks - Critical path validation ## 2. Contract Tests (Base Score: ${BASE_SCORES.contract}) **Purpose**: Ensure services adhere to agreed-upon API contracts, preventing integration issues between services. **Required Inputs**: - **OpenAPI Schema** (JSON/YAML) - API specification file - **Endpoint URL** - Target endpoint to test - **Response Validation** (Optional) - Expected response structure **Use Cases**: - API compatibility validation - Service contract enforcement - Breaking change detection ## 3. Fuzz Tests (Base Score: ${BASE_SCORES.fuzz}) **Purpose**: Identify vulnerabilities and unexpected behaviors by sending random or invalid data to the application. **Required Inputs**: - **OpenAPI Schema** (JSON/YAML) - API specification file - **Endpoint URL** - Target endpoint to test - **Fuzz Parameters** (Optional) - Custom fuzzing configuration **Use Cases**: - Security vulnerability testing - Input validation verification - Edge case discovery ## 4. Integration Tests (Base Score: ${BASE_SCORES.integration}) **Purpose**: Verify that different components of a system work together as expected, ensuring reliable data flow and system behavior. **Required Inputs**: - **OpenAPI Schema** (JSON/YAML) - API specification file - **Endpoint URL** - Target endpoint to test - **Integration Scenarios** (Optional) - Specific integration flows **Use Cases**: - Microservices integration - Database connectivity testing - External API integration ## 5. Load Tests (Base Score: ${BASE_SCORES.load}) **Purpose**: Assess performance and scalability under various load conditions. **Required Inputs**: - **OpenAPI Schema** (JSON/YAML) - API specification file - **Endpoint URL** - Target endpoint to test - **Load Parameters**: - \`--load-duration\` (default: 5 seconds) - \`--load-num-threads\` (default: 1) - \`--load-target-rps\` (requests per second) - \`--load-rampup-duration\` (gradual load increase) **Use Cases**: - Performance benchmarking - Scalability assessment - Stress testing ## 6. UI Tests (Base Score: ${BASE_SCORES.ui}) **Purpose**: Validate user interface functionality and user experience. **Required Inputs**: - **Playwright Recording** - ZIP file containing UI interaction traces - **Browser Context** (Optional) - Specific browser/device configurations **Use Cases**: - User workflow validation - Cross-browser compatibility - UI regression testing ## 7. End-to-End (E2E) Tests (Base Score: ${BASE_SCORES.e2e}) **Purpose**: Test complete application flow from start to finish, ensuring all integrated components function as expected. **Required Inputs**: - **Trace File** - JSON file containing API interactions - **Playwright Recording** - ZIP file containing UI interactions - **Integration Scenarios** - Complete user journey definitions **Use Cases**: - Complete user journey testing - Full-stack integration validation - Business process verification ## Test Type Priority Hierarchy (Base Impact Score) Based on impact and value: 1. **E2E Tests: ${BASE_SCORES.e2e}** - Highest value: validates complete user journeys - Catches integration issues across full stack - Most realistic representation of user experience 2. **UI Tests: ${BASE_SCORES.ui}** - Critical for user-facing functionality - Prevents UI regressions - Validates actual user interactions 3. **Integration Tests: ${BASE_SCORES.integration}** - Validates component interactions - Catches interface mismatches - Tests realistic workflows 4. **Load Tests: ${BASE_SCORES.load}** - Ensures performance under pressure - Prevents production outages from traffic spikes - Validates scalability 5. **Fuzz Tests: ${BASE_SCORES.fuzz}** - Uncovers security vulnerabilities - Finds edge cases - Validates input handling 6. **Contract Tests: ${BASE_SCORES.contract}** - Prevents API breaking changes - Ensures service compatibility - Important for microservices 7. **Smoke Tests: ${BASE_SCORES.smoke}** - Basic verification only - Quick feedback but shallow coverage - Catches only obvious failures --- ## Contextual Score Adjustment by Test Type ### Scoring Formula \`\`\` _finalScore = _baseScore × contextMultiplier \`\`\` ### E2E Tests Context Multipliers - **Full-stack application**: ×1.2 (full value) - **Backend-only API**: ×0.7 (reduced, no UI to test end-to-end) - **Frontend SPA without backend**: ×0.9 (slightly reduced) - **Library/SDK**: ×0 (not applicable) ### UI Tests Context Multipliers - **Frontend SPA or full-stack**: ×1.2 (full value) - **Backend-only**: ×0 (not applicable) ### Integration Tests Context Multipliers - **Full-stack application**: ×1.2 (full value) - **Microservices**: ×1.1 (service communication important) - **Has unit tests, missing integration**: ×1.2 (fill coverage gap) ### Load Tests Context Multipliers - **Has Kubernetes or Docker Compose**: ×1.2 (scaled infrastructure suggests high traffic) - **Daily deployments**: ×1.15 (frequent deploys need performance validation) - **CLI tool or library**: ×0.4 (low traffic expected) - **Internal tool (<10 users)**: ×0.4 (minimal load) ### Fuzz Tests Context Multipliers - **Handles payments or PII**: ×1.2 (security critical) - **OAuth2 authentication**: ×1.15 (public API indicator) - **Public-facing API**: ×1.2 (higher security needs) - **Internal service**: ×0.9 (lower security priority) ### Contract Tests Context Multipliers - **Microservices architecture**: ×1.2 (critical for service contracts) - **Multiple services detected**: ×1.15 (service interactions important) - **Monolithic application**: ×0.9 (less critical) ### Smoke Tests Context Multipliers - **No existing tests**: ×1.2 (quick wins needed) - **Production system**: ×1.1 (deployment validation) - **Already has comprehensive tests**: ×0.8 (less valuable) --- ## Context Multiplier Rules (Programmatic) ${generateContextRulesTable()} ## Repository Analysis \`\`\`json ${JSON.stringify(analysis, null, 2)} \`\`\` ## Your Task Calculate priority scores for ALL test types and return a JSON object with this structure: \`\`\`json { "priorityScores": [ { "testType": "integration", "_baseScore": 85, "contextMultiplier": 1.2, "_finalScore": 102, "feasibility": "high", "requiredArtifacts": { "available": ["openApiSpec"], "missing": [] }, "reasoning": "Detailed explanation of why this score was calculated" } ], "contextFactors": { "applied": [ { "factor": "hasDockerCompose", "impact": "Increases integration test importance", "multiplier": 1.1 } ] }, "summary": { "highPriority": ["integration", "fuzz"], "mediumPriority": ["contract", "load"], "lowPriority": ["smoke"] } } \`\`\` Calculate scores now. Return ONLY the JSON object, no other text. `; } function generateContextRulesTable() { let table = ""; for (const [testType, rules] of Object.entries(CONTEXT_RULES)) { table += `\n**${testType.toUpperCase()} Context Multipliers:**\n`; for (const rule of rules) { table += `- ${rule.condition}: ×${rule.multiplier} (${rule.description})\n`; } } return table; }