UNPKG

@smartbear/mcp

Version:

MCP server for interacting SmartBear Products

291 lines (290 loc) 16.7 kB
import { QMetryToolsHandlers } from "../../config/constants.js"; import { FetchAutomationStatusPayloadSchema, ImportAutomationResultsPayloadSchema, } from "../../types/common.js"; export const AUTOMATION_TOOLS = [ { handler: QMetryToolsHandlers.IMPORT_AUTOMATION_RESULTS, title: "Import Automation Test Results", summary: "Import/Publish automation test results from TestNG, JUnit, Cucumber, Robot, HPUFT, or QAF frameworks into QMetry", purpose: "Upload and import automation test result files to create test suites, test cases, and execution records in QMetry", inputSchema: ImportAutomationResultsPayloadSchema, useCases: [ "1. Import TestNG XML results after CI/CD pipeline execution", "2. Publish JUnit test results to QMetry for tracking and reporting", "3. Upload Cucumber JSON results with custom test suite organization", "4. Import Robot Framework results with specific release/cycle mapping", "5. Link automation results to existing test suites for version tracking", "6. Create new test suites with custom names and folder structures", "7. Map test results to specific platforms (browsers, OS, devices)", "8. Associate imported results with releases, cycles, and builds", "9. Bulk import multiple test results from ZIP archive", "10. Configure test case/suite fields and user-defined fields during import", ], examples: [ { description: "Basic TestNG result import", parameters: { file: "<base64_encoded_testng_xml_content>", fileName: "testng-results.xml", entityType: "TESTNG", }, expectedOutput: "Auto-generated test suite created with UTC timestamp, test cases auto-linked, execution results updated, 'No Platform' linked", }, { description: "JUnit results with custom test suite name", parameters: { file: "<base64_encoded_junit_xml_content>", fileName: "junit-results.xml", entityType: "JUNIT", testsuiteName: "Regression Suite - Build 123", automationHierarchy: "1", }, expectedOutput: "Test suite 'Regression Suite - Build 123' created with Test Case-Test Step hierarchy", }, { description: "Cucumber results with platform and release mapping", parameters: { file: "<base64_encoded_cucumber_json_content>", fileName: "cucumber-results.json", entityType: "CUCUMBER", platformID: "Chrome 120", releaseID: "Release 2.0", cycleID: "Sprint 15", testsuiteName: "API Automation Tests", }, expectedOutput: "Test suite created, linked to Chrome platform, Release 2.0, and Sprint 15 cycle", }, { description: "Reuse existing test suite", parameters: { file: "<base64_encoded_testng_xml_content>", fileName: "testng-regression.xml", entityType: "TESTNG", testsuiteId: "PROJ-TS-42", }, expectedOutput: "Test cases auto-linked to existing test suite PROJ-TS-42, execution results updated", }, { description: "Import with folder organization", parameters: { file: "<base64_encoded_junit_xml_content>", fileName: "junit-results.xml", entityType: "JUNIT", tsFolderPath: "/Automation/Regression", tcFolderPath: "/Automation/API Tests", testsuiteName: "API Regression Suite", }, expectedOutput: "Test suite created in '/Automation/Regression' folder, test cases in '/Automation/API Tests' folder", }, { description: "Import with test case custom fields", parameters: { file: "<base64_encoded_testng_xml_content>", fileName: "testng-results.xml", entityType: "TESTNG", testcase_fields: JSON.stringify({ priority: "High", testCaseType: "Automated", component: ["API", "Backend"], testcaseOwner: "john.doe", estimatedTime: "2h:30m:0s", }), }, expectedOutput: "Test cases created with High priority, Automated type, API and Backend components", }, { description: "Import ZIP file with multiple results", parameters: { file: "<base64_encoded_zip_content>", fileName: "test-results.zip", entityType: "JUNIT", testsuiteName: "Full Regression Suite", skipWarning: "1", }, expectedOutput: "Multiple test results imported from ZIP, summaries truncated if >255 chars", }, { description: "Import with custom hierarchy for JUnit", parameters: { file: "<base64_encoded_junit_xml_content>", fileName: "junit-results.xml", entityType: "JUNIT", automationHierarchy: "3", projectID: "PROJ", }, expectedOutput: "Multiple test suites created per <testsuite> tag, test cases per <testcase> tag", }, { description: "Import with build and platform mapping", parameters: { file: "<base64_encoded_testng_xml_content>", fileName: "testng-results.xml", entityType: "TESTNG", buildID: "Build-1.2.3", platformID: "Safari 17", releaseID: "Release 1.2", cycleID: "QA Cycle", }, expectedOutput: "Results linked to Build 1.2.3, Safari 17 platform, Release 1.2, QA Cycle", }, { description: "Import with test suite and test case fields", parameters: { file: "<base64_encoded_cucumber_json_content>", fileName: "cucumber-results.json", entityType: "CUCUMBER", testsuite_fields: JSON.stringify({ testSuiteState: "In Progress", testsuiteOwner: "jane.smith", description: "Sprint 15 automation results", }), testcase_fields: JSON.stringify({ priority: "Medium", component: ["UI", "Frontend"], userDefinedFields: { reviewedDate: "11-20-2024", environment: "Staging", }, }), }, expectedOutput: "Test suite and test cases created with custom fields and UDFs", }, ], hints: [ "1. CRITICAL: User MUST upload a valid result file before calling this tool", "2. USER FILE UPLOAD REQUIRED: Ask user to provide file in chat - system will convert to base64", "3. FILE REQUIREMENTS:", " - Supported extensions: .json, .xml, .zip", " - Maximum size: 30 MB", " - ZIP files must contain files matching the specified entityType format", "4. REQUIRED PARAMETERS:", " - file: Base64 encoded content or file path", " - fileName: Original filename with extension", " - entityType: TESTNG, CUCUMBER, JUNIT, HPUFT, QAF, or ROBOT", "5. ENTITY TYPES:", " - TESTNG: TestNG XML format", " - JUNIT: JUnit XML format", " - CUCUMBER: Cucumber JSON format", " - ROBOT: Robot Framework XML format", " - HPUFT: HP UFT format", " - QAF: QAF format", "6. AUTOMATION HIERARCHY (TestNG/JUnit only):", " - TestNG:", " * 1 (default): <class name> = Test Case, <test-method> = Test Step", " * 2: <test-method> = Test Case only", " * 3: <name> under <test> = Test Case, <test-method> = Test Step", " - JUnit:", " * 1 (default): <testsuite> = Test Case, <testcase> = Test Step", " * 2: <testcase> = Test Case only", " * 3: <testsuite> = Test Suite, <testcase> = Test Case (creates multiple test suites)", "7. TEST SUITE OPTIONS:", " - testsuiteName: Custom name for new test suite", " - testsuiteId: Reuse existing test suite by ID or Entity Key (e.g., 'PROJ-TS-42')", " - tsFolderPath: Create test suite in specific folder (e.g., '/Automation/Regression')", " - Note: testsuiteName/testsuiteId ignored if automationHierarchy=3 for JUnit or =2 for ROBOT", "8. TEST CASE OPTIONS:", " - tcFolderPath: Create test cases in specific folder (e.g., '/Automation/API Tests')", " - Folders created automatically if they don't exist", "9. LINKING OPTIONS:", " - platformID: Platform ID or name (e.g., 'Chrome 120', 'Safari 17')", " - projectID: Project ID, key, or name (overrides header project)", " - releaseID: Release ID or name (requires projectID)", " - cycleID: Cycle ID or name (requires releaseID and projectID)", " - buildID: Build ID or name", "10. GET IDs FROM OTHER TOOLS:", " - Platform IDs: Use 'Platform/List' API (FETCH_PLATFORMS tool)", " - Project IDs: Use 'Project/List' API (FETCH_PROJECTS tool)", " - Release IDs: Use 'Release/List' API (FETCH_RELEASES_CYCLES tool)", " - Cycle IDs: Use 'Cycle/List' API (FETCH_RELEASES_CYCLES tool)", " - Build IDs: Use 'Build/List' API (FETCH_BUILDS tool)", " - Test Suite IDs: Use 'Testsuite/Fetch' API (FETCH_TEST_SUITES tool)", "11. CUSTOM FIELDS (testcase_fields):", " - JSON string with system fields and UDFs", " - System fields: component, priority, testCaseState, testCaseType, testcaseOwner, estimatedTime, description", ' - Example: {"component":["API"], "priority":"High", "testcaseOwner":"user"}', " - Ignored if reusing existing test case", "12. CUSTOM FIELDS (testsuite_fields):", " - JSON string with system fields and UDFs", " - System fields: testSuiteState, testsuiteOwner, description", ' - Example: {"testSuiteState":"Open", "testsuiteOwner":"user"}', " - Ignored if reusing existing test suite", "13. USER DEFINED FIELDS (UDFs):", " - Include in testcase_fields or testsuite_fields under 'userDefinedFields' key", ' - Example: {"userDefinedFields": {"reviewedDate": "11-20-2024", "environment": "Staging"}}', " - UDF types: STRING, LARGETEXT, LOOKUPLIST, MULTILOOKUPLIST, DATEPICKER, NUMBER", " - See tool metadata for UDF validation rules and auto-create behavior", "14. SKIP WARNING OPTIONS:", " - skipWarning='0' (default): Fail import if test case summary >255 characters", " - skipWarning='1': Truncate summary to 255 characters and continue import", "15. MATCHING BEHAVIOR:", " - is_matching_required='true' (default): Create new TC/version if summary/steps don't match", " - is_matching_required='false': Reuse existing TC version if entity key or summary matches", "16. IMPORT BEHAVIOR EXAMPLES:", " - Only file + entityType → Auto-generated test suite, 'No Platform', test cases auto-linked", " - file + entityType + platformID → Auto-generated test suite with specified platform", " - file + entityType + testsuiteId → Results updated in existing test suite", " - file + entityType + platformID + testsuiteId → Results updated in existing test suite with platform", "17. FOLDER CREATION:", " - If tsFolderPath or tcFolderPath specified and doesn't exist, it will be created automatically", " - Use forward slashes for folder paths (e.g., '/Parent/Child')", "18. ESTIMATED TIME FORMAT:", " - Format: '2h:30m:15s' or '4h' or '7m' or '0s'", " - Range: 0 to 99999 minutes", "19. OWNER FIELDS:", " - Use userAlias (username) not display name", " - testcaseOwner: User must have Test Case module rights", " - testsuiteOwner: User must have Test Suite module rights", " - Owner not set if user not found or lacks permissions", "20. LOOKUPLIST/MULTILOOKUPLIST BEHAVIOR:", " - If value doesn't exist and auto-create is ON: Value added to list", " - If value doesn't exist and auto-create is OFF: Field blank or default value", " - MULTILOOKUPLIST: New values added, old values persist", "21. MANDATORY FIELD VALIDATION:", " - If mandatory system/UDF field missing:", " * Auto-create OFF + value doesn't exist = Import FAIL", " * Auto-create ON + value doesn't exist = Import SUCCESS (value created)", " * Value exists = Import SUCCESS", "22. ERROR HANDLING:", " - Check file size before upload (must be ≤30 MB)", " - Validate file extension matches entityType", " - Ensure required dependencies: cycleID requires releaseID and projectID", " - If import fails, check QMetry UI for detailed error messages", "23. WORKFLOW:", " Step 1: Ask user to upload result file in chat", " Step 2: System converts file to base64", " Step 3: Collect entityType and optional parameters", " Step 4: Call this tool with file data and configuration", " Step 5: QMetry processes file and creates/updates test artifacts", " Step 6: Return import results with test suite and execution details", "24. USER INTERACTION REQUIRED:", " - ALWAYS ask user to upload file before calling this tool", " - Display supported formats: .json, .xml, .zip (up to 30 MB)", " - Ask for entityType (framework used)", " - Ask for optional parameters based on user's needs", "25. PERFORMANCE TIPS:", " - For large imports, consider using ZIP files", " - Reusing existing test suites is faster than creating new ones", " - Use automationHierarchy wisely to control test case/suite structure", ], }, { handler: QMetryToolsHandlers.FETCH_AUTOMATION_STATUS, title: "Fetch Automation Status", summary: "Fetches the status of an automation import job by request ID.", purpose: "Track the progress and result of an automation import operation in QMetry.", inputSchema: FetchAutomationStatusPayloadSchema, useCases: [ "1. Check if an automation import job is completed or still in progress.", "2. Retrieve status, progress, and details for a specific automation import request.", "3. Monitor automation result processing for CI/CD integrations.", ], examples: [ { description: "Fetch status for request ID 12345", parameters: { requestID: 12345, }, expectedOutput: "Status, progress, and details of the automation import job for request ID 12345.", }, ], }, ];