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('status') + ' | ' +
'' + Lang.get('codeception_suite') + ' | ' +
'' + Lang.get('codeception_feature') + ' | ' +
'' + Lang.get('file') + ' | ' +
'' + Lang.get('message') + ' | ' +
'' + 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].pass ? '' + Lang.get('success') + '' : '' + Lang.get('failed') + '') + ' | ' +
'' + tests[i].suite + ' | ' +
'' + tests[i].feature + ' | ' +
'' + tests[i].file + ' | ' +
'' + ((tests[i].message) ? tests[i].message : '') + ' | ' +
'' + tests[i].time + ' | ' +
'
');
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());