UNPKG

trident-beta

Version:

trident is a sample and lightly tools aims to improve collaboration efficiency between SDET and QA based on initiative from Einstein/TestIT.

275 lines (257 loc) 13.1 kB
import _ from "lodash"; import TestItSDK from "../src/sdk/testit" import { PASSWORD, PROJECT_ID, PROJECT_NAME, SECTION_ID, SUITE_ID, TESTIT_ENDPOINT, TEST_CASE_ID, TEST_CASE_ID_ARRAY, TEST_CASE_KEY, TEST_PLAN_ID, USERNAME } from "./fixtures/fixtures" describe('Test TestIt SDK',() => { const testItSDK = new TestItSDK(TESTIT_ENDPOINT); beforeAll(async () => { await testItSDK.login(USERNAME,PASSWORD); }); /* 1.Test Login */ // 1.1 Test login successfully. test('Should login successfully with correct username and password.', async ()=>{ const TestItSDK2 = new TestItSDK(TESTIT_ENDPOINT); await TestItSDK2.login(USERNAME,PASSWORD); expect(TestItSDK2.getAutorized()).toEqual(true); }); // 1.2 Test login failed. // test('Should failed to login with incorrect username and password.', async () => { // const TestItSDK2 = new TestItSDK(TESTIT_ENDPOINT); // let error; // try { // await TestItSDK2.login(USERNAME, '123456'); // } catch (err) { // error = err; // } // expect(error).toEqual(new Error('Failed to login TestIt, please check your username and password.')); // }); // /* 2.Test Projects API */ // 2.1 Test get all projects. // test("Should get projects.",async ()=>{ // const projects = await testItSDK.getProjects(); // expect(_.isArray(projects)).toEqual(true); // const project = _.first(projects); // expect(project).toHaveProperty('id'); // expect(project).toHaveProperty('name'); // expect(project).toHaveProperty('dateCreated'); // expect(project).toHaveProperty('createdBy'); // expect(project).toHaveProperty('suitsNo'); // expect(project).toHaveProperty('casesNo'); // }); // 2.2 Test get project by id. // test("Should get project by project id.", async ()=>{ // const project = await testItSDK.getProjectById(PROJECT_ID); // expect(project).toHaveProperty('id'); // expect(project).toHaveProperty('name'); // expect(project).toHaveProperty('dateCreated'); // expect(project).toHaveProperty('createdBy'); // expect(project).toHaveProperty('suitsNo'); // expect(project).toHaveProperty('casesNo'); // }); // 2.3 Test get project tree by project id. // test("Should get project tree by project id",async ()=> { // const projectTree = await testItSDK.getProjectTreeById(PROJECT_ID); // expect(projectTree).toHaveProperty('id'); // expect(projectTree).toHaveProperty('name'); // expect(projectTree).toHaveProperty('type'); // expect(projectTree).toHaveProperty('order'); // }); // 2.4 Test get project by project name. // test("Should get project by project name",async ()=>{ // const project = await testItSDK.getProjectByName(PROJECT_NAME); // expect(project).toHaveProperty('id'); // expect(project).toHaveProperty('name'); // expect(project).toHaveProperty('dateCreated'); // expect(project).toHaveProperty('createdBy'); // expect(project).toHaveProperty('suitsNo'); // expect(project).toHaveProperty('casesNo'); // }); /* 3.Test Section API */ // 3.1 Test get test section by id. // test("Should get section by section id",async ()=>{ // const section = await testItSDK.getSectionById(SECTION_ID); // expect(section).toHaveProperty('id'); // expect(section).toHaveProperty('name'); // expect(section).toHaveProperty('ascendants'); // expect(section).toHaveProperty('projectId'); // }); /* 4.Test Case API */ // 4.1 Test get case by id. // test("Should get test case by case id",async ()=>{ // const testCase = await testItSDK.getTestCaseById(TEST_CASE_ID); // expect(_.isObject(testCase)).toEqual(true); // expect(testCase).toHaveProperty('id'); // expect(testCase).toHaveProperty('parentId'); // expect(testCase).toHaveProperty('name'); // expect(testCase).toHaveProperty('summary'); // expect(testCase).toHaveProperty('preconditions'); // expect(testCase).toHaveProperty('versions'); // expect(testCase).toHaveProperty('version'); // expect(testCase).toHaveProperty('ascendants'); // expect(testCase).toHaveProperty('children'); // expect(testCase).toHaveProperty('values'); // expect(testCase).toHaveProperty('priority'); // expect(testCase).toHaveProperty('executionType'); // expect(testCase).toHaveProperty('externalId'); // expect(testCase).toHaveProperty('dateCreated'); // expect(testCase).toHaveProperty('createdBy'); // expect(testCase).toHaveProperty('lastUpdated'); // expect(testCase).toHaveProperty('lastUpdatedBy'); // }); // 4.2 Test get test plans by case id. // test("Should get test plans by test case id",async ()=>{ // const testPlans = await testItSDK.getTestPlansByTestCaseId(TEST_CASE_ID); // expect(_.isArray(testPlans)).toEqual(true); // const testPlan = _.first(testPlans); // expect(testPlan).toHaveProperty('id'); // expect(testPlan).toHaveProperty('name'); // expect(testPlan).toHaveProperty('latestBuildId'); // expect(testPlan).toHaveProperty('isObsolete'); // expect(testPlan).toHaveProperty('projectId'); // expect(testPlan).toHaveProperty('testCaseVersionNumber'); // }); // // 4.3 Test get test case by case key. // test("Should get test case by case key",async ()=>{ // const testCase = await testItSDK.getTestCaseByKey(TEST_CASE_KEY); // expect(_.isObject(testCase)).toEqual(true); // expect(testCase).toHaveProperty('id'); // expect(testCase).toHaveProperty('parentId'); // expect(testCase).toHaveProperty('name'); // expect(testCase).toHaveProperty('summary'); // expect(testCase).toHaveProperty('preconditions'); // expect(testCase).toHaveProperty('versions'); // expect(testCase).toHaveProperty('version'); // expect(testCase).toHaveProperty('ascendants'); // expect(testCase).toHaveProperty('children'); // expect(testCase).toHaveProperty('values'); // expect(testCase).toHaveProperty('priority'); // expect(testCase).toHaveProperty('executionType'); // expect(testCase).toHaveProperty('externalId'); // expect(testCase).toHaveProperty('dateCreated'); // expect(testCase).toHaveProperty('createdBy'); // expect(testCase).toHaveProperty('lastUpdated'); // expect(testCase).toHaveProperty('lastUpdatedBy'); // }); // 4.4 Test get execution history by case id. // test('Should get execution history by case id',async ()=>{ // const execution_history = await testItSDK.getExecutionHistoryByTestCaseId(TEST_CASE_ID); // expect(_.isObject(execution_history)).toEqual(true); // expect(execution_history).toHaveProperty('items'); // expect(execution_history).toHaveProperty('limit'); // expect(execution_history).toHaveProperty('offset'); // expect(execution_history).toHaveProperty('total'); // }); // 4.5 Test get many cases by id array. // test('Should get many cases by test case array',async ()=> { // const testCases_array = await testItSDK.getTestCasesByIds(TEST_CASE_ID_ARRAY); // expect(_.isArray(testCases_array)).toEqual(true); // const testCase = _.first(testCases_array); // expect(testCase).toHaveProperty('id'); // expect(testCase).toHaveProperty('parentId'); // expect(testCase).toHaveProperty('name'); // expect(testCase).toHaveProperty('summary'); // expect(testCase).toHaveProperty('preconditions'); // expect(testCase).toHaveProperty('versions'); // expect(testCase).toHaveProperty('version'); // expect(testCase).toHaveProperty('ascendants'); // expect(testCase).toHaveProperty('children'); // expect(testCase).toHaveProperty('values'); // expect(testCase).toHaveProperty('priority'); // expect(testCase).toHaveProperty('executionType'); // expect(testCase).toHaveProperty('externalId'); // expect(testCase).toHaveProperty('dateCreated'); // expect(testCase).toHaveProperty('createdBy'); // expect(testCase).toHaveProperty('lastUpdated'); // expect(testCase).toHaveProperty('lastUpdatedBy'); // }); /* 5.Test Suite API */ // 5.1 Test get suite by suite id. // test('Should get suite by suite id',async ()=> { // const suite = await testItSDK.getSuiteById(SUITE_ID); // expect(suite).toHaveProperty('ascendants'); // expect(suite).toHaveProperty('attachments'); // expect(suite).toHaveProperty('createdBy'); // expect(suite).toHaveProperty('dateCreated'); // expect(suite).toHaveProperty('details'); // expect(suite).toHaveProperty('id'); // expect(suite).toHaveProperty('isJunk'); // expect(suite).toHaveProperty('name'); // // expect(suite).toHaveProperty('Discover apps'); // expect(suite).toHaveProperty('parentId'); // expect(suite).toHaveProperty('projectId'); // }); // 5.2 Test get suite tree by suite id. // test('Should get suite tree by suite id',async ()=> { // const suiteTree = await testItSDK.getSuiteTreeById(SUITE_ID); // expect(_.isArray(suiteTree)).toEqual(true); // //... // }); /* 6.Test Test Plan API */ // 6.1 Test get test plan by test plan id. // test('Should get test plan by test plan id',async ()=> { // const testPlan = await testItSDK.getTestPlanById(TEST_PLAN_ID); // expect(testPlan).toHaveProperty('id'); // expect(testPlan).toHaveProperty('name'); // expect(testPlan).toHaveProperty('isObsolete'); // expect(testPlan).toHaveProperty('projectId'); // expect(testPlan).toHaveProperty('status'); // }); // const testPlans = await testItSdk.getTestPlanById(TSP_KEY); // console.log(testPlans); // 6.2 Test get test plan tree by test plan id. // test('Should get test plan tree by test plan id',async ()=> { // const testPlanTree = await testItSDK.getTreeByTestPlanId(TEST_PLAN_ID); // expect(testPlanTree).toHaveProperty('executionConfigs'); // expect(testPlanTree).toHaveProperty('plan'); // }); // const TSP_KEY = 13079448; // const testTree = await testItSdk.getTreeByTestPlanId(TSP_KEY); // console.log(testTree); // 6.3 Test get builds by test plan id. // test('Should get builds by test plan id',async ()=> { // const builds = await testItSDK.getBuildsByTestPlanId(TEST_PLAN_ID); // expect(_.isArray(builds)).toEqual(true); // const build = _.first(builds); // expect(build).toHaveProperty('createdBy'); // expect(build).toHaveProperty('dateCreated'); // expect(build).toHaveProperty('id'); // expect(build).toHaveProperty('name'); // expect(build).toHaveProperty('notes'); // expect(build).toHaveProperty('testPlanId'); // }); // 6.4 Test get execution progress by test plan id. // test('Should get execution progress by test plan id',async ()=> { // const executionProgress = await testItSDK.getExecutionProgressByTestPlanId(TEST_PLAN_ID); // expect(executionProgress).toHaveProperty('builds'); // expect(executionProgress).toHaveProperty('executionConfigs'); // expect(executionProgress).toHaveProperty('executions'); // }); /* 7.Test Builds API */ // 7.1 Test get build by build id. // test('Should get build by build id',async ()=> { // const build = await testItSDK.getBuildById(BUILD_ID); // expect(build).toHaveProperty('createdBy'); // expect(build).toHaveProperty('dateCreated'); // expect(build).toHaveProperty('id'); // expect(build).toHaveProperty('name'); // expect(build).toHaveProperty('notes'); // expect(build).toHaveProperty('projectId'); // expect(build).toHaveProperty('testPlanId'); // }); /* 8.Test Sync API */ // 8.1 Test get sync projects. // test('Should get sync projects',async ()=> { // const project = await testItSDK.getSyncProjects(); // expect(project).toHaveProperty('comment'); // //... // }); /* 9.Test Store API */ // 9.1 Test store pproject by project id. // test('Should get store project by id',async ()=> { // const storeProject = await testItSDK.getStoreProjectById(PROJECT_ID); // expect(storeProject).toHaveProperty('casesNo'); // expect(storeProject).toHaveProperty('counter'); // expect(storeProject).toHaveProperty('createdBy'); // expect(storeProject).toHaveProperty('dateCreated'); // expect(storeProject).toHaveProperty('defaultExecutionType'); // }); })