Skip to main content
Glama

Automation Script Generator MCP Server

smart-analysis-demo.js6.28 kB
/** * Smart File Analysis Demo * Demonstrates the intelligent file update vs create decision making */ import Ajv from 'ajv'; const ajv = new Ajv({ allErrors: true }); // Enhanced schema for smart processing const processTestScenarioSchema = { type: 'object', properties: { scenario_title: { type: 'string', description: 'Title of the test scenario', minLength: 1, }, tags: { type: 'array', items: { type: 'string' }, description: 'Test ID tags for the scenario', }, gherkin_syntax: { type: 'string', description: 'Complete Gherkin syntax with Given/When/Then steps', minLength: 1, }, selectors: { type: 'object', description: 'UI element selectors as key-value pairs', }, data_items: { type: 'object', description: 'Test data items and configurations (optional)', }, output_directory: { type: 'string', description: 'Base directory where all generated files should be saved', minLength: 1, }, repo_path: { type: 'string', description: 'Path to existing repository for pattern analysis (optional)', }, }, required: ['scenario_title', 'gherkin_syntax', 'selectors', 'output_directory'], additionalProperties: false, }; function validateAndLog(testName, testData, shouldPass = true) { const validate = ajv.compile(processTestScenarioSchema); const valid = validate(testData); if (valid) { console.log(`✅ ${shouldPass ? 'PASS' : 'UNEXPECTED PASS'}: ${testName}`); } else { console.log(`${shouldPass ? '❌ UNEXPECTED FAIL' : '✅ EXPECTED FAIL'}: ${testName}`); const errors = validate.errors .map(err => `${err.instancePath || 'root'}: ${err.message}`) .join(', '); console.log(` Errors: ${errors}\n`); } } console.log('🧠 Smart File Analysis Demo\n'); console.log('📋 Testing scenarios that demonstrate intelligent file management:\n'); // Test case 1: New feature scenario console.log('1️⃣ New Feature Scenario (will create new files):'); validateAndLog('User Registration', { scenario_title: 'User Registration Process', tags: ['@registration', '@smoke', '@TEST-REG-001'], gherkin_syntax: `Feature: User Registration Scenario: Successful user registration Given I am on the registration page When I fill in registration form Then I should see success message`, selectors: { firstNameInput: '[data-testid="first-name"]', lastNameInput: '[data-testid="last-name"]', emailInput: '#email', submitButton: '.register-btn' }, output_directory: './tests' }); // Test case 2: Similar feature scenario (will update existing) console.log('\n2️⃣ Similar Feature Scenario (will update existing login feature):'); validateAndLog('Login with Remember Me', { scenario_title: 'Login with Remember Me Option', tags: ['@login', '@enhancement', '@TEST-LOGIN-002'], gherkin_syntax: `Scenario: Login with remember me checked Given I am on the login page When I enter valid credentials And I check the remember me option And I click login button Then I should be logged in And my session should be remembered`, selectors: { usernameInput: '[data-testid="username"]', passwordInput: '[data-testid="password"]', loginButton: '.login-btn', rememberMeCheckbox: '#remember-me' }, output_directory: './tests' }); // Test case 3: Adding to existing page object console.log('\n3️⃣ Existing Page Enhancement (will update page object):'); validateAndLog('Profile Update Feature', { scenario_title: 'User Profile Update', tags: ['@profile', '@user-management'], gherkin_syntax: `Scenario: Update user profile information Given I am on my profile page When I update my personal information Then I should see confirmation message`, selectors: { // Some new selectors + some existing ones profileImage: '.profile-image', phoneInput: '#phone-number', bioTextarea: '#bio', saveButton: '.save-btn' // This might already exist }, output_directory: './tests', repo_path: './existing-tests' }); console.log('\n🧠 Smart Decision Making Features:'); console.log(' • Analyzes existing feature files for similarity'); console.log(' • Detects matching page objects based on selectors'); console.log(' • Identifies reusable step definitions'); console.log(' • Calculates content similarity scores'); console.log(' • Makes intelligent update vs create decisions'); console.log('\n📊 Decision Logic:'); console.log(' • Feature Similarity > 60% → Update existing feature'); console.log(' • Matching Selectors Found → Update page object'); console.log(' • Step Similarity > 80% → Reuse existing steps'); console.log(' • No Matches Found → Create new files'); console.log('\n🎯 Smart Analysis Examples:'); console.log('\n📝 Scenario 1: "User Login with 2FA"'); console.log(' Decision: Update existing login.feature (85% similarity)'); console.log(' Action: Add new scenario to existing file'); console.log(' Reason: Keywords match: "user", "login", "credentials"'); console.log('\n📝 Scenario 2: "Product Catalog Search"'); console.log(' Decision: Create new product-catalog.feature'); console.log(' Action: Generate new test suite'); console.log(' Reason: No similar features found (<30% similarity)'); console.log('\n📝 Scenario 3: "Login Page Validation"'); console.log(' Decision: Update existing login.page.js'); console.log(' Action: Add validation selectors to page object'); console.log(' Reason: Selectors overlap: usernameInput, passwordInput'); console.log('\n🚀 Benefits:'); console.log(' • Maintains organized test structure'); console.log(' • Prevents duplicate test scenarios'); console.log(' • Reuses existing step definitions'); console.log(' • Keeps related tests together'); console.log(' • Reduces maintenance overhead');

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/raymondsambur/automation-script-generator'

If you have feedback or need assistance with the MCP directory API, please join our Discord server