php-censor/public/assets/js/build-plugins/codeception.js

106 lines
3.3 KiB
JavaScript
Raw Normal View History

2015-02-04 15:21:21 +01:00
var codeceptionPlugin = ActiveBuild.UiPlugin.extend({
2017-09-17 06:22:05 +02:00
id: 'build-codeception-errors',
css: 'col-xs-12',
title: Lang.get('codeception'),
lastData: null,
lastMeta: null,
2015-02-04 15:21:21 +01:00
displayOnUpdate: false,
2017-09-17 06:22:05 +02:00
rendered: false,
2015-02-04 15:21:21 +01:00
2017-09-17 06:22:05 +02:00
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'});
2015-02-04 15:21:21 +01:00
2017-09-17 06:22:05 +02:00
$(window).on('codeception-data', function (data) {
self.onUpdateData(data);
});
2017-09-17 06:22:05 +02:00
$(window).on('codeception-meta', function (data) {
self.onUpdateMeta(data);
2015-02-04 15:21:21 +01:00
});
2017-09-17 06:22:05 +02:00
$(window).on('build-updated', function () {
2015-02-04 15:21:21 +01:00
if (!self.rendered) {
self.displayOnUpdate = true;
2017-09-17 06:22:05 +02:00
query_data();
query_meta_data();
2015-02-04 15:21:21 +01:00
}
});
},
2017-09-17 06:22:05 +02:00
render: function () {
2017-02-02 15:55:29 +01:00
return $('<table class="table table-hover" id="codeception-data">' +
2015-02-04 15:21:21 +01:00
'<thead>' +
2017-09-16 16:26:53 +02:00
'<tr><th>' + Lang.get('status') + '</th>' +
'<th>' + Lang.get('codeception_suite') + '</th>' +
'<th>' + Lang.get('codeception_feature') + '</th>' +
'<th>' + Lang.get('file') + '</th>' +
'<th>' + Lang.get('message') + '</th>' +
'<th>' + Lang.get('codeception_time') + '</th></tr>' +
'</thead><tbody></tbody><tfoot></tfoot></table>');
2015-02-04 15:21:21 +01:00
},
2017-09-17 06:22:05 +02:00
onUpdateData: function (e) {
2015-02-04 15:21:21 +01:00
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');
2017-09-17 06:22:05 +02:00
2015-02-04 15:21:21 +01:00
tbody.empty();
if (tests.length == 0) {
$('#build-codeception-errors').hide();
return;
}
for (var i in tests) {
2017-09-16 16:26:53 +02:00
var rows = $('<tr>' +
'<td>' + (tests[i].pass ? '<span class="label label-success">' + Lang.get('success') + '</span>' : '<span class="label label-danger">' + Lang.get('failed') + '</span>') + '</td>' +
'<td>' + tests[i].suite + '</td>' +
'<td>' + tests[i].feature + '</td>' +
2017-09-17 06:22:05 +02:00
'<td>' + tests[i].file + '</td>' +
'<td>' + ((tests[i].message) ? tests[i].message : '') + '</td>' +
'<td>' + tests[i].time + '</td>' +
2015-02-04 15:21:21 +01:00
'</tr>');
tbody.append(rows);
}
$('#build-codeception-errors').show();
},
2017-09-17 06:22:05 +02:00
onUpdateMeta: function (e) {
if (!e.queryData) {
return;
2015-02-04 15:21:21 +01:00
}
$('#build-codeception-errors').show();
$('#build-codeception-errors td').tooltip();
this.lastMeta = e.queryData;
2017-09-17 06:22:05 +02:00
var data = this.lastMeta[0].meta_value;
var tfoot = $('#codeception-data tfoot');
2017-09-17 06:22:05 +02:00
tfoot.empty();
var row = $('<tr>' +
'<td colspan="3">' +
Lang.get('codeception_synopsis', data.tests, data.timetaken, data.failures) +
'</td>' +
'</tr>');
tfoot.append(row);
2015-02-04 15:21:21 +01:00
}
});
ActiveBuild.registerPlugin(new codeceptionPlugin());