var codeceptionPlugin = ActiveBuild.UiPlugin.extend({
id: 'build-codeception-errors',
css: 'col-xs-12',
title: Lang.get('codeception'),
lastData: null,
lastMeta: null,
displayOnUpdate: false,
rendered: false,
register: function() {
var self = this;
var query_data = ActiveBuild.registerQuery('codeception-data', -1, {key: 'codeception-data'});
var query_meta_data = ActiveBuild.registerQuery('codeception-meta', -1, {key: 'codeception-meta'});
$(window).on('codeception-data', function(data) {
self.onUpdateData(data);
});
$(window).on('codeception-meta', function(data) {
self.onUpdateMeta(data);
});
$(window).on('build-updated', function() {
if (!self.rendered) {
self.displayOnUpdate = true;
query_data();
query_meta_data();
}
});
},
render: function() {
return $('
' +
'' +
'| '+Lang.get('codeception_suite')+' | ' +
''+Lang.get('codeception_feature')+' | ' +
''+Lang.get('codeception_time')+' |
' +
'
');
},
onUpdateData: function(e) {
if (!e.queryData) {
$('#build-codeception-errors').hide();
return;
}
this.rendered = true;
this.lastData = e.queryData;
var tests = this.lastData[0].meta_value;
var tbody = $('#codeception-data tbody');
tbody.empty();
if (tests.length == 0) {
$('#build-codeception-errors').hide();
return;
}
for (var i in tests) {
var rows = $('' +
'| '+tests[i].suite+'' +
' | '+tests[i].feature+' | ' +
''+tests[i].time+' | '+
'
' +
'' +
' | ' +
''+Lang.get('name')+': '+tests[i].name+' ' +
''+Lang.get('file')+': '+tests[i].file+' ' +
(tests[i].message
? ''+Lang.get('message')+': '+tests[i].message+''
: '') +
' | ' +
'
');
if (!tests[i].pass) {
rows.first().addClass('danger');
} else {
rows.first().addClass('success');
}
tbody.append(rows);
}
$('#build-codeception-errors').show();
},
onUpdateMeta: function(e) {
if (!e.queryData) {
return;
}
$('#build-codeception-errors').show();
$('#build-codeception-errors td').tooltip();
this.lastMeta = e.queryData;
var data = this.lastMeta[0].meta_value;
var tfoot = $('#codeception-data tfoot');
tfoot.empty();
var row = $('' +
'| ' +
Lang.get('codeception_synopsis', data.tests, data.timetaken, data.failures) +
' | ' +
'
');
tfoot.append(row);
}
});
ActiveBuild.registerPlugin(new codeceptionPlugin());