UNPKG

einstein-sdk

Version:

einstein sdk for javascript and typescript.

412 lines (314 loc) 14.3 kB
# Einstein SDK API SDK for Einstein according to [Einstein SDK HTTP API](https://wiki.ringcentral.com/display/QA/EINSTEIN+INTEGRATION+API) ## Installation ``` npm install einstein-sdk ``` ## APIs ### Login ```javascript import EinsteinSDK from 'einstein-sdk'; // or use: const EinsteinSDK = require('einstein-sdk').default; const EINSTEIN_ENDPOINT = 'https://einstein.ringcentral.com'; const einsteinSdk = new EinsteinSDK(EINSTEIN_ENDPOINT); await einsteinSdk.login('username', 'password'); ``` ### Logout ```javascript einsteinSdk.logout(); ``` ### Get Projects ```javascript const projects = await einsteinSdk.getProjects(); ``` ### Get Project ```javascript const project = await einsteinSdk.getProject(projectId); ``` ### Get Suites ```javascript const suites = await einsteinSdk.getSuites(projectId); ``` ### Get Test Cases ```javascript const testCase = await einsteinSdk.getTestCase(testCaseId); ``` ### Update Test Case ```javascript const testCase = await einsteinSDK.getTestCase(TEST_CASE_ID); const parameter = { id: testCase.id, versionId: testCase.version.id, name: `${testCase.name} new`, summary: `${testCase.summary} new`, preconditions: `${testCase.preconditions} new`, priority: PRIORITY_ENUM.P3, executionType: EXECUTION_TYPE_ENUM.Automated, steps: [ ...testCase.children, { name: 'step1', expectedResult: 'no result', execution: EXECUTION_TYPE_ENUM.Automated, }, { name: 'step2', expectedResult: 'no result2', execution: EXECUTION_TYPE_ENUM.Automated, } ] }; const response = await einsteinSDK.updateTestCase(parameter); ``` ### Create Test Case ```javascript const data = { projectId: ${projectId}, parentId: ${parentId}, name: 'Einstein SDK Test', priority: PRIORITY_ENUM.P3, executionType: EXECUTION_TYPE_ENUM.Automated, summary: 'This is summary.', preconditions: 'This is preconditions.', steps: [ { name: 'Step 1', expectedResult: 'Expected result 1', execution: EXECUTION_TYPE_ENUM.Automated, }, { name: 'Step 2', expectedResult: 'Expected result 2', execution: EXECUTION_TYPE_ENUM.Automated, }, { name: 'Step 3', expectedResult: 'Expected result 3', execution: EXECUTION_TYPE_ENUM.Automated, }, ] }; const response = await einsteinSDK.createTestCase(data); ``` ### Get Test Cases By Keyword Ids ```javascript const testCases = await einsteinSdk.getTestCasesByKeywordIds(projectId, keywordsIds); ``` ### Get Test Plans ```javascript const testPlans = await einsteinSdk.getTestPlans(projectId); ``` ### Create Test Plan ```javascript await einsteinSdk.createTestPlan(projectId, testPlanName, notes); ``` ### Add Test Case To Test Plans ```javascript await einsteinSdk.addTestCaseToTestPlans(testCaseId, testPlanIds); ``` ### Add Test Cases To Test Plan ```javascript await einsteinSDK.addTestCasesToTestPlan(projectIds, testCaseIds, testPlanId); ``` ### Get Builds ```javascript const builds = await einsteinSdk.getBuilds(testPlanId); ``` ### Create Build ```javascript await einsteinSdk.createBuild(testPlanId, buildName, notes); ``` ### Add Value To Custom Field ```javascript await einsteinSdk.addValueToCustomField(projectId, customFieldName, name, description, visibility); ``` ### Get Test Executions ```javascript const executions = await einsteinSdk.getTestExecutions(testCaseId); ``` ### Get Project Keywords ```javascript const keywords = await einsteinSdk.getKeywords(projectId); ``` ### Get Meta Data By Project Name ```javascript const metaData = await einsteinSdk.getMetaDataByProjectName(projectName); ``` ### Search Test Case In Test Suite Scope ```javascript const testCases = await einsteinSdk.searchTestCasesByExpression(projectName, expression); ``` ### Search Test Case In Test Executions Scope ```javascript const testCases = await einsteinSdk.searchTestCasesInTestExecutionsByExpression(projectName, testPlanName, expression); ``` ### Update test case properties ```javascript await einsteinSDK.bulkUpdateTestCaseProperties(data); ```` ### Get suggest test cases ```javascript const pattern = 'xxx'; await einsteinSDK.getSuggestTestCases(pattern); ``` ## Fields For Searching Test Cases | Field | Keyword In Expression | Available Operators | Predefined Values | Available? | | :---------------------: | :-------------------: | :-----------------: | :----------------------------------------------------------: | :--------: | | Project | project | **=** | n/a | ✅ | | Test plan | test_plan | **=**, **in** | n/a | ✅ | | Case Id | case_id | **=**, **in** | n/a | ✅ | | Case Name | case_name | **like** | n/a | ✅ | | Suite | suite | **=**, **in** | n/a | ✅ | | Suite Name | suite_name | **like** | n/a | ✅ | | Summary | summary | **like** | n/a | ✅ | | Preconditions | preconditions | **like** | n/a | ✅ | | Test Step | test_step | **like** | n/a | ✅ | | Expected Result | expected_result | **like** | n/a | ✅ | | Text | text | **like** | n/a | ✅ | | Priority | priority | **=**, **in** | "P0", "P1", "P2", "P3" | ✅ | | Execution Type | execution_type | **=**, **in** | "Manual", "Automated", "Automatable", "NotAutomatable", "ReadyForAutomation", "AutomationExpired", "AutomationSuspended" | ✅ | | Last Execution Status | last_execution_status | **=**, **in** | "Passed", "Failed", "Blocked", "Skipped", "NotApplicable", "NotRun" | ✅ | | Execution Status | execution_status | **=**, **in** | "Passed", "Failed", "Blocked", "Skipped", "NotApplicable", "NotRun" | ✅ | | Tested By | tested_by | **=**, **in** | n/a | ✅ | | Version | version | **=**, **in** | "Active", "Last" | ✅ | | Version Number | version_number | **=**, **in** | n/a | ✅ | | Created By | created_by | **=**, **in** | n/a | ✅ | | Date Created | date_created | **<**,**<=**,**>**,**>=** | n/a | ✅ | | Last Updated | last_updated | **<**,**<=**,**>**,**>=** | n/a | ✅ | | Date Update | date_updated | **<**,**<=**,**>**,**>=** | n/a | ✅ | | Updated By | updated_by | **=**, **in** | n/a | ✅ | | Req. Doc. Id (coverage) | document_id | **like** | n/a | ✅ | | Run | run | **in** | n/a | ✅ | | Custom Fields | @custom field name@ | **in** | n/a | ✅ | ## Searching Expression Samples ### Search Test Cases By Project Name Only ```bash project = "RC Cloud Integration" ``` ### Search Test Cases By Project Name And Test Plan Name ```bash project in "RC Cloud Integration" and test_plan = "Salesforce V3.41" project in "RC Cloud Integration" and test_plan in "Salesforce V3.41, Google&Office365 - V2.6.0" ``` ### Search Test Cases By Project Name And Test Case Id ```bash project = "RC Cloud Integration" and case_id = "1286" project = "RC Cloud Integration" and case_id in "1286, 42" ``` ### Search Test Cases By Project Name And Test Case Name ```bash project = "RC Cloud Integration" and case_name like "Log into RC CTI app with phone number/email" ``` ### Search Test Cases By Project Name And Suite Name (suite name can be a nested structure split by '.') ```bash project = "RC Cloud Integration" and suite = "Firefox" project = "RC Cloud Integration" and suite in "Firefox, Skype for Business" project = "Ringcentral meetings" and suite = "SW - Settings/Reports/Dashboard.Meetings Report.Admin Portal.Webinar" and version = "Active" project = "RC Cloud Integration" and suite_name like "Firefox" ``` ### Search Test Cases By Project Name And Summary ```bash project = "RC Cloud Integration" and summary like "To verify whether user is able to log into RC CTI" ``` ### Search Test Cases By Project Name And Preconditions ```bash project = "RC Cloud Integration" and preconditions like "User must have RC CTI account" ``` ### Search Test Cases By Project Name And Test Step ```bash project = "RC Cloud Integration" and test_step like "enter extension(optional) and password" ``` ### Search Test Cases By Project Name And Expected Result ```bash project = "RC Cloud Integration" and expected_result like "Password entered, value is hidden" ``` ### Search Test Cases By Project Name And Text ```bash project = "RC Cloud Integration" and text like "password" ``` ### Search Test Cases By Project Name And Priority **Optional values for priority: "P0", "P1", "P2", "P3"** ```bash project = "RC Cloud Integration" and priority = "P0" project = "RC Cloud Integration" and priority in "P0, P1, P2" ``` ### Search Test Cases By Project Name And Execution Type **Optional values for execution type: "Manual", "Automated", "Automatable", "NotAutomatable", "ReadyForAutomation"** ```bash project = "RC Cloud Integration" and execution_type = "Automated" project = "RC Cloud Integration" and execution_type in "Automated, Automatable" ``` ### Search Test Cases By Project Name And Last Execution Status **Optional values for last execution status: "Passed", "Failed", "Blocked", "Skipped", "NotApplicable", "NotRun"** ```bash project = "RC Cloud Integration" and last_execution_status = "Passed" project = "RC Cloud Integration" and last_execution_status in "Passed, Failed, Skipped" ``` ### Search Test Cases By Project Name And Execution Status **Optional values for execution status: "Passed", "Failed", "Blocked", "Skipped", "NotApplicable", "NotRun"** ```bash project = "RC Cloud Integration" and execution_status = "Passed" project = "RC Cloud Integration" and execution_status in "Passed, Failed, Skipped" ``` ### Search Test Cases By Tested By ```bash project = "RC Cloud Integration" and tested_by = "yuki.chen" project = "RC Cloud Integration" and tested_by in "yuki.chen, klay.chen" ``` ### Search Test Cases By Project Name And Version **Optional values for version: "Active", "Last"** ```bash project = "RC Cloud Integration" and version = "Active" project = "RC Cloud Integration" and version in "Active, Last" ``` ### Search Test Cases By Project Name And Version Number ```bash project = "RC Cloud Integration" and version_number = "21" project = "RC Cloud Integration" and version_number in "20, 21" ``` ### Search Test Cases By Created By ```bash project = "RC Cloud Integration" and created_by = "yuki.chen" project = "RC Cloud Integration" and created_by in "yuki.chen, klay.chen" ``` ### Search Test Cases By Date Created ```bash project = "RC Cloud Integration" and date_created >= "2019-04-01" project = "RC Cloud Integration" and date_created < "2019-04-01" ``` ### Search Test Cases By Updated By ```bash project = "RC Cloud Integration" and updated_by = "yuki.chen" project = "RC Cloud Integration" and updated_by in "yuki.chen, klay.chen" ``` ### Search Test Cases By Last Updated ```bash project = "RC Cloud Integration" and last_updated >= "2019-04-01" project = "RC Cloud Integration" and last_updated < "2019-04-01" ``` ### Search Test Cases By Document Id ```bash project = "RC Cloud Integration" and document_id like "abc" ``` ### Search Test Cases By Project Name And Custom Fields **Wrapper custom field with "@" and "@".** ```bash project = "RC Cloud Integration" and @Keywords@ in "Salesforce, Outlook" project = "RC Cloud Integration" and @Automation@ in "Automatable, Automated" project = "RC Cloud Integration" and @Release Name@ in "Release_10.0, Release_10.1" ``` ### Search Test Cases By Run ```bash project = "Ringcentral meetings" and run in "9.4 Meeings Dashboard Regression testing: 5.4 Mac Rooms" and version = "Active" ``` ### Search Test Cases Using "in", "or", "()" and "!' ```bash (project = "RC Cloud Integration" and @Keywords@ in "Salesforce, Outlook") or ((project = "RC Cloud Integration" and execution_type = "Automated")) ``` ```bash project = "RC Cloud Integration" and @Keywords@ in "Google" and priority="P0" and !(@Keywords@ in "Automation_Expired, Manual, Automated_Google") ``` ## Important Notice It's necessary to add `version = "Active"` in every query expression. ## More Information **See [Test Cases for Einstein SDK](test/einstein-sdk.test.ts) to get more details.**