-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathreportgen.html
More file actions
76 lines (75 loc) · 8.11 KB
/
reportgen.html
File metadata and controls
76 lines (75 loc) · 8.11 KB
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
<html>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.4/Chart.min.css">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta2/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-BmbxuPwQa2lc/FVzBcNJ7UAyJxM6wuqIj61tLrc4wSX0szH/Ev+nYRRuWlolflfl" crossorigin="anonymous">
<style>#main {display: none;}</style>
<body class="container-fluid">
<nav class="navbar-light bg-light">
<div style="text-align:center; height: 6vh; margin-top: 2em;">
<a class="navbar-brand" href="#">API Test Report</a>
</div>
</nav>
<div id="main">
<div class="row">
<div class="col-md-4">
<ul class="list-group">
<li class="list-group-item">Project: <span id="project"></span></li>
<li class="list-group-item">Domain: <span id="domain"></span></li>
<li class="list-group-item">Collection: <span id="collection"></span></li>
<li class="list-group-item">Environment: <span id="environment"></span></li>
<li class="list-group-item">RunID: <span id="runid"></span></li>
<li class="list-group-item">Time: <span id="runat"></span></li>
</ul>
</div>
<div class="col-md-4">
<div id="canvas-holder" style="width:100%;">
<canvas id="chart-area"></canvas>
</div>
</div>
<div class="col-md-4">
<ul class="list-group">
<li class="list-group-item"><span id="pass"></span> Passed.</li>
<li class="list-group-item"><span id="fail"></span> Failed.</li>
<li class="list-group-item"><span id="errors"></span> Error(s)</li>
<li class="list-group-item">Pass Rate: <span id="srate"></span></li>
<li class="list-group-item">Failure Rate: <span id="frate"></span></li>
<li class="list-group-item">Error Rate: <span id="erate"></span></li>
</ul>
</div>
<div id="accordion">
</div>
</div>
</div>
<div class="container" style="text-align: center;margin-top: 10em;">
<form id="jsonFile" name="jsonFile" enctype="multipart/form-data" method="post">
<fieldset>
<h5>Upload Test API Json File :</h5>
<input type='file' id='fileinput'>
<input type='button' id='btnLoad' value='Load' onclick='load();'>
</fieldset>
</form>
</div>
<script src="https://code.jquery.com/jquery-3.5.1.min.js"
integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.4/Chart.min.js"> </script>
<script type="text/javascript"
src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.4/Chart.bundle.js"> </script>
<script type="text/javascript"
src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.4/Chart.bundle.js"> </script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta2/dist/js/bootstrap.bundle.min.js"
integrity="sha384-b5kHyXgcpbZJO/tY9Ul7kGkf1S0CWuKcCD38l8YkeH8z8QjE0GmW1gYU5S9FOnJ0"
crossorigin="anonymous"></script>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"
integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN"
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"
integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q"
crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"
integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl"
crossorigin="anonymous"></script>
<script>
function load() { var e, l, i, a = Array(); Array(); "function" == typeof window.FileReader ? ((e = document.getElementById("fileinput")) ? e.files ? e.files[0] ? (l = e.files[0], (i = new FileReader).onload = function (e) { let l = e.target.result; a = JSON.parse(l) }, i.readAsText(l)) : alert("Please select a file before clicking 'Load'") : alert("This browser doesn't seem to support the `files` property of file inputs.") : alert("Um, couldn't find the fileinput element."), i.onloadend = function (e) { $("#jsonFile").remove(), $("#main").show(); var l, i = document.getElementById("chart-area").getContext("2d"), t = 0, s = 0, o = 0, n = a[0].project, r = a[0].collection, d = a[0].environment, p = a[0].domain; l = a[0].run_id.split("_"), $("#runid").append(l[1]), $("#domain").append(p), $("#project").append(n), $("#collection").append(r), $("#environment").append(d), $("#runat").append(l[0]); for (var c = 0; c < a.length; c++) { var m; 0, t += a[c].total_pass, s += a[c].total_fail, "error" === a[c].outcome ? (o++, m = "warning") : m = "passed" === a[c].outcome ? "success" : "danger", $("#accordion").append('<div class="card">\n <div class="card-header" id="heading' + c + '">\n <h5 class="mb-0">\n <button class="btn btn-' + m + ' collapsed" data-toggle="collapse" style="text-align:left;"\n data-target="#collapse' + c + '" aria-expanded="false" aria-controls="collapse' + c + '">\n <small><i>(service)</i></small>' + a[c].service + " | <small><i>(scenario)</i></small>" + a[c].scenario + " |<small><i>(outcome)</i></small> " + a[c].outcome + "\n | <small><i>(url)</i></small>" + a[c].url + "|validations(<i> <small>" + a[c].total_pass + " passed</small></i> <i><small>" + a[c].total_fail + ' failed</small></i>)\n </button>\n </h5>\n </div>\n <div id="collapse' + c + '" class="collapse" aria-labelledby="heading' + c + '" data-parent="#accordion">\n <div class="card-body">\n <li class="list-group-item">Service: ' + a[c].service + '</li>\n <li class="list-group-item">Scenario: ' + a[c].scenario + '</li>\n <li class="list-group-item">Outcome: ' + a[c].outcome + '</li>\n <li class="list-group-item">Url: ' + a[c].url + '</li>\n <li class="list-group-item">Method: ' + a[c].method + '</li>\n <li class="list-group-item">Request Body: ' + a[c].request_body + '</li>\n <li class="list-group-item">Expected Status: ' + a[c].status + '</li>\n <li class="list-group-item">Response Body: ' + a[c].response_body + '</li>\n <li class="list-group-item">Error description: ' + a[c].error_description + '</li>\n <li class="list-group-item">Validators: ' + a[c].validators + '</li>\n <li class="list-group-item">Validation Outcome: ' + a[c].validation_description + '</li>\n <li class="list-group-item">Response Code: ' + a[c].response_code + '</li>\n <li class="list-group-item">Developer: ' + a[c].developer + '</li>\n <li class="list-group-item">Tester: ' + a[c].tester + '</li>\n <li class="list-group-item">Response Time: ' + a[c].response_time + '</li>\n <li class="list-group-item">Tag: ' + a[c].tag + "</li>\n </div>\n </div>\n </div>") } var u = t + s + o; if (0 == u) $("#srate").append("0 %"), $("#frate").append("0 %"); else { var g = s / u * 100, f = String((t / u * 100).toFixed(2)) + "%", v = String(g.toFixed(2)) + "%"; $("#srate").append(f), $("#frate").append(v) } $("#pass").append(t), $("#fail").append(s), $("#errors").append(o); var h = String((o / u * 100).toFixed(2)) + "%"; $("#erate").append(h); new Chart(i, { type: "doughnut", data: { datasets: [{ data: [t, s, o], backgroundColor: ["green", "red", "orange"], label: "pass/fail/error" }], labels: ["pass", "fail", "error"] }, options: { responsive: !0, legend: { position: "top" }, title: { display: !0, text: "pass/fail/error" }, animation: { animateScale: !0, animateRotate: !0 } } }) }) : alert("The file API isn't supported on this browser yet.") }
</script>
</body>
</html>