1 | <!DOCTYPE html>
|
2 | <html lang="en">
|
3 | <head>
|
4 | <meta charset="utf-8">
|
5 | <title>JSDoc: Source: RallyHelper.js</title>
|
6 |
|
7 | <script src="scripts/prettify/prettify.js"> </script>
|
8 | <script src="scripts/prettify/lang-css.js"> </script>
|
9 | |
10 |
|
11 |
|
12 | <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
|
13 | <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
|
14 | </head>
|
15 |
|
16 | <body>
|
17 |
|
18 | <div id="main">
|
19 |
|
20 | <h1 class="page-title">Source: RallyHelper.js</h1>
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 | <section>
|
28 | <article>
|
29 | <pre class="prettyprint source linenums"><code>/**
|
30 | * Created by 212571071 on 7/21/16.
|
31 | */
|
32 | /**
|
33 | * Copyright (c) 2013 - 2014 GE Global Research. All rights reserved.
|
34 | * The copyright to the computer software herein is the property of
|
35 | * GE Global Research. The software may be used and/or copied only
|
36 | * with the written permission of GE Global Research or in accordance
|
37 | * with the terms and conditions stipulated in the agreement/contract
|
38 | * under which the software has been supplied.
|
39 | */
|
40 |
|
41 | (function () {
|
42 |
|
43 | var logger = require('./Logger.js');
|
44 | var request = require('request-promise');
|
45 | require('dotenv').config();
|
46 | var build_num,testset,postOnlyTS;
|
47 | if (process.env.build_no != undefined)
|
48 | build_num = process.env.build_no;
|
49 | else build_num = 1;
|
50 |
|
51 | for (var arg = 0; arg < process.argv.length; arg++) {
|
52 | var temp1 = process.argv[arg].split('=');
|
53 | if (temp1[0] == "--params") {
|
54 | var param = process.argv[arg];
|
55 | var args = param.split('=');
|
56 | var indiv = args[1].split(',');
|
57 | var apikey = indiv[0];
|
58 | apikey = apikey.split(':'); // apikey is: apikey[1]
|
59 | }
|
60 | }
|
61 | var User_Story;
|
62 | if (process.env.rallyworkspace != undefined)
|
63 | var workspace = process.env.rallyworkspace;
|
64 | else
|
65 | workspace = ""; // default workspace
|
66 | if (process.env.method != undefined)
|
67 | var method = process.env.method;
|
68 | else
|
69 | var method = "Automated"; // default workspace
|
70 | if (process.env.rallyProxy != undefined) {
|
71 | var proxy = process.env.rallyProxy;
|
72 | } else {
|
73 | logger.info('No proxy defined - check .env file');
|
74 | console.log('No proxy defined - check .env file');
|
75 | callback();
|
76 | }
|
77 | var zsessionid;
|
78 | if (apikey != undefined)
|
79 | zsessionid = apikey[1];
|
80 | else if ((apikey == undefined) && (process.env.apiKey != undefined))
|
81 | zsessionid = process.env.apiKey;
|
82 | else {
|
83 | logger.info('No apiKey provided - check .env file or command line parameter');
|
84 | console.log('No apiKey provided - check .env file or command line parameter');
|
85 | callback();
|
86 | }
|
87 | var baseUrl = 'https://rally1.rallydev.com/slm/webservice/v2.0/';
|
88 | /**
|
89 | * Creates new RestHelper
|
90 | * @class RestHelper
|
91 | */
|
92 | var RallyHelper = function () {
|
93 |
|
94 | return {
|
95 | queryUserStory: function (user_story, json, i, j, test_case_name, test_case_description, glb_folder_id, line, duration, status, callbck) {
|
96 | var user_story_id;
|
97 | var request = require("request-promise");
|
98 | var options = {
|
99 | method: 'GET',
|
100 | url: 'https://rally1.rallydev.com/slm/webservice/v2.0/hierarchicalrequirement?' +
|
101 | 'query=(FormattedID%20%3D%20' + user_story + ')&fetch=true',
|
102 | headers: {zsessionid: zsessionid},
|
103 | proxy: proxy
|
104 | };
|
105 | var to_return;
|
106 | request(options)
|
107 | .then(function (body,error) {
|
108 | if (error) {
|
109 | console.log('error: ' + error);
|
110 | callbck(to_return);
|
111 | } else {
|
112 | //console.log('body US: ' + body);
|
113 | var json_body = JSON.parse(body);
|
114 | if (json_body.QueryResult.TotalResultCount > 0) {
|
115 | user_story_id = json_body.QueryResult.Results[0].ObjectID;
|
116 | } else {
|
117 | user_story_id = '';
|
118 | }
|
119 | to_return = {
|
120 | body: json_body,
|
121 | user_story_id: user_story_id,
|
122 | json: json,
|
123 | i: i,
|
124 | j: j,
|
125 | test_case_name: test_case_name,
|
126 | test_case_description: test_case_description,
|
127 | glb_folder_id: glb_folder_id,
|
128 | line: line,
|
129 | duration: duration,
|
130 | status: status
|
131 | }
|
132 | return callbck(to_return);
|
133 | }
|
134 | });
|
135 | },
|
136 | queryTestCases: function (test_case, json, i, j, user_story, glb_folder_id, callbck){
|
137 | var last_run = false; var test_case_result_id = 0;
|
138 | var request = require("request-promise");
|
139 | var options = {
|
140 | method: 'GET',
|
141 | url: baseUrl + 'testcase?query=(Name%20%3D%20' + test_case + ')&fetch=true',
|
142 | headers: {
|
143 | zsessionid: zsessionid
|
144 | },
|
145 | proxy: proxy
|
146 | };
|
147 | var revision_history_ref;
|
148 | request(options)
|
149 | .then(function (body,error) {
|
150 | var id = 0;
|
151 | if (error) {
|
152 | console.log("Rally error: " + error);
|
153 | } else {
|
154 | // console.log('else case:');
|
155 | // console.log('query test case: ' + body);
|
156 | var json_body = JSON.parse(body);
|
157 | //console.log('last result is: ' + JSON.stringify(json_body.QueryResult.Results[0].LastResult));
|
158 | if (json_body.QueryResult.TotalResultCount > 0) {
|
159 | if (json_body.QueryResult.Results[0]._refObjectName == test_case) {
|
160 |
|
161 | if(json_body.QueryResult.Results[0].LastResult == null) {
|
162 | //console.log('no result');
|
163 | last_run = false;
|
164 | } else {
|
165 | last_run = true;
|
166 | test_case_result_id = json_body.QueryResult.Results[0].LastResult._ref;
|
167 | test_case_result_id = test_case_result_id.split('/');
|
168 | test_case_result_id = test_case_result_id[7];
|
169 | //console.log('test case result id: ' + test_case_result_id);
|
170 | }
|
171 | id = json_body.QueryResult.Results[0].ObjectID;
|
172 | //console.log('id in test case is: ' + id);
|
173 | if(json_body.QueryResult.Results[0].RevisionHistory._ref != null)
|
174 | revision_history_ref = json_body.QueryResult.Results[0].RevisionHistory._ref;
|
175 | else
|
176 | revision_history_ref = '';
|
177 | found = true;
|
178 | } else {
|
179 | found = false;
|
180 | last_run = false;
|
181 | }
|
182 | } else {
|
183 | found = false;
|
184 | last_run = false;
|
185 | }
|
186 | var to_return = {
|
187 | found: found,
|
188 | json: json,
|
189 | i: i,
|
190 | j: j,
|
191 | id: id,
|
192 | case_name: test_case,
|
193 | user_story: user_story,
|
194 | glb_folder_id: glb_folder_id,
|
195 | last_run: last_run,
|
196 | test_case_result_id:test_case_result_id,
|
197 | revision_history_ref:revision_history_ref
|
198 | };
|
199 | callbck(to_return);
|
200 | }
|
201 | });
|
202 | },
|
203 | queryTestFolders: function (test_plan, json, i, j, folder_id, callbck) {
|
204 | var request = require("request-promise");
|
205 | var options = {
|
206 | method: 'GET',
|
207 | url: baseUrl + 'testfolder?query=(Name%20%3D%20' + test_plan + ')&fetch=true',
|
208 | headers: {
|
209 | zsessionid: zsessionid
|
210 | },
|
211 | proxy: proxy
|
212 | };
|
213 | request(options)
|
214 | .then(function (body, error) {
|
215 | var folderID = 0;
|
216 | if (error) {
|
217 | console.log("Rally error: " + error);
|
218 | } else {
|
219 | //console.log('query TF: ' + body);
|
220 | var json_body = JSON.parse(body);
|
221 | if (json_body.QueryResult.TotalResultCount > 0) {
|
222 | if (json_body.QueryResult.Results[0]._refObjectName == test_plan) {
|
223 | if ((folder_id == 0) || (json_body.QueryResult.Results[0].Parent != null)) {
|
224 | folderID = json_body.QueryResult.Results[0].ObjectID;
|
225 | found = true;
|
226 | } else {
|
227 | found = false
|
228 | }
|
229 | } else {
|
230 | found = false;
|
231 | }
|
232 | } else {
|
233 | found = false;
|
234 | }
|
235 | var to_return = {
|
236 | found: found,
|
237 | json: json,
|
238 | i: i,
|
239 | j: j,
|
240 | folderID: folderID,
|
241 | test_plan: test_plan
|
242 | };
|
243 | callbck(to_return);
|
244 | }
|
245 | });
|
246 |
|
247 | },
|
248 | queryTestSet: function(testset, status, duration, glb_test_case_id, glb_folder_id, json, i, j, k, callbck) {
|
249 | if(testset==''){
|
250 | to_return = {
|
251 | test_set_id:'',
|
252 | status:status,
|
253 | duration:duration,
|
254 | glb_test_case_id:glb_test_case_id,
|
255 | glb_folder_id:glb_folder_id,
|
256 | json:json,
|
257 | i:i,
|
258 | j:j,
|
259 | k:k
|
260 | }
|
261 | callbck(to_return);
|
262 | } else {
|
263 | var request = require('request-promise');
|
264 | var test_set_id;
|
265 | var options = {
|
266 | method: 'GET',
|
267 | url: 'https://rally1.rallydev.com/slm/webservice/v2.0/testset?' +
|
268 | 'query=(FormattedID%20%3D%20' + testset + ')&fetch=true',
|
269 | headers: {zsessionid: zsessionid},
|
270 | proxy: proxy
|
271 | };
|
272 | var to_return;
|
273 | request(options)
|
274 | .then(function (body, error) {
|
275 | //console.log('query test set: ' + body);
|
276 | var json_body = JSON.parse(body);
|
277 | if (json_body.QueryResult.TotalResultCount > 0) {
|
278 | test_set_id = json_body.QueryResult.Results[0].ObjectID;
|
279 | } else {
|
280 | test_set_id = '';
|
281 | }
|
282 | to_return = {
|
283 | test_set_id: test_set_id,
|
284 | status: status,
|
285 | duration: duration,
|
286 | glb_test_case_id: glb_test_case_id,
|
287 | glb_folder_id: glb_folder_id,
|
288 | json: json,
|
289 | i: i,
|
290 | j: j,
|
291 | k: k
|
292 | }
|
293 | callbck(to_return);
|
294 | });
|
295 | }
|
296 | },
|
297 | queryRevisionHistory: function(revision_history_ref, user_story, json, i, j, test_case_name, test_case_description, glb_folder_id, line, duration, status, callbck){
|
298 | var request = require("request-promise");
|
299 | var options = {
|
300 | method: 'GET',
|
301 | url: revision_history_ref + '/Revisions',
|
302 | headers:
|
303 | { zsessionid:zsessionid},
|
304 | proxy:proxy
|
305 | };
|
306 | var owner_url, owner;
|
307 | request(options)
|
308 | .then(function (body,error) {
|
309 | if(error) {
|
310 | console.log('Rally error: '+ error);
|
311 | callbck();
|
312 | }
|
313 | else {
|
314 | //console.log('revision history: ' + body);
|
315 | var json_body = JSON.parse(body);
|
316 | if(json_body.QueryResult.TotalResultCount > 0){
|
317 | owner_url = json_body.QueryResult.Results[0].User._ref;
|
318 | owner = owner_url.split('/');
|
319 | var to_return = {
|
320 | owner: owner[7],
|
321 | user_story: user_story,
|
322 | json:json,
|
323 | i:i,
|
324 | j:j,
|
325 | test_case_name: test_case_name,
|
326 | test_case_description:test_case_description,
|
327 | glb_folder_id: glb_folder_id,
|
328 | line:line,
|
329 | duration:duration,
|
330 | status:status
|
331 | }
|
332 |
|
333 | callbck(to_return);
|
334 | }
|
335 | }
|
336 | });
|
337 | },
|
338 | createTestPlan: function (test_plan, test_plan_description, parent_folder, json, i, j, callbck) {
|
339 | var body, folder_id;
|
340 | if (parent_folder == 0) {
|
341 | if (workspace != "") {
|
342 | body = '{\n' +
|
343 | ' "testfolder":\n' +
|
344 | ' {\n' +
|
345 | ' "Name":"' + test_plan + '",\n' +
|
346 | ' "Workspace":"/Workspace/' + workspace + '"\n' +
|
347 | ' }\n' +
|
348 | '}'
|
349 | } else {
|
350 | body = '{\n' +
|
351 | ' "testfolder":\n' +
|
352 | ' {\n' +
|
353 | ' "Name":"' + test_plan + '"\n' +
|
354 | ' }\n' +
|
355 | '}'
|
356 | }
|
357 | } else {
|
358 | if (workspace != "") {
|
359 | body = '{\n' +
|
360 | ' "testfolder":\n' +
|
361 | ' {\n' +
|
362 | ' "Name":"' + test_plan + '" ,\n' +
|
363 | ' "Parent":"' + parent_folder + '"\n' +
|
364 | ' "Workspace":"/Workspace/' + workspace + '"\n' +
|
365 | ' }\n' +
|
366 | '}'
|
367 | } else {
|
368 | body = '{\n' +
|
369 | ' "testfolder":\n' +
|
370 | ' {\n' +
|
371 | ' "Name":"' + test_plan + '" ,\n' +
|
372 | ' "Parent":"' + parent_folder + '"\n' +
|
373 | ' }\n' +
|
374 | '}'
|
375 | }
|
376 | }
|
377 | var to_return;
|
378 | var request = require("request-promise");
|
379 | var options = {
|
380 | method: 'POST',
|
381 | url: baseUrl + 'testfolder/create?fetch=true',
|
382 | headers: {
|
383 | zsessionid: zsessionid
|
384 | },
|
385 | body: body,
|
386 | proxy: proxy
|
387 | };
|
388 | request(options)
|
389 | .then(function (body,error) {
|
390 | if (error) {
|
391 | console.log("Rally error: " + error);
|
392 | }
|
393 | else {
|
394 | //console.log('create test plan: ' + body);
|
395 | var json_body = JSON.parse(body);
|
396 | folder_id = json_body.CreateResult.Object.ObjectID;
|
397 | to_return = {
|
398 | json: json,
|
399 | i: i,
|
400 | j: j,
|
401 | id: folder_id
|
402 | }
|
403 | }
|
404 | return callbck(to_return);
|
405 | });
|
406 | },
|
407 | createTestCaseResult: function (name, status, duration, test_case_id, glb_folder_id, json, i, j, k, testset, callbck) {
|
408 | if (duration > 9999999999) {
|
409 | duration = 9999999999;
|
410 | }
|
411 | if (status == 'passed') {
|
412 | status = 'Pass';
|
413 | } else if (status == "failed") {
|
414 | status = 'Fail';
|
415 | } else if (status == "skipped") {
|
416 | status = 'Inconclusive';
|
417 | duration = 0;
|
418 | }
|
419 |
|
420 | var d = new Date();
|
421 | var date = d.toISOString();
|
422 | var request = require("request-promise");
|
423 | var options = {
|
424 | method: 'POST',
|
425 | url: baseUrl + 'testcaseresult/create',
|
426 | headers: {
|
427 | zsessionid: zsessionid
|
428 | },
|
429 | proxy: proxy,
|
430 | body:
|
431 | '{\n "testcaseresult":\n' +
|
432 | ' {\n' +
|
433 | ' "TestCase":"/testcase/' + test_case_id + '",\n' +
|
434 | ' "Build":"' + name + '",\n' +
|
435 | ' "Duration":"' + duration + '",\n' +
|
436 | ' "Verdict":"' + status + '",\n' +
|
437 | ' "Date":"' + date + '",\n' +
|
438 | ' "TestSet":"' + testset + '"\n' +
|
439 | ' }\n' +
|
440 | '}'
|
441 | };
|
442 | var id=0;
|
443 | request(options)
|
444 | .then(function (body,error) {
|
445 | if (error) {
|
446 | console.log("Rally error: " + error);
|
447 | } else {
|
448 | //console.log('result created: ' + body);
|
449 | body = JSON.parse(body);
|
450 | var err = body.CreateResult.Errors;
|
451 | if(err != '') {
|
452 | //console.log('concurrency error: calling again should call again');
|
453 | id=null;
|
454 | //return callbck('concurrency');
|
455 | }
|
456 | else {
|
457 | id = body.CreateResult.Object.ObjectID;
|
458 | }
|
459 | var to_return = {
|
460 | json: json,
|
461 | i: i,
|
462 | j: j,
|
463 | k: k,
|
464 | id:id
|
465 | };
|
466 | return callbck(to_return);
|
467 | }
|
468 | });
|
469 | },
|
470 | createTestCase: function (test_case_name, test_case_description, folder_id, json, i, j, k, duration, line, status, user_story, callbck_create) {
|
471 | //console.log('in create TC: ' + test_case_name);
|
472 | var request = require('request-promise');
|
473 | if (duration == undefined) {
|
474 | duration = 0;
|
475 | }
|
476 | if (folder_id == null) {
|
477 | folder_id = glb_subfolder_id;
|
478 | }
|
479 | var create_id = 0;
|
480 | var to_ret, body;
|
481 | if (test_case_description == "") {
|
482 | test_case_description = "N/A";
|
483 | }
|
484 | if (workspace != "") {
|
485 | if (User_Story != "") { // defined user story & workspace
|
486 | body = '{\n' +
|
487 | ' "testcase":\n' +
|
488 | ' {\n' +
|
489 | ' "Name":"' + test_case_name + '",\n' +
|
490 | ' "Description":"' + test_case_description + '",\n' +
|
491 | ' "Method":"'+method+'",\n' +
|
492 | ' "TestFolder":"' + folder_id + '",\n' +
|
493 | ' "Workspace":"/Workspace/' + workspace + '",\n' +
|
494 | ' "WorkProduct":"' + user_story + '"\n' +
|
495 | ' }\n' +
|
496 | '}'
|
497 | } else { //no user story & defined workspace
|
498 | body = '{\n' +
|
499 | ' "testcase":\n' +
|
500 | ' {\n' +
|
501 | ' "Name":"' + test_case_name + '",\n' +
|
502 | ' "Description":"' + test_case_description + '",\n' +
|
503 | ' "Method":"'+method+'",\n' +
|
504 | ' "TestFolder":"' + folder_id + '",\n' +
|
505 | ' "Workspace":"/Workspace/' + workspace + '"\n' +
|
506 | ' }\n' +
|
507 | '}'
|
508 | }
|
509 | } else {
|
510 | if (User_Story != "") { //no defined workspace / defined user story
|
511 | body = '{\n' +
|
512 | ' "testcase":\n' +
|
513 | ' {\n' +
|
514 | ' "Name":"' + test_case_name + '",\n' +
|
515 | ' "Description":"' + test_case_description + '",\n' +
|
516 | ' "Method":"'+method+'",\n' +
|
517 | ' "TestFolder":"' + folder_id + '",\n' +
|
518 | ' "WorkProduct":"' + user_story + '"\n' +
|
519 | ' }\n' +
|
520 | '}'
|
521 | } else {
|
522 | body = '{\n' +
|
523 | ' "testcase":\n' +
|
524 | ' {\n' +
|
525 | ' "Name":"' + test_case_name + '",\n' +
|
526 | ' "Description":"' + test_case_description + '",\n' +
|
527 | ' "Method":"'+method+'",\n' +
|
528 | ' "TestFolder":"' + folder_id + '"\n' +
|
529 | ' }\n' +
|
530 | '}'
|
531 | }
|
532 | }
|
533 | var options = {
|
534 | method: 'POST',
|
535 | url: baseUrl + 'testcase/create',
|
536 | headers: {
|
537 | zsessionid: zsessionid
|
538 | },
|
539 | proxy: proxy,
|
540 | body: body
|
541 | };
|
542 | request(options)
|
543 | .then( function (body,error) {
|
544 | if (error) {
|
545 | console.log('Rally error: ' + error);
|
546 | to_ret = {
|
547 | json: json,
|
548 | i: i,
|
549 | j: j,
|
550 | k: k,
|
551 | duration: duration,
|
552 | line: line,
|
553 | id: 'returned null',
|
554 | status: status,
|
555 | folder_id: folder_id,
|
556 | user_story: user_story
|
557 | };
|
558 | return callbck_create(to_ret);
|
559 | } else {
|
560 | //console.log('create test case: ' + body);
|
561 | body = JSON.parse(body);
|
562 |
|
563 | if (body.CreateResult.Object != undefined) {
|
564 | create_id = body.CreateResult.Object.ObjectID;
|
565 | }
|
566 | else {
|
567 | create_id = 0;
|
568 | }
|
569 | to_ret = {
|
570 | json: json,
|
571 | i: i,
|
572 | j: j,
|
573 | k: k,
|
574 | duration: duration,
|
575 | line: line,
|
576 | id: create_id,
|
577 | status: status,
|
578 | folder_id: folder_id,
|
579 | user_story: user_story
|
580 | };
|
581 | return callbck_create(to_ret);
|
582 | }
|
583 | });
|
584 | },
|
585 | updateTestCaseResult: function (test_case_id, test_case_result_id, duration, name, status, user_story, i, j, k, testset, callbck) {
|
586 | //console.log('update TCR fxn: ' + testset + ' tc: ' + test_case_id + ' tcrid ' + test_case_result_id);
|
587 | if (duration == undefined) {
|
588 | duration = 0;
|
589 | }
|
590 | if ((duration != undefined) && (duration > 9999999999)) {
|
591 | duration = 9999999999;
|
592 | }
|
593 | if (status == 'passed') {
|
594 | status = 'Pass';
|
595 | } else if (status == "failed") {
|
596 | status = 'Fail';
|
597 | } else if (status == "skipped") {
|
598 | status = 'Inconclusive';
|
599 | duration = 0;
|
600 | }
|
601 |
|
602 | var d = new Date();
|
603 | var date = d.toISOString();
|
604 | var request = require("request-promise");
|
605 | var to_return;
|
606 | var options = {
|
607 | method: 'POST',
|
608 | url: baseUrl + 'testcaseresult/' + test_case_result_id,
|
609 | headers: {
|
610 | zsessionid: zsessionid
|
611 | },
|
612 | proxy: proxy,
|
613 | body: '{\n' +
|
614 | ' "testcaseresult":\n' +
|
615 | ' {\n' +
|
616 | ' "Build":"' + name + '",\n' +
|
617 | ' "Duration":"' + duration + '",\n' +
|
618 | ' "Date":"' + date + '",\n' +
|
619 | ' "TestCase":"/testcase/' + test_case_id + '",\n' +
|
620 | ' "Verdict":"' + status + '",\n' +
|
621 | ' "TestSet":"' + testset + '"\n' +
|
622 | ' }\n' +
|
623 | '}'
|
624 | };
|
625 | request(options)
|
626 | .then(function (body,error) {
|
627 | if (error) {
|
628 | console.log("Rally error: " + error);
|
629 | } else {
|
630 | //console.log('update test case result: ' + body);
|
631 | to_return = {
|
632 | i: i,
|
633 | j: j,
|
634 | k: k
|
635 | };
|
636 | return callbck(to_return);
|
637 | }
|
638 | });
|
639 | },
|
640 | updateTestCase: function (test_case_id, user_story, i, j, body, json, test_case_name, test_case_description, glb_folder_id, line, duration, status, owner, testset, callbck) {
|
641 | //console.log('in update TC fxn');
|
642 | var request = require("request-promise");
|
643 | var options = {
|
644 | method: 'POST',
|
645 | url: baseUrl + '/testcase/' + test_case_id,
|
646 | headers: {zsessionid: zsessionid},
|
647 | proxy: proxy,
|
648 | body: '{\n' +
|
649 | ' "testcase":\n {\n' +
|
650 | ' "WorkProduct":"' + user_story + '",\n' +
|
651 | ' "Owner":"' + owner + '"\n' +
|
652 | ' "Method":"'+method+'",\n' +
|
653 | ' }\n' +
|
654 | '}'
|
655 | };
|
656 | request(options)
|
657 | .then(function (body,error) {
|
658 | var to_return;
|
659 | if (error) {
|
660 | console.log('error occurred: ' + error);
|
661 | callbck();
|
662 | } else {
|
663 | //console.log('updated test case: ' + body);
|
664 | body = JSON.parse(body);
|
665 | to_return = {
|
666 | test_case_id: test_case_id,
|
667 | user_story: user_story,
|
668 | i: i,
|
669 | j:j,
|
670 | body:body,
|
671 | json:json,
|
672 | test_case_name: test_case_name,
|
673 | test_case_description: test_case_description,
|
674 | glb_folder_id:glb_folder_id,
|
675 | line:line,
|
676 | duration: duration,
|
677 | status:status
|
678 | };
|
679 | callbck(to_return);
|
680 | }
|
681 | });
|
682 | },
|
683 | updateTestSet: function(testset, testcase, status, duration, glb_test_case_id, glb_folder_id, json, i, j, k, callbck){
|
684 | //TODO: add error handling here - if testset is null, callback
|
685 | //console.log('in update TS fxn');
|
686 | if(testset == ''){
|
687 | to_return = {
|
688 | test_set_id:'',
|
689 | status:status,
|
690 | duration:duration,
|
691 | glb_test_case_id:glb_test_case_id,
|
692 | glb_folder_id:glb_folder_id,
|
693 | json:json,
|
694 | i:i,
|
695 | j:j,
|
696 | k:k
|
697 | }
|
698 | callbck(to_return);
|
699 | } else {
|
700 | var request = require("request-promise");
|
701 | var options = {
|
702 | method: 'POST',
|
703 | url: 'https://rally1.rallydev.com/slm/webservice/v2.x/TestSet/' + testset + '/TestCases/add?fetch=true',
|
704 | headers: {zsessionid: zsessionid},
|
705 | proxy: proxy,
|
706 | body: '{"CollectionItems":[{"_ref":"/testcase/' + testcase + '"}]}'
|
707 | };
|
708 | var to_return;
|
709 | request(options)
|
710 | .then(function (body, error) {
|
711 | //console.log('updated test set: ' + body);
|
712 | to_return = {
|
713 | test_set_id: testset,
|
714 | status: status,
|
715 | duration: duration,
|
716 | glb_test_case_id: glb_test_case_id,
|
717 | glb_folder_id: glb_folder_id,
|
718 | json: json,
|
719 | i: i,
|
720 | j: j,
|
721 | k: k
|
722 | }
|
723 | callbck(to_return);
|
724 | });
|
725 | }
|
726 | }
|
727 | }
|
728 | };
|
729 | module.exports = new RallyHelper();
|
730 | }());</code></pre>
|
731 | </article>
|
732 | </section>
|
733 |
|
734 |
|
735 |
|
736 |
|
737 | </div>
|
738 |
|
739 | <nav>
|
740 | <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="HighChart.html">HighChart</a></li><li><a href="PxDataTable.html">PxDataTable</a></li><li><a href="RestHelper.html">RestHelper</a></li><li><a href="TestHelper.html">TestHelper</a></li></ul><h3>Global</h3><ul><li><a href="global.html#acceptAlert">acceptAlert</a></li><li><a href="global.html#alertIsPresent">alertIsPresent</a></li><li><a href="global.html#assertEqual">assertEqual</a></li><li><a href="global.html#assertInclude">assertInclude</a></li><li><a href="global.html#assertTrue">assertTrue</a></li><li><a href="global.html#clearFilter">clearFilter</a></li><li><a href="global.html#compareData">compareData</a></li><li><a href="global.html#createTestcase">createTestcase</a></li><li><a href="global.html#createTestcaseResult">createTestcaseResult</a></li><li><a href="global.html#createTestPlan">createTestPlan</a></li><li><a href="global.html#dismissAlert">dismissAlert</a></li><li><a href="global.html#dragAndDrop">dragAndDrop</a></li><li><a href="global.html#dragAndDrop2">dragAndDrop2</a></li><li><a href="global.html#elementToBeClickable">elementToBeClickable</a></li><li><a href="global.html#elementToBeSelected">elementToBeSelected</a></li><li><a href="global.html#executeDeleteRequest">executeDeleteRequest</a></li><li><a href="global.html#executeGetRequest">executeGetRequest</a></li><li><a href="global.html#executePatchRequest">executePatchRequest</a></li><li><a href="global.html#executePostRequest">executePostRequest</a></li><li><a href="global.html#executePutRequest">executePutRequest</a></li><li><a href="global.html#geSSOLogin">geSSOLogin</a></li><li><a href="global.html#getAccessToken">getAccessToken</a></li><li><a href="global.html#getAttribute">getAttribute</a></li><li><a href="global.html#getAxisLabels">getAxisLabels</a></li><li><a href="global.html#getAxisText">getAxisText</a></li><li><a href="global.html#getAxisTextByIndex">getAxisTextByIndex</a></li><li><a href="global.html#getBMChartData">getBMChartData</a></li><li><a href="global.html#getCellElement">getCellElement</a></li><li><a href="global.html#getCellElements">getCellElements</a></li><li><a href="global.html#getCellElementText">getCellElementText</a></li><li><a href="global.html#getCellHtml">getCellHtml</a></li><li><a href="global.html#getCellText">getCellText</a></li><li><a href="global.html#getChartData">getChartData</a></li><li><a href="global.html#getColumnCount">getColumnCount</a></li><li><a href="global.html#getColumnElementValues">getColumnElementValues</a></li><li><a href="global.html#getColumnHeaderElements">getColumnHeaderElements</a></li><li><a href="global.html#getColumnHtmlValues">getColumnHtmlValues</a></li><li><a href="global.html#getColumnindex">getColumnindex</a></li><li><a href="global.html#getColumnNames">getColumnNames</a></li><li><a href="global.html#getColumnTextValues">getColumnTextValues</a></li><li><a href="global.html#getContainer">getContainer</a></li><li><a href="global.html#getCssValue">getCssValue</a></li><li><a href="global.html#getCurrentPage">getCurrentPage</a></li><li><a href="global.html#getElementManager">getElementManager</a></li><li><a href="global.html#getFilter">getFilter</a></li><li><a href="global.html#getLegendsFromSection">getLegendsFromSection</a></li><li><a href="global.html#getObjectRef">getObjectRef</a></li><li><a href="global.html#getOOChartData">getOOChartData</a></li><li><a href="global.html#getRandomString">getRandomString</a></li><li><a href="global.html#getRowCount">getRowCount</a></li><li><a href="global.html#getRowElementValues">getRowElementValues</a></li><li><a href="global.html#getRowHtmlValues">getRowHtmlValues</a></li><li><a href="global.html#getRowPerPageValue">getRowPerPageValue</a></li><li><a href="global.html#getRowTextValues">getRowTextValues</a></li><li><a href="global.html#getSVG">getSVG</a></li><li><a href="global.html#getText">getText</a></li><li><a href="global.html#getTooltipInfo">getTooltipInfo</a></li><li><a href="global.html#getUSTSRef">getUSTSRef</a></li><li><a href="global.html#getXaxisLabels">getXaxisLabels</a></li><li><a href="global.html#getXaxisText">getXaxisText</a></li><li><a href="global.html#getYaxisLabels">getYaxisLabels</a></li><li><a href="global.html#getYaxisText">getYaxisText</a></li><li><a href="global.html#goToNextPage">goToNextPage</a></li><li><a href="global.html#goToPage">goToPage</a></li><li><a href="global.html#goToPreviousPage">goToPreviousPage</a></li><li><a href="global.html#iFrameSwitch">iFrameSwitch</a></li><li><a href="global.html#initialize">initialize</a></li><li><a href="global.html#isChartDisplayed">isChartDisplayed</a></li><li><a href="global.html#isElementNotPresent">isElementNotPresent</a></li><li><a href="global.html#isElementPresent">isElementPresent</a></li><li><a href="global.html#isElementVisible">isElementVisible</a></li><li><a href="global.html#name">name</a></li><li><a href="global.html#noTestCaseFound">noTestCaseFound</a></li><li><a href="global.html#noTestFolderFound">noTestFolderFound</a></li><li><a href="global.html#onPageLoad">onPageLoad</a></li><li><a href="global.html#onPageStable">onPageStable</a></li><li><a href="global.html#postResults">postResults</a></li><li><a href="global.html#postTest">postTest</a></li><li><a href="global.html#scrollIntoView">scrollIntoView</a></li><li><a href="global.html#sendKeys">sendKeys</a></li><li><a href="global.html#setChartElements">setChartElements</a></li><li><a href="global.html#setContainer">setContainer</a></li><li><a href="global.html#setContianer">setContianer</a></li><li><a href="global.html#setElementManager">setElementManager</a></li><li><a href="global.html#setFilter">setFilter</a></li><li><a href="global.html#setRowPerPageValue">setRowPerPageValue</a></li><li><a href="global.html#setSVG">setSVG</a></li><li><a href="global.html#setup">setup</a></li><li><a href="global.html#skipAngularStability">skipAngularStability</a></li><li><a href="global.html#sortColumn">sortColumn</a></li><li><a href="global.html#teardown">teardown</a></li><li><a href="global.html#TestCaseFound">TestCaseFound</a></li><li><a href="global.html#TestCaseResult">TestCaseResult</a></li><li><a href="global.html#TestFolderFound">TestFolderFound</a></li><li><a href="global.html#textToBePresentInElement">textToBePresentInElement</a></li><li><a href="global.html#textToBePresentInElementValue">textToBePresentInElementValue</a></li><li><a href="global.html#titleContains">titleContains</a></li><li><a href="global.html#titleIs">titleIs</a></li><li><a href="global.html#updateTestCase">updateTestCase</a></li><li><a href="global.html#updateTestCaseResult">updateTestCaseResult</a></li><li><a href="global.html#updateTestSet">updateTestSet</a></li><li><a href="global.html#uploadFile">uploadFile</a></li><li><a href="global.html#UserPermissions">UserPermissions</a></li><li><a href="global.html#waitForAngular">waitForAngular</a></li><li><a href="global.html#waitForCondition">waitForCondition</a></li><li><a href="global.html#waitForElementToDisappear">waitForElementToDisappear</a></li><li><a href="global.html#waitForPromise">waitForPromise</a></li><li><a href="global.html#winston">winston</a></li></ul>
|
741 | </nav>
|
742 |
|
743 | <br class="clear">
|
744 |
|
745 | <footer>
|
746 | Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.1</a> on Mon Oct 30 2017 11:31:46 GMT-0700 (PDT)
|
747 | </footer>
|
748 |
|
749 | <script> prettyPrint(); </script>
|
750 | <script src="scripts/linenumber.js"> </script>
|
751 | </body>
|
752 | </html>
|