forked from RallyApps/app-catalog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TestCasePassFailHistoryApp.html
384 lines (336 loc) · 15.2 KB
/
TestCasePassFailHistoryApp.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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<!-- Copyright (c) 2002-2011 Rally Software Development Corp. All rights reserved. -->
<html>
<head>
<title>Test Case Pass/Fail History</title>
<meta name="Name" content="App: Test Case Pass/Fail History"/>
<meta name="Version" content="2012.01.14"/>
<meta name="Vendor" content="Rally Software"/>
<script type="text/javascript" src="/apps/1.33/sdk.js?apiVersion=1.29"></script>
<style type="text/css">
body {
font-family: tahoma, geneva, helvetica, arial, sans-serif;
font-size: 11px;
background: white;
}
.heading {
font-weight: bold;
border: 0px;
padding-top: 10px;
}
table {
background: white;
}
td {
font-family: tahoma, geneva, helvetica, arial, sans-serif;
font-size: 10px;
font-weight: normal;
white-space: nowrap;
}
th {
font-family: tahoma, geneva, helvetica, arial, sans-serif;
font-size: 10px;
font-weight: bold;
white-space: nowrap;
}
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;
}
/* Test Case Result Div and Table styling */
.tcrDiv {
width: 275px;
margin-left: 35px;
margin-top: 6px;
border-left: 2px solid #E6E6FA;
padding-left: 10px;
padding-bottom: 2px;
}
/* Color Squares */
.pass-legend {
width: 80px;
background: #B2E3B6 none repeat scroll 0%; /* std Rally muted green */
border: 1px solid #DDDDDD;
color: black;
cursor: default;
float: left;
height: 14px;
line-height: 14px;
margin-right: 1px;
text-align: center;
/* font-weight: bold; */
}
.pass-legend-inconclusive {
width: 80px;
background: #fbde98 none repeat scroll 0%; /* std Rally muted yellow/tan */
border: 1px solid #DDDDDD;
color: black;
cursor: default;
float: left;
height: 14px;
line-height: 14px;
margin-right: 1px;
text-align: center;
/* font-weight: bold; */
}
.pass-legend-fail {
width: 80px;
background: #fCB5B1 none repeat scroll 0%; /* std Rally muted red */
border: 1px solid #DDDDDD;
color: black;
cursor: default;
float: left;
height: 14px;
line-height: 14px;
margin-right: 1px;
text-align: center;
/* font-weight: bold; */
}
</style>
<script type="text/javascript">
function shortUrl(type) {
if (type == "User Story") {
return "ar";
}
if (type == "Defect") {
return "df";
}
else if (type == "Test Case") {
return "tc";
}
else if (type == "Test Case Result") {
return "tcr";
}
return "error";
}
var TC_TABLE_START = "<table><tr><td>";
var ROW_END = " </td>\n </tr>\n";
var EMPTY_CELL = " <td> </td>\n";
var EMPTY_ROW = " <tr>\n" + EMPTY_CELL + "</tr>\n";
var TABLE_END = "</table>";
var TC_LINK = "<div class=\"heading\"><a href=\"_TARGET_URL_\" target=\"_top\">_ID_ _NAME_</a>_WP_LINK_</div>";
var WP_LINK = "(<a href=\"_WP_TARGET_\" target=\"_top\">_WP_TEXT_</a>)";
var TCR_TABLE_START = " <table width=\"180px\">\n";
var TCR_HEADER_ROW = "<tr> <th>ID</th>" +
"<th> </th>" +
"<th>Build</th>" +
"<th> </th>" +
"<th>Date and Time</th>" +
"<th> </th>" +
"<th>Verdict</th>" +
"<th> </th>" +
"<th>Tester</th>" +
"</tr>";
var EMPTY_TCR_TABLE = TCR_TABLE_START + " <tr>\n <th align=\"left\">None</th>\n </tr>\n</table>\n";
var TCR_TABLE = TCR_TABLE_START + " " + TCR_HEADER_ROW + "\n";
var TCR_ROW = " <tr>\n" +
" <td valign=\"middle\"><a href=\"_TCR_LINK_\" target=\"_top\">_TCR_IDENT_</a></td>\n" +
EMPTY_CELL +
" <td valign=\"middle\" align=\"center\">_BUILD_</td>\n" +
EMPTY_CELL +
" <td valign=\"middle\" align=\"center\">_DATE_</td>\n" +
EMPTY_CELL +
" <td valign=\"middle\" align=\"center\">_VERDICT_BOX_</td>\n" +
EMPTY_CELL +
" <td valign=\"middle\" align=\"center\">_TESTER_</td>\n" +
" </tr>\n";
// Here's what a Test Case Result table looks like:
//<table width="180px">
// <HEADER_ROW>
// <tr>
// <td valign="middle"><a href=\"_TCR_LINK_\" target=\"_top\">_TCR_IDENT_</a></td>
// <td>< </td>
// <td valign="middle" align="center">_BUILD_</td>
// <td>< </td>
// <td valign="middle" align="center">_DATE_</td>
// <td>< </td>
// <td valign="middle" align="center">_VERDICT_BOX_</td>
// <td>< </td>
// <td valign="middle" align="center">_TESTER_</td>
// </tr>
// more testcaseresult rows...
//</table>
function byFormattedID(a, b) {
// compares the integer portion of TC22, TC9
var a_num = parseInt(a.substring(2, a.length), 10);
var b_num = parseInt(b.substring(2, b.length), 10);
return a_num - b_num;
}
var busySpinner;
function organizeResultsByTestCase(testCaseResults) {
var testCaseHolder = {}; // will be keyed by TestCase FormattedID with a value of
// {'TestCase': tc, 'results': [tcr, tcr, tcr, tcr, ...]}
var tcr, tc;
for (var ix = 0; ix < testCaseResults.length; ix++) {
tcr = testCaseResults[ix];
if (tcr.hasOwnProperty('TestCase')) // and some TestCaseResult items won't
{
tc = tcr.TestCase;
if (tc !== undefined) {
if (!testCaseHolder.hasOwnProperty(tc.FormattedID)) // no existing entry for tc.FormattedID ?
{
testCaseHolder[tc.FormattedID] = {'TestCase': tc, 'results': []};
}
testCaseHolder[tc.FormattedID].results.push(tcr);
}
}
}
return testCaseHolder;
}
function ascendingOrderedTestCases(testCaseHolder) {
var testCases = [];
rally.forEach(testCaseHolder, function (targetObj, formattedID) {
testCases.push(formattedID);
});
testCases.sort(byFormattedID);
return testCases;
}
function drawBox(verdict) {
var verdictClass = 'pass-legend-inconclusive';
if (verdict === 'Pass') {
verdictClass = 'pass-legend';
}
if (verdict === 'Fail') {
verdictClass = 'pass-legend-fail';
}
return '<div class="' + verdictClass + '">' + verdict + '</div>';
}
function createTestCaseResultTable(testcaseresults) {
// construct a table with a header row for the testcaseresults
var tcrTable = TCR_TABLE;
// add a row in the table for each testcaseresult
for (rix = 0; rix < testcaseresults.length; rix++) {
var tcr = testcaseresults[rix];
var tcrDate = tcr.Date.replace('T', ' ').replace(/\.\d+Z/, ' UTC');
var verdictBox = drawBox(tcr.Verdict);
//console.log(" " + tcr.ObjectID + " " + tcr.Build + " " + tcrDate + " " + tcr.Verdict);
//console.log(" -- (" + tcr.WorkProduct.FormattedID + " " + tcr.WorkProduct.Name + ")");
tcrLink = rally.sdk.util.Navigation.createRallyDetailUrl(tcr);
var tcrRow = TCR_ROW.replace('_TCR_LINK_', tcrLink);
tcrRow = tcrRow.replace('_TCR_IDENT_', tcr.ObjectID);
tcrRow = tcrRow.replace('_BUILD_', tcr.Build);
tcrRow = tcrRow.replace('_DATE_', tcrDate);
tcrRow = tcrRow.replace('_VERDICT_BOX_', verdictBox);
var tester = "";
if ((tcr.Tester !== null) && (tcr.Tester.DisplayName !== null)) {
tester = tcr.Tester.DisplayName;
}
tcrRow = tcrRow.replace('_TESTER_', tester);
tcrTable += tcrRow;
}
tcrTable += TABLE_END;
// wrap the Test Case Result table in a DIV
tcrTable = '<DIV class="tcrDiv">' + tcrTable + '</DIV>';
return tcrTable;
}
function assembleTestCaseAndResultsTable(testCases, testCaseHolder) {
var table = "";
var testCase, testCaseResults;
var tcIdent, tcLink, tcDetailUrl;
var wpInfo, wpLink, wpDetailUrl;
var tcFormattedID, tcrLink;
for (var ix = 0; ix < testCases.length; ix++) {
tcFormattedID = testCases[ix];
testCase = testCaseHolder[tcFormattedID].TestCase;
testCaseResults = testCaseHolder[tcFormattedID].results;
table += TC_TABLE_START;
tcDetailUrl = rally.sdk.util.Navigation.createRallyDetailUrl(testCase);
tcLink = TC_LINK.replace('_TARGET_URL_', tcDetailUrl);
tcLink = tcLink.replace('_ID_', testCase.FormattedID);
tcLink = tcLink.replace('_NAME_', testCase.Name);
tcIdent = testCase.ObjectID + " " + testCase.FormattedID + " " + testCase.Name;
wpInfo = ""; // WorkProduct info (Ident + Name) for link purposes
wpLink = ""; // prime to be empty just in case the Test Case has no associated WorkProduct
if (testCase.WorkProduct !== null) {
wpInfo = testCase.WorkProduct.FormattedID + " " + testCase.WorkProduct.Name;
wpDetailUrl = rally.sdk.util.Navigation.createRallyDetailUrl(testCase.WorkProduct);
wpLink = WP_LINK.replace("_WP_TARGET_", wpDetailUrl).replace("_WP_TEXT_", wpInfo);
}
tcLink = tcLink.replace("_WP_LINK_", " " + wpLink);
//console.log(tcIdent + " (" + wpInfo + ")");
table += tcLink;
if (testCaseResults.length < 1) {
console.log("-----> no testcaseresults associated with this Test Case");
// wrap the 'None' indication table in a DIV
table += '<DIV class="tcrDiv">' + EMPTY_TCR_TABLE + '</DIV>';
}
else {
// add a nested table with a row for each TestCaseResult in testCaseResults,
// have the TestCaseResult.ObjectID field be a link to open up the detail for the TestCaseResult
// also show the build, the date the TestCaseresult was generated and the verdict (Pass/Fail)
//console.log("-----> " + testCaseResults.length + " results associated with this TestCase");
var tcrTable = createTestCaseResultTable(testCaseResults);
table += tcrTable;
}
table += ROW_END + EMPTY_ROW + TABLE_END;
}
return table;
}
function showResults(queryResults) {
busySpinner.hide();
//console.log("Number of test cases returned by the Test Case/Test Case Results query: " +
// queryResults.testcase.length);
if (queryResults.testcaseresults.length === 0) {
var message = "No Test Case information found for the current workspace and project";
document.getElementById("TestCaseInfo").innerHTML = message;
return;
}
var testCaseHolder = organizeResultsByTestCase(queryResults.testcaseresults);
var testCases = ascendingOrderedTestCases(testCaseHolder);
var table = assembleTestCaseAndResultsTable(testCases, testCaseHolder);
document.getElementById("TestCaseInfo").innerHTML = table;
}
function previousDate(spanDays) {
var dayMillis = 86400 * 1000; // seconds in 1 day times 1000 for milliseconds value
var today = new Date().getTime(); // in terms of epoch milliseconds
var prevDate = new Date(today - (spanDays * dayMillis));
var isoDate = rally.sdk.util.DateTime.toIsoString(prevDate);
return isoDate;
}
function runMainQuery(rallyDataSource) {
document.getElementById("TestCaseInfo").innerHTML = "";
busySpinner = new rally.sdk.ui.basic.Wait({hideTarget: false});
busySpinner.display('spinner');
var daySpan = 30; // how many days back from today for TestCaseResult inclusion
var dateBoundingClause = '(Date >= "' + previousDate(daySpan) + '")';
querySpec = {
key : "testcaseresults",
type : "testcaseresults",
fetch : 'ObjectID,Build,Date,Verdict,Duration,Tester,UserName,DisplayName,TestCase,FormattedID,Name,WorkProduct',
query : dateBoundingClause,
order : 'Date Desc'
};
rallyDataSource.findAll(querySpec, showResults);
}
function testCasePassFailHistory() {
rally.sdk.ui.AppHeader.setHelpTopic("256");
rally.sdk.ui.AppHeader.showPageTools(true);
var rallyDataSource =
new rally.sdk.data.RallyDataSource('__WORKSPACE_OID__',
'__PROJECT_OID__',
'__PROJECT_SCOPING_UP__',
'__PROJECT_SCOPING_DOWN__');
runMainQuery(rallyDataSource);
}
rally.addOnLoad(testCasePassFailHistory);
</script>
</head>
<body>
<div id="spinner"></div>
<div id="TestCaseInfo"></div>
</body>
</html>