-
Notifications
You must be signed in to change notification settings - Fork 217
/
TestCaseEstimation.html
449 lines (384 loc) · 14.2 KB
/
TestCaseEstimation.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<!-- Copyright (c) 2002-2010 Rally Software Development Corp. All rights reserved. -->
<html>
<head>
<title>Test Case Estimation</title>
<meta name="Name" content="Mashup: Test Case Estimation"/>
<meta name="Version" content="2.0"/>
<meta name="Vendor" content="Rally Software"/>
<link rel="stylesheet" type="text/css" href="/slm/css/rally/core.css" charset="utf-8"/>
<link rel="stylesheet" type="text/css" href="/slm/css/slm.css" charset="utf-8"/>
<style type="text/css">
body {
font-family: tahoma, geneva, helvetica, arial, sans-serif;
font-size: 11px;
background: white;
}
.heading {
font-weight: bold;
border: 0px;
}
table {
background: white;
}
th {
font-family: tahoma, geneva, helvetica, arial, sans-serif;
font-size: 11px;
font-weight: bold;
}
td {
font-family: tahoma, geneva, helvetica, arial, sans-serif;
font-size: 10px;
font-weight: normal;
}
.tchl {
text-align: left;
padding-left: 4px;
}
.tchc {
text-align: center;
padding-right: 4px;
}
.tchr {
text-align: right;
padding-right: 4px;
}
.tccl {
text-align: left;
padding-left: 4px;
}
.tccc {
text-align: center;
padding-right: 4px;
}
.tccr {
text-align: right;
padding-right: 12px;
}
a {
font-family: tahoma, geneva, helvetica, arial, sans-serif;
font-size: 10px;
text-decoration: none;
}
a:link {
font-family: tahoma, geneva, helvetica, arial, sans-serif;
font-size: 10px;
color: #366AB7;
}
a:visited {
font-family: tahoma, geneva, helvetica, arial, sans-serif;
font-size: 10px;
color: #366AB7;
}
a img {
cursor: pointer;
}
/* Color Squares for the Verdict table cell */
.pass-legend {
width: 35px;
background: #6AB17D none repeat scroll 0%;
border: 1px solid #DDDDDD;
color: white;
cursor: default;
float: left;
height: 14px;
line-height: 14px;
margin-right: 1px;
margin-left: 1px;
text-align: center;
font-weight: bold;
}
.pass-legend-fail {
width: 35px;
background: #F47168 none repeat scroll 0%;
border: 1px solid #DDDDDD;
color: black;
cursor: default;
float: left;
height: 14px;
line-height: 14px;
margin-right: 1px;
margin-left: 1px;
text-align: center;
font-weight: bold;
}
.none-legend {
width: 35px;
background: #FFFFFF none repeat scroll 0%;
border: 1px solid #AAAAAA;
color: black;
cursor: default;
float: left;
height: 14px;
line-height: 14px;
margin-right: 1px;
margin-left: 1px;
text-align: center;
font-weight: normal;
}
</style>
<script src="/slm/js-lib/dojo/1.3.1/dojo/dojo.js"></script>
<script src="/slm/js/slm.js"></script>
<script src="/slm/mashup/1.18/js/batch-toolkit.js"></script>
<script src="/slm/mashup/1.18/js/utilities.js"></script>
<script src="/slm/js-lib/ejsc/2.0.1/EJSChart.js"></script>
<script type="text/javascript">
function dontProceedNotification(targetDiv) {
var noJoy = "<strong>You do not have the necessary custom fields defined for this mashup.<br>" +
"<p>TestCaseEstimate, TestCaseToDo and TestCaseActual must be defined " +
"as custom fields for the 'Test Case' artifact</strong></p>";
targetDiv.innerHTML = noJoy;
}
function hasNecessaryCustomFields(attributes, requiredCustomFields) {
var status = false;
var customFieldsDetected = 0;
customFields = [];
for (var ix = 0; ix < attributes.length; ix++) {
attribute = attributes[ix];
if (attribute.Custom === true) {
customFields.push(attribute);
}
}
//console.log("Your custom fields:");
//console.log(customFields);
var attr = null;
for (var j = 0; j < requiredCustomFields.length; j++) {
ncfName = requiredCustomFields[j];
//console.log("Looking to see if _" + ncfName + "_ exists as a custom field ...");
for (var k = 0; k < customFields.length; k++) {
attr = customFields[k];
//console.log("_____ " + attr.ElementName + " " + attr.AttributeType);
if (attr.ElementName === ncfName && attr.AttributeType === 'DECIMAL') {
//console.log(" bingo!!");
customFieldsDetected++;
}
}
}
//console.log("found " + customFieldsDetected + " of the " + requiredCustomFields.length + " required custom fields");
if (customFieldsDetected === requiredCustomFields.length) {
status = true;
}
return status;
}
function shortUrl(type) {
if (type == "User Story") {
return "ar";
}
else if (type == "Defect") {
return "df";
}
else if (type == "Task") {
return "tk";
}
else if (type == "Test Case") {
return "tc";
}
else if (type == "Test Case Result") {
return "tcr";
}
return "error";
}
function createUrl(type, ident) {
var url = "__SERVER_URL__" + "/detail/" + shortUrl(type) + "/" + ident;
return url;
}
function drawBox(verdict) {
if (verdict === 'Pass') {
verdict_class = 'pass-legend';
}
else if (verdict === 'Fail') {
verdict_class = 'pass-legend-fail';
}
else {
verdict_class = 'none-legend';
}
return '<div class="' + verdict_class + '">' + verdict + '</div>';
}
function makeChart(est, todo, act) {
var chart_options = { show_legend: false,
axis_left : {caption: "", size: 15},
axis_bottom: {caption: "", size: 10},
axis_right : {size: 20}
};
var chart = new EJSC.Chart("TCE_Chart", chart_options);
chart.setTitle("");
var dataSeries = [
["Est", est],
["ToDo", todo],
["Actual", act]
];
var adh = new EJSC.ArrayDataHandler(dataSeries);
chart.addSeries(new EJSC.BarSeries(adh, {intervalOffset: 0.5}));
}
var TABLE_START = '<table width="60%" style="margin-top: 15px; margin-left: 5px;">';
var TABLE_END = "</table>";
var HEADER_ROW = '<tr><th class="tchl">Test Case</th> <th> </th> <th class="tchr">Estimate</th> <th> </th> ' +
'<th class="tchr">To Do</th> <th> </th> <th class="tchr">Actual</th> ' +
'<th> </th> <th class="tchc">Verdict</th></tr>';
var TC_ROW = '<tr><td class="tccl">_TC_INFO_</td><td> </td> <td class="tccr">_TC_ESTIMATE_</td> <td> </td> ' +
'<td class="tccr">_TC_TODO_</td> <td> </td> <td class="tccr">_TC_ACTUAL_</td> ' +
'<td> </td> <td class="tccc">_VERDICT_</td> </tr>';
var TC_LINK = "<div class=\"heading\"><a href=\"_TARGET_URL_\" target=\"_top\">_ID_ _NAME_</a></div>";
var TOTALS_TABLE = '<table>' +
' <tr>' +
' <th>Test Case <br>Estimate Total</th> ' +
' <th> </th> ' +
' <th>Test Case <br>Estimate To Do</th> ' +
' <th> </th> ' +
' <th>Test Case <br>Actual</th>' +
' </tr>\n' +
' <tr>' +
' <td align="center">_TOT_EST_</td> ' +
' <td> </td> ' +
' <td align="center">_TOT_TODO_</td> ' +
' <td> </td> ' +
' <td align="center">_TOT_ACT_</td>' +
' </tr>' +
'</table>';
function showTestCaseEstimateInfo(testcaseResults) {
//console.log(" ... in showTestCaseEstimateInfo ...");
var totalTestCaseEstimates = 0;
var totalTestCaseToDo = 0;
var totalTestCaseActual = 0;
var blurb = "";
var tableRows = [];
var row = "";
var testCase = "";
var verdictBox = "";
for (var ix = 0; ix < testcaseResults.length; ix++) {
testCase = testcaseResults[ix];
targetUrl = createUrl('Test Case', testCase.ObjectID);
tcLink = TC_LINK.replace('_ID_', testCase.FormattedID).replace('_NAME_', testCase.Name);
tcInfo = tcLink.replace('_TARGET_URL_', targetUrl);
row = TC_ROW.replace('_TC_INFO_', tcInfo);
//
//blurb += "_IDENT_ _NAME_<br>\n".replace('_IDENT_', testCase.FormattedID).replace('_NAME_', testCase.Name);
//console.log(testCase.FormattedID + " " + testCase.Name + " Estimate: " + testCase.TestCaseEstimate);
//
est = testCase.TestCaseEstimate !== 'undefined' && testCase.TestCaseEstimate !== null ? testCase.TestCaseEstimate : "";
todo = testCase.TestCaseToDo !== 'undefined' && testCase.TestCaseToDo !== null ? testCase.TestCaseToDo : "";
act = testCase.TestCaseActual !== 'undefined' && testCase.TestCaseActual !== null ? testCase.TestCaseActual : "";
row = row.replace('_TC_ESTIMATE_', est).replace('_TC_TODO_', todo).replace('_TC_ACTUAL_', act);
// get the verdict of the last run test result for this testCase
// (which will be the first one since we ordered our query results in Date descending order)
if (testCase.Results === 'undefined' || testCase.Results === null || testCase.Results.length < 1) {
tcr = {Verdict: 'None'};
}
else {
tcr = testCase.Results[0];
}
verdictBox = drawBox(tcr.Verdict);
row = row.replace('_VERDICT_', verdictBox);
tableRows.push(row);
estNum = est !== "" ? est : 0;
todoNum = todo !== "" ? todo : 0;
actNum = act !== "" ? act : 0;
totalTestCaseEstimates += estNum;
totalTestCaseToDo += todoNum;
totalTestCaseActual += actNum;
}
//console.log("There are " + tableRows.length + " rows in tableRows");
tcTable = TABLE_START + HEADER_ROW + tableRows.join("\n") + TABLE_END;
totalsTable = TOTALS_TABLE.replace('_TOT_EST_', parseInt(totalTestCaseEstimates, 10));
totalsTable = totalsTable.replace('_TOT_TODO_', parseInt(totalTestCaseToDo, 10));
totalsTable = totalsTable.replace('_TOT_ACT_', parseInt(totalTestCaseActual, 10));
makeChart(totalTestCaseEstimates, totalTestCaseToDo, totalTestCaseActual);
tce_table_div.innerHTML = "<br>" + tcTable;
tce_totals_div.innerHTML = totalsTable;
}
function showResults(queryResults) {
RALLY.Mashup.Utilities.hideWait("spinner", "TCE_Totals");
if (queryResults.errors.length > 0) {
console.log("Errors detected for queries...");
console.log(queryResults.errors);
return;
}
attributes = queryResults.tca[0].Attributes;
//console.log("attribute results: ");
//for (var ix=0; ix < attributes.length; ix++)
//{
// attribute = attributes[ix];
// console.log("----> " + attribute.Name + " ElementName: " + attribute.ElementName +
// " Type: " + attribute.AttributeType + " Custom: " + attribute.Custom);
//}
if (!hasNecessaryCustomFields(attributes, requiredCustomFields)) {
dontProceedNotification(tce_totals_div);
return;
}
testcaseResults = queryResults.testcase;
showTestCaseEstimateInfo(testcaseResults);
return;
}
function runMashupQueries() {
RALLY.Mashup.Utilities.showWait("spinner", "TCE_Totals");
querySpec = [];
querySpec[0] = {
key : 'tca',
type : 'TypeDefinition',
fetch: 'Attributes,AttributeDefinition,Name,Custom,AttributeType',
query: '(Name = "Test Case")'
};
querySpec[1] = {
key : "testcase",
type : "testcase",
fetch : 'FormattedID,Name,TestCaseEstimate,TestCaseToDo,TestCaseActual,Results,ObjectID,Date,Verdict',
order : 'FormattedID,Date desc'
};
batchToolkit.findAll(querySpec, showResults);
}
</script>
<script type="text/javascript" charset="utf-8">
function testCaseEstimationMashup() {
batchToolkit = new RALLY.Mashup.BatchToolkit('__WORKSPACE_OID__',
'__PROJECT_OID__',
'__PROJECT_SCOPING_UP__',
'__PROJECT_SCOPING_DOWN__');
targetArtifact = "TestCase";
requiredCustomFields = ['TestCaseEstimate', 'TestCaseToDo', 'TestCaseActual'];
tce_chart_div = document.getElementById("TCE_Chart");
tce_table_div = document.getElementById("TCE_Table");
tce_totals_div = document.getElementById("TCE_Totals");
runMashupQueries();
}
dojo.addOnLoad(testCaseEstimationMashup);
</script>
</head>
<body>
<div>
<table width="80%" style="padding-right:10px;">
<tr>
<td align="left" style="padding-bottom: 5px;">
<H2>Test Case Estimation</H2>
</td>
<!-- float the Activity->Print Page button set on the right side of the page-->
<td align="left" style="margin-top: 5px;">
<div style="width: 80px;">
<img id="do" onmouseover="RALLY.Mashup.Utilities.showcbButton();"
onmouseout="hidecbMenu('buttons',event);"
style="vertical-align: middle;"
src="https://preview.rallydev.com/slm/images/menu_actions.gif"/>
<div style="position:relative; top:5px" align="left">
<div id="buttons" class="do-menu" style="left: 0px;"
onmouseover="document.body.style.cursor='pointer';"
onmouseout="document.body.style.cursor='default';hidecbMenu('buttons',event);">
<a id="print" onclick="RALLY.Mashup.Utilities.printPage();">Print...</a>
</div>
</div>
</div>
</td>
</tr>
</table>
</div>
<!-- The spinner shows while the query is being executed, it is hidden after the query completes -->
<div id="spinner"></div>
<!-- The bar chart with Estimate, ToDo, Actual counts gets placed in here ... -->
<div id="TCE_Chart" style="margin-left: 30px; width: 200px; height: 220px;
border: 1px solid #B5D8EB; background-color: white;"></div>
<!-- The generated table with TC ident,name, counts and verdict rows -->
<div id="TCE_Table"></div>
<p>
<hr align="left" width="60%">
</p>
<div id="TCE_Totals" style="margin-left: 80px;"></div>
</body>
</html>