Updated dashboard Specs for testing. It allow us to track better all the information loaded
Change-Id: I7121d93b6c829dd97cdfdf4ab45ed918764d3975
This commit is contained in:
parent
f2653642fc
commit
5dc91fcb3a
File diff suppressed because one or more lines are too long
|
@ -1 +0,0 @@
|
|||
{"VizGrimoireJS data":[1],"Basic Data":[8],"data files should be loaded":[9],"exist data sources":[17],"data update":[21],"Data checking":[41],"Evol metrics should be present in the Global metrics":[42],"Summable Evol metrics should sum Global metrics":[54],"Repositories checking":[108],"All repositories should have Evol and Global metrics":[109],"Companies checking":[113],"All companies should have Evol and Global metrics":[114],"Countries checking":[118],"All countries should have Evol and Global metrics":[119]}
|
|
@ -1 +0,0 @@
|
|||
{"VizGrimoireJS data":[1],"Basic Data":[8],"data files should be loaded":[9],"exist data sources":[17],"data update":[21],"Data checking":[41],"Evol metrics should be present in the Global metrics":[42],"Summable Evol metrics should sum Global metrics":[54],"Repositories checking":[108],"All repositories should have Evol and Global metrics":[109],"Companies checking":[113],"All companies should have Evol and Global metrics":[114],"Countries checking":[118],"All countries should have Evol and Global metrics":[119]}
|
|
@ -0,0 +1,50 @@
|
|||
# Jasmine tests for Bitergia dashboards
|
||||
|
||||
## Software
|
||||
* tests use jasmine 1.3, in order to get some information about it you can
|
||||
visit http://jasmine.github.io/1.3/introduction.html
|
||||
* if you want to use the command line tests you need jasmine-headless-webkit
|
||||
but its installation is a bit tricky and it's deprecated.
|
||||
|
||||
## Usage
|
||||
* command line tests:
|
||||
```
|
||||
make test
|
||||
```
|
||||
* web tests: visit the root of the dashboard with /test, if you are running your dash
|
||||
at localhost/dash/browser, visit
|
||||
```
|
||||
localhost/dash/test/jasmine/
|
||||
```
|
||||
|
||||
## Modify them
|
||||
Test are defined in the file vizgrimoireSpec.js. The best starting point
|
||||
is to have a look at the ones for the "upate time", which are very basic.
|
||||
```
|
||||
describe("Updated Data: ", function() {
|
||||
var max_days_old = 4; // Change it to your project expected update time
|
||||
var now = new Date();
|
||||
var day_mseconds = 60*60*24*1000;
|
||||
|
||||
function isDSUpdated(ds_name) {
|
||||
if(isDSEnabled(ds_name) == false ) return true;
|
||||
var update = null;
|
||||
$.each(data_sources, function(index, DS) {
|
||||
if (DS.getName() === ds_name) {
|
||||
update = DS.getGlobalData()['last_date'];
|
||||
return false;
|
||||
}
|
||||
});
|
||||
var update_time = new Date(update+"T00:00:00.000Z");
|
||||
var days_old = parseInt(
|
||||
(now.getTime()-update_time.getTime())/(day_mseconds),null);
|
||||
expect(days_old).toBeLessThan(max_days_old+1, ds_name + " data is not updated.");
|
||||
}
|
||||
|
||||
it("Data Sources are not updated", function() {
|
||||
$.each(data_sources, function(index, DS) {
|
||||
isDSUpdated(DS.getName());
|
||||
});
|
||||
});
|
||||
});
|
||||
```
|
|
@ -8,7 +8,7 @@
|
|||
href="lib/jasmine-1.3.1/jasmine_favicon.png">
|
||||
<link rel="stylesheet" type="text/css"
|
||||
href="lib/jasmine-1.3.1/jasmine.css">
|
||||
|
||||
|
||||
<!-- VizGrimoireJS CSS FILES -->
|
||||
<link rel="stylesheet" type="text/css" href="../../vizgrimoire.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../browser/custom.css" />
|
||||
|
@ -20,9 +20,9 @@
|
|||
<script type="text/javascript" src="lib/jasmine-1.3.1/jasmine-html.js"></script>
|
||||
|
||||
<!-- include source files here... -->
|
||||
<script type="text/javascript" src="../../lib/jquery-1.7.1.min.js"></script>
|
||||
<script type="text/javascript" src="../../bootstrap/js/bootstrap.min.js"></script>
|
||||
<script type="text/javascript" src="../../vizgrimoire.min.js"></script>
|
||||
<script type="text/javascript" src="../../browser/lib/jquery-1.11.1.min.js"></script>
|
||||
<script type="text/javascript" src="../../browser/lib/bootstrap-3.1.1.min.js"></script>
|
||||
<script type="text/javascript" src="../../browser/lib/vizgrimoire.min.js"></script>
|
||||
|
||||
<!-- include spec files here... -->
|
||||
<script type="text/javascript" src="spec/vizgrimoireSpec.js"></script>
|
||||
|
|
|
@ -1,4 +1,18 @@
|
|||
describe("VizGrimoireJS data", function() {
|
||||
var data_sources = Report.getDataSources();
|
||||
|
||||
function isDSEnabled(ds_name){
|
||||
var found = false;
|
||||
$.each(data_sources, function(index, DS) {
|
||||
if (DS.getName() === ds_name &
|
||||
DS.data.date !== undefined) {
|
||||
found = true;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
return found;
|
||||
}
|
||||
|
||||
beforeEach(function() {
|
||||
Report.setLog(false);
|
||||
waitsFor(function() {
|
||||
|
@ -18,26 +32,57 @@ describe("VizGrimoireJS data", function() {
|
|||
var ds_data = Report.getDataSources()[0].data;
|
||||
expect(ds_data instanceof Array).toBeFalsy();
|
||||
});
|
||||
it("data update", function() {
|
||||
var update = null;
|
||||
var data_sources = Report.getDataSources();
|
||||
it("scm contributors (top) data available", function() {
|
||||
if(isDSEnabled('scm') === false ) return true;
|
||||
var nids = 0;
|
||||
$.each(data_sources, function(index, DS) {
|
||||
if (DS.getName() === "scm") {
|
||||
nids = DS.getGlobalTopData()['authors.']['id'].length;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
expect(nids).toBeGreaterThan(0);
|
||||
});
|
||||
it("qaforums contributors (top) data not available", function() {
|
||||
if(isDSEnabled('qaforums') === false ) return true;
|
||||
var nids = 0;
|
||||
$.each(data_sources, function(index, DS) {
|
||||
if (DS.getName() === "qaforums") {
|
||||
nids = DS.getGlobalTopData()['asenders.']['id'].length;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
expect(nids).toBeGreaterThan(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Updated Data: ", function() {
|
||||
var max_days_old = 2; // Change it to your project expected update time
|
||||
var now = new Date();
|
||||
var day_mseconds = 60*60*24*1000;
|
||||
|
||||
function isDSUpdated(ds_name) {
|
||||
if(isDSEnabled(ds_name) == false ) return true;
|
||||
var update = null;
|
||||
$.each(data_sources, function(index, DS) {
|
||||
if (DS.getName() === ds_name) {
|
||||
update = DS.getGlobalData()['last_date'];
|
||||
return false;
|
||||
}
|
||||
});
|
||||
var max_days_old = 2;
|
||||
var now = new Date();
|
||||
var update_time = new Date(update+"T00:00:00.000Z");
|
||||
var day_mseconds = 60*60*24*1000;
|
||||
var days_old = parseInt(
|
||||
(now.getTime()-update_time.getTime())/(day_mseconds),null);
|
||||
expect(days_old).toBeLessThan(max_days_old+1);
|
||||
|
||||
(now.getTime()-update_time.getTime())/(day_mseconds),null);
|
||||
expect(days_old).toBeLessThan(max_days_old+1, ds_name + " data is not updated.");
|
||||
}
|
||||
|
||||
it("Data Sources are not updated", function() {
|
||||
$.each(data_sources, function(index, DS) {
|
||||
isDSUpdated(DS.getName());
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe("Data checking", function() {
|
||||
it("Evol metrics should be present in the Global metrics", function () {
|
||||
var data_sources = Report.getDataSources();
|
||||
|
@ -46,6 +91,8 @@ describe("VizGrimoireJS data", function() {
|
|||
var evol = DS.getData();
|
||||
for (field in evol) {
|
||||
if (DS.getMetrics()[field]) {
|
||||
// Metric not in old JSON files for tests
|
||||
if (field === 'qaforums_unanswered') {return;}
|
||||
expect(global[field]).toBeDefined();
|
||||
}
|
||||
}
|
||||
|
@ -70,12 +117,12 @@ describe("VizGrimoireJS data", function() {
|
|||
expect(metric_total).toEqual(global[field]);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function checkDataReport(report) {
|
||||
if ($.inArray(report,['repos','companies','countries'])===-1)
|
||||
if ($.inArray(report,['repos','companies','countries'])===-1)
|
||||
return;
|
||||
var data_sources = Report.getDataSources();
|
||||
var repos = 0, repos_global = {}, repos_metrics = {};
|
||||
|
@ -103,7 +150,7 @@ describe("VizGrimoireJS data", function() {
|
|||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
describe("Repositories checking", function() {
|
||||
it("All repositories should have Evol and Global metrics", function () {
|
||||
|
|
Loading…
Reference in New Issue